forked from shihaam/thijooree
redsign wheel page (action bar and logo
This commit is contained in:
@@ -13,8 +13,8 @@ import android.animation.Animator
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.core.graphics.drawable.DrawableCompat
|
import androidx.core.graphics.drawable.DrawableCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.google.android.material.color.MaterialColors
|
import com.google.android.material.color.MaterialColors
|
||||||
@@ -41,36 +41,7 @@ class CircularNavFragment : Fragment() {
|
|||||||
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header: launcher icon + app name
|
// Wheel area (weight 1, fills remaining space)
|
||||||
val header = android.widget.LinearLayout(ctx).apply {
|
|
||||||
orientation = android.widget.LinearLayout.HORIZONTAL
|
|
||||||
gravity = Gravity.CENTER
|
|
||||||
val vp = dp(14f).toInt()
|
|
||||||
setPadding(0, vp, 0, vp)
|
|
||||||
layoutParams = android.widget.LinearLayout.LayoutParams(
|
|
||||||
android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
|
|
||||||
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val iconSz = dp(38f).toInt()
|
|
||||||
val logoView = android.widget.ImageView(ctx).apply {
|
|
||||||
setImageResource(R.mipmap.ic_launcher_round)
|
|
||||||
layoutParams = android.widget.LinearLayout.LayoutParams(iconSz, iconSz)
|
|
||||||
}
|
|
||||||
val nameView = android.widget.TextView(ctx).apply {
|
|
||||||
text = getString(R.string.app_name)
|
|
||||||
setTextColor(colorOnSurface)
|
|
||||||
textSize = 21f
|
|
||||||
typeface = Typeface.DEFAULT_BOLD
|
|
||||||
layoutParams = android.widget.LinearLayout.LayoutParams(
|
|
||||||
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
||||||
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
).also { it.marginStart = dp(10f).toInt() }
|
|
||||||
}
|
|
||||||
header.addView(logoView)
|
|
||||||
header.addView(nameView)
|
|
||||||
|
|
||||||
// Wheel area (fills remaining height)
|
|
||||||
val wheelContainer = FrameLayout(ctx).apply {
|
val wheelContainer = FrameLayout(ctx).apply {
|
||||||
layoutParams = android.widget.LinearLayout.LayoutParams(
|
layoutParams = android.widget.LinearLayout.LayoutParams(
|
||||||
android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f
|
android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f
|
||||||
@@ -99,18 +70,52 @@ class CircularNavFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
wheelContainer.addView(wheelView)
|
wheelContainer.addView(wheelView)
|
||||||
|
|
||||||
root.addView(header)
|
// App icon centered at the bottom
|
||||||
|
val iconSz = dp(48f).toInt()
|
||||||
|
val footerIcon = android.widget.ImageView(ctx).apply {
|
||||||
|
setImageDrawable(ctx.packageManager.getApplicationIcon(ctx.packageName))
|
||||||
|
layoutParams = android.widget.LinearLayout.LayoutParams(iconSz, iconSz).also {
|
||||||
|
it.gravity = Gravity.CENTER_HORIZONTAL
|
||||||
|
it.topMargin = dp(12f).toInt()
|
||||||
|
it.bottomMargin = dp(16f).toInt()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
root.addView(wheelContainer)
|
root.addView(wheelContainer)
|
||||||
|
root.addView(footerIcon)
|
||||||
return root
|
return root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
(activity as? AppCompatActivity)?.supportActionBar?.hide()
|
requireActivity().invalidateOptionsMenu()
|
||||||
|
val ctx = requireContext()
|
||||||
|
val toolbar = requireActivity().findViewById<com.google.android.material.appbar.MaterialToolbar>(R.id.toolbar)
|
||||||
|
requireActivity().title = ""
|
||||||
|
|
||||||
|
val textColor = MaterialColors.getColor(ctx, com.google.android.material.R.attr.colorOnSurface, android.graphics.Color.DKGRAY)
|
||||||
|
|
||||||
|
val container = android.widget.TextView(ctx).apply {
|
||||||
|
text = getString(R.string.app_name)
|
||||||
|
setTextColor(textColor)
|
||||||
|
textSize = 20f
|
||||||
|
typeface = Typeface.DEFAULT_BOLD
|
||||||
|
tag = "wheel_title"
|
||||||
|
}
|
||||||
|
|
||||||
|
toolbar.addView(container, Toolbar.LayoutParams(
|
||||||
|
Toolbar.LayoutParams.WRAP_CONTENT,
|
||||||
|
Toolbar.LayoutParams.WRAP_CONTENT,
|
||||||
|
Gravity.CENTER
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Action bar is restored by HomeActivity.navigateTo() / applyNavMode()
|
override fun onPause() {
|
||||||
// so we don't touch it here — avoids flashing on lock.
|
super.onPause()
|
||||||
|
val toolbar = requireActivity().findViewById<com.google.android.material.appbar.MaterialToolbar>(R.id.toolbar)
|
||||||
|
toolbar.findViewWithTag<android.view.View>("wheel_title")?.let { toolbar.removeView(it) }
|
||||||
|
requireActivity().invalidateOptionsMenu()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class DashboardFragment : Fragment() {
|
|||||||
|
|
||||||
val bottomPaddingBase = (16 * resources.displayMetrics.density).toInt()
|
val bottomPaddingBase = (16 * resources.displayMetrics.density).toInt()
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(binding.buttonBar) { v, insets ->
|
ViewCompat.setOnApplyWindowInsetsListener(binding.buttonBar) { v, insets ->
|
||||||
val isBottomNav = requireContext().getSharedPreferences("prefs", android.content.Context.MODE_PRIVATE).getBoolean("bottom_nav", false)
|
val isBottomNav = NavCustomization.getNavMode(requireContext().getSharedPreferences("prefs", android.content.Context.MODE_PRIVATE)) == NavCustomization.NAV_MODE_BOTTOM
|
||||||
val navBar = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
val navBar = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
val extraBottom = if (isBottomNav) 0 else navBar.bottom
|
val extraBottom = if (isBottomNav) 0 else navBar.bottom
|
||||||
v.setPadding(v.paddingLeft, v.paddingTop, v.paddingRight, bottomPaddingBase + extraBottom)
|
v.setPadding(v.paddingLeft, v.paddingTop, v.paddingRight, bottomPaddingBase + extraBottom)
|
||||||
@@ -145,8 +145,7 @@ class DashboardFragment : Fragment() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
val isBottom = requireContext().getSharedPreferences("prefs", Context.MODE_PRIVATE)
|
val isBottom = NavCustomization.getNavMode(requireContext().getSharedPreferences("prefs", Context.MODE_PRIVATE)) == NavCustomization.NAV_MODE_BOTTOM
|
||||||
.getBoolean("bottom_nav", false)
|
|
||||||
if (isBottom) {
|
if (isBottom) {
|
||||||
requireActivity().title = getString(R.string.app_name)
|
requireActivity().title = getString(R.string.app_name)
|
||||||
val size = (28 * resources.displayMetrics.density).toInt()
|
val size = (28 * resources.displayMetrics.density).toInt()
|
||||||
@@ -171,7 +170,7 @@ class DashboardFragment : Fragment() {
|
|||||||
|
|
||||||
private fun refreshQuickActions() {
|
private fun refreshQuickActions() {
|
||||||
val prefs = requireContext().getSharedPreferences("prefs", Context.MODE_PRIVATE)
|
val prefs = requireContext().getSharedPreferences("prefs", Context.MODE_PRIVATE)
|
||||||
val isBottom = prefs.getBoolean("bottom_nav", false)
|
val isBottom = NavCustomization.getNavMode(prefs) == NavCustomization.NAV_MODE_BOTTOM
|
||||||
if (isBottom) {
|
if (isBottom) {
|
||||||
binding.buttonBar.visibility = View.GONE
|
binding.buttonBar.visibility = View.GONE
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -605,6 +605,13 @@ fun applyNavLabelVisibility() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||||
|
val onWheel = supportFragmentManager.findFragmentById(R.id.contentFrame) is CircularNavFragment
|
||||||
|
menu.findItem(R.id.action_hide_amounts)?.isVisible = !onWheel
|
||||||
|
menu.findItem(R.id.action_lock)?.isVisible = !onWheel
|
||||||
|
return super.onPrepareOptionsMenu(menu)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
if (item.itemId == R.id.action_lock) {
|
if (item.itemId == R.id.action_lock) {
|
||||||
val avd = getDrawable(R.drawable.avd_lock) as? android.graphics.drawable.AnimatedVectorDrawable
|
val avd = getDrawable(R.drawable.avd_lock) as? android.graphics.drawable.AnimatedVectorDrawable
|
||||||
|
|||||||
Reference in New Issue
Block a user