mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-04 07:42:30 -08:00
feat: Add a time view to the Magikeyboard #2317
This commit is contained in:
10 files changed
+71
-19
No files matched your search
@@ -5,7 +5,7 @@ KeePassDX(4.4.0)
|
||||
* Hidden tag history #2374 #1405
|
||||
* Improved accessibility #2475
|
||||
* Improved security #2481 #2482 #2483 #2484 #2485 #2487 #2488 #2489 #2480
|
||||
* Filter browser appId in Magikeyboard #2466 #2394 #2400
|
||||
* Filter browser appId in Magikeyboard #2466 #2394 #2400 #2317
|
||||
* Fix history save #2471
|
||||
* Fix screenshot mode #2407
|
||||
* Small fixes #2476
|
||||
|
||||
+20
-2
@@ -39,6 +39,7 @@ import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.BlendModeColorFilterCompat
|
||||
@@ -70,11 +71,13 @@ import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.AppUtil
|
||||
import com.kunzisoft.keepass.utils.AppUtil.isElementAllowed
|
||||
import com.kunzisoft.keepass.utils.AppUtil.withoutBrowserOrAppBlocked
|
||||
import com.kunzisoft.keepass.utils.EXTRA_PROGRESS
|
||||
import com.kunzisoft.keepass.utils.KeyboardUtil.showKeyboardPicker
|
||||
import com.kunzisoft.keepass.utils.KeyboardUtil.switchToPreviousKeyboard
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
import com.kunzisoft.keepass.utils.LockReceiver
|
||||
import com.kunzisoft.keepass.utils.REMOVE_ENTRY_MAGIKEYBOARD_ACTION
|
||||
import com.kunzisoft.keepass.utils.UPDATE_TIMEOUT_PROGRESS_ACTION
|
||||
import com.kunzisoft.keepass.utils.clear
|
||||
import com.kunzisoft.keepass.utils.registerLockReceiver
|
||||
import com.kunzisoft.keepass.utils.unregisterLockReceiver
|
||||
@@ -102,6 +105,7 @@ class MagikeyboardService : InputMethodService(),
|
||||
private var entryListView: RecyclerView? = null
|
||||
private var popupCustomKeys: PopupWindow? = null
|
||||
private var screenshotModeView: View? = null
|
||||
private var timeoutProgressBar: ProgressBar? = null
|
||||
private var entriesAdapter: KeyboardEntriesAdapter? = null
|
||||
private var fieldsAdapter: KeyboardFieldsAdapter? = null
|
||||
private var playSoundDuringCLick: Boolean = false
|
||||
@@ -130,10 +134,19 @@ class MagikeyboardService : InputMethodService(),
|
||||
assignKeyboardView()
|
||||
}
|
||||
// Remove the entry and lock the keyboard when the lock signal is receive
|
||||
lockReceiver = LockReceiver {
|
||||
lockReceiver = object : LockReceiver({
|
||||
removeSearchInfo()
|
||||
removeEntryInfo()
|
||||
assignKeyboardView()
|
||||
}) {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
super.onReceive(context, intent)
|
||||
if (intent.action == UPDATE_TIMEOUT_PROGRESS_ACTION) {
|
||||
val progress = intent.getIntExtra(EXTRA_PROGRESS, 0)
|
||||
timeoutProgressBar?.progress = progress
|
||||
timeoutProgressBar?.visibility = if (progress > 0) VISIBLE else GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
lockReceiver?.backToPreviousKeyboardAction = {
|
||||
switchToPreviousKeyboard()
|
||||
@@ -188,7 +201,11 @@ class MagikeyboardService : InputMethodService(),
|
||||
PreferenceManager.getDefaultSharedPreferences(this)
|
||||
.registerOnSharedPreferenceChangeListener(onScreenshotModePrefListener)
|
||||
|
||||
registerLockReceiver(lockReceiver, true)
|
||||
registerLockReceiver(
|
||||
lockReceiver = lockReceiver,
|
||||
registerKeyboardAction = true,
|
||||
registerTimeoutProgress = true
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindInput() {
|
||||
@@ -211,6 +228,7 @@ class MagikeyboardService : InputMethodService(),
|
||||
webDomainIcon = rootKeyboardView.findViewById(R.id.magikeyboard_web_domain_icon)
|
||||
keyboardView = rootKeyboardView.findViewById(R.id.magikeyboard_view)
|
||||
screenshotModeView = rootKeyboardView.findViewById(R.id.screenshot_mode_banner)
|
||||
timeoutProgressBar = rootKeyboardView.findViewById(R.id.magikeyboard_timeout_progress)
|
||||
|
||||
if (keyboardView != null) {
|
||||
keyboard = Keyboard(this, R.xml.keyboard_password)
|
||||
|
||||
+3
-2
@@ -118,10 +118,11 @@ class ClipboardEntryNotificationService : LockNotificationServiceParam<OtpElemen
|
||||
}
|
||||
if (otpElement.type == OtpType.TOTP) {
|
||||
defineTimerJob(
|
||||
builder,
|
||||
builder = builder,
|
||||
type = NotificationServiceType.CLIPBOARD,
|
||||
timeoutMilliseconds = otpElement.period * 1000L,
|
||||
timerData = otpElement
|
||||
timerData = otpElement,
|
||||
actionAfterASecond = null
|
||||
) {
|
||||
stopService()
|
||||
}
|
||||
|
||||
@@ -92,9 +92,10 @@ class DeviceUnlockNotificationService : NotificationService() {
|
||||
// Not necessarily a foreground service
|
||||
if (mTimerJob == null && notificationTimeoutMilliSecs > NEVER) {
|
||||
defineTimerJob(
|
||||
notificationBuilder,
|
||||
NotificationServiceType.DEVICE_UNLOCK,
|
||||
notificationTimeoutMilliSecs
|
||||
builder = notificationBuilder,
|
||||
type = NotificationServiceType.DEVICE_UNLOCK,
|
||||
timeoutMilliseconds = notificationTimeoutMilliSecs,
|
||||
actionAfterASecond = null
|
||||
) {
|
||||
sendBroadcast(Intent(REMOVE_DEVICE_UNLOCK_KEY_ACTION))
|
||||
}
|
||||
|
||||
+12
-2
@@ -32,7 +32,9 @@ import com.kunzisoft.keepass.credentialprovider.magikeyboard.MagikeyboardService
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper.NEVER
|
||||
import com.kunzisoft.keepass.utils.EXTRA_PROGRESS
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
import com.kunzisoft.keepass.utils.UPDATE_TIMEOUT_PROGRESS_ACTION
|
||||
|
||||
class KeyboardEntryNotificationService : LockNotificationService() {
|
||||
|
||||
@@ -111,10 +113,18 @@ class KeyboardEntryNotificationService : LockNotificationService() {
|
||||
if (PreferencesUtil.isClearKeyboardNotificationEnable(this)) {
|
||||
if (mNotificationTimeoutMilliSecs > NEVER) {
|
||||
defineTimerJob(
|
||||
builder,
|
||||
builder = builder,
|
||||
type = NotificationServiceType.KEYBOARD,
|
||||
timeoutMilliseconds = mNotificationTimeoutMilliSecs
|
||||
timeoutMilliseconds = mNotificationTimeoutMilliSecs,
|
||||
actionAfterASecond = { progress ->
|
||||
sendBroadcast(Intent(UPDATE_TIMEOUT_PROGRESS_ACTION).apply {
|
||||
putExtra(EXTRA_PROGRESS, progress)
|
||||
})
|
||||
}
|
||||
) {
|
||||
sendBroadcast(Intent(UPDATE_TIMEOUT_PROGRESS_ACTION).apply {
|
||||
putExtra(EXTRA_PROGRESS, 0)
|
||||
})
|
||||
stopNotificationAndSendLockIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ abstract class NotificationServiceParam<T> : Service() {
|
||||
type: NotificationServiceType,
|
||||
timeoutMilliseconds: Long,
|
||||
timerData: T? = null,
|
||||
actionAfterASecond: (() -> Unit)? = null,
|
||||
actionAfterASecond: ((progress: Int) -> Unit)? = null,
|
||||
actionEnd: () -> Unit
|
||||
) {
|
||||
mTimerJob?.cancel()
|
||||
@@ -142,10 +142,11 @@ abstract class NotificationServiceParam<T> : Service() {
|
||||
currentTime = timeoutMilliseconds
|
||||
}
|
||||
// Update every second
|
||||
actionAfterASecond?.invoke()
|
||||
val progress = (currentTime * 100 / timeoutMilliseconds).toInt()
|
||||
actionAfterASecond?.invoke(progress)
|
||||
builder.apply {
|
||||
setProgress(100,
|
||||
(currentTime * 100 / timeoutMilliseconds).toInt(),
|
||||
progress,
|
||||
false
|
||||
)
|
||||
timerContentText(timerData)?.let {
|
||||
|
||||
@@ -43,10 +43,12 @@ const val DATABASE_START_TASK_ACTION = "com.kunzisoft.keepass.DATABASE_START_TAS
|
||||
const val DATABASE_STOP_TASK_ACTION = "com.kunzisoft.keepass.DATABASE_STOP_TASK_ACTION"
|
||||
|
||||
const val LOCK_ACTION = "com.kunzisoft.keepass.LOCK"
|
||||
const val UPDATE_TIMEOUT_PROGRESS_ACTION = "com.kunzisoft.keepass.UPDATE_TIMEOUT_PROGRESS"
|
||||
const val EXTRA_PROGRESS = "com.kunzisoft.keepass.EXTRA_PROGRESS"
|
||||
const val REMOVE_ENTRY_MAGIKEYBOARD_ACTION = "com.kunzisoft.keepass.REMOVE_ENTRY_MAGIKEYBOARD"
|
||||
const val BACK_PREVIOUS_KEYBOARD_ACTION = "com.kunzisoft.keepass.BACK_PREVIOUS_KEYBOARD"
|
||||
|
||||
class LockReceiver(private var lockAction: () -> Unit) : BroadcastReceiver() {
|
||||
open class LockReceiver(private var lockAction: () -> Unit) : BroadcastReceiver() {
|
||||
|
||||
private var mLockPendingIntent: PendingIntent? = null
|
||||
var backToPreviousKeyboardAction: (() -> Unit)? = null
|
||||
@@ -123,8 +125,11 @@ class LockReceiver(private var lockAction: () -> Unit) : BroadcastReceiver() {
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.registerLockReceiver(lockReceiver: LockReceiver?,
|
||||
registerKeyboardAction: Boolean = false) {
|
||||
fun Context.registerLockReceiver(
|
||||
lockReceiver: LockReceiver?,
|
||||
registerKeyboardAction: Boolean = false,
|
||||
registerTimeoutProgress: Boolean = false
|
||||
) {
|
||||
lockReceiver?.let {
|
||||
ContextCompat.registerReceiver(this, it, IntentFilter().apply {
|
||||
addAction(Intent.ACTION_SCREEN_OFF)
|
||||
@@ -134,6 +139,9 @@ fun Context.registerLockReceiver(lockReceiver: LockReceiver?,
|
||||
addAction(REMOVE_ENTRY_MAGIKEYBOARD_ACTION)
|
||||
addAction(BACK_PREVIOUS_KEYBOARD_ACTION)
|
||||
}
|
||||
if (registerTimeoutProgress) {
|
||||
addAction(UPDATE_TIMEOUT_PROGRESS_ACTION)
|
||||
}
|
||||
}, ContextCompat.RECEIVER_EXPORTED)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,8 +130,21 @@
|
||||
tools:text="Database A"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:textColor="@color/grey_blue_slighter"/>
|
||||
android:textColor="@color/green_white"/>
|
||||
</LinearLayout>
|
||||
<ProgressBar
|
||||
android:id="@+id/magikeyboard_timeout_progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:progress="0"
|
||||
android:max="100"
|
||||
android:visibility="gone"
|
||||
android:progressBackgroundTint="@color/grey_blue_deep"
|
||||
android:progressTint="@color/white"
|
||||
tools:visibility="visible"
|
||||
tools:progress="50"/>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/magikeyboard_entry_list"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Hidden tag history #2374 #1405
|
||||
* Improved accessibility #2475
|
||||
* Improved security #2481 #2482 #2483 #2484 #2485 #2487 #2488 #2489 #2480
|
||||
* Filter browser appId in Magikeyboard #2466 #2394 #2400
|
||||
* Filter browser appId in Magikeyboard #2466 #2394 #2400 #2317
|
||||
* Fix history save #2471
|
||||
* Fix screenshot mode #2407
|
||||
* Small fixes #2476
|
||||
@@ -4,7 +4,7 @@
|
||||
* Historique des Tags caché #2374 #1405
|
||||
* Accessibilité améliorée #2475
|
||||
* Sécurité améliorée #2481 #2482 #2483 #2484 #2485 #2487 #2488 #2489 #2480
|
||||
* Filtre les id de navigateurs dans le Magiclavier #2466 #2394 #2400
|
||||
* Filtre les id de navigateurs dans le Magiclavier #2466 #2394 #2400 #2317
|
||||
* Correction de la sauvegarde de l'historique #2471
|
||||
* Correction du mode capture d'écran #2407
|
||||
* Petites corrections #2476
|
||||
Reference in new issue
Block a user