Skip to content

Commit

Permalink
fix lint (first batch)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShareASmile committed Nov 1, 2023
1 parent 798a4cf commit b661313
Show file tree
Hide file tree
Showing 30 changed files with 495 additions and 366 deletions.
81 changes: 53 additions & 28 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,39 +108,54 @@ configurations {
ktlint
}

def outputDir = "${project.buildDir}/reports/ktlint/"
def inputFiles = project.fileTree(dir: "src", include: "**/*.kt")

task runKtlint(type: JavaExec) {
inputs.files(inputFiles)
outputs.dir(outputDir)
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
}

task formatKtlint(type: JavaExec) {
inputs.files(inputFiles)
outputs.dir(outputDir)
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}

afterEvaluate {
preDebugBuild.dependsOn runKtlint
preDebugBuild.dependsOn formatKtlint, runKtlint
}

dependencies {
/** Desugaring **/
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

implementation "frankiesardo:icepick:${icepickVersion}"
kapt "frankiesardo:icepick-processor:${icepickVersion}"

/** Ktlint **/
ktlint "com.pinterest:ktlint:0.40.0"

debugImplementation "com.facebook.stetho:stetho:${stethoVersion}"
debugImplementation "com.facebook.stetho:stetho-okhttp3:${stethoVersion}"

debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}"
implementation "com.squareup.leakcanary:leakcanary-object-watcher-android:${leakCanaryVersion}"
/** Kotlin **/
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

/** AndroidX **/
implementation "androidx.appcompat:appcompat:1.1.0" //no change
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
implementation "androidx.lifecycle:lifecycle-livedata:${androidxLifecycleVersion}"
implementation "androidx.lifecycle:lifecycle-viewmodel:${androidxLifecycleVersion}"
implementation "androidx.lifecycle:lifecycle-extensions:${androidxLifecycleVersion}"
implementation 'androidx.media:media:1.2.1'
implementation "androidx.multidex:multidex:2.0.1"
implementation "androidx.preference:preference:1.1.1"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.room:room-runtime:${androidxRoomVersion}"
implementation "androidx.room:room-rxjava2:${androidxRoomVersion}"
kapt "androidx.room:room-compiler:${androidxRoomVersion}"
implementation "com.google.android.material:material:1.1.0"

/** NewPipe libraries **/
// You can use a local version by uncommenting a few lines in settings.gradle
Expand All @@ -150,53 +165,63 @@ dependencies {
implementation "com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751"
implementation 'com.github.ShareASmile:NewPipeExtractor:5f3f61701e'

/** Third-party libraries **/
// Instance state boilerplate elimination
implementation "frankiesardo:icepick:${icepickVersion}"
kapt "frankiesardo:icepick-processor:${icepickVersion}"

// HTML parser
implementation "org.jsoup:jsoup:1.13.1"

// HTTP client
//noinspection GradleDependency --> do not update okhttp beyond 3.12.x to keep supporting Android 4.4 & Lower users
implementation "com.squareup.okhttp3:okhttp:3.12.13"

// Media player
implementation "com.google.android.exoplayer:exoplayer:${exoPlayerVersion}"
implementation "com.google.android.exoplayer:extension-mediasession:${exoPlayerVersion}"

implementation "com.google.android.material:material:1.1.0"

// Metadata generator for service descriptors
compileOnly "com.google.auto.service:auto-service-annotations:${googleAutoServiceVersion}"
kapt "com.google.auto.service:auto-service:${googleAutoServiceVersion}"

implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.preference:preference:1.1.1"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
implementation 'androidx.media:media:1.2.1'

implementation "androidx.lifecycle:lifecycle-livedata:${androidxLifecycleVersion}"
implementation "androidx.lifecycle:lifecycle-viewmodel:${androidxLifecycleVersion}"
implementation "androidx.lifecycle:lifecycle-extensions:${androidxLifecycleVersion}"

implementation "androidx.room:room-runtime:${androidxRoomVersion}"
implementation "androidx.room:room-rxjava2:${androidxRoomVersion}"
kapt "androidx.room:room-compiler:${androidxRoomVersion}"

// Manager for complex RecyclerView layouts
implementation "com.xwray:groupie:${groupieVersion}"
implementation "com.xwray:groupie-kotlin-android-extensions:${groupieVersion}"

// Circular ImageView
implementation "de.hdodenhof:circleimageview:3.1.0"
// Image loading
implementation "com.nostra13.universalimageloader:universal-image-loader:1.9.5"

// Markdown library for Android
implementation "io.noties.markwon:core:${markwonVersion}"
implementation "io.noties.markwon:linkify:${markwonVersion}"

// File picker
implementation "com.nononsenseapps:filepicker:4.2.1"

// Crash reporting
implementation "ch.acra:acra-core:5.5.0"

// Reactive extensions for Java VM
implementation "io.reactivex.rxjava2:rxjava:2.2.19"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
// RxJava binding APIs for Android UI widgets
implementation "com.jakewharton.rxbinding2:rxbinding:2.2.0"

// Date and time formatting
implementation "org.ocpsoft.prettytime:prettytime:5.0.6.Final"

/** Debugging **/
// Memory leak detection
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}"
implementation "com.squareup.leakcanary:leakcanary-object-watcher-android:${leakCanaryVersion}"
// Debug bridge for Android
debugImplementation "com.facebook.stetho:stetho:${stethoVersion}"
debugImplementation "com.facebook.stetho:stetho-okhttp3:${stethoVersion}"

/** Testing **/
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.6.0'

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/org/schabi/newpipelegacy/about/License.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ protected License(final Parcel in) {

public Uri getContentUri() {
return new Uri.Builder()
.scheme("file")
.path("/android_asset")
.appendPath(filename)
.build();
.scheme("file")
.path("/android_asset")
.appendPath(filename)
.build();
}

public String getAbbreviation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import androidx.room.Query
import androidx.room.Transaction
import androidx.room.Update
import io.reactivex.Flowable
import java.util.Date
import org.schabi.newpipelegacy.database.feed.model.FeedEntity
import org.schabi.newpipelegacy.database.feed.model.FeedLastUpdatedEntity
import org.schabi.newpipelegacy.database.stream.model.StreamEntity
import org.schabi.newpipelegacy.database.subscription.SubscriptionEntity
import java.util.Date

@Dao
abstract class FeedDAO {
@Query("DELETE FROM feed")
abstract fun deleteAll(): Int

@Query("""
@Query(
"""
SELECT s.* FROM streams s
INNER JOIN feed f
Expand All @@ -27,10 +28,12 @@ abstract class FeedDAO {
ORDER BY s.upload_date IS NULL DESC, s.upload_date DESC, s.uploader ASC
LIMIT 500
""")
"""
)
abstract fun getAllStreams(): Flowable<List<StreamEntity>>

@Query("""
@Query(
"""
SELECT s.* FROM streams s
INNER JOIN feed f
Expand All @@ -46,10 +49,12 @@ abstract class FeedDAO {
ORDER BY s.upload_date IS NULL DESC, s.upload_date DESC, s.uploader ASC
LIMIT 500
""")
"""
)
abstract fun getAllStreamsFromGroup(groupId: Long): Flowable<List<StreamEntity>>

@Query("""
@Query(
"""
DELETE FROM feed WHERE
feed.stream_id IN (
Expand All @@ -60,10 +65,12 @@ abstract class FeedDAO {
WHERE s.upload_date < :date
)
""")
"""
)
abstract fun unlinkStreamsOlderThan(date: Date)

@Query("""
@Query(
"""
DELETE FROM feed
WHERE feed.subscription_id = :subscriptionId
Expand All @@ -76,7 +83,8 @@ abstract class FeedDAO {
WHERE s.stream_type = "LIVE_STREAM" OR s.stream_type = "AUDIO_LIVE_STREAM"
)
""")
"""
)
abstract fun unlinkOldLivestreams(subscriptionId: Long)

@Insert(onConflict = OnConflictStrategy.IGNORE)
Expand All @@ -100,12 +108,14 @@ abstract class FeedDAO {
}
}

@Query("""
@Query(
"""
SELECT MIN(lu.last_updated) FROM feed_last_updated lu
INNER JOIN feed_group_subscription_join fgs
ON fgs.subscription_id = lu.subscription_id AND fgs.group_id = :groupId
""")
"""
)
abstract fun oldestSubscriptionUpdate(groupId: Long): Flowable<List<Date>>

@Query("SELECT MIN(last_updated) FROM feed_last_updated")
Expand All @@ -114,7 +124,8 @@ abstract class FeedDAO {
@Query("SELECT COUNT(*) FROM feed_last_updated WHERE last_updated IS NULL")
abstract fun notLoadedCount(): Flowable<Long>

@Query("""
@Query(
"""
SELECT COUNT(*) FROM subscriptions s
INNER JOIN feed_group_subscription_join fgs
Expand All @@ -124,20 +135,24 @@ abstract class FeedDAO {
ON s.uid = lu.subscription_id
WHERE lu.last_updated IS NULL
""")
"""
)
abstract fun notLoadedCountForGroup(groupId: Long): Flowable<Long>

@Query("""
@Query(
"""
SELECT s.* FROM subscriptions s
LEFT JOIN feed_last_updated lu
ON s.uid = lu.subscription_id
WHERE lu.last_updated IS NULL OR lu.last_updated < :outdatedThreshold
""")
"""
)
abstract fun getAllOutdated(outdatedThreshold: Date): Flowable<List<SubscriptionEntity>>

@Query("""
@Query(
"""
SELECT s.* FROM subscriptions s
INNER JOIN feed_group_subscription_join fgs
Expand All @@ -147,6 +162,7 @@ abstract class FeedDAO {
ON s.uid = lu.subscription_id
WHERE lu.last_updated IS NULL OR lu.last_updated < :outdatedThreshold
""")
"""
)
abstract fun getAllOutdatedForGroup(groupId: Long, outdatedThreshold: Date): Flowable<List<SubscriptionEntity>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ import org.schabi.newpipelegacy.database.feed.model.FeedEntity.Companion.SUBSCRI
import org.schabi.newpipelegacy.database.stream.model.StreamEntity
import org.schabi.newpipelegacy.database.subscription.SubscriptionEntity

@Entity(tableName = FEED_TABLE,
primaryKeys = [STREAM_ID, SUBSCRIPTION_ID],
indices = [Index(SUBSCRIPTION_ID)],
foreignKeys = [
ForeignKey(
entity = StreamEntity::class,
parentColumns = [StreamEntity.STREAM_ID],
childColumns = [STREAM_ID],
onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE, deferred = true),
ForeignKey(
entity = SubscriptionEntity::class,
parentColumns = [SubscriptionEntity.SUBSCRIPTION_UID],
childColumns = [SUBSCRIPTION_ID],
onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE, deferred = true)
]
@Entity(
tableName = FEED_TABLE,
primaryKeys = [STREAM_ID, SUBSCRIPTION_ID],
indices = [Index(SUBSCRIPTION_ID)],
foreignKeys = [
ForeignKey(
entity = StreamEntity::class,
parentColumns = [StreamEntity.STREAM_ID],
childColumns = [STREAM_ID],
onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE, deferred = true
),
ForeignKey(
entity = SubscriptionEntity::class,
parentColumns = [SubscriptionEntity.SUBSCRIPTION_UID],
childColumns = [SUBSCRIPTION_ID],
onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.CASCADE, deferred = true
)
]
)
data class FeedEntity(
@ColumnInfo(name = STREAM_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import org.schabi.newpipelegacy.database.feed.model.FeedGroupEntity.Companion.SO
import org.schabi.newpipelegacy.local.subscription.FeedGroupIcon

@Entity(
tableName = FEED_GROUP_TABLE,
indices = [Index(SORT_ORDER)]
tableName = FEED_GROUP_TABLE,
indices = [Index(SORT_ORDER)]
)
data class FeedGroupEntity(
@PrimaryKey(autoGenerate = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@ import org.schabi.newpipelegacy.database.feed.model.FeedGroupSubscriptionEntity.
import org.schabi.newpipelegacy.database.subscription.SubscriptionEntity

@Entity(
tableName = FEED_GROUP_SUBSCRIPTION_TABLE,
primaryKeys = [GROUP_ID, SUBSCRIPTION_ID],
indices = [Index(SUBSCRIPTION_ID)],
foreignKeys = [
ForeignKey(
entity = FeedGroupEntity::class,
parentColumns = [FeedGroupEntity.ID],
childColumns = [GROUP_ID],
onDelete = CASCADE, onUpdate = CASCADE, deferred = true),
tableName = FEED_GROUP_SUBSCRIPTION_TABLE,
primaryKeys = [GROUP_ID, SUBSCRIPTION_ID],
indices = [Index(SUBSCRIPTION_ID)],
foreignKeys = [
ForeignKey(
entity = FeedGroupEntity::class,
parentColumns = [FeedGroupEntity.ID],
childColumns = [GROUP_ID],
onDelete = CASCADE, onUpdate = CASCADE, deferred = true
),

ForeignKey(
entity = SubscriptionEntity::class,
parentColumns = [SubscriptionEntity.SUBSCRIPTION_UID],
childColumns = [SUBSCRIPTION_ID],
onDelete = CASCADE, onUpdate = CASCADE, deferred = true)
]
ForeignKey(
entity = SubscriptionEntity::class,
parentColumns = [SubscriptionEntity.SUBSCRIPTION_UID],
childColumns = [SUBSCRIPTION_ID],
onDelete = CASCADE, onUpdate = CASCADE, deferred = true
)
]
)
data class FeedGroupSubscriptionEntity(
@ColumnInfo(name = GROUP_ID)
Expand Down
Loading

0 comments on commit b661313

Please sign in to comment.