escape question char in strings

This commit is contained in:
lucky 2021-12-29 16:57:39 +03:00
parent afce3f24df
commit ee3a0f4d89
10 changed files with 18 additions and 30 deletions

View File

@ -10,8 +10,8 @@ android {
applicationId "me.lucky.wasted"
minSdk 23
targetSdk 31
versionCode 9
versionName "1.1.2"
versionCode 10
versionName "1.1.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -1,6 +1,5 @@
package me.lucky.wasted
import android.app.admin.DevicePolicyManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@ -17,10 +16,10 @@ class CodeReceiver : BroadcastReceiver() {
code == "" ||
intent.action != TRIGGER ||
intent.getStringExtra("code") != code) return
val dpm = context.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
val admin = DeviceAdmin(context)
try {
dpm.lockNow()
if (prefs.doWipe) dpm.wipeData(Utils.getWipeDataFlags())
admin.dpm.lockNow()
if (prefs.doWipe) admin.wipeData()
} catch (exc: SecurityException) {}
}
}

View File

@ -3,6 +3,7 @@ package me.lucky.wasted
import android.app.admin.DevicePolicyManager
import android.content.ComponentName
import android.content.Context
import android.os.Build
class DeviceAdmin(ctx: Context) {
val dpm by lazy {
@ -12,4 +13,9 @@ class DeviceAdmin(ctx: Context) {
fun remove() = dpm.removeActiveAdmin(deviceAdmin)
fun isActive(): Boolean = dpm.isAdminActive(deviceAdmin)
fun wipeData() {
dpm.wipeData(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
DevicePolicyManager.WIPE_SILENTLY else 0)
}
}

View File

@ -9,9 +9,8 @@ import android.os.Bundle
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import java.util.*
import me.lucky.wasted.databinding.ActivityMainBinding
import java.util.*
open class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding

View File

@ -1,7 +1,5 @@
package me.lucky.wasted
import android.app.admin.DevicePolicyManager
import android.content.Context
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
@ -10,9 +8,7 @@ import info.guardianproject.panic.PanicResponder
class PanicResponderActivity : AppCompatActivity() {
private val prefs by lazy { Preferences(this) }
private val dpm by lazy {
getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
}
private val admin by lazy { DeviceAdmin(this) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -21,9 +17,9 @@ class PanicResponderActivity : AppCompatActivity() {
return
}
try {
dpm.lockNow()
admin.dpm.lockNow()
if (PanicResponder.receivedTriggerFromConnectedApp(this) &&
prefs.doWipe) dpm.wipeData(Utils.getWipeDataFlags())
prefs.doWipe) admin.wipeData()
} catch (exc: SecurityException) {}
finish()
}

View File

@ -40,7 +40,7 @@ class QSTileService : TileService() {
timer?.schedule(timerTask {
try {
admin.dpm.lockNow()
admin.dpm.wipeData(Utils.getWipeDataFlags())
admin.wipeData()
} catch (exc: SecurityException) {}
}, 2000)
}

View File

@ -1,13 +0,0 @@
package me.lucky.wasted
import android.app.admin.DevicePolicyManager
import android.os.Build
class Utils {
companion object {
fun getWipeDataFlags(): Int {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
DevicePolicyManager.WIPE_SILENTLY else 0
}
}
}

View File

@ -6,7 +6,7 @@
<string name="service_unavailable_toast">Admin service unavailable</string>
<string name="wipe_data_check_box">Wipe data</string>
<string name="panic_app_dialog_title">Confirm Panic App</string>
<string name="panic_app_dialog_message">Are you sure that you want to allow %1$s to trigger destructive panic actions?</string>
<string name="panic_app_dialog_message">Are you sure that you want to allow %1$s to trigger destructive panic actions\?</string>
<string name="panic_app_unknown_app">an unknown app</string>
<string name="allow">Allow</string>
<string name="cancel">Cancel</string>

View File

@ -0,0 +1 @@
under the hood improvements

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 72 KiB