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 9ab1f1822..f84ab9cf5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt @@ -1,7 +1,9 @@ package com.topjohnwu.magisk.redesign import android.graphics.Insets +import android.os.Bundle import androidx.fragment.app.Fragment +import com.ncapdevi.fragnav.FragNavController import com.topjohnwu.magisk.R import com.topjohnwu.magisk.databinding.ActivityMainMd2Binding import com.topjohnwu.magisk.redesign.compat.CompatActivity @@ -20,8 +22,39 @@ open class MainActivity : CompatActivity( HomeFragment::class ) + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setSupportActionBar(binding.mainToolbar) + } + + 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 + } + } + override fun peekSystemWindowInsets(insets: Insets) { viewModel.insets.value = insets } + fun setDisplayHomeAsUpEnabled(isEnabled: Boolean) { + when { + isEnabled -> binding.mainToolbar.setNavigationIcon(R.drawable.ic_back_md2) + else -> binding.mainToolbar.navigationIcon = null + } + } + } \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeFragment.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeFragment.kt index 9807f1512..8770bad72 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeFragment.kt @@ -13,4 +13,10 @@ class HomeFragment : CompatFragment() { override fun consumeSystemWindowInsets(insets: Insets) = insets + override fun onStart() { + super.onStart() + + activity.title = "Home" + } + } \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_accent.xml b/app/src/main/res/drawable/bg_accent.xml index 2d253a52c..35ad197a8 100644 --- a/app/src/main/res/drawable/bg_accent.xml +++ b/app/src/main/res/drawable/bg_accent.xml @@ -2,8 +2,6 @@ - - + + diff --git a/app/src/main/res/layout/activity_main_md2.xml b/app/src/main/res/layout/activity_main_md2.xml index 5280337be..da1b213bb 100644 --- a/app/src/main/res/layout/activity_main_md2.xml +++ b/app/src/main/res/layout/activity_main_md2.xml @@ -24,39 +24,22 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?colorSurfaceVariant" - android:paddingTop="@{viewModel.insets.top}"> + android:paddingTop="@{viewModel.insets.top}" + tools:paddingTop="24dp"> + tools:title="Home" /> - - - - - - - - - + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index e8b9c2b44..ba79b71f0 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -14,7 +14,6 @@ - diff --git a/app/src/main/res/values/styles_md2.xml b/app/src/main/res/values/styles_md2.xml index 36d69b7b0..570e9c0e8 100644 --- a/app/src/main/res/values/styles_md2.xml +++ b/app/src/main/res/values/styles_md2.xml @@ -9,9 +9,11 @@ - -