Skip to content

Commit

Permalink
chore: Disable Jetifier
Browse files Browse the repository at this point in the history
This disables jetifier and removes the following libraries

* EasyDeviceInfo - no update so brought code we use into the embyclient.
* Android Priority Job Queue - replaced with coroutines and repository pattern
* Moxy App Compat - No update, so brought the two classes we use into the app and
  updated them to use the androidx app compat library

In addition converted last of the Job Manager implementation to use coroutines.
  • Loading branch information
kingargyle committed Dec 18, 2024
1 parent c1a1173 commit a701ca4
Show file tree
Hide file tree
Showing 22 changed files with 244 additions and 225 deletions.
3 changes: 0 additions & 3 deletions emby-lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ dependencies {
releaseApi(libs.toothpick.javax.annotations)
ksp(libs.toothpick.ksp.compiler)

implementation(libs.android.priority.jobqueue)
implementation(libs.eventbus)
implementation(libs.moshi)
implementation(libs.retrofit.moshi)
Expand All @@ -75,8 +74,6 @@ dependencies {
implementation(libs.okhttp)
implementation(libs.okhttp.logging.interceptor)
implementation(libs.timber)
implementation(libs.easydeviceinfo.base)
implementation(libs.easydeviceinfo.common)

testImplementation(libs.junit)
testImplementation(libs.assertj.core)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
package us.nineworlds.serenity.emby.server.api

import android.content.Context
import android.os.Build
import android.preference.PreferenceManager
import android.util.Log
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import github.nisrulz.easydeviceinfo.base.EasyDeviceMod
import github.nisrulz.easydeviceinfo.base.EasyIdMod
import me.jessyan.retrofiturlmanager.RetrofitUrlManager
import okhttp3.Cache
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.joda.time.LocalDateTime
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import timber.log.Timber
import us.nineworlds.serenity.common.media.model.IMediaContainer
import us.nineworlds.serenity.common.rest.SerenityClient
import us.nineworlds.serenity.common.rest.SerenityUser
import us.nineworlds.serenity.common.rest.Types
import us.nineworlds.serenity.emby.BuildConfig
import us.nineworlds.serenity.emby.adapters.MediaContainerAdaptor
import us.nineworlds.serenity.emby.moshi.LocalDateJsonAdapter
import us.nineworlds.serenity.emby.server.model.*
import us.nineworlds.serenity.emby.server.model.AuthenticateUserByName
import us.nineworlds.serenity.emby.server.model.AuthenticationResult
import us.nineworlds.serenity.emby.server.model.Item
import us.nineworlds.serenity.emby.server.model.PublicUserInfo
import us.nineworlds.serenity.emby.server.model.QueryFilters
import us.nineworlds.serenity.emby.server.model.QueryResult
import java.io.File
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import java.util.UUID

class EmbyAPIClient(val context: Context, baseUrl: String = "http://localhost:8096") : SerenityClient {

Expand Down Expand Up @@ -66,12 +68,11 @@ class EmbyAPIClient(val context: Context, baseUrl: String = "http://localhost:80
usersService = embyRetrofit.create(UsersService::class.java)
filterService = embyRetrofit.create(FilterService::class.java)

val easyDeviceMod = EasyDeviceMod(context)

deviceId = EasyIdMod(context).pseudoUniqueID
deviceName = "${easyDeviceMod.manufacturer} ${easyDeviceMod.model}"
Log.d(this::class.java.simpleName, "Device Id: $deviceId")
Log.d(this::class.java.simpleName, "Device Name : $deviceName")
deviceId = pseudoUniqueID()
deviceName = "${Build.MANUFACTURER} ${Build.MODEL} "
Timber.d(this::class.java.simpleName, "Device Id: $deviceId")
Timber.d(this::class.java.simpleName, "Device Name : $deviceName")
}

fun fetchAllPublicUsers(): List<PublicUserInfo> {
Expand Down Expand Up @@ -535,4 +536,44 @@ class EmbyAPIClient(val context: Context, baseUrl: String = "http://localhost:80
fun fetchAccessToken() = prefs.getString("embyAccessToken", "")

override fun supportsMultipleUsers(): Boolean = true

private fun pseudoUniqueID(): String {
// If all else fails, if the user does have lower than API 9 (lower
// than Gingerbread), has reset their phone or 'Secure.ANDROID_ID'
// returns 'null', then simply the ID returned will be solely based
// off their Android device information. This is where the collisions
// can happen.
// Try not to use DISPLAY, HOST or ID - these items could change.
// If there are collisions, there will be overlapping data
var devIDShort = "35" + (Build.BOARD.length % 10) + (Build.BRAND.length % 10)

devIDShort += if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
(Build.SUPPORTED_ABIS[0].length % 10)
} else {
(Build.CPU_ABI.length % 10)
}

devIDShort +=
(Build.DEVICE.length % 10) + (Build.MANUFACTURER.length % 10) + (Build.MODEL.length
% 10) + (Build.PRODUCT.length % 10)

// Only devices with API >= 9 have android.os.Build.SERIAL
// http://developer.android.com/reference/android/os/Build.html#SERIAL
// If a user upgrades software or roots their phone, there will be a duplicate entry
var serial: String
try {
serial = Build::class.java.getField("SERIAL")[null]?.toString() ?: ""

// Go ahead and return the serial for api => 9
return UUID(devIDShort.hashCode().toLong(), serial.hashCode().toLong()).toString()
} catch (e: java.lang.Exception) {
// String needs to be initialized
Timber.e(EmbyAPIClient::class.java.simpleName, "getPseudoUniqueID: ", e)
serial = "ESYDV000" // some value
}

// Finally, combine the values we have found by using the UUID class to create a unique identifier
return UUID(devIDShort.hashCode().toLong(), serial.hashCode().toLong()).toString()
}

}

This file was deleted.

6 changes: 2 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
org.gradle.daemon=false
org.gradle.jvmargs=-Xms1024m -Xmx1024m -XX:+UseStringDeduplication
org.gradle.jvmargs=-Xms1024m -Xmx2048m -XX:+UseStringDeduplication
kotlin.incremental=true
org.gradle.configureondemand=true
android.useAndroidX=true
android.enableJetifier=true
android.jetifier.ignorelist=bcprov,robolectric
android.enableJetifier=false
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configuration-cache=true

6 changes: 2 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ androidPluginVersion = "8.6.1"
leanbackPreferenceVersion = "1.1.0-rc01"
leanbackVersion = "1.1.0-rc02"
legacySupportV4Version = "1.0.0"
lifecycleVersion = "2.8.7"
materialVersion = "1.12.0"
minSdkVersion = "27"
mockwebserverVersion = "4.9.1"
Expand Down Expand Up @@ -50,7 +51,6 @@ openglApiVersion = "gl1.1-android-2.1_r1"
assertJAndroidVersion = "1.1.1"
toothPickVersion = "3.1.0"
toothPickKspVersion = "1.1.0"
easydeviceInfoVersion = "2.4.1"

androidxTestCoreVersion = "1.6.1"
androidxRecyclerViewVersion = "1.3.2"
Expand All @@ -68,6 +68,7 @@ androidx-junit = { module = "androidx.test.ext:junit", version.ref = "junit" }
androidx-leanback = { module = "androidx.leanback:leanback", version.ref = "leanbackVersion" }
androidx-leanback-preference = { module = "androidx.leanback:leanback-preference", version.ref = "leanbackPreferenceVersion" }
androidx-legacy-support-v4 = { module = "androidx.legacy:legacy-support-v4", version.ref = "legacySupportV4Version" }
androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref="lifecycleVersion"}
androidx-percentlayout = { module = "androidx.percentlayout:percentlayout", version.ref = "percentlayoutVersion" }
androidx-recycler-view = { module = "androidx.recyclerview:recyclerview", version.ref = "androidxRecyclerViewVersion"}
commons-io = { module = "commons-io:commons-io", version.ref = "commonsIo" }
Expand All @@ -87,7 +88,6 @@ kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref="
kotlin-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref="kotlinCoroutinesVersion" }
kotlin-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref="kotlinCoroutinesVersion" }

android-priority-jobqueue = { group = "com.birbit", name = "android-priority-jobqueue", version.ref="androidPriorityJobQueueVersion" }
eventbus = { group = "org.greenrobot", name = "eventbus", version.ref = "eventBus"}
material = { module = "com.google.android.material:material", version.ref = "materialVersion" }
moxy-compiler = { module = "com.github.moxy-community:moxy-compiler", version.ref = "moxyCompilerVersion" }
Expand All @@ -104,8 +104,6 @@ joda-time = { group = "net.danlew", name = "android.joda", version.ref = "jodaTi
okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttpVersion" }
okhttp-logging-interceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttpVersion" }
timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timberVersion" }
easydeviceinfo-base = { group = "com.github.nisrulz", name = "easydeviceinfo-base", version.ref = "easydeviceInfoVersion" }
easydeviceinfo-common = { group = "com.github.nisrulz", name = "easydeviceinfo-common", version.ref = "easydeviceInfoVersion" }
resourceful = { group = "com.github.rstanic12", name = "Resourceful", version.ref = "resourcefulVersion"}
simple-xml = { group = "org.simpleframework", name = "simple-xml", version.ref = "simpleXmlVersion" }

Expand Down
1 change: 0 additions & 1 deletion serenity-android-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ dependencies {
api(project(":serenity-common"))
api(libs.eventbus)
implementation(libs.kotlin)
api(libs.android.priority.jobqueue)

releaseApi(libs.toothpick.runtime) {
exclude(group = "javax.inject")
Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions serenity-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,15 @@ dependencies {
exclude(group = "com.android.support")
}

implementation(libs.androidx.lifecycle.runtime)
implementation(libs.androidx.fragment.ktx)
implementation(libs.material)
implementation(libs.kotlin)
implementation(libs.kotlin.coroutines.android)
implementation(libs.moxy.community.moxy)
implementation(libs.moxy.community.moxy.app.compat)
implementation(libs.moxy.ktx)
implementation(libs.github.glide)
ksp(libs.glide.compiler)
implementation(libs.android.priority.jobqueue)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.leanback)
implementation(libs.androidx.leanback.preference)
Expand Down
69 changes: 69 additions & 0 deletions serenity-app/src/main/java/moxy/MvpAppCompatActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package moxy;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

@SuppressWarnings("unused")
public class MvpAppCompatActivity extends AppCompatActivity implements MvpDelegateHolder {

private MvpDelegate<? extends MvpAppCompatActivity> mvpDelegate;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

getMvpDelegate().onCreate(savedInstanceState);
}

@Override
protected void onStart() {
super.onStart();

getMvpDelegate().onAttach();
}

@Override
protected void onResume() {
super.onResume();

getMvpDelegate().onAttach();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);

getMvpDelegate().onSaveInstanceState(outState);
getMvpDelegate().onDetach();
}

@Override
protected void onStop() {
super.onStop();

getMvpDelegate().onDetach();
}

@Override
protected void onDestroy() {
super.onDestroy();

getMvpDelegate().onDestroyView();

if (isFinishing()) {
getMvpDelegate().onDestroy();
}
}

/**
* @return The {@link MvpDelegate} being used by this Activity.
*/
@Override
public MvpDelegate getMvpDelegate() {
if (mvpDelegate == null) {
mvpDelegate = new MvpDelegate<>(this);
}
return mvpDelegate;
}
}
Loading

0 comments on commit a701ca4

Please sign in to comment.