diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt index 69036d5d0..d7018c996 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -1,6 +1,7 @@ package io.legado.app.constant import android.annotation.SuppressLint +import android.provider.Settings import io.legado.app.R import splitties.init.appCtx import java.text.SimpleDateFormat @@ -76,4 +77,30 @@ object AppConst { document.getElementsByTagName('body')[0].style.webkitTextFillColor = '#8a8a8a'; """.trimIndent() } + + val androidId: String by lazy { + Settings.System.getString(appCtx.contentResolver, Settings.Secure.ANDROID_ID) + } + + val appInfo: AppInfo by lazy { + val appInfo = AppInfo() + appCtx.packageManager.getPackageInfo(appCtx.packageName, 0)?.let { + appInfo.versionName = it.versionName + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) { + appInfo.versionCode = it.longVersionCode + } else { + @Suppress("DEPRECATION") + appInfo.versionCode = it.versionCode.toLong() + } + } + appInfo + } + + val charsets = + arrayListOf("UTF-8", "GB2312", "GB18030", "GBK", "Unicode", "UTF-16", "UTF-16LE", "ASCII") + + data class AppInfo( + var versionCode: Long = 0L, + var versionName: String = "" + ) } diff --git a/app/src/main/java/io/legado/app/constant/Const.kt b/app/src/main/java/io/legado/app/constant/Const.kt deleted file mode 100644 index b3500a2ae..000000000 --- a/app/src/main/java/io/legado/app/constant/Const.kt +++ /dev/null @@ -1,30 +0,0 @@ -package io.legado.app.constant - -import android.provider.Settings -import splitties.init.appCtx - -val androidId: String by lazy { - Settings.System.getString(appCtx.contentResolver, Settings.Secure.ANDROID_ID) -} - -val appInfo: AppInfo by lazy { - val appInfo = AppInfo() - appCtx.packageManager.getPackageInfo(appCtx.packageName, 0)?.let { - appInfo.versionName = it.versionName - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) { - appInfo.versionCode = it.longVersionCode - } else { - @Suppress("DEPRECATION") - appInfo.versionCode = it.versionCode.toLong() - } - } - appInfo -} - -val charsets = - arrayListOf("UTF-8", "GB2312", "GB18030", "GBK", "Unicode", "UTF-16", "UTF-16LE", "ASCII") - -data class AppInfo( - var versionCode: Long = 0L, - var versionName: String = "" -) \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/AppDatabase.kt b/app/src/main/java/io/legado/app/data/AppDatabase.kt index 451c659c3..c48736382 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -7,7 +7,7 @@ import androidx.room.RoomDatabase import androidx.room.migration.Migration import androidx.sqlite.db.SupportSQLiteDatabase import io.legado.app.constant.AppConst -import io.legado.app.constant.androidId +import io.legado.app.constant.AppConst.androidId import io.legado.app.data.dao.* import io.legado.app.data.entities.* import splitties.init.appCtx diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index 435946e38..f2be6b7b5 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -11,8 +11,8 @@ import com.jayway.jsonpath.Option import com.jayway.jsonpath.ParseContext import io.legado.app.BuildConfig import io.legado.app.R +import io.legado.app.constant.AppConst.androidId import io.legado.app.constant.PreferKey -import io.legado.app.constant.androidId import io.legado.app.data.appDb import io.legado.app.data.entities.* import io.legado.app.help.DefaultData diff --git a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt index 166161c19..2a4c3dbf7 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt @@ -8,7 +8,7 @@ import androidx.annotation.StringRes import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import io.legado.app.R -import io.legado.app.constant.appInfo +import io.legado.app.constant.AppConst.appInfo import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.selector diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt index 121f4f114..015c30399 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt @@ -12,9 +12,9 @@ import com.google.android.material.snackbar.Snackbar import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.AppConst +import io.legado.app.constant.AppConst.charsets import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey -import io.legado.app.constant.charsets import io.legado.app.data.appDb import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt index 8dde10425..843995702 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt @@ -10,8 +10,8 @@ import androidx.activity.viewModels import androidx.core.view.isVisible import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.constant.AppConst.charsets import io.legado.app.constant.PreferKey -import io.legado.app.constant.charsets import io.legado.app.data.appDb import io.legado.app.data.entities.Bookmark import io.legado.app.databinding.ActivityBookReadBinding diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 5a45149a3..55a1498f4 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -13,9 +13,9 @@ import com.google.android.material.bottomnavigation.BottomNavigationView import io.legado.app.BuildConfig import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.constant.AppConst.appInfo import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey -import io.legado.app.constant.appInfo import io.legado.app.databinding.ActivityMainBinding import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp