mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-12 00:33:37 +00:00
parent
f7abc03dac
commit
113eec59f9
@ -53,7 +53,7 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
|
||||
// ---
|
||||
|
||||
interface Callback {
|
||||
fun onItemPressed(view: View, item: SettingsItem)
|
||||
fun onItemPressed(view: View, item: SettingsItem, method: () -> Unit)
|
||||
fun onItemChanged(view: View, item: SettingsItem)
|
||||
}
|
||||
|
||||
@ -80,9 +80,10 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
|
||||
override val layoutRes = R.layout.item_settings_toggle
|
||||
|
||||
override fun onPressed(view: View, callback: Callback) {
|
||||
callback.onItemPressed(view, this)
|
||||
value = !value
|
||||
super.onPressed(view, callback)
|
||||
callback.onItemPressed(view, this) {
|
||||
value = !value
|
||||
super.onPressed(view, callback)
|
||||
}
|
||||
}
|
||||
|
||||
fun onTouched(view: View, callback: Callback, event: MotionEvent): Boolean {
|
||||
@ -103,27 +104,28 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
|
||||
protected abstract val intermediate: String?
|
||||
|
||||
override fun onPressed(view: View, callback: Callback) {
|
||||
callback.onItemPressed(view, this)
|
||||
MagiskDialog(view.context)
|
||||
.applyTitle(title.getText(resources))
|
||||
.applyView(getView(view.context))
|
||||
.applyButton(MagiskDialog.ButtonType.POSITIVE) {
|
||||
titleRes = android.R.string.ok
|
||||
onClick {
|
||||
intermediate?.let { result ->
|
||||
preventDismiss = false
|
||||
value = result
|
||||
it.dismiss()
|
||||
super.onPressed(view, callback)
|
||||
return@onClick
|
||||
callback.onItemPressed(view, this) {
|
||||
MagiskDialog(view.context)
|
||||
.applyTitle(title.getText(resources))
|
||||
.applyView(getView(view.context))
|
||||
.applyButton(MagiskDialog.ButtonType.POSITIVE) {
|
||||
titleRes = android.R.string.ok
|
||||
onClick {
|
||||
intermediate?.let { result ->
|
||||
preventDismiss = false
|
||||
value = result
|
||||
it.dismiss()
|
||||
super.onPressed(view, callback)
|
||||
return@onClick
|
||||
}
|
||||
preventDismiss = true
|
||||
}
|
||||
preventDismiss = true
|
||||
}
|
||||
}
|
||||
.applyButton(MagiskDialog.ButtonType.NEGATIVE) {
|
||||
titleRes = android.R.string.cancel
|
||||
}
|
||||
.reveal()
|
||||
.applyButton(MagiskDialog.ButtonType.NEGATIVE) {
|
||||
titleRes = android.R.string.cancel
|
||||
}
|
||||
.reveal()
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun getView(context: Context): View
|
||||
@ -156,18 +158,19 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
|
||||
|
||||
override fun onPressed(view: View, callback: Callback) {
|
||||
if (entries.isEmpty() || entryValues.isEmpty()) return
|
||||
callback.onItemPressed(view, this)
|
||||
MagiskDialog(view.context)
|
||||
.applyTitle(title.getText(resources))
|
||||
.applyButton(MagiskDialog.ButtonType.NEGATIVE) {
|
||||
titleRes = android.R.string.cancel
|
||||
}
|
||||
.applyAdapter(entries) {
|
||||
value = it
|
||||
notifyPropertyChanged(BR.selectedEntry)
|
||||
super.onPressed(view, callback)
|
||||
}
|
||||
.reveal()
|
||||
callback.onItemPressed(view, this) {
|
||||
MagiskDialog(view.context)
|
||||
.applyTitle(title.getText(resources))
|
||||
.applyButton(MagiskDialog.ButtonType.NEGATIVE) {
|
||||
titleRes = android.R.string.cancel
|
||||
}
|
||||
.applyAdapter(entries) {
|
||||
value = it
|
||||
notifyPropertyChanged(BR.selectedEntry)
|
||||
super.onPressed(view, callback)
|
||||
}
|
||||
.reveal()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -177,8 +180,9 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
|
||||
override val layoutRes = R.layout.item_settings_blank
|
||||
|
||||
override fun onPressed(view: View, callback: Callback) {
|
||||
callback.onItemPressed(view, this)
|
||||
super.onPressed(view, callback)
|
||||
callback.onItemPressed(view, this) {
|
||||
super.onPressed(view, callback)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.navigation.NavDirections
|
||||
import com.topjohnwu.magisk.BR
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.base.BaseActivity
|
||||
import com.topjohnwu.magisk.model.events.*
|
||||
@ -85,8 +86,14 @@ abstract class BaseViewModel(
|
||||
PermissionEvent(permissions.toList(), callback).publish()
|
||||
}
|
||||
|
||||
fun withExternalRW(callback: (Boolean) -> Unit) {
|
||||
withPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, callback = callback)
|
||||
fun withExternalRW(callback: () -> Unit) {
|
||||
withPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE) {
|
||||
if (!it) {
|
||||
SnackbarEvent(R.string.external_rw_permission_denied).publish()
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun back() = BackPressEvent().publish()
|
||||
|
@ -107,8 +107,6 @@ class FlashViewModel(
|
||||
}
|
||||
|
||||
private fun savePressed() = withExternalRW {
|
||||
if (!it)
|
||||
return@withExternalRW
|
||||
viewModelScope.launch {
|
||||
val name = Const.MAGISK_INSTALL_LOG_FILENAME.format(now.toTime(timeFormatStandard))
|
||||
val file = File(Config.downloadDirectory, name)
|
||||
|
@ -131,9 +131,7 @@ class HomeViewModel(
|
||||
fun onManagerPressed() = ManagerInstallDialog().publish()
|
||||
|
||||
fun onMagiskPressed() = withExternalRW {
|
||||
if (it) {
|
||||
HomeFragmentDirections.actionHomeFragmentToInstallFragment().publish()
|
||||
}
|
||||
HomeFragmentDirections.actionHomeFragmentToInstallFragment().publish()
|
||||
}
|
||||
|
||||
fun hideNotice() {
|
||||
|
@ -57,7 +57,7 @@ class LogViewModel(
|
||||
items.lastOrNull()?.isBottom = true
|
||||
}
|
||||
|
||||
fun saveMagiskLog() {
|
||||
fun saveMagiskLog() = withExternalRW {
|
||||
val now = Calendar.getInstance()
|
||||
val filename = "magisk_log_%04d%02d%02d_%02d%02d%02d.log".format(
|
||||
now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,
|
||||
@ -70,7 +70,7 @@ class LogViewModel(
|
||||
logFile.createNewFile()
|
||||
} catch (e: IOException) {
|
||||
Timber.e(e)
|
||||
return
|
||||
return@withExternalRW
|
||||
}
|
||||
|
||||
Shell.su("cat ${Const.MAGISK_LOG} > $logFile").submit {
|
||||
|
@ -19,7 +19,6 @@ import com.topjohnwu.magisk.model.entity.internal.DownloadSubject
|
||||
import com.topjohnwu.magisk.model.entity.recycler.*
|
||||
import com.topjohnwu.magisk.model.events.InstallExternalModuleEvent
|
||||
import com.topjohnwu.magisk.model.events.OpenChangelogEvent
|
||||
import com.topjohnwu.magisk.model.events.SnackbarEvent
|
||||
import com.topjohnwu.magisk.model.events.dialog.ModuleInstallDialog
|
||||
import com.topjohnwu.magisk.ui.base.*
|
||||
import com.topjohnwu.magisk.utils.EndlessRecyclerScrollListener
|
||||
@ -323,26 +322,15 @@ class ModuleViewModel(
|
||||
}
|
||||
|
||||
fun downloadPressed(item: RepoItem) = withExternalRW {
|
||||
if (it)
|
||||
ModuleInstallDialog(item.item).publish()
|
||||
else
|
||||
permissionDenied()
|
||||
ModuleInstallDialog(item.item).publish()
|
||||
}
|
||||
|
||||
fun installPressed() = withExternalRW {
|
||||
if (it)
|
||||
InstallExternalModuleEvent().publish()
|
||||
else
|
||||
permissionDenied()
|
||||
InstallExternalModuleEvent().publish()
|
||||
}
|
||||
|
||||
fun infoPressed(item: RepoItem) = OpenChangelogEvent(item.item).publish()
|
||||
fun infoPressed(item: ModuleItem) {
|
||||
OpenChangelogEvent(item.repo ?: return).publish()
|
||||
}
|
||||
|
||||
private fun permissionDenied() {
|
||||
SnackbarEvent(R.string.module_permission_declined).publish()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -87,9 +87,9 @@ class SettingsViewModel(
|
||||
return list
|
||||
}
|
||||
|
||||
override fun onItemPressed(view: View, item: SettingsItem) = when (item) {
|
||||
is DownloadPath -> requireRWPermission()
|
||||
else -> Unit
|
||||
override fun onItemPressed(view: View, item: SettingsItem, method: () -> Unit) = when (item) {
|
||||
is DownloadPath -> withExternalRW(method)
|
||||
else -> method()
|
||||
}
|
||||
|
||||
override fun onItemChanged(view: View, item: SettingsItem) = when (item) {
|
||||
@ -136,10 +136,6 @@ class SettingsViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun requireRWPermission() {
|
||||
withExternalRW { if (!it) requireRWPermission() }
|
||||
}
|
||||
|
||||
private fun updateManager(hide: Boolean) {
|
||||
if (hide) {
|
||||
PatchAPK.hideManager(get(), Hide.value)
|
||||
|
@ -137,7 +137,7 @@
|
||||
<string name="update_available">التحديث متوفر</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">تسلسل الترتيب</string>
|
||||
<string name="module_permission_declined">امنحني إذن الولوج للذاكرة الداخلية</string>
|
||||
<string name="external_rw_permission_denied">امنحني إذن الولوج للذاكرة الداخلية</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">وضـعية الِسمات</string>
|
||||
|
@ -128,7 +128,7 @@
|
||||
<string name="update_available">Даступныя абнаўленні</string>
|
||||
<string name="module_installed">Усталяваныя</string>
|
||||
<string name="sorting_order">Парадак сартавання</string>
|
||||
<string name="module_permission_declined">Дайце доступ да сховішча, каб уключыць гэтую функцыю</string>
|
||||
<string name="external_rw_permission_denied">Дайце доступ да сховішча, каб уключыць гэтую функцыю</string>
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Рэжым афармлення</string>
|
||||
<string name="settings_dark_mode_message">Абярыце рэжым, які вам больш даспадобы!</string>
|
||||
|
@ -137,7 +137,7 @@
|
||||
<string name="update_available">Actualització Disponible</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">Ordre de Classificació</string>
|
||||
<string name="module_permission_declined">Garanteix permís d\'emmagatzematge per activar aquesta funcionalitat</string>
|
||||
<string name="external_rw_permission_denied">Garanteix permís d\'emmagatzematge per activar aquesta funcionalitat</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Mode del tema</string>
|
||||
|
@ -136,7 +136,7 @@
|
||||
<string name="update_available">Update verfügbar</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">Sortierreihenfolge</string>
|
||||
<string name="module_permission_declined">Gewähre den Speicher-Zugriff, um diese Funtion zu aktivieren.</string>
|
||||
<string name="external_rw_permission_denied">Gewähre den Speicher-Zugriff, um diese Funtion zu aktivieren.</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Themen-Modus</string>
|
||||
|
@ -134,7 +134,7 @@
|
||||
<string name="update_available">Actualización disponible</string>
|
||||
<string name="home_installed_version">Instalado</string>
|
||||
<string name="sorting_order">Clasificar por</string>
|
||||
<string name="module_permission_declined">Conceder permiso de almacenamiento para habilitar esta funcionalidad</string>
|
||||
<string name="external_rw_permission_denied">Conceder permiso de almacenamiento para habilitar esta funcionalidad</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Elegir modo</string>
|
||||
|
@ -137,7 +137,7 @@
|
||||
<string name="update_available">Mise à jour disponible</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">Classement</string>
|
||||
<string name="module_permission_declined">Autorisez l’accès au stockage pour activer cette fonctionnalité</string>
|
||||
<string name="external_rw_permission_denied">Autorisez l’accès au stockage pour activer cette fonctionnalité</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Mode du thème</string>
|
||||
|
@ -137,7 +137,7 @@
|
||||
<string name="update_available">Pembaruan Tersedia</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">Urutkan Susunan</string>
|
||||
<string name="module_permission_declined">Berikan izin penyimpanan untuk mengaktifkan fungsi ini</string>
|
||||
<string name="external_rw_permission_denied">Berikan izin penyimpanan untuk mengaktifkan fungsi ini</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Mode Tema</string>
|
||||
|
@ -137,7 +137,7 @@
|
||||
<string name="update_available">עדכונים זמינים</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">סדר מיון</string>
|
||||
<string name="module_permission_declined">הענק הרשאה לאחסון כדי לאפשר פונקציונליות זו</string>
|
||||
<string name="external_rw_permission_denied">הענק הרשאה לאחסון כדי לאפשר פונקציונליות זו</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">מצב עיצוב</string>
|
||||
|
@ -251,7 +251,7 @@
|
||||
<string name="settings_grid_column_count_summary">リストの幅を設定します。アプリを再起動して変更を適用します。</string>
|
||||
<string name="settings_download_path_error">フォルダの作成エラー。ルートディレクトリからアクセスできなければならず、そしてファイルでない必要があります。</string>
|
||||
<string name="settings_dark_mode_message">自分のスタイルに合ったモードを選択!</string>
|
||||
<string name="module_permission_declined">この機能を有効にするためにストレージの許可を付与</string>
|
||||
<string name="external_rw_permission_denied">この機能を有効にするためにストレージの許可を付与</string>
|
||||
<string name="download_open_parent">"親フォルダに表示 "</string>
|
||||
<string name="download_open_self">ファイルを表示</string>
|
||||
<string name="unsupport_magisk_msg">このバージョンの Magisk Manager は、%1$s 以下の Magisk バージョンには対応していません。 アプリは Magisk がインストールされていないかのように動作しますので、できるだけ早く Magisk をアップグレードしてください。</string>
|
||||
|
@ -137,7 +137,7 @@
|
||||
<string name="update_available">ხელმისაწვდომია განახლება</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">სორტირება</string>
|
||||
<string name="module_permission_declined">დართეთ მეხსიერებასთან წვდომის ნებართვა ამ ფუნქციის გამოსაყნებლად</string>
|
||||
<string name="external_rw_permission_denied">დართეთ მეხსიერებასთან წვდომის ნებართვა ამ ფუნქციის გამოსაყნებლად</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">თემების ჩამონათვალი</string>
|
||||
|
@ -136,7 +136,7 @@
|
||||
<string name="update_available">Update beschikbaar</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">Sorteervolgorde</string>
|
||||
<string name="module_permission_declined">Verleen de machtiging \'Opslag\' om deze functie te kunnen gebruiken</string>
|
||||
<string name="external_rw_permission_denied">Verleen de machtiging \'Opslag\' om deze functie te kunnen gebruiken</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Thema</string>
|
||||
|
@ -136,7 +136,7 @@
|
||||
<string name="update_available">Dostępna aktualizacja</string>
|
||||
<string name="module_installed">Zainstalowane</string>
|
||||
<string name="sorting_order">Kolejność sortowania</string>
|
||||
<string name="module_permission_declined">Zezwól na dostęp do pamięci wewnętrznej, aby włączyć tę funkcjonalność.</string>
|
||||
<string name="external_rw_permission_denied">Zezwól na dostęp do pamięci wewnętrznej, aby włączyć tę funkcjonalność.</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Tryb motywu</string>
|
||||
|
@ -136,7 +136,7 @@
|
||||
<string name="update_available">Actualizare disponibilă</string>
|
||||
<string name="module_installed">Instalate</string>
|
||||
<string name="sorting_order">Ordine de sortare</string>
|
||||
<string name="module_permission_declined">Acordă permisiunea de stocare pentru a activa această funcționalitate</string>
|
||||
<string name="external_rw_permission_denied">Acordă permisiunea de stocare pentru a activa această funcționalitate</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Mod pentru temă</string>
|
||||
|
@ -137,7 +137,7 @@
|
||||
<string name="update_available">Доступно обновление</string>
|
||||
<string name="module_installed">Установлены</string>
|
||||
<string name="sorting_order">Сортировка</string>
|
||||
<string name="module_permission_declined">Пожалуйста, предоставьте доступ к хранилищу</string>
|
||||
<string name="external_rw_permission_denied">Пожалуйста, предоставьте доступ к хранилищу</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Оттенок</string>
|
||||
|
@ -137,7 +137,7 @@
|
||||
<string name="update_available">Dostupná aktualizácia</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">Zoradenie</string>
|
||||
<string name="module_permission_declined">Udeľte povolenie pre povolenie tejto funkcie</string>
|
||||
<string name="external_rw_permission_denied">Udeľte povolenie pre povolenie tejto funkcie</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Režim motívu</string>
|
||||
|
@ -137,7 +137,7 @@
|
||||
<string name="update_available">Доступне оновлення</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">Порядок сортування</string>
|
||||
<string name="module_permission_declined">Надайте доступ до сховища, щоб увімкнути цей функціонал</string>
|
||||
<string name="external_rw_permission_denied">Надайте доступ до сховища, щоб увімкнути цей функціонал</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Режим теми</string>
|
||||
|
@ -137,7 +137,7 @@
|
||||
<string name="update_available">可更新</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">排序方式</string>
|
||||
<string name="module_permission_declined">请允许访问存储空间以使用此功能</string>
|
||||
<string name="external_rw_permission_denied">请允许访问存储空间以使用此功能</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">主题模式</string>
|
||||
|
@ -136,7 +136,7 @@
|
||||
<string name="update_available">有可用的更新</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">排序方式</string>
|
||||
<string name="module_permission_declined">授予儲存權限以啟用這個功能</string>
|
||||
<string name="external_rw_permission_denied">授予儲存權限以啟用這個功能</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">主題模式</string>
|
||||
|
@ -137,7 +137,6 @@
|
||||
<string name="update_available">Update Available</string>
|
||||
<string name="module_installed">@string/home_installed_version</string>
|
||||
<string name="sorting_order">Sorting Order</string>
|
||||
<string name="module_permission_declined">Grant storage permission to enable this functionality</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">Theme Mode</string>
|
||||
@ -255,5 +254,6 @@
|
||||
<string name="authenticate">Authenticate</string>
|
||||
<string name="unsupport_magisk_title">Unsupported Magisk Version</string>
|
||||
<string name="unsupport_magisk_msg">This version of Magisk Manager does not support Magisk version lower than %1$s.\n\nThe app will behave as if no Magisk is installed, please upgrade Magisk as soon as possible.</string>
|
||||
<string name="external_rw_permission_denied">Grant storage permission to enable this functionality</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user