mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 10:35:26 +00:00
Added hide fragment for future use
This commit is contained in:
parent
96ef9cdbee
commit
512f533a80
@ -2,6 +2,7 @@ package com.topjohnwu.magisk.di
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.redesign.MainViewModel
|
import com.topjohnwu.magisk.redesign.MainViewModel
|
||||||
import com.topjohnwu.magisk.redesign.flash.FlashViewModel
|
import com.topjohnwu.magisk.redesign.flash.FlashViewModel
|
||||||
|
import com.topjohnwu.magisk.redesign.hide.HideViewModel
|
||||||
import com.topjohnwu.magisk.redesign.home.HomeViewModel
|
import com.topjohnwu.magisk.redesign.home.HomeViewModel
|
||||||
import com.topjohnwu.magisk.redesign.log.LogViewModel
|
import com.topjohnwu.magisk.redesign.log.LogViewModel
|
||||||
import com.topjohnwu.magisk.redesign.module.ModuleViewModel
|
import com.topjohnwu.magisk.redesign.module.ModuleViewModel
|
||||||
@ -15,6 +16,7 @@ import org.koin.dsl.module
|
|||||||
|
|
||||||
val redesignModule = module {
|
val redesignModule = module {
|
||||||
viewModel { FlashViewModel() }
|
viewModel { FlashViewModel() }
|
||||||
|
viewModel { HideViewModel() }
|
||||||
viewModel { HomeViewModel(get()) }
|
viewModel { HomeViewModel(get()) }
|
||||||
viewModel { LogViewModel() }
|
viewModel { LogViewModel() }
|
||||||
viewModel { ModuleViewModel() }
|
viewModel { ModuleViewModel() }
|
||||||
|
@ -15,6 +15,7 @@ import com.topjohnwu.magisk.ui.module.ReposFragment
|
|||||||
import com.topjohnwu.magisk.ui.settings.SettingsFragment
|
import com.topjohnwu.magisk.ui.settings.SettingsFragment
|
||||||
import com.topjohnwu.magisk.ui.superuser.SuperuserFragment
|
import com.topjohnwu.magisk.ui.superuser.SuperuserFragment
|
||||||
import com.topjohnwu.magisk.redesign.MainActivity as RedesignActivity
|
import com.topjohnwu.magisk.redesign.MainActivity as RedesignActivity
|
||||||
|
import com.topjohnwu.magisk.redesign.hide.HideFragment as RedesignHideFragment
|
||||||
import com.topjohnwu.magisk.redesign.home.HomeFragment as RedesignHomeFragment
|
import com.topjohnwu.magisk.redesign.home.HomeFragment as RedesignHomeFragment
|
||||||
import com.topjohnwu.magisk.redesign.log.LogFragment as RedesignLogFragment
|
import com.topjohnwu.magisk.redesign.log.LogFragment as RedesignLogFragment
|
||||||
import com.topjohnwu.magisk.redesign.module.ModuleFragment as RedesignModulesFragment
|
import com.topjohnwu.magisk.redesign.module.ModuleFragment as RedesignModulesFragment
|
||||||
@ -61,7 +62,12 @@ object Navigation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun hide() = MagiskNavigationEvent {
|
fun hide() = MagiskNavigationEvent {
|
||||||
navDirections { destination = MagiskHideFragment::class }
|
navDirections {
|
||||||
|
destination = when {
|
||||||
|
Config.redesign -> RedesignHideFragment::class
|
||||||
|
else -> MagiskHideFragment::class
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun log() = MagiskNavigationEvent {
|
fun log() = MagiskNavigationEvent {
|
||||||
|
@ -2,11 +2,15 @@ package com.topjohnwu.magisk.redesign
|
|||||||
|
|
||||||
import android.graphics.Insets
|
import android.graphics.Insets
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.ViewGroup
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.setPadding
|
import androidx.core.view.setPadding
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
import com.ncapdevi.fragnav.FragNavController
|
import com.ncapdevi.fragnav.FragNavController
|
||||||
import com.topjohnwu.magisk.Const
|
import com.topjohnwu.magisk.Const
|
||||||
@ -92,6 +96,14 @@ open class MainActivity : CompatActivity<MainViewModel, ActivityMainMd2Binding>(
|
|||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
when (item.itemId) {
|
||||||
|
android.R.id.home -> onBackPressed()
|
||||||
|
else -> return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
override fun onTabTransaction(fragment: Fragment?, index: Int) {
|
override fun onTabTransaction(fragment: Fragment?, index: Int) {
|
||||||
setDisplayHomeAsUpEnabled(false)
|
setDisplayHomeAsUpEnabled(false)
|
||||||
}
|
}
|
||||||
@ -99,9 +111,21 @@ open class MainActivity : CompatActivity<MainViewModel, ActivityMainMd2Binding>(
|
|||||||
override fun onFragmentTransaction(
|
override fun onFragmentTransaction(
|
||||||
fragment: Fragment?,
|
fragment: Fragment?,
|
||||||
transactionType: FragNavController.TransactionType
|
transactionType: FragNavController.TransactionType
|
||||||
) = when (transactionType) {
|
) {
|
||||||
FragNavController.TransactionType.PUSH -> setDisplayHomeAsUpEnabled(!navigation.isRoot)
|
setDisplayHomeAsUpEnabled(!navigation.isRoot)
|
||||||
else -> Unit //dunno might be useful
|
|
||||||
|
val lapam = binding.mainBottomBar.layoutParams as ViewGroup.MarginLayoutParams
|
||||||
|
val height = binding.mainBottomBar.measuredHeight
|
||||||
|
val verticalMargin = lapam.let { it.topMargin + it.bottomMargin }
|
||||||
|
val maxTranslation = height + verticalMargin
|
||||||
|
val translation = if (navigation.isRoot) 0 else maxTranslation
|
||||||
|
|
||||||
|
binding.mainBottomBar.animate()
|
||||||
|
.translationY(translation.toFloat())
|
||||||
|
.setInterpolator(FastOutSlowInInterpolator())
|
||||||
|
.withStartAction { if (translation == 0) binding.mainBottomBar.isVisible = true }
|
||||||
|
.withEndAction { if (translation > 0) binding.mainBottomBar.isVisible = false }
|
||||||
|
.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun peekSystemWindowInsets(insets: Insets) {
|
override fun peekSystemWindowInsets(insets: Insets) {
|
||||||
|
@ -10,6 +10,6 @@ internal interface CompatView<ViewModel : CompatViewModel> {
|
|||||||
val navigation: CompatNavigationDelegate<*>?
|
val navigation: CompatNavigationDelegate<*>?
|
||||||
|
|
||||||
fun peekSystemWindowInsets(insets: Insets) = Unit
|
fun peekSystemWindowInsets(insets: Insets) = Unit
|
||||||
fun consumeSystemWindowInsets(insets: Insets) = Insets.NONE
|
fun consumeSystemWindowInsets(insets: Insets): Insets? = null
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.topjohnwu.magisk.redesign.hide
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.databinding.FragmentHideMd2Binding
|
||||||
|
import com.topjohnwu.magisk.redesign.compat.CompatFragment
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
|
||||||
|
class HideFragment : CompatFragment<HideViewModel, FragmentHideMd2Binding>() {
|
||||||
|
|
||||||
|
override val layoutRes = R.layout.fragment_hide_md2
|
||||||
|
override val viewModel by viewModel<HideViewModel>()
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
super.onAttach(context)
|
||||||
|
|
||||||
|
activity.setTitle(R.string.magiskhide)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.topjohnwu.magisk.redesign.hide
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.redesign.compat.CompatViewModel
|
||||||
|
|
||||||
|
class HideViewModel : CompatViewModel()
|
@ -1,5 +1,6 @@
|
|||||||
package com.topjohnwu.magisk.redesign.superuser
|
package com.topjohnwu.magisk.redesign.superuser
|
||||||
|
|
||||||
|
import android.graphics.Insets
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
import com.topjohnwu.magisk.databinding.FragmentSuperuserMd2Binding
|
import com.topjohnwu.magisk.databinding.FragmentSuperuserMd2Binding
|
||||||
import com.topjohnwu.magisk.redesign.compat.CompatFragment
|
import com.topjohnwu.magisk.redesign.compat.CompatFragment
|
||||||
@ -10,6 +11,8 @@ class SuperuserFragment : CompatFragment<SuperuserViewModel, FragmentSuperuserMd
|
|||||||
override val layoutRes = R.layout.fragment_superuser_md2
|
override val layoutRes = R.layout.fragment_superuser_md2
|
||||||
override val viewModel by viewModel<SuperuserViewModel>()
|
override val viewModel by viewModel<SuperuserViewModel>()
|
||||||
|
|
||||||
|
override fun consumeSystemWindowInsets(insets: Insets) = insets
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.topjohnwu.magisk.redesign.superuser
|
package com.topjohnwu.magisk.redesign.superuser
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.model.navigation.Navigation
|
||||||
import com.topjohnwu.magisk.redesign.compat.CompatViewModel
|
import com.topjohnwu.magisk.redesign.compat.CompatViewModel
|
||||||
|
|
||||||
class SuperuserViewModel : CompatViewModel()
|
class SuperuserViewModel : CompatViewModel() {
|
||||||
|
|
||||||
|
fun hidePressed() = Navigation.hide().publish()
|
||||||
|
|
||||||
|
}
|
23
app/src/main/res/layout/fragment_hide_md2.xml
Normal file
23
app/src/main/res/layout/fragment_hide_md2.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="viewModel"
|
||||||
|
type="com.topjohnwu.magisk.redesign.hide.HideViewModel" />
|
||||||
|
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fillViewport="true">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</layout>
|
@ -1,5 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
@ -12,11 +14,65 @@
|
|||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true">
|
android:clipToPadding="false"
|
||||||
|
android:fillViewport="true"
|
||||||
|
android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size + (int) @dimen/l2}"
|
||||||
|
android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/l2}"
|
||||||
|
tools:layout_marginTop="24dp">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
style="?styleCardNormal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/l1"
|
||||||
|
android:onClick="@{() -> viewModel.hidePressed()}"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/superuser_hide_icon"
|
||||||
|
style="?styleIconNormal"
|
||||||
|
android:background="@null"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/ic_magiskhide" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/l1"
|
||||||
|
android:layout_marginEnd="@dimen/l1"
|
||||||
|
android:text="@string/magiskhide"
|
||||||
|
android:textAppearance="?appearanceTextBodyNormal"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/superuser_hide_icon_pointer"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/superuser_hide_icon"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/superuser_hide_icon_pointer"
|
||||||
|
style="?styleIconNormal"
|
||||||
|
android:background="@null"
|
||||||
|
android:rotation="180"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/ic_back_md2" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user