Skip to content

Commit

Permalink
1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky committed Aug 18, 2022
1 parent 5690004 commit 607b3e7
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 25 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Duress password trigger.
height="80">](https://play.google.com/store/apps/details?id=me.lucky.duress)

<img
src="https://raw.githubusercontent.com/x13a/Duress/main/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png"
src="fastlane/metadata/android/en-US/images/phoneScreenshots/1.png"
width="30%"
height="30%">

Expand All @@ -30,8 +30,16 @@ When found, it can send a broadcast message or wipe the device.
* ACCESSIBILITY - listen for a duress password on the lockscreen
* DEVICE_ADMIN - wipe the device (optional)

## Localization

[<img
height="51"
src="https://badges.crowdin.net/badge/dark/crowdin-on-light@2x.png"
alt="Crowdin">](https://crwd.in/me-lucky-duress)

## Related

* [pam_duress](https://github.com/rafket/pam_duress)
* [pam_panic](https://github.com/pampanic/pam_panic)
* [pam-party](https://github.com/x13a/pam-party)
* [lockup](https://github.com/nekohasekai/lockup)
Expand Down
12 changes: 8 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "me.lucky.duress"
minSdk 23
targetSdk 32
versionCode 9
versionName "1.0.8"
versionCode 10
versionName "1.0.9"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -40,14 +40,18 @@ android {

dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'androidx.security:security-crypto:1.0.0'
implementation 'androidx.preference:preference-ktx:1.2.0'
// https://issuetracker.google.com/issues/238425626
implementation('androidx.preference:preference-ktx:1.2.0') {
exclude group: 'androidx.lifecycle', module:'lifecycle-viewmodel'
exclude group: 'androidx.lifecycle', module:'lifecycle-viewmodel-ktx'
}
implementation 'androidx.biometric:biometric:1.1.0'
}
5 changes: 2 additions & 3 deletions app/src/main/java/me/lucky/duress/AccessibilityService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class AccessibilityService : AccessibilityService() {
companion object {
private const val MIN_KEYGUARD_LEN = 4
private const val MIN_LEN = MIN_KEYGUARD_LEN + 2
private const val KEY = "code"
private const val BUTTON_DELETE_DESC = "delete"
private const val BUTTON_OK_DESC = "ok"
private const val BUTTON_ENTER_DESC = "enter"
Expand Down Expand Up @@ -226,8 +225,8 @@ class AccessibilityService : AccessibilityService() {
)
}
addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
val secret = prefs.secret
if (secret.isNotEmpty()) putExtra(KEY, secret)
val extraKey = prefs.extraKey
if (extraKey.isNotEmpty()) putExtra(extraKey, prefs.extraValue)
})
}

Expand Down
20 changes: 14 additions & 6 deletions app/src/main/java/me/lucky/duress/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class MainActivity : AppCompatActivity() {
prefsdb = Preferences(this, encrypted = false)
prefs.copyTo(prefsdb)
accessibilityManager = getSystemService(AccessibilityManager::class.java)
NotificationManager(this).createNotificationChannels()
}

private fun init2() {
Expand All @@ -66,7 +65,8 @@ class MainActivity : AppCompatActivity() {
tabs.selectTab(tabs.getTabAt(prefs.mode))
action.editText?.setText(prefs.action)
receiver.editText?.setText(prefs.receiver)
secret.editText?.setText(prefs.secret)
extraKey.editText?.setText(prefs.extraKey)
extraValue.editText?.setText(prefs.extraValue)
passwordOrLen.editText?.setText(prefs.passwordOrLen)
keyguardType.check(when (prefs.keyguardType) {
KeyguardType.A.value -> R.id.keyguardTypeA
Expand Down Expand Up @@ -139,8 +139,11 @@ class MainActivity : AppCompatActivity() {
receiver.editText?.doAfterTextChanged {
prefs.receiver = it?.toString()?.trim() ?: ""
}
secret.editText?.doAfterTextChanged {
prefs.secret = it?.toString()?.trim() ?: ""
extraKey.editText?.doAfterTextChanged {
prefs.extraKey = it?.toString()?.trim() ?: ""
}
extraValue.editText?.doAfterTextChanged {
prefs.extraValue = it?.toString()?.trim() ?: ""
}
passwordOrLen.editText?.doAfterTextChanged {
prefs.passwordOrLen = it?.toString()?.trim() ?: ""
Expand All @@ -166,16 +169,21 @@ class MainActivity : AppCompatActivity() {
val v = when (prefs.mode) {
Mode.BROADCAST.value -> View.VISIBLE
Mode.WIPE.value -> View.GONE
Mode.TEST.value -> View.GONE
Mode.TEST.value -> {
NotificationManager(this).createNotificationChannels()
View.GONE
}
else -> View.GONE
}
binding.apply {
action.visibility = v
receiver.visibility = v
secret.visibility = v
extraKey.visibility = v
extraValue.visibility = v
space1.visibility = v
space2.visibility = v
space3.visibility = v
space4.visibility = v
}
}

Expand Down
22 changes: 17 additions & 5 deletions app/src/main/java/me/lucky/duress/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Preferences(ctx: Context, encrypted: Boolean = true) {
private const val MODE = "mode"
private const val ACTION = "action"
private const val RECEIVER = "receiver"
private const val SECRET = "secret"
private const val EXTRA_KEY = "extra_key"
private const val EXTRA_VALUE = "extra_value"
private const val PASSWORD_OR_LEN = "password_or_len"
private const val KEYGUARD_TYPE = "keyguard_type"
private const val SHOW_PROMINENT_DISCLOSURE = "show_prominent_disclosure"
Expand All @@ -25,6 +26,7 @@ class Preferences(ctx: Context, encrypted: Boolean = true) {
private const val SERVICE_ENABLED = "service_enabled"
private const val AUTHENTICATION_CODE = "authentication_code"
private const val PASSWORD_LEN = "password_len"
private const val SECRET = "secret"

fun new(ctx: Context) = Preferences(
ctx,
Expand Down Expand Up @@ -64,12 +66,22 @@ class Preferences(ctx: Context, encrypted: Boolean = true) {
get() = prefs.getString(RECEIVER, "") ?: ""
set(value) = prefs.edit { putString(RECEIVER, value) }

var secret: String
get() = prefs.getString(SECRET, prefs.getString(AUTHENTICATION_CODE, "")) ?: ""
set(value) = prefs.edit { putString(SECRET, value) }
var extraKey: String
get() = prefs.getString(EXTRA_KEY, "code") ?: ""
set(value) = prefs.edit { putString(EXTRA_KEY, value) }

var extraValue: String
get() = prefs.getString(
EXTRA_VALUE,
prefs.getString(SECRET, prefs.getString(AUTHENTICATION_CODE, "")),
) ?: ""
set(value) = prefs.edit { putString(EXTRA_VALUE, value) }

var passwordOrLen: String
get() = prefs.getString(PASSWORD_OR_LEN, prefs.getString(PASSWORD_LEN, "")) ?: ""
get() = prefs.getString(
PASSWORD_OR_LEN,
prefs.getInt(PASSWORD_LEN, 0).toString(),
) ?: ""
set(value) = prefs.edit { putString(PASSWORD_OR_LEN, value) }

var keyguardType: Int
Expand Down
22 changes: 20 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@
android:layout_marginVertical="5dp" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/secret"
android:id="@+id/extraKey"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/secret">
android:hint="@string/extra_key">

<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
Expand All @@ -101,6 +101,24 @@
android:layout_height="wrap_content"
android:layout_marginVertical="5dp" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/extraValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/extra_value">

<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</com.google.android.material.textfield.TextInputLayout>

<Space
android:id="@+id/space4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="5dp" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/passwordOrLen"
android:layout_width="match_parent"
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Duress</string>
<string name="service_unavailable_popup">Service indisponible</string>
<string name="prominent_disclosure_title">Divulgation Importante</string>
<string name="prominent_disclosure_message">L\'application utilise le service d\'accessibilité pour écouter un mot de passe de contrainte sur l\'écran de verrouillage. Une fois trouvé, il peut envoyer un message de diffusion ou effacer l\'appareil.</string>
<string name="accept">Accepter</string>
<string name="exit">Quitter</string>
<string name="action">action*</string>
<string name="receiver">récepteur</string>
<string name="password_or_len">Code PIN/mot de passe ou longueur*</string>
<string name="password_or_len_helper_text">La longueur doit être d\'au moins la longueur de votre code PIN/mot de passe plus deux.</string>
<string name="tab_broadcast">DIFFUSER</string>
<string name="tab_wipe">EFFACER</string>
<string name="tab_test">TEST</string>
<string name="keyguard_type">Garde-clefs:</string>
<string name="keyguard_type_a">A</string>
<string name="keyguard_type_b">B (PIN uniquement)</string>
<string name="keyguard_type_description">Si vous utilisez un code PIN/mot de passe (et non la longueur), le Garde-clefs A requiert que l\'option d\'affichage des caractères du mot de passe lors de la saisie soit activée. Garde-clefs B peut être dépendant de la langue (EN). Si vous changez le type de Garde-clefs, redémarrez le service d\'accessibilité.</string>
<string name="authentication">Authentification</string>
<string name="notification_channel_default_name">Défaut</string>
<string name="notification_title">Test</string>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
<string name="exit">Выйти</string>
<string name="action">Действие *</string>
<string name="receiver">Получатель</string>
<string name="secret">Код аутентификации</string>
</resources>
23 changes: 23 additions & 0 deletions app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Duress</string>
<string name="service_unavailable_popup">Сервіс недоступний</string>
<string name="prominent_disclosure_title">Помітне розкриття інформації</string>
<string name="prominent_disclosure_message">Додаток використовує службу доступності, щоб прослуховувати примусовий пароль на екрані блокування. Коли він знайдений, він може надіслати широкомовне повідомлення або стерти пристрій.</string>
<string name="accept">Прийняти</string>
<string name="exit">Вихід</string>
<string name="action">дія*</string>
<string name="receiver">приймач</string>
<string name="password_or_len">PIN-код/пароль або довжина*</string>
<string name="password_or_len_helper_text">Довжина має бути принаймні довжиною вашого PIN-коду/пароля не менше 2.</string>
<string name="tab_broadcast">ТРАНСЛЯЦІЯ</string>
<string name="tab_wipe">ОЧИЩЕННЯ</string>
<string name="tab_test">ТЕСТ</string>
<string name="keyguard_type">Блокування клавіш:</string>
<string name="keyguard_type_a">A</string>
<string name="keyguard_type_b">B (лише PIN-код)</string>
<string name="keyguard_type_description">Якщо ви використовуєте PIN-код/пароль (а не довжину), функція блокування клавіатури A вимагає відображення символів пароля під час введення. Блокування клавіатури B може залежати від мови (EN). Якщо ви змінили тип блокування клавіатури, перезапустіть службу доступності.</string>
<string name="authentication">Автентифікація</string>
<string name="notification_channel_default_name">За замовчуванням</string>
<string name="notification_title">Тест</string>
</resources>
24 changes: 24 additions & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">緊急脅迫</string>
<string name="service_unavailable_popup">服務無法使用</string>
<string name="prominent_disclosure_title">重要訊息揭露</string>
<string name="prominent_disclosure_message">這個APP使用無障礙服務來在鎖定螢幕上監聽脅迫密碼。當發現時會發送廣播訊息或清除裝置。</string>
<string name="accept">接受</string>
<string name="exit">離開</string>
<string name="action">動作*</string>
<string name="receiver">接收器</string>
<string name="password_or_len">PIN/密碼或長度*</string>
<string name="password_or_len_helper_text">長度至少要是你的PIN或密碼的長度加2</string>
<string name="tab_broadcast">廣播</string>
<string name="tab_wipe">清除裝置</string>
<string name="tab_test">測試</string>
<string name="keyguard_type">鍵盤類型:</string>
<string name="keyguard_type_a">A</string>
<string name="keyguard_type_b">B(僅限PIN)</string>
<string name="keyguard_type_description">如果你使用PIN或密碼(而非長度),鍵盤A需要啟用輸入時顯示密碼字元之選項,鍵盤B可能限定語言(如英文)
如果你改變鍵盤類型,需重啟無障礙服務</string>
<string name="authentication">驗證</string>
<string name="notification_channel_default_name">預設值</string>
<string name="notification_title">測試</string>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<string name="exit">Exit</string>
<string name="action">action*</string>
<string name="receiver">receiver</string>
<string name="secret">secret</string>
<string name="extra_key">key</string>
<string name="extra_value">value</string>
<string name="password_or_len">PIN/password or length*</string>
<string name="password_or_len_helper_text">The length has to be at least your PIN/password length plus two.</string>
<string name="tab_broadcast">BROADCAST</string>
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}

Expand Down
5 changes: 5 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
custom extra key
prepare Android 13
add Ukrainian translation, thanks to GNCanva
add French translation, thanks to Nathanaël Gagnepain (@Ilithy)
add Chinese Traditional translation, thanks to rdol724
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 607b3e7

Please sign in to comment.