diff --git a/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt index 10e5e3814..fafd9e11e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt @@ -12,10 +12,10 @@ import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.JobService +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.isRunningAsStub import com.topjohnwu.magisk.core.tasks.HideAPK import com.topjohnwu.magisk.core.utils.RootUtils -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.magisk.ui.theme.Theme import com.topjohnwu.magisk.utils.Utils import com.topjohnwu.magisk.view.MagiskDialog diff --git a/app/src/main/java/com/topjohnwu/magisk/core/App.kt b/app/src/main/java/com/topjohnwu/magisk/core/App.kt index 4b2ef3c92..d764281cf 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/App.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/App.kt @@ -7,8 +7,8 @@ import android.content.Context import android.content.res.Configuration import android.os.Bundle import com.topjohnwu.magisk.StubApk +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.utils.* -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.magisk.ui.surequest.SuRequestActivity import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.internal.UiThreadHandler diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Config.kt b/app/src/main/java/com/topjohnwu/magisk/core/Config.kt index 3ac22e870..9272fc354 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Config.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Config.kt @@ -6,21 +6,23 @@ import android.util.Xml import androidx.appcompat.app.AppCompatDelegate import androidx.core.content.edit import com.topjohnwu.magisk.BuildConfig +import com.topjohnwu.magisk.core.di.ServiceLocator +import com.topjohnwu.magisk.core.repository.BoolDBPropertyNoWrite +import com.topjohnwu.magisk.core.repository.DBConfig +import com.topjohnwu.magisk.core.repository.PreferenceConfig import com.topjohnwu.magisk.core.utils.refreshLocale -import com.topjohnwu.magisk.data.preference.PreferenceModel -import com.topjohnwu.magisk.data.repository.DBBoolSettingsNoWrite -import com.topjohnwu.magisk.data.repository.DBConfig -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.magisk.ui.theme.Theme +import kotlinx.coroutines.GlobalScope import org.xmlpull.v1.XmlPullParser import java.io.File import java.io.InputStream -object Config : PreferenceModel, DBConfig { +object Config : PreferenceConfig, DBConfig { override val stringDB get() = ServiceLocator.stringDB override val settingsDB get() = ServiceLocator.settingsDB override val context get() = ServiceLocator.deContext + override val coroutineScope get() = GlobalScope @get:SuppressLint("ApplySharedPref") val prefsFile: File get() { @@ -152,7 +154,7 @@ object Config : PreferenceModel, DBConfig { var suMultiuserMode by dbSettings(Key.SU_MULTIUSER_MODE, Value.MULTIUSER_MODE_OWNER_ONLY) var suBiometric by dbSettings(Key.SU_BIOMETRIC, false) var zygisk by dbSettings(Key.ZYGISK, false) - var denyList by DBBoolSettingsNoWrite(Key.DENYLIST, false) + var denyList by BoolDBPropertyNoWrite(Key.DENYLIST, false) var suManager by dbStrings(Key.SU_MANAGER, "", true) var keyStoreRaw by dbStrings(Key.KEYSTORE, "", true) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt b/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt index b5ad7f2a4..b2d2e4aba 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt @@ -13,8 +13,8 @@ import android.content.res.Resources import android.util.DisplayMetrics import com.topjohnwu.magisk.R import com.topjohnwu.magisk.StubApk +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.core.utils.syncLocale -import com.topjohnwu.magisk.di.AppContext lateinit var AppApkPath: String diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Info.kt b/app/src/main/java/com/topjohnwu/magisk/core/Info.kt index aa1b73dbe..d9bd771c5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Info.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Info.kt @@ -3,10 +3,10 @@ package com.topjohnwu.magisk.core import android.os.Build import androidx.databinding.ObservableBoolean import com.topjohnwu.magisk.StubApk +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.core.model.UpdateInfo +import com.topjohnwu.magisk.core.repository.NetworkService import com.topjohnwu.magisk.core.utils.net.NetworkObserver -import com.topjohnwu.magisk.data.repository.NetworkService -import com.topjohnwu.magisk.di.AppContext import com.topjohnwu.magisk.ktx.getProperty import com.topjohnwu.superuser.ShellUtils.fastCmd import com.topjohnwu.superuser.internal.UiThreadHandler diff --git a/app/src/main/java/com/topjohnwu/magisk/core/JobService.kt b/app/src/main/java/com/topjohnwu/magisk/core/JobService.kt index 702504fee..9390a2ded 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/JobService.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/JobService.kt @@ -7,7 +7,7 @@ import android.content.Context import androidx.core.content.getSystemService import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.core.base.BaseJobService -import com.topjohnwu.magisk.di.ServiceLocator +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.view.Notifications import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Receiver.kt b/app/src/main/java/com/topjohnwu/magisk/core/Receiver.kt index f1bcf12dd..c016ddde3 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Receiver.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Receiver.kt @@ -4,7 +4,7 @@ import android.annotation.SuppressLint import android.content.ContextWrapper import android.content.Intent import com.topjohnwu.magisk.core.base.BaseReceiver -import com.topjohnwu.magisk.di.ServiceLocator +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.view.Notifications import com.topjohnwu.magisk.view.Shortcuts import com.topjohnwu.superuser.Shell diff --git a/app/src/main/java/com/topjohnwu/magisk/data/network/NetworkServices.kt b/app/src/main/java/com/topjohnwu/magisk/core/data/NetworkServices.kt similarity index 96% rename from app/src/main/java/com/topjohnwu/magisk/data/network/NetworkServices.kt rename to app/src/main/java/com/topjohnwu/magisk/core/data/NetworkServices.kt index 1e00b4b09..cbbde75d5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/network/NetworkServices.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/data/NetworkServices.kt @@ -1,4 +1,4 @@ -package com.topjohnwu.magisk.data.network +package com.topjohnwu.magisk.core.data import com.topjohnwu.magisk.core.model.BranchInfo import com.topjohnwu.magisk.core.model.ModuleJson diff --git a/app/src/main/java/com/topjohnwu/magisk/data/database/SuLogDao.kt b/app/src/main/java/com/topjohnwu/magisk/core/data/SuLogDao.kt similarity index 95% rename from app/src/main/java/com/topjohnwu/magisk/data/database/SuLogDao.kt rename to app/src/main/java/com/topjohnwu/magisk/core/data/SuLogDao.kt index e86b48c87..37570115d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/database/SuLogDao.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/data/SuLogDao.kt @@ -1,4 +1,4 @@ -package com.topjohnwu.magisk.data.database +package com.topjohnwu.magisk.core.data import androidx.room.* import com.topjohnwu.magisk.core.model.su.SuLog diff --git a/app/src/main/java/com/topjohnwu/magisk/core/magiskdb/MagiskDB.kt b/app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/MagiskDB.kt similarity index 96% rename from app/src/main/java/com/topjohnwu/magisk/core/magiskdb/MagiskDB.kt rename to app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/MagiskDB.kt index 6ddafc1d4..f78b27226 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/magiskdb/MagiskDB.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/MagiskDB.kt @@ -1,4 +1,4 @@ -package com.topjohnwu.magisk.core.magiskdb +package com.topjohnwu.magisk.core.data.magiskdb import com.topjohnwu.magisk.ktx.await import com.topjohnwu.superuser.Shell diff --git a/app/src/main/java/com/topjohnwu/magisk/core/magiskdb/PolicyDao.kt b/app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/PolicyDao.kt similarity index 94% rename from app/src/main/java/com/topjohnwu/magisk/core/magiskdb/PolicyDao.kt rename to app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/PolicyDao.kt index dae76188a..9c3727c08 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/magiskdb/PolicyDao.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/PolicyDao.kt @@ -1,8 +1,8 @@ -package com.topjohnwu.magisk.core.magiskdb +package com.topjohnwu.magisk.core.data.magiskdb import com.topjohnwu.magisk.core.Const +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.core.model.su.SuPolicy -import com.topjohnwu.magisk.di.AppContext import java.util.concurrent.TimeUnit class PolicyDao : MagiskDB() { diff --git a/app/src/main/java/com/topjohnwu/magisk/core/magiskdb/SettingsDao.kt b/app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/SettingsDao.kt similarity index 92% rename from app/src/main/java/com/topjohnwu/magisk/core/magiskdb/SettingsDao.kt rename to app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/SettingsDao.kt index b9e42f364..b7a8cc9e0 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/magiskdb/SettingsDao.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/SettingsDao.kt @@ -1,4 +1,4 @@ -package com.topjohnwu.magisk.core.magiskdb +package com.topjohnwu.magisk.core.data.magiskdb class SettingsDao : MagiskDB() { diff --git a/app/src/main/java/com/topjohnwu/magisk/core/magiskdb/StringDao.kt b/app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/StringDao.kt similarity index 92% rename from app/src/main/java/com/topjohnwu/magisk/core/magiskdb/StringDao.kt rename to app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/StringDao.kt index 8f5f6b2e4..bdc4c3155 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/magiskdb/StringDao.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/data/magiskdb/StringDao.kt @@ -1,4 +1,4 @@ -package com.topjohnwu.magisk.core.magiskdb +package com.topjohnwu.magisk.core.data.magiskdb class StringDao : MagiskDB() { diff --git a/app/src/main/java/com/topjohnwu/magisk/di/Networking.kt b/app/src/main/java/com/topjohnwu/magisk/core/di/Networking.kt similarity index 98% rename from app/src/main/java/com/topjohnwu/magisk/di/Networking.kt rename to app/src/main/java/com/topjohnwu/magisk/core/di/Networking.kt index cd54edf63..1cade82d6 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/Networking.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/di/Networking.kt @@ -1,4 +1,4 @@ -package com.topjohnwu.magisk.di +package com.topjohnwu.magisk.core.di import android.content.Context import com.squareup.moshi.Moshi diff --git a/app/src/main/java/com/topjohnwu/magisk/di/ServiceLocator.kt b/app/src/main/java/com/topjohnwu/magisk/core/di/ServiceLocator.kt similarity index 89% rename from app/src/main/java/com/topjohnwu/magisk/di/ServiceLocator.kt rename to app/src/main/java/com/topjohnwu/magisk/core/di/ServiceLocator.kt index 4b80264c2..a7a4ad26c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/ServiceLocator.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/di/ServiceLocator.kt @@ -1,4 +1,4 @@ -package com.topjohnwu.magisk.di +package com.topjohnwu.magisk.core.di import android.annotation.SuppressLint import android.content.Context @@ -8,12 +8,12 @@ import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelStoreOwner import androidx.room.Room import com.topjohnwu.magisk.core.Const -import com.topjohnwu.magisk.core.magiskdb.PolicyDao -import com.topjohnwu.magisk.core.magiskdb.SettingsDao -import com.topjohnwu.magisk.core.magiskdb.StringDao -import com.topjohnwu.magisk.data.database.SuLogDatabase -import com.topjohnwu.magisk.data.repository.LogRepository -import com.topjohnwu.magisk.data.repository.NetworkService +import com.topjohnwu.magisk.core.data.SuLogDatabase +import com.topjohnwu.magisk.core.data.magiskdb.PolicyDao +import com.topjohnwu.magisk.core.data.magiskdb.SettingsDao +import com.topjohnwu.magisk.core.data.magiskdb.StringDao +import com.topjohnwu.magisk.core.repository.LogRepository +import com.topjohnwu.magisk.core.repository.NetworkService import com.topjohnwu.magisk.ktx.deviceProtectedContext import com.topjohnwu.magisk.ui.home.HomeViewModel import com.topjohnwu.magisk.ui.install.InstallViewModel diff --git a/app/src/main/java/com/topjohnwu/magisk/core/download/DownloadService.kt b/app/src/main/java/com/topjohnwu/magisk/core/download/DownloadService.kt index 31a5d31df..179c9b8bf 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/download/DownloadService.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/download/DownloadService.kt @@ -11,7 +11,10 @@ import androidx.core.net.toFile import androidx.lifecycle.LifecycleOwner import com.topjohnwu.magisk.R import com.topjohnwu.magisk.StubApk -import com.topjohnwu.magisk.core.* +import com.topjohnwu.magisk.core.ActivityTracker +import com.topjohnwu.magisk.core.Info +import com.topjohnwu.magisk.core.intent +import com.topjohnwu.magisk.core.isRunningAsStub import com.topjohnwu.magisk.core.tasks.HideAPK import com.topjohnwu.magisk.core.utils.MediaStoreUtils import com.topjohnwu.magisk.core.utils.MediaStoreUtils.outputStream diff --git a/app/src/main/java/com/topjohnwu/magisk/core/download/NotificationService.kt b/app/src/main/java/com/topjohnwu/magisk/core/download/NotificationService.kt index 2161ecd6a..3e2cfac8d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/download/NotificationService.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/download/NotificationService.kt @@ -6,8 +6,8 @@ import android.os.IBinder import androidx.lifecycle.MutableLiveData import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.base.BaseService +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.utils.ProgressInputStream -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.magisk.ktx.synchronized import com.topjohnwu.magisk.view.Notifications import okhttp3.ResponseBody diff --git a/app/src/main/java/com/topjohnwu/magisk/core/download/Subject.kt b/app/src/main/java/com/topjohnwu/magisk/core/download/Subject.kt index a43a9382a..fdac8b0fe 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/download/Subject.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/download/Subject.kt @@ -8,11 +8,11 @@ import android.net.Uri import android.os.Parcelable import androidx.core.net.toUri import com.topjohnwu.magisk.core.Info +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.core.model.MagiskJson import com.topjohnwu.magisk.core.model.StubJson import com.topjohnwu.magisk.core.model.module.OnlineModule import com.topjohnwu.magisk.core.utils.MediaStoreUtils -import com.topjohnwu.magisk.di.AppContext import com.topjohnwu.magisk.ktx.cachedFile import com.topjohnwu.magisk.ui.flash.FlashFragment import com.topjohnwu.magisk.view.Notifications diff --git a/app/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt b/app/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt index 64a5725a2..225830aba 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt @@ -2,8 +2,8 @@ package com.topjohnwu.magisk.core.model.module import com.squareup.moshi.JsonDataException import com.topjohnwu.magisk.core.Const +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.utils.RootUtils -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.superuser.Shell import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/DBConfig.kt b/app/src/main/java/com/topjohnwu/magisk/core/repository/DBConfig.kt similarity index 79% rename from app/src/main/java/com/topjohnwu/magisk/data/repository/DBConfig.kt rename to app/src/main/java/com/topjohnwu/magisk/core/repository/DBConfig.kt index 66bcd5671..e7df2e7af 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/repository/DBConfig.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/repository/DBConfig.kt @@ -1,8 +1,8 @@ -package com.topjohnwu.magisk.data.repository +package com.topjohnwu.magisk.core.repository -import com.topjohnwu.magisk.core.magiskdb.SettingsDao -import com.topjohnwu.magisk.core.magiskdb.StringDao -import kotlinx.coroutines.GlobalScope +import com.topjohnwu.magisk.core.data.magiskdb.SettingsDao +import com.topjohnwu.magisk.core.data.magiskdb.StringDao +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlin.properties.ReadWriteProperty @@ -11,26 +11,27 @@ import kotlin.reflect.KProperty interface DBConfig { val settingsDB: SettingsDao val stringDB: StringDao + val coroutineScope: CoroutineScope fun dbSettings( name: String, default: Int - ) = DBSettingsValue(name, default) + ) = IntDBProperty(name, default) fun dbSettings( name: String, default: Boolean - ) = DBBoolSettings(name, default) + ) = BoolDBProperty(name, default) fun dbStrings( name: String, default: String, sync: Boolean = false - ) = DBStringsValue(name, default, sync) + ) = StringDBProperty(name, default, sync) } -class DBSettingsValue( +class IntDBProperty( private val name: String, private val default: Int ) : ReadWriteProperty { @@ -48,18 +49,18 @@ class DBSettingsValue( synchronized(this) { this.value = value } - GlobalScope.launch { + thisRef.coroutineScope.launch { thisRef.settingsDB.put(name, value) } } } -open class DBBoolSettings( +open class BoolDBProperty( name: String, default: Boolean ) : ReadWriteProperty { - val base = DBSettingsValue(name, if (default) 1 else 0) + val base = IntDBProperty(name, if (default) 1 else 0) override fun getValue(thisRef: DBConfig, property: KProperty<*>): Boolean = base.getValue(thisRef, property) != 0 @@ -68,10 +69,10 @@ open class DBBoolSettings( base.setValue(thisRef, property, if (value) 1 else 0) } -class DBBoolSettingsNoWrite( +class BoolDBPropertyNoWrite( name: String, default: Boolean -) : DBBoolSettings(name, default) { +) : BoolDBProperty(name, default) { override fun setValue(thisRef: DBConfig, property: KProperty<*>, value: Boolean) { synchronized(base) { base.value = if (value) 1 else 0 @@ -79,7 +80,7 @@ class DBBoolSettingsNoWrite( } } -class DBStringsValue( +class StringDBProperty( private val name: String, private val default: String, private val sync: Boolean @@ -106,7 +107,7 @@ class DBStringsValue( thisRef.stringDB.delete(name) } } else { - GlobalScope.launch { + thisRef.coroutineScope.launch { thisRef.stringDB.delete(name) } } @@ -116,7 +117,7 @@ class DBStringsValue( thisRef.stringDB.put(name, value) } } else { - GlobalScope.launch { + thisRef.coroutineScope.launch { thisRef.stringDB.put(name, value) } } diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt b/app/src/main/java/com/topjohnwu/magisk/core/repository/LogRepository.kt similarity index 93% rename from app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt rename to app/src/main/java/com/topjohnwu/magisk/core/repository/LogRepository.kt index b825a7b7e..cbd93bb9d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/repository/LogRepository.kt @@ -1,9 +1,9 @@ -package com.topjohnwu.magisk.data.repository +package com.topjohnwu.magisk.core.repository import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.Info +import com.topjohnwu.magisk.core.data.SuLogDao import com.topjohnwu.magisk.core.model.su.SuLog -import com.topjohnwu.magisk.data.database.SuLogDao import com.topjohnwu.magisk.ktx.await import com.topjohnwu.superuser.Shell diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/NetworkService.kt b/app/src/main/java/com/topjohnwu/magisk/core/repository/NetworkService.kt similarity index 91% rename from app/src/main/java/com/topjohnwu/magisk/data/repository/NetworkService.kt rename to app/src/main/java/com/topjohnwu/magisk/core/repository/NetworkService.kt index 96ec749f0..6e897e1ae 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/repository/NetworkService.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/repository/NetworkService.kt @@ -1,4 +1,4 @@ -package com.topjohnwu.magisk.data.repository +package com.topjohnwu.magisk.core.repository import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.Config.Value.BETA_CHANNEL @@ -8,9 +8,9 @@ import com.topjohnwu.magisk.core.Config.Value.DEBUG_CHANNEL import com.topjohnwu.magisk.core.Config.Value.DEFAULT_CHANNEL import com.topjohnwu.magisk.core.Config.Value.STABLE_CHANNEL import com.topjohnwu.magisk.core.Info -import com.topjohnwu.magisk.data.network.GithubApiServices -import com.topjohnwu.magisk.data.network.GithubPageServices -import com.topjohnwu.magisk.data.network.RawServices +import com.topjohnwu.magisk.core.data.GithubApiServices +import com.topjohnwu.magisk.core.data.GithubPageServices +import com.topjohnwu.magisk.core.data.RawServices import retrofit2.HttpException import timber.log.Timber import java.io.IOException diff --git a/app/src/main/java/com/topjohnwu/magisk/data/preference/Property.kt b/app/src/main/java/com/topjohnwu/magisk/core/repository/PreferenceConfig.kt similarity index 62% rename from app/src/main/java/com/topjohnwu/magisk/data/preference/Property.kt rename to app/src/main/java/com/topjohnwu/magisk/core/repository/PreferenceConfig.kt index df8075139..1005619ec 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/preference/Property.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/repository/PreferenceConfig.kt @@ -1,11 +1,73 @@ -package com.topjohnwu.magisk.data.preference +package com.topjohnwu.magisk.core.repository +import android.content.Context import android.content.SharedPreferences import androidx.core.content.edit import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty -abstract class Property { +interface PreferenceConfig { + + val context: Context + + val fileName: String + get() = "${context.packageName}_preferences" + + val prefs: SharedPreferences + get() = context.getSharedPreferences(fileName, Context.MODE_PRIVATE) + + fun preferenceStrInt( + name: String, + default: Int, + commit: Boolean = false + ) = object: ReadWriteProperty { + val base = StringProperty(name, default.toString(), commit) + override fun getValue(thisRef: PreferenceConfig, property: KProperty<*>): Int = + base.getValue(thisRef, property).toInt() + + override fun setValue(thisRef: PreferenceConfig, property: KProperty<*>, value: Int) = + base.setValue(thisRef, property, value.toString()) + } + + fun preference( + name: String, + default: Boolean, + commit: Boolean = false + ) = BooleanProperty(name, default, commit) + + fun preference( + name: String, + default: Float, + commit: Boolean = false + ) = FloatProperty(name, default, commit) + + fun preference( + name: String, + default: Int, + commit: Boolean = false + ) = IntProperty(name, default, commit) + + fun preference( + name: String, + default: Long, + commit: Boolean = false + ) = LongProperty(name, default, commit) + + fun preference( + name: String, + default: String, + commit: Boolean = false + ) = StringProperty(name, default, commit) + + fun preference( + name: String, + default: Set, + commit: Boolean = false + ) = StringSetProperty(name, default, commit) + +} + +abstract class PreferenceProperty { fun SharedPreferences.Editor.put(name: String, value: Boolean) = putBoolean(name, value) fun SharedPreferences.Editor.put(name: String, value: Float) = putFloat(name, value) @@ -27,10 +89,10 @@ class BooleanProperty( private val name: String, private val default: Boolean, private val commit: Boolean -) : Property(), ReadWriteProperty { +) : PreferenceProperty(), ReadWriteProperty { override operator fun getValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*> ): Boolean { val prefName = name.ifBlank { property.name } @@ -38,7 +100,7 @@ class BooleanProperty( } override operator fun setValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*>, value: Boolean ) { @@ -51,10 +113,10 @@ class FloatProperty( private val name: String, private val default: Float, private val commit: Boolean -) : Property(), ReadWriteProperty { +) : PreferenceProperty(), ReadWriteProperty { override operator fun getValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*> ): Float { val prefName = name.ifBlank { property.name } @@ -62,7 +124,7 @@ class FloatProperty( } override operator fun setValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*>, value: Float ) { @@ -75,10 +137,10 @@ class IntProperty( private val name: String, private val default: Int, private val commit: Boolean -) : Property(), ReadWriteProperty { +) : PreferenceProperty(), ReadWriteProperty { override operator fun getValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*> ): Int { val prefName = name.ifBlank { property.name } @@ -86,7 +148,7 @@ class IntProperty( } override operator fun setValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*>, value: Int ) { @@ -99,10 +161,10 @@ class LongProperty( private val name: String, private val default: Long, private val commit: Boolean -) : Property(), ReadWriteProperty { +) : PreferenceProperty(), ReadWriteProperty { override operator fun getValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*> ): Long { val prefName = name.ifBlank { property.name } @@ -110,7 +172,7 @@ class LongProperty( } override operator fun setValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*>, value: Long ) { @@ -123,10 +185,10 @@ class StringProperty( private val name: String, private val default: String, private val commit: Boolean -) : Property(), ReadWriteProperty { +) : PreferenceProperty(), ReadWriteProperty { override operator fun getValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*> ): String { val prefName = name.ifBlank { property.name } @@ -134,7 +196,7 @@ class StringProperty( } override operator fun setValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*>, value: String ) { @@ -147,10 +209,10 @@ class StringSetProperty( private val name: String, private val default: Set, private val commit: Boolean -) : Property(), ReadWriteProperty> { +) : PreferenceProperty(), ReadWriteProperty> { override operator fun getValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*> ): Set { val prefName = name.ifBlank { property.name } @@ -158,7 +220,7 @@ class StringSetProperty( } override operator fun setValue( - thisRef: PreferenceModel, + thisRef: PreferenceConfig, property: KProperty<*>, value: Set ) { diff --git a/app/src/main/java/com/topjohnwu/magisk/core/su/SuCallbackHandler.kt b/app/src/main/java/com/topjohnwu/magisk/core/su/SuCallbackHandler.kt index d33f748c9..e98cd95f5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/su/SuCallbackHandler.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/su/SuCallbackHandler.kt @@ -6,9 +6,9 @@ import android.widget.Toast import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Config +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.model.su.SuPolicy import com.topjohnwu.magisk.core.model.su.createSuLog -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.magisk.ktx.getLabel import com.topjohnwu.magisk.ktx.getPackageInfo import com.topjohnwu.magisk.utils.Utils diff --git a/app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt b/app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt index d2e09c51f..207273a0d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt @@ -5,7 +5,7 @@ import android.content.pm.PackageInfo import android.content.pm.PackageManager import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.core.Config -import com.topjohnwu.magisk.core.magiskdb.PolicyDao +import com.topjohnwu.magisk.core.data.magiskdb.PolicyDao import com.topjohnwu.magisk.core.model.su.SuPolicy import com.topjohnwu.magisk.ktx.getPackageInfo import com.topjohnwu.superuser.Shell diff --git a/app/src/main/java/com/topjohnwu/magisk/core/tasks/FlashZip.kt b/app/src/main/java/com/topjohnwu/magisk/core/tasks/FlashZip.kt index 480f86c96..d26bce8b2 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/tasks/FlashZip.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/tasks/FlashZip.kt @@ -3,10 +3,10 @@ package com.topjohnwu.magisk.core.tasks import android.net.Uri import androidx.core.net.toFile import com.topjohnwu.magisk.core.Const +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.core.utils.MediaStoreUtils.displayName import com.topjohnwu.magisk.core.utils.MediaStoreUtils.inputStream import com.topjohnwu.magisk.core.utils.unzip -import com.topjohnwu.magisk.di.AppContext import com.topjohnwu.magisk.ktx.writeTo import com.topjohnwu.superuser.Shell import kotlinx.coroutines.Dispatchers diff --git a/app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt b/app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt index 061e714be..fa8ff1621 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt @@ -11,9 +11,9 @@ import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.Provider +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.utils.AXML import com.topjohnwu.magisk.core.utils.Keygen -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.magisk.ktx.await import com.topjohnwu.magisk.ktx.writeTo import com.topjohnwu.magisk.signing.JarMap diff --git a/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt b/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt index 00361f436..daa434dd1 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt @@ -9,11 +9,11 @@ import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.R import com.topjohnwu.magisk.StubApk import com.topjohnwu.magisk.core.* +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.utils.MediaStoreUtils import com.topjohnwu.magisk.core.utils.MediaStoreUtils.inputStream import com.topjohnwu.magisk.core.utils.MediaStoreUtils.outputStream import com.topjohnwu.magisk.core.utils.RootUtils -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.magisk.ktx.reboot import com.topjohnwu.magisk.ktx.withStreams import com.topjohnwu.magisk.ktx.writeTo diff --git a/app/src/main/java/com/topjohnwu/magisk/core/utils/AXML.kt b/app/src/main/java/com/topjohnwu/magisk/core/utils/AXML.kt index 0775e81ac..a36c4ce24 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/utils/AXML.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/utils/AXML.kt @@ -4,7 +4,6 @@ import java.io.ByteArrayOutputStream import java.nio.ByteBuffer import java.nio.ByteOrder.LITTLE_ENDIAN import java.nio.charset.Charset -import java.util.* class AXML(b: ByteArray) { diff --git a/app/src/main/java/com/topjohnwu/magisk/core/utils/BiometricHelper.kt b/app/src/main/java/com/topjohnwu/magisk/core/utils/BiometricHelper.kt index 4c155599f..073d3514e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/utils/BiometricHelper.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/utils/BiometricHelper.kt @@ -6,7 +6,7 @@ import androidx.core.content.ContextCompat import androidx.fragment.app.FragmentActivity import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Config -import com.topjohnwu.magisk.di.AppContext +import com.topjohnwu.magisk.core.di.AppContext object BiometricHelper { diff --git a/app/src/main/java/com/topjohnwu/magisk/core/utils/Locales.kt b/app/src/main/java/com/topjohnwu/magisk/core/utils/Locales.kt index 7ec5691c5..a9c92a04c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/utils/Locales.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/utils/Locales.kt @@ -8,11 +8,10 @@ import android.content.res.Resources import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.createNewResources -import com.topjohnwu.magisk.di.AppContext +import com.topjohnwu.magisk.core.di.AppContext import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import java.util.* -import kotlin.collections.ArrayList var currentLocale: Locale = Locale.getDefault() diff --git a/app/src/main/java/com/topjohnwu/magisk/core/utils/MediaStoreUtils.kt b/app/src/main/java/com/topjohnwu/magisk/core/utils/MediaStoreUtils.kt index 57e0d785c..14c16d0c0 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/utils/MediaStoreUtils.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/utils/MediaStoreUtils.kt @@ -11,7 +11,7 @@ import androidx.annotation.RequiresApi import androidx.core.net.toFile import androidx.core.net.toUri import com.topjohnwu.magisk.core.Config -import com.topjohnwu.magisk.di.AppContext +import com.topjohnwu.magisk.core.di.AppContext import java.io.File import java.io.FileNotFoundException import java.io.IOException diff --git a/app/src/main/java/com/topjohnwu/magisk/data/preference/PreferenceModel.kt b/app/src/main/java/com/topjohnwu/magisk/data/preference/PreferenceModel.kt deleted file mode 100644 index a6bf16c0d..000000000 --- a/app/src/main/java/com/topjohnwu/magisk/data/preference/PreferenceModel.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.topjohnwu.magisk.data.preference - -import android.content.Context -import android.content.SharedPreferences -import kotlin.properties.ReadWriteProperty -import kotlin.reflect.KProperty - -interface PreferenceModel { - - val context: Context - - val fileName: String - get() = "${context.packageName}_preferences" - - val prefs: SharedPreferences - get() = context.getSharedPreferences(fileName, Context.MODE_PRIVATE) - - fun preferenceStrInt( - name: String, - default: Int, - commit: Boolean = false - ) = object: ReadWriteProperty { - val base = StringProperty(name, default.toString(), commit) - override fun getValue(thisRef: PreferenceModel, property: KProperty<*>): Int = - base.getValue(thisRef, property).toInt() - - override fun setValue(thisRef: PreferenceModel, property: KProperty<*>, value: Int) = - base.setValue(thisRef, property, value.toString()) - } - - fun preference( - name: String, - default: Boolean, - commit: Boolean = false - ) = BooleanProperty(name, default, commit) - - fun preference( - name: String, - default: Float, - commit: Boolean = false - ) = FloatProperty(name, default, commit) - - fun preference( - name: String, - default: Int, - commit: Boolean = false - ) = IntProperty(name, default, commit) - - fun preference( - name: String, - default: Long, - commit: Boolean = false - ) = LongProperty(name, default, commit) - - fun preference( - name: String, - default: String, - commit: Boolean = false - ) = StringProperty(name, default, commit) - - fun preference( - name: String, - default: Set, - commit: Boolean = false - ) = StringSetProperty(name, default, commit) - -} diff --git a/app/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt b/app/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt index fd5f09f31..47eaa6b63 100644 --- a/app/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt +++ b/app/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt @@ -29,7 +29,7 @@ import com.google.android.material.card.MaterialCardView import com.google.android.material.chip.Chip import com.google.android.material.textfield.TextInputLayout import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.di.ServiceLocator +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.superuser.internal.UiThreadHandler import com.topjohnwu.widget.IndeterminateCheckBox import kotlin.math.roundToInt diff --git a/app/src/main/java/com/topjohnwu/magisk/databinding/DiffObservableList.kt b/app/src/main/java/com/topjohnwu/magisk/databinding/DiffObservableList.kt index d2839161d..cda73bf7b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/databinding/DiffObservableList.kt +++ b/app/src/main/java/com/topjohnwu/magisk/databinding/DiffObservableList.kt @@ -6,7 +6,6 @@ import androidx.databinding.ObservableList import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListUpdateCallback import java.util.* -import kotlin.collections.ArrayList /** * @param callback The callback that controls the behavior of the DiffObservableList. diff --git a/app/src/main/java/com/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt b/app/src/main/java/com/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt index c3a881cf9..e40f32af5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt +++ b/app/src/main/java/com/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt @@ -2,10 +2,10 @@ package com.topjohnwu.magisk.events.dialog import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Info +import com.topjohnwu.magisk.core.di.AppContext +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.download.DownloadService import com.topjohnwu.magisk.core.download.Subject -import com.topjohnwu.magisk.di.AppContext -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.magisk.view.MagiskDialog import java.io.File diff --git a/app/src/main/java/com/topjohnwu/magisk/events/dialog/MarkDownDialog.kt b/app/src/main/java/com/topjohnwu/magisk/events/dialog/MarkDownDialog.kt index 7204296ab..0b8efa1dd 100644 --- a/app/src/main/java/com/topjohnwu/magisk/events/dialog/MarkDownDialog.kt +++ b/app/src/main/java/com/topjohnwu/magisk/events/dialog/MarkDownDialog.kt @@ -6,7 +6,7 @@ import androidx.annotation.CallSuper import androidx.lifecycle.lifecycleScope import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.base.BaseActivity -import com.topjohnwu.magisk.di.ServiceLocator +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.view.MagiskDialog import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt b/app/src/main/java/com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt index 4fccf7c44..37134847f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt +++ b/app/src/main/java/com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt @@ -1,11 +1,11 @@ package com.topjohnwu.magisk.events.dialog import com.topjohnwu.magisk.R +import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.download.Action import com.topjohnwu.magisk.core.download.DownloadService import com.topjohnwu.magisk.core.download.Subject import com.topjohnwu.magisk.core.model.module.OnlineModule -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.magisk.view.MagiskDialog class ModuleInstallDialog(private val item: OnlineModule) : MarkDownDialog() { diff --git a/app/src/main/java/com/topjohnwu/magisk/signing/SignApk.java b/app/src/main/java/com/topjohnwu/magisk/signing/SignApk.java index f14001328..a8728cdd5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/signing/SignApk.java +++ b/app/src/main/java/com/topjohnwu/magisk/signing/SignApk.java @@ -17,7 +17,6 @@ import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder; import org.bouncycastle.util.encoders.Base64; import java.io.ByteArrayOutputStream; -import java.io.FileOutputStream; import java.io.FilterOutputStream; import java.io.IOException; import java.io.InputStream; diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt index 7929dbb82..34cce6814 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt @@ -18,9 +18,9 @@ import com.topjohnwu.magisk.arch.BaseViewModel import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.Info +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.core.isRunningAsStub import com.topjohnwu.magisk.databinding.ActivityMainMd2Binding -import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.ktx.startAnimations import com.topjohnwu.magisk.ui.home.HomeFragmentDirections import com.topjohnwu.magisk.utils.Utils diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt index 69099ce2a..e353e34a7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListFragment.kt @@ -10,8 +10,8 @@ import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.RecyclerView import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseFragment +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.databinding.FragmentDenyMd2Binding -import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.ktx.hideKeyboard import rikka.recyclerview.addEdgeSpacing import rikka.recyclerview.addItemSpacing diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt index 288cbf097..7e0a3a846 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt @@ -5,15 +5,18 @@ import android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES import androidx.lifecycle.viewModelScope import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.arch.BaseViewModel +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.databinding.filterableListOf import com.topjohnwu.magisk.databinding.itemBindingOf -import com.topjohnwu.magisk.di.AppContext import com.topjohnwu.magisk.ktx.concurrentMap import com.topjohnwu.magisk.utils.Utils import com.topjohnwu.superuser.Shell -import kotlinx.coroutines.* -import kotlinx.coroutines.flow.* -import java.util.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.asFlow +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.toCollection +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext class DenyListViewModel : BaseViewModel() { diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashFragment.kt index bf423a048..f5cae0b03 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashFragment.kt @@ -12,8 +12,8 @@ import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.cmp +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.databinding.FragmentFlashMd2Binding -import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.ui.MainActivity class FlashFragment : BaseFragment() { diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt index 6974576b3..1954b9d61 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt @@ -7,9 +7,9 @@ import android.widget.TextView import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.core.Info +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.core.download.DownloadService import com.topjohnwu.magisk.databinding.FragmentHomeMd2Binding -import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.events.RebootEvent class HomeFragment : BaseFragment() { diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt index 6828dc215..2ba65f39b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt @@ -11,7 +11,7 @@ import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.download.Subject import com.topjohnwu.magisk.core.download.Subject.App -import com.topjohnwu.magisk.data.repository.NetworkService +import com.topjohnwu.magisk.core.repository.NetworkService import com.topjohnwu.magisk.databinding.itemBindingOf import com.topjohnwu.magisk.databinding.set import com.topjohnwu.magisk.events.SnackbarEvent diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallFragment.kt index bbf8e1e93..e2f4db864 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallFragment.kt @@ -2,8 +2,8 @@ package com.topjohnwu.magisk.ui.install import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseFragment +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.databinding.FragmentInstallMd2Binding -import com.topjohnwu.magisk.di.viewModel class InstallFragment : BaseFragment() { diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt index 5541f292e..f96307ec2 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt @@ -18,10 +18,10 @@ import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.base.ContentResultCallback -import com.topjohnwu.magisk.data.repository.NetworkService +import com.topjohnwu.magisk.core.di.AppContext +import com.topjohnwu.magisk.core.di.ServiceLocator +import com.topjohnwu.magisk.core.repository.NetworkService import com.topjohnwu.magisk.databinding.set -import com.topjohnwu.magisk.di.AppContext -import com.topjohnwu.magisk.di.ServiceLocator import com.topjohnwu.magisk.events.GetContentEvent import com.topjohnwu.magisk.events.dialog.SecondSlotWarningDialog import com.topjohnwu.magisk.ui.flash.FlashFragment diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt index 4cd2467ef..9a1b7172a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt @@ -8,8 +8,8 @@ import android.view.View import androidx.core.view.isVisible import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseFragment +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.databinding.FragmentLogMd2Binding -import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.ui.MainActivity import com.topjohnwu.magisk.utils.MotionRevealHelper import rikka.recyclerview.addEdgeSpacing diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt index 3b24e6a11..fab4d2564 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt @@ -7,9 +7,9 @@ import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseViewModel import com.topjohnwu.magisk.core.Info +import com.topjohnwu.magisk.core.repository.LogRepository import com.topjohnwu.magisk.core.utils.MediaStoreUtils import com.topjohnwu.magisk.core.utils.MediaStoreUtils.outputStream -import com.topjohnwu.magisk.data.repository.LogRepository import com.topjohnwu.magisk.databinding.diffListOf import com.topjohnwu.magisk.databinding.itemBindingOf import com.topjohnwu.magisk.databinding.set diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt index ee4797782..d9deae102 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt @@ -6,10 +6,10 @@ import com.topjohnwu.magisk.MainDirections import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseFragment import com.topjohnwu.magisk.core.Const +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding import com.topjohnwu.magisk.databinding.RvItem import com.topjohnwu.magisk.databinding.adapterOf -import com.topjohnwu.magisk.di.viewModel import rikka.recyclerview.addEdgeSpacing import rikka.recyclerview.addInvalidateItemDecorationsObserver import rikka.recyclerview.addItemSpacing diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt index 0bc9b6295..a689e2a69 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt @@ -4,8 +4,8 @@ import android.os.Bundle import android.view.View import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseFragment +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.databinding.FragmentSettingsMd2Binding -import com.topjohnwu.magisk.di.viewModel import rikka.recyclerview.addEdgeSpacing import rikka.recyclerview.addItemSpacing import rikka.recyclerview.fixEdgeEffect diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt index adfcd03e3..daed4f377 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt @@ -13,6 +13,7 @@ import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.JobService +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.core.tasks.HideAPK import com.topjohnwu.magisk.core.utils.BiometricHelper import com.topjohnwu.magisk.core.utils.MediaStoreUtils @@ -22,7 +23,6 @@ import com.topjohnwu.magisk.databinding.DialogSettingsAppNameBinding import com.topjohnwu.magisk.databinding.DialogSettingsDownloadPathBinding import com.topjohnwu.magisk.databinding.DialogSettingsUpdateChannelBinding import com.topjohnwu.magisk.databinding.set -import com.topjohnwu.magisk.di.AppContext import com.topjohnwu.magisk.utils.Utils import com.topjohnwu.magisk.utils.asText import com.topjohnwu.magisk.view.MagiskDialog diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt index e6c18a86e..96694c0a9 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt @@ -11,11 +11,11 @@ import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseViewModel import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.Info +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.core.isRunningAsStub import com.topjohnwu.magisk.core.tasks.HideAPK import com.topjohnwu.magisk.databinding.adapterOf import com.topjohnwu.magisk.databinding.itemBindingOf -import com.topjohnwu.magisk.di.AppContext import com.topjohnwu.magisk.events.AddHomeIconEvent import com.topjohnwu.magisk.events.RecreateEvent import com.topjohnwu.magisk.events.SnackbarEvent diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt index 2e63d4251..badecc7b4 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserFragment.kt @@ -4,10 +4,10 @@ import android.os.Bundle import android.view.View import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseFragment +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.databinding.AnyDiffRvItem import com.topjohnwu.magisk.databinding.FragmentSuperuserMd2Binding import com.topjohnwu.magisk.databinding.adapterOf -import com.topjohnwu.magisk.di.viewModel import rikka.recyclerview.addEdgeSpacing import rikka.recyclerview.addItemSpacing import rikka.recyclerview.fixEdgeEffect diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt index 030580462..8a65feffb 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt @@ -8,14 +8,14 @@ import androidx.lifecycle.viewModelScope import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseViewModel -import com.topjohnwu.magisk.core.magiskdb.PolicyDao +import com.topjohnwu.magisk.core.data.magiskdb.PolicyDao +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.core.model.su.SuPolicy import com.topjohnwu.magisk.core.utils.BiometricHelper import com.topjohnwu.magisk.core.utils.currentLocale import com.topjohnwu.magisk.databinding.AnyDiffRvItem import com.topjohnwu.magisk.databinding.diffListOf import com.topjohnwu.magisk.databinding.itemBindingOf -import com.topjohnwu.magisk.di.AppContext import com.topjohnwu.magisk.events.SnackbarEvent import com.topjohnwu.magisk.events.dialog.BiometricEvent import com.topjohnwu.magisk.events.dialog.SuperuserRevokeDialog diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt index 2b6b903a8..36327c6f4 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.kt @@ -10,10 +10,10 @@ import android.view.WindowManager import androidx.lifecycle.lifecycleScope import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.UIActivity +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.core.su.SuCallbackHandler import com.topjohnwu.magisk.core.su.SuCallbackHandler.REQUEST import com.topjohnwu.magisk.databinding.ActivityRequestBinding -import com.topjohnwu.magisk.di.viewModel import com.topjohnwu.magisk.ui.theme.Theme import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt index 5e53991ae..307ab2b0b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt @@ -20,13 +20,13 @@ import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseViewModel import com.topjohnwu.magisk.core.Config -import com.topjohnwu.magisk.core.magiskdb.PolicyDao +import com.topjohnwu.magisk.core.data.magiskdb.PolicyDao +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.core.model.su.SuPolicy.Companion.ALLOW import com.topjohnwu.magisk.core.model.su.SuPolicy.Companion.DENY import com.topjohnwu.magisk.core.su.SuRequestHandler import com.topjohnwu.magisk.core.utils.BiometricHelper import com.topjohnwu.magisk.databinding.set -import com.topjohnwu.magisk.di.AppContext import com.topjohnwu.magisk.events.DieEvent import com.topjohnwu.magisk.events.ShowUIEvent import com.topjohnwu.magisk.events.dialog.BiometricEvent diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt index ac892c194..9db424025 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt @@ -9,9 +9,9 @@ import android.widget.FrameLayout import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.BaseFragment +import com.topjohnwu.magisk.core.di.viewModel import com.topjohnwu.magisk.databinding.FragmentThemeMd2Binding import com.topjohnwu.magisk.databinding.ItemThemeBindingImpl -import com.topjohnwu.magisk.di.viewModel class ThemeFragment : BaseFragment() { diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt index 9dffa979f..6b72afcde 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt @@ -9,7 +9,7 @@ import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.Info -import com.topjohnwu.magisk.di.AppContext +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.superuser.internal.UiThreadHandler object Utils { diff --git a/app/src/main/java/com/topjohnwu/magisk/view/Notifications.kt b/app/src/main/java/com/topjohnwu/magisk/view/Notifications.kt index f7e9846da..99fbe946f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/view/Notifications.kt +++ b/app/src/main/java/com/topjohnwu/magisk/view/Notifications.kt @@ -11,9 +11,9 @@ import android.os.Build.VERSION.SDK_INT import androidx.core.content.getSystemService import androidx.core.graphics.drawable.toIcon import com.topjohnwu.magisk.R +import com.topjohnwu.magisk.core.di.AppContext import com.topjohnwu.magisk.core.download.DownloadService import com.topjohnwu.magisk.core.download.Subject -import com.topjohnwu.magisk.di.AppContext import com.topjohnwu.magisk.ktx.getBitmap import java.util.concurrent.atomic.AtomicInteger