From 5b0d63b580dc587f5b47117212e6008bcc896172 Mon Sep 17 00:00:00 2001 From: the-weird-aquarian Date: Mon, 1 Jul 2024 21:09:28 +0530 Subject: [PATCH] minor fixes --- .../techlore/plexus/activities/MainActivity.kt | 15 ++++++++------- .../techlore/plexus/activities/SubmitActivity.kt | 2 +- .../bottomsheets/main/DeleteAccountBottomSheet.kt | 4 +++- .../settings/DefaultViewBottomSheet.kt | 9 +++------ .../bottomsheets/splash/FirstLaunchBottomSheet.kt | 2 +- app/src/main/res/values/styles.xml | 2 ++ 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/tech/techlore/plexus/activities/MainActivity.kt b/app/src/main/java/tech/techlore/plexus/activities/MainActivity.kt index 658f8d1d..5876b2a1 100755 --- a/app/src/main/java/tech/techlore/plexus/activities/MainActivity.kt +++ b/app/src/main/java/tech/techlore/plexus/activities/MainActivity.kt @@ -48,8 +48,8 @@ class MainActivity : AppCompatActivity(), MenuProvider { lateinit var bottomSheetBehavior: BottomSheetBehavior private lateinit var navHostFragment: NavHostFragment lateinit var navController: NavController - private var defaultView = 0 - private var defaultSelectedNavItem = 0 + private var defaultFragment = 0 + var defaultSelectedNavItem = 0 var clickedNavItem = 0 var selectedNavItem = 0 private var surfaceContainerLowColor = 0 @@ -74,25 +74,26 @@ class MainActivity : AppCompatActivity(), MenuProvider { val navMyAccountItems = listOf(R.id.nav_my_ratings, R.id.nav_delete_account) val encPreferenceManager = EncryptedPreferenceManager(this) + // Set default view // Theme bottom sheet was reused for this purpose // Don't get confused by the "R.id.followSystem" & "R.id.light" when ((applicationContext as ApplicationManager).preferenceManager.getInt(DEF_VIEW, R.id.followSystem)) { R.id.followSystem -> { - defaultView = R.id.plexusDataFragment + defaultFragment = R.id.plexusDataFragment defaultSelectedNavItem = R.id.nav_plexus_data } R.id.light -> { - defaultView = R.id.installedAppsFragment + defaultFragment = R.id.installedAppsFragment defaultSelectedNavItem = R.id.nav_installed_apps } else -> { - defaultView = R.id.favoritesFragment + defaultFragment = R.id.favoritesFragment defaultSelectedNavItem = R.id.nav_fav } } // Set start destination as default view - navGraph.setStartDestination(defaultView) + navGraph.setStartDestination(defaultFragment) navController.setGraph(navGraph, intent.extras) activityBinding.toolbarBottom.apply { @@ -299,7 +300,7 @@ class MainActivity : AppCompatActivity(), MenuProvider { bottomSheetBehavior.state != BottomSheetBehavior.STATE_COLLAPSED -> bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED - navController.currentDestination?.id != defaultView -> { + navController.currentDestination?.id != defaultFragment -> { clickedNavItem = defaultSelectedNavItem selectedNavItem = clickedNavItem displayFragment(clickedNavItem) diff --git a/app/src/main/java/tech/techlore/plexus/activities/SubmitActivity.kt b/app/src/main/java/tech/techlore/plexus/activities/SubmitActivity.kt index d7e6c55c..d9f154f1 100644 --- a/app/src/main/java/tech/techlore/plexus/activities/SubmitActivity.kt +++ b/app/src/main/java/tech/techlore/plexus/activities/SubmitActivity.kt @@ -123,7 +123,7 @@ class SubmitActivity : AppCompatActivity() { // FAB activityBinding.submitFab.setOnClickListener { - if ((applicationContext as ApplicationManager).preferenceManager.getBoolean(CONF_BEFORE_SUBMIT)) { + if ((applicationContext as ApplicationManager).preferenceManager.getBoolean(CONF_BEFORE_SUBMIT, defValue = false)) { ConfirmSubmitBottomSheet().show(supportFragmentManager, "ConfirmSubmitBottomSheet") } else { diff --git a/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/main/DeleteAccountBottomSheet.kt b/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/main/DeleteAccountBottomSheet.kt index c877430a..225518c2 100644 --- a/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/main/DeleteAccountBottomSheet.kt +++ b/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/main/DeleteAccountBottomSheet.kt @@ -22,6 +22,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.content.ContextCompat import androidx.lifecycle.lifecycleScope import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.google.android.material.color.MaterialColors @@ -62,6 +63,7 @@ class DeleteAccountBottomSheet : BottomSheetDialogFragment() { // Proceed footerBinding.positiveButton.apply { setBackgroundColor(MaterialColors.getColor(this, com.google.android.material.R.attr.colorError)) + icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_delete_account) iconTint = ColorStateList.valueOf(MaterialColors.getColor(this, com.google.android.material.R.attr.colorOnError)) setTextColor(MaterialColors.getColor(this, com.google.android.material.R.attr.colorOnError)) text = getString(R.string.proceed) @@ -78,7 +80,7 @@ class DeleteAccountBottomSheet : BottomSheetDialogFragment() { dismiss() (requireActivity() as MainActivity).apply { if (selectedNavItem == R.id.nav_my_ratings) { - clickedNavItem = R.id.nav_plexus_data + clickedNavItem = defaultSelectedNavItem selectedNavItem = clickedNavItem displayFragment(clickedNavItem) } diff --git a/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/settings/DefaultViewBottomSheet.kt b/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/settings/DefaultViewBottomSheet.kt index 228080fb..619f8ea1 100644 --- a/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/settings/DefaultViewBottomSheet.kt +++ b/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/settings/DefaultViewBottomSheet.kt @@ -17,13 +17,11 @@ package tech.techlore.plexus.fragments.bottomsheets.settings -import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat -import androidx.core.view.get import androidx.core.view.isVisible import com.google.android.material.bottomsheet.BottomSheetDialogFragment import tech.techlore.plexus.R @@ -32,7 +30,6 @@ import tech.techlore.plexus.databinding.BottomSheetFooterBinding import tech.techlore.plexus.databinding.BottomSheetHeaderBinding import tech.techlore.plexus.databinding.BottomSheetThemeBinding import tech.techlore.plexus.preferences.PreferenceManager.Companion.DEF_VIEW -import tech.techlore.plexus.utils.UiUtils.Companion.setAppTheme // Reuse "Theme" bottom sheet layout class DefaultViewBottomSheet : BottomSheetDialogFragment() { @@ -56,17 +53,17 @@ class DefaultViewBottomSheet : BottomSheetDialogFragment() { BottomSheetHeaderBinding.bind(bottomSheetBinding.root).bottomSheetTitle.setText(R.string.default_view) bottomSheetBinding.followSystem.apply { - closeIcon = ContextCompat.getDrawable(context, R.drawable.ic_plexus_data) + closeIcon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_plexus_data) text = getString(R.string.plexus_data) } bottomSheetBinding.light.apply { - closeIcon = ContextCompat.getDrawable(context, R.drawable.ic_installed_apps) + closeIcon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_installed_apps) text = getString(R.string.installed_apps) } bottomSheetBinding.dark.apply { - closeIcon = ContextCompat.getDrawable(context, R.drawable.ic_fav_outline) + closeIcon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_fav_outline) text = getString(R.string.favorites) } diff --git a/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/splash/FirstLaunchBottomSheet.kt b/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/splash/FirstLaunchBottomSheet.kt index 57e322be..025b603e 100644 --- a/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/splash/FirstLaunchBottomSheet.kt +++ b/app/src/main/java/tech/techlore/plexus/fragments/bottomsheets/splash/FirstLaunchBottomSheet.kt @@ -103,7 +103,7 @@ class FirstLaunchBottomSheet : BottomSheetDialogFragment() { // Proceed bottomSheetBinding.proceedButton.setOnClickListener { startActivity(Intent(requireActivity(), SettingsActivity::class.java) - .putExtra("frag", R.id.helpFragment)) + .putExtra("fragId", R.id.helpFragment)) onDestroy() } diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 8f6805bd..ebd89cb6 100755 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -161,6 +161,8 @@