mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-04 15:52:34 -08:00
fix: Large pass to add Material 3
This commit is contained in:
1 parent
71fd17c0ac
commit
8570f47372
57 files changed
+750
-1176
No files matched your search
@@ -21,7 +21,6 @@ package com.kunzisoft.keepass.activities
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
@@ -70,8 +69,6 @@ import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.utils.UriUtil.openUrl
|
||||
import com.kunzisoft.keepass.utils.UuidUtil
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.view.changeControlColor
|
||||
import com.kunzisoft.keepass.view.changeTitleColor
|
||||
import com.kunzisoft.keepass.view.hideByFading
|
||||
import com.kunzisoft.keepass.view.showActionErrorIfNeeded
|
||||
import com.kunzisoft.keepass.viewmodels.EntryViewModel
|
||||
@@ -113,8 +110,6 @@ class EntryActivity : DatabaseLockActivity() {
|
||||
|
||||
private var mIcon: IconImage? = null
|
||||
private var mColorSecondary: Int = 0
|
||||
private var mControlColor: Int = 0
|
||||
private var mColorPrimary: Int = 0
|
||||
private var mColorBackground: Int = 0
|
||||
private var mBackgroundColor: Int? = null
|
||||
private var mForegroundColor: Int? = null
|
||||
@@ -147,16 +142,10 @@ class EntryActivity : DatabaseLockActivity() {
|
||||
|
||||
// Retrieve the textColor to tint the toolbar
|
||||
val taColorSecondary = theme.obtainStyledAttributes(intArrayOf(R.attr.colorSecondary))
|
||||
val taControlColor = theme.obtainStyledAttributes(intArrayOf(R.attr.toolbarColorControl))
|
||||
val taColorPrimary = theme.obtainStyledAttributes(intArrayOf(R.attr.colorPrimary))
|
||||
val taColorBackground = theme.obtainStyledAttributes(intArrayOf(android.R.attr.windowBackground))
|
||||
mColorSecondary = taColorSecondary.getColor(0, Color.BLACK)
|
||||
mControlColor = taControlColor.getColor(0, Color.BLACK)
|
||||
mColorPrimary = taColorPrimary.getColor(0, Color.BLACK)
|
||||
mColorBackground = taColorBackground.getColor(0, Color.BLACK)
|
||||
taColorSecondary.recycle()
|
||||
taControlColor.recycle()
|
||||
taColorPrimary.recycle()
|
||||
taColorBackground.recycle()
|
||||
|
||||
// Init Tags adapter
|
||||
@@ -225,10 +214,10 @@ class EntryActivity : DatabaseLockActivity() {
|
||||
this.mEntryIsHistory = entryIsHistory
|
||||
// Assign history dedicated view
|
||||
historyView?.visibility = if (entryIsHistory) View.VISIBLE else View.GONE
|
||||
// TODO History badge
|
||||
/*
|
||||
if (entryIsHistory) {
|
||||
collapsingToolbarLayout?.contentScrim =
|
||||
ColorDrawable(mColorSecondary)
|
||||
}
|
||||
}*/
|
||||
|
||||
val entryInfo = entryInfoHistory.entryInfo
|
||||
// Manage entry copy to start notification if allowed (at the first start)
|
||||
@@ -366,8 +355,6 @@ class EntryActivity : DatabaseLockActivity() {
|
||||
}
|
||||
|
||||
private fun applyToolbarColors() {
|
||||
appBarLayout?.setBackgroundColor(mBackgroundColor ?: mColorPrimary)
|
||||
collapsingToolbarLayout?.contentScrim = ColorDrawable(mBackgroundColor ?: mColorPrimary)
|
||||
val backgroundDarker = if (mBackgroundColor != null) {
|
||||
ColorUtils.blendARGB(mBackgroundColor!!, Color.WHITE, 0.1f)
|
||||
} else {
|
||||
@@ -384,8 +371,6 @@ class EntryActivity : DatabaseLockActivity() {
|
||||
)
|
||||
}
|
||||
}
|
||||
toolbar?.changeControlColor(mForegroundColor ?: mControlColor)
|
||||
collapsingToolbarLayout?.changeTitleColor(mForegroundColor ?: mControlColor)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.kunzisoft.keepass.activities.helpers.SpecialMode
|
||||
import com.kunzisoft.keepass.activities.helpers.TypeMode
|
||||
import com.kunzisoft.keepass.model.SearchInfo
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.view.SpecialModeView
|
||||
import com.kunzisoft.keepass.view.ToolbarSpecial
|
||||
|
||||
|
||||
/**
|
||||
@@ -20,7 +20,7 @@ abstract class DatabaseModeActivity : DatabaseActivity() {
|
||||
protected var mSpecialMode: SpecialMode = SpecialMode.DEFAULT
|
||||
private var mTypeMode: TypeMode = TypeMode.DEFAULT
|
||||
|
||||
private var mSpecialModeView: SpecialModeView? = null
|
||||
private var mToolbarSpecial: ToolbarSpecial? = null
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (mSpecialMode != SpecialMode.DEFAULT)
|
||||
@@ -113,8 +113,8 @@ abstract class DatabaseModeActivity : DatabaseActivity() {
|
||||
?: EntrySelectionHelper.retrieveSearchInfoFromIntent(intent)
|
||||
|
||||
// To show the selection mode
|
||||
mSpecialModeView = findViewById(R.id.special_mode_view)
|
||||
mSpecialModeView?.apply {
|
||||
mToolbarSpecial = findViewById(R.id.special_mode_view)
|
||||
mToolbarSpecial?.apply {
|
||||
// Populate title
|
||||
val selectionModeStringId = when (mSpecialMode) {
|
||||
SpecialMode.DEFAULT, // Not important because hidden
|
||||
|
||||
@@ -39,10 +39,10 @@ class BreadcrumbAdapter(val context: Context)
|
||||
mShowNumberEntries = PreferencesUtil.showNumberEntries(context)
|
||||
mShowUUID = PreferencesUtil.showUUID(context)
|
||||
|
||||
// Retrieve the textColor to tint the icon
|
||||
val taTextColor = context.theme.obtainStyledAttributes(intArrayOf(R.attr.colorOnPrimary))
|
||||
mIconColor = taTextColor.getColor(0, Color.WHITE)
|
||||
taTextColor.recycle()
|
||||
// Retrieve the color to tint the icon
|
||||
val taIconColor = context.theme.obtainStyledAttributes(intArrayOf(R.attr.colorOnSurface))
|
||||
mIconColor = taIconColor.getColor(0, Color.WHITE)
|
||||
taIconColor.recycle()
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@@ -71,7 +71,7 @@ class BreadcrumbAdapter(val context: Context)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BreadcrumbGroupViewHolder {
|
||||
return BreadcrumbGroupViewHolder(inflater.inflate(
|
||||
when (viewType) {
|
||||
0 -> R.layout.item_group
|
||||
0 -> R.layout.item_breadcrumb_important
|
||||
else -> R.layout.item_breadcrumb
|
||||
}, parent, false)
|
||||
)
|
||||
|
||||
@@ -43,10 +43,8 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
|
||||
var addButtonView: FloatingActionButton? = null
|
||||
private lateinit var addEntryView: View
|
||||
private lateinit var textAddEntryView: View
|
||||
private lateinit var fabAddEntryView: View
|
||||
private lateinit var addGroupView: View
|
||||
private lateinit var textAddGroupView: View
|
||||
private lateinit var fabAddGroupView: View
|
||||
|
||||
private var addEntryEnable: Boolean = false
|
||||
@@ -81,10 +79,8 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
|
||||
addButtonView = findViewById(R.id.add_button)
|
||||
addEntryView = findViewById(R.id.container_add_entry)
|
||||
textAddEntryView = findViewById(R.id.text_add_entry)
|
||||
fabAddEntryView = findViewById(R.id.fab_add_entry)
|
||||
addGroupView = findViewById(R.id.container_add_group)
|
||||
textAddGroupView = findViewById(R.id.text_add_group)
|
||||
fabAddGroupView = findViewById(R.id.fab_add_group)
|
||||
|
||||
animationDuration = 300L
|
||||
@@ -205,14 +201,12 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
|
||||
fun setAddGroupClickListener(onClickListener: OnClickListener) {
|
||||
if (addGroupEnable) {
|
||||
textAddGroupView.setOnClickListener(onButtonClickListener(onClickListener))
|
||||
fabAddGroupView.setOnClickListener(onButtonClickListener(onClickListener))
|
||||
}
|
||||
}
|
||||
|
||||
fun setAddEntryClickListener(onClickListener: OnClickListener) {
|
||||
if (addEntryEnable) {
|
||||
textAddEntryView.setOnClickListener(onButtonClickListener(onClickListener))
|
||||
fabAddEntryView.setOnClickListener(onButtonClickListener(onClickListener))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ import android.view.View
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.appcompat.view.ActionMode
|
||||
import androidx.appcompat.view.SupportMenuInflater
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import com.kunzisoft.keepass.R
|
||||
|
||||
class ToolbarAction @JvmOverloads constructor(context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = androidx.appcompat.R.attr.toolbarStyle)
|
||||
: Toolbar(context, attrs, defStyle) {
|
||||
defStyle: Int = R.attr.toolbarActionStyle)
|
||||
: MaterialToolbar(context, attrs, defStyle) {
|
||||
|
||||
private var mActionModeCallback: ActionMode.Callback? = null
|
||||
private val actionMode = NodeActionMode(this)
|
||||
@@ -47,7 +47,7 @@ class ToolbarAction @JvmOverloads constructor(context: Context,
|
||||
init {
|
||||
ContextCompat.getDrawable(context, R.drawable.ic_close_white_24dp)?.let { closeDrawable ->
|
||||
val typedValue = TypedValue()
|
||||
context.theme.resolveAttribute(R.attr.colorControlNormal, typedValue, true)
|
||||
context.theme.resolveAttribute(R.attr.colorOnSurface, typedValue, true)
|
||||
@ColorInt val colorControl = typedValue.data
|
||||
closeDrawable.colorFilter = PorterDuffColorFilter(colorControl, PorterDuff.Mode.SRC_ATOP)
|
||||
navigationIcon = closeDrawable
|
||||
|
||||
+5
-5
@@ -26,14 +26,14 @@ import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import com.kunzisoft.keepass.R
|
||||
|
||||
class SpecialModeView @JvmOverloads constructor(context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = androidx.appcompat.R.attr.toolbarStyle)
|
||||
: Toolbar(context, attrs, defStyle) {
|
||||
class ToolbarSpecial @JvmOverloads constructor(context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = R.attr.toolbarSpecialStyle)
|
||||
: MaterialToolbar(context, attrs, defStyle) {
|
||||
|
||||
init {
|
||||
ContextCompat.getDrawable(context, R.drawable.ic_arrow_back_white_24dp)?.let { closeDrawable ->
|
||||
Reference in new issue
Block a user