Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
StellarSand committed Jul 1, 2024
1 parent 2a4862e commit 5b0d63b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class MainActivity : AppCompatActivity(), MenuProvider {
lateinit var bottomSheetBehavior: BottomSheetBehavior<FrameLayout>
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
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@
<!--Bottom sheet rounded corners-->
<style name="BottomSheetShapeStyle" parent="ShapeAppearance.Material3.LargeComponent">
<item name="cornerSize">@dimen/margin_16</item>
<item name="cornerSizeBottomLeft">0dp</item>
<item name="cornerSizeBottomRight">0dp</item>
</style>

<!--Bottom sheet buttons-->
Expand Down

0 comments on commit 5b0d63b

Please sign in to comment.