From 974cb1167f75fed4a20a174d0efed248c921bc45 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Wed, 16 Oct 2019 17:53:35 +0200 Subject: [PATCH] Added post-merge fixes --- app/build.gradle | 2 ++ app/src/main/AndroidManifest.xml | 3 +-- .../magisk/model/entity/recycler/HomeItems.kt | 2 +- .../magisk/model/events/OpenInappLinkEvent.kt | 1 - .../magisk/model/events/ViewEvents.kt | 1 - .../magisk/model/events/dialog/DialogEvent.kt | 2 +- .../model/navigation/MagiskNavigationEvent.kt | 4 ++-- .../topjohnwu/magisk/redesign/MainActivity.kt | 21 ++++++++----------- .../magisk/redesign/compat/CompatActivity.kt | 17 +++++++++++---- .../magisk/redesign/compat/CompatDelegate.kt | 2 +- .../magisk/redesign/compat/CompatFragment.kt | 6 +++--- .../compat/CompatNavigationDelegate.kt | 4 ++-- .../magisk/redesign/compat/CompatViewModel.kt | 6 +++--- .../magisk/redesign/home/HomeViewModel.kt | 6 +++--- .../com/topjohnwu/magisk/view/MagiskDialog.kt | 2 +- 15 files changed, 42 insertions(+), 37 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7e992561e..b9d07c8ee 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -122,6 +122,7 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03' + implementation 'androidx.browser:browser:1.0.0' implementation 'androidx.preference:preference:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.0.0' implementation 'androidx.work:work-runtime:2.2.0' @@ -129,4 +130,5 @@ dependencies { implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.core:core-ktx:1.1.0' implementation 'com.google.android.material:material:1.1.0-beta01' + implementation 'com.karumi:dexter:6.0.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8d47f905a..2a2189477 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -56,8 +56,7 @@ + android:exported="true" /> () { diff --git a/app/src/main/java/com/topjohnwu/magisk/model/events/OpenInappLinkEvent.kt b/app/src/main/java/com/topjohnwu/magisk/model/events/OpenInappLinkEvent.kt index 522b1c88f..6c02e267f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/events/OpenInappLinkEvent.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/events/OpenInappLinkEvent.kt @@ -6,7 +6,6 @@ import android.util.TypedValue import androidx.annotation.AttrRes import androidx.browser.customtabs.CustomTabsIntent import androidx.core.net.toUri -import com.skoumal.teanity.viewevents.ViewEvent import com.topjohnwu.magisk.R data class OpenInappLinkEvent( diff --git a/app/src/main/java/com/topjohnwu/magisk/model/events/ViewEvents.kt b/app/src/main/java/com/topjohnwu/magisk/model/events/ViewEvents.kt index 02062c62b..48c25fb92 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/events/ViewEvents.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/events/ViewEvents.kt @@ -7,7 +7,6 @@ import com.karumi.dexter.MultiplePermissionsReport import com.karumi.dexter.PermissionToken import com.karumi.dexter.listener.PermissionRequest import com.karumi.dexter.listener.multi.MultiplePermissionsListener -import com.skoumal.teanity.viewevents.ViewEvent import com.topjohnwu.magisk.model.entity.module.Repo import com.topjohnwu.magisk.model.permissions.PermissionRequestBuilder import io.reactivex.subjects.PublishSubject diff --git a/app/src/main/java/com/topjohnwu/magisk/model/events/dialog/DialogEvent.kt b/app/src/main/java/com/topjohnwu/magisk/model/events/dialog/DialogEvent.kt index dc41fe709..ed7b67692 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/events/dialog/DialogEvent.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/events/dialog/DialogEvent.kt @@ -1,8 +1,8 @@ package com.topjohnwu.magisk.model.events.dialog import android.content.Context -import com.skoumal.teanity.viewevents.ViewEvent import com.topjohnwu.magisk.model.events.ContextExecutor +import com.topjohnwu.magisk.model.events.ViewEvent import com.topjohnwu.magisk.view.MagiskDialog abstract class DialogEvent : ViewEvent(), ContextExecutor { diff --git a/app/src/main/java/com/topjohnwu/magisk/model/navigation/MagiskNavigationEvent.kt b/app/src/main/java/com/topjohnwu/magisk/model/navigation/MagiskNavigationEvent.kt index 5a84deaec..a5cf30cac 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/navigation/MagiskNavigationEvent.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/navigation/MagiskNavigationEvent.kt @@ -5,8 +5,8 @@ import androidx.annotation.AnimRes import androidx.annotation.AnimatorRes import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment -import com.topjohnwu.magisk.model.events.ViewEvent import com.topjohnwu.magisk.model.events.ActivityExecutor +import com.topjohnwu.magisk.model.events.ViewEvent import com.topjohnwu.magisk.redesign.compat.CompatActivity import kotlin.reflect.KClass @@ -25,7 +25,7 @@ class MagiskNavigationEvent( override fun invoke(activity: AppCompatActivity) { if (activity !is CompatActivity<*, *>) return - activity.navigation.navigateTo(this) + activity.navigation?.navigateTo(this) } @NavigationDslMarker diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt index 81772bc15..cdabd6a83 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt @@ -14,6 +14,7 @@ import com.topjohnwu.magisk.R import com.topjohnwu.magisk.databinding.ActivityMainMd2Binding import com.topjohnwu.magisk.model.navigation.Navigation import com.topjohnwu.magisk.redesign.compat.CompatActivity +import com.topjohnwu.magisk.redesign.compat.CompatNavigationDelegate import com.topjohnwu.magisk.redesign.home.HomeFragment import com.topjohnwu.magisk.ui.log.LogFragment import com.topjohnwu.magisk.ui.module.ModulesFragment @@ -24,13 +25,14 @@ import com.topjohnwu.superuser.Shell import org.koin.androidx.viewmodel.ext.android.viewModel import kotlin.reflect.KClass -open class MainActivity : CompatActivity() { +open class MainActivity : CompatActivity(), + FragNavController.TransactionListener { override val layoutRes = R.layout.activity_main_md2 override val viewModel by viewModel() - override val navHostId: Int = R.id.main_nav_host override val navHost: Int = R.id.main_nav_host - override val defaultPosition: Int = 0 + + override val navigation by lazy { CompatNavigationDelegate(this, this) } override val baseFragments: List> = listOf( HomeFragment::class, @@ -39,6 +41,7 @@ open class MainActivity : CompatActivity( LogFragment::class, SettingsFragment::class ) + //This temporarily fixes unwanted feature of BottomNavigationView - where the view applies //padding on itself given insets are not consumed beforehand. Unfortunately the listener //implementation doesn't favor us against the design library, so on re-create it's often given @@ -90,21 +93,15 @@ open class MainActivity : CompatActivity( } override fun onTabTransaction(fragment: Fragment?, index: Int) { - super.onTabTransaction(fragment, index) - setDisplayHomeAsUpEnabled(false) } override fun onFragmentTransaction( fragment: Fragment?, transactionType: FragNavController.TransactionType - ) { - super.onFragmentTransaction(fragment, transactionType) - - when (transactionType) { - FragNavController.TransactionType.PUSH -> setDisplayHomeAsUpEnabled(true) - else -> Unit //dunno might be useful - } + ) = when (transactionType) { + FragNavController.TransactionType.PUSH -> setDisplayHomeAsUpEnabled(true) + else -> Unit //dunno might be useful } override fun peekSystemWindowInsets(insets: Insets) { diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatActivity.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatActivity.kt index 33c5e9092..e52f8d293 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatActivity.kt @@ -3,17 +3,23 @@ package com.topjohnwu.magisk.redesign.compat import android.os.Bundle import android.view.View import androidx.databinding.ViewDataBinding -import com.skoumal.teanity.viewevents.ViewEvent -import com.topjohnwu.magisk.ui.base.MagiskActivity +import androidx.fragment.app.Fragment +import com.topjohnwu.magisk.R +import com.topjohnwu.magisk.base.BaseActivity +import com.topjohnwu.magisk.model.events.ViewEvent +import com.topjohnwu.magisk.model.navigation.MagiskNavigationEvent +import com.topjohnwu.magisk.model.navigation.Navigator +import kotlin.reflect.KClass abstract class CompatActivity : - MagiskActivity(), CompatView { + BaseActivity(), CompatView, Navigator { + override val themeRes = R.style.Foundation_Default override val viewRoot: View get() = binding.root override val navigation: CompatNavigationDelegate>? by lazy { CompatNavigationDelegate(this) } - + override val baseFragments = listOf>() private val delegate by lazy { CompatDelegate(this) } internal abstract val navHost: Int @@ -48,6 +54,9 @@ abstract class CompatActivity - : MagiskFragment(), CompatView { + : BaseFragment(), CompatView { override val viewRoot: View get() = binding.root override val navigation by lazy { compatActivity.navigation } diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatNavigationDelegate.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatNavigationDelegate.kt index 5a9a67463..3fe6b5123 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatNavigationDelegate.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatNavigationDelegate.kt @@ -10,7 +10,7 @@ import com.topjohnwu.magisk.model.navigation.MagiskNavigationEvent import com.topjohnwu.magisk.model.navigation.Navigator import timber.log.Timber -class CompatNavigationDelegate( +class CompatNavigationDelegate( private val source: Source, private val listener: FragNavController.TransactionListener? = null ) : FragNavController.RootFragmentListener where Source : CompatActivity<*, *>, Source : Navigator { @@ -33,7 +33,7 @@ class CompatNavigationDelegate( fun onCreate(savedInstanceState: Bundle?) = controller.run { - rootFragmentListener = source + rootFragmentListener = this@CompatNavigationDelegate transactionListener = listener initialize(0, savedInstanceState) } diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatViewModel.kt index 9c639b1c4..fb4cb11d1 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatViewModel.kt @@ -3,11 +3,11 @@ package com.topjohnwu.magisk.redesign.compat import android.graphics.Insets import androidx.annotation.CallSuper import androidx.databinding.Observable -import com.skoumal.teanity.util.KObservableField -import com.topjohnwu.magisk.ui.base.MagiskViewModel +import com.topjohnwu.magisk.base.viewmodel.BaseViewModel +import com.topjohnwu.magisk.utils.KObservableField import io.reactivex.disposables.Disposable -abstract class CompatViewModel : MagiskViewModel() { +abstract class CompatViewModel : BaseViewModel() { val insets = KObservableField(Insets.NONE) diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt index 79862dc58..4c939240e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt @@ -1,15 +1,14 @@ package com.topjohnwu.magisk.redesign.home -import com.skoumal.teanity.databinding.ComparableRvItem -import com.skoumal.teanity.extensions.subscribeK -import com.skoumal.teanity.util.KObservableField import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.Info import com.topjohnwu.magisk.R import com.topjohnwu.magisk.data.repository.MagiskRepository +import com.topjohnwu.magisk.databinding.ComparableRvItem import com.topjohnwu.magisk.extensions.packageName import com.topjohnwu.magisk.extensions.replaceRandomWithSpecial import com.topjohnwu.magisk.extensions.res +import com.topjohnwu.magisk.extensions.subscribeK import com.topjohnwu.magisk.model.entity.MagiskJson import com.topjohnwu.magisk.model.entity.ManagerJson import com.topjohnwu.magisk.model.entity.UpdateInfo @@ -20,6 +19,7 @@ import com.topjohnwu.magisk.model.events.dialog.ManagerInstallDialog import com.topjohnwu.magisk.model.observer.Observer import com.topjohnwu.magisk.redesign.compat.CompatViewModel import com.topjohnwu.magisk.ui.home.MagiskState +import com.topjohnwu.magisk.utils.KObservableField import me.tatarka.bindingcollectionadapter2.BR import me.tatarka.bindingcollectionadapter2.ItemBinding import me.tatarka.bindingcollectionadapter2.OnItemBind diff --git a/app/src/main/java/com/topjohnwu/magisk/view/MagiskDialog.kt b/app/src/main/java/com/topjohnwu/magisk/view/MagiskDialog.kt index fdcc01a1c..b7f1d4df1 100644 --- a/app/src/main/java/com/topjohnwu/magisk/view/MagiskDialog.kt +++ b/app/src/main/java/com/topjohnwu/magisk/view/MagiskDialog.kt @@ -12,10 +12,10 @@ import androidx.annotation.StringRes import androidx.appcompat.app.AlertDialog import androidx.databinding.DataBindingUtil import androidx.databinding.ViewDataBinding -import com.skoumal.teanity.util.KObservableField import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.R import com.topjohnwu.magisk.databinding.DialogMagiskBaseBinding +import com.topjohnwu.magisk.utils.KObservableField class MagiskDialog @JvmOverloads constructor( context: Context, theme: Int = 0