@@ -42,7 +42,7 @@ class MainActivity : AppCompatActivity() {
4242 private lateinit var batteryButton: Button
4343
4444 private lateinit var checkUpdateButton: Button
45- private lateinit var setPasswordButton : Button
45+ private lateinit var setPinButton : Button
4646 private lateinit var botTokenInput: EditText
4747 private lateinit var chatIdInput: EditText
4848 private lateinit var saveButton: Button
@@ -62,19 +62,13 @@ class MainActivity : AppCompatActivity() {
6262 chatIdInput = findViewById(R .id.et_chat_id)
6363 saveButton = findViewById(R .id.btn_save_connection)
6464 testButton = findViewById(R .id.btn_test_connection)
65- setPasswordButton = findViewById(R .id.btn_set_password)
65+ setPinButton = findViewById(R .id.btn_set_password)
6666 checkUpdateButton = findViewById(R .id.btn_check_update)
6767
6868 val prefsManager = com.zero.sentinel.data.EncryptedPrefsManager (this )
6969
70- // Check for App Lock
71- val alreadyAuthenticated = intent.getBooleanExtra(" EXTRA_AUTHENTICATED" , false )
72- if (! alreadyAuthenticated) {
73- checkAppLock(prefsManager)
74- }
75-
76- setPasswordButton.setOnClickListener {
77- showSetPasswordDialog(prefsManager)
70+ setPinButton.setOnClickListener {
71+ showSetPinDialog(prefsManager)
7872 }
7973
8074 // Check for Update
@@ -248,13 +242,6 @@ class MainActivity : AppCompatActivity() {
248242
249243
250244
251- private fun checkAppLock (prefs : com.zero.sentinel.data.EncryptedPrefsManager ) {
252- val password = prefs.getAppPassword()
253- if (! password.isNullOrEmpty()) {
254- showLoginDialog(password)
255- }
256- }
257-
258245 private fun showAdminDialog () {
259246 val componentName = android.content.ComponentName (this , com.zero.sentinel.receivers.SentinelDeviceAdminReceiver ::class .java)
260247 val intent = Intent (android.app.admin.DevicePolicyManager .ACTION_ADD_DEVICE_ADMIN )
@@ -269,34 +256,7 @@ class MainActivity : AppCompatActivity() {
269256 return dpm.isAdminActive(componentName)
270257 }
271258
272- private fun showLoginDialog (correctPassword : String ) {
273- val input = EditText (this )
274- input.inputType = android.text.InputType .TYPE_CLASS_NUMBER or android.text.InputType .TYPE_NUMBER_VARIATION_PASSWORD
275- input.filters = arrayOf(android.text.InputFilter .LengthFilter (6 ))
276- input.hint = " Enter 6-digit PIN"
277-
278- val dialog = androidx.appcompat.app.AlertDialog .Builder (this )
279- .setTitle(" App Locked" )
280- .setView(input)
281- .setCancelable(false )
282- .setPositiveButton(" Unlock" ) { _, _ ->
283- val entered = input.text.toString()
284- if (entered == correctPassword) {
285- Toast .makeText(this , " Welcome back" , Toast .LENGTH_SHORT ).show()
286- } else {
287- Toast .makeText(this , " Wrong Password" , Toast .LENGTH_SHORT ).show()
288- finishAffinity() // Close app on failure
289- }
290- }
291- .setNegativeButton(" Exit" ) { _, _ ->
292- finishAffinity()
293- }
294- .create()
295-
296- dialog.show()
297- }
298-
299- private fun showSetPasswordDialog (prefs : com.zero.sentinel.data.EncryptedPrefsManager ) {
259+ private fun showSetPinDialog (prefs : com.zero.sentinel.data.EncryptedPrefsManager ) {
300260 val layout = android.widget.LinearLayout (this )
301261 layout.orientation = android.widget.LinearLayout .VERTICAL
302262 layout.setPadding(50 , 40 , 50 , 10 )
@@ -314,7 +274,7 @@ class MainActivity : AppCompatActivity() {
314274 layout.addView(input2)
315275
316276 androidx.appcompat.app.AlertDialog .Builder (this )
317- .setTitle(" Set App Password " )
277+ .setTitle(" Set App PIN " )
318278 .setView(layout)
319279 .setPositiveButton(" Save" ) { _, _ ->
320280 val p1 = input1.text.toString()
0 commit comments