From d8d1aef7062de4b567dc425f0dc601fa006a59c4 Mon Sep 17 00:00:00 2001 From: lucky <> Date: Fri, 7 Jan 2022 06:08:07 +0300 Subject: [PATCH] change some ui to be material --- .../main/java/me/lucky/wasted/MainActivity.kt | 20 ++++--------------- .../lucky/wasted/PanicConnectionActivity.kt | 4 ++-- app/src/main/res/layout/activity_main.xml | 8 ++++---- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/me/lucky/wasted/MainActivity.kt b/app/src/main/java/me/lucky/wasted/MainActivity.kt index 29a6c07..96ad38d 100644 --- a/app/src/main/java/me/lucky/wasted/MainActivity.kt +++ b/app/src/main/java/me/lucky/wasted/MainActivity.kt @@ -6,7 +6,6 @@ import android.content.pm.PackageManager import android.os.Build import android.os.Bundle import android.view.View -import android.widget.SeekBar import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity @@ -60,7 +59,7 @@ open class MainActivity : AppCompatActivity() { wipeData.isChecked = prefs.isWipeData wipeESIM.isChecked = prefs.isWipeESIM wipeESIM.isEnabled = wipeData.isChecked - maxFailedPasswordAttempts.progress = prefs.maxFailedPasswordAttempts + maxFailedPasswordAttempts.value = prefs.maxFailedPasswordAttempts.toFloat() toggle.isChecked = prefs.isServiceEnabled } } @@ -87,20 +86,9 @@ open class MainActivity : AppCompatActivity() { wipeESIM.setOnCheckedChangeListener { _, isChecked -> prefs.isWipeESIM = isChecked } - maxFailedPasswordAttempts.setOnSeekBarChangeListener( - object : SeekBar.OnSeekBarChangeListener { - - override fun onProgressChanged( - seekBar: SeekBar?, - progress: Int, - fromUser: Boolean, - ) { - prefs.maxFailedPasswordAttempts = progress - } - - override fun onStartTrackingTouch(seekBar: SeekBar?) {} - override fun onStopTrackingTouch(seekBar: SeekBar?) {} - }) + maxFailedPasswordAttempts.addOnChangeListener { _, value, _ -> + prefs.maxFailedPasswordAttempts = value.toInt() + } toggle.setOnCheckedChangeListener { _, isChecked -> when (isChecked) { true -> if (!admin.isActive()) requestAdmin() else setOn() diff --git a/app/src/main/java/me/lucky/wasted/PanicConnectionActivity.kt b/app/src/main/java/me/lucky/wasted/PanicConnectionActivity.kt index 181fd91..4be3f89 100644 --- a/app/src/main/java/me/lucky/wasted/PanicConnectionActivity.kt +++ b/app/src/main/java/me/lucky/wasted/PanicConnectionActivity.kt @@ -2,7 +2,7 @@ package me.lucky.wasted import android.content.pm.PackageManager import android.os.Bundle -import androidx.appcompat.app.AlertDialog +import com.google.android.material.dialog.MaterialAlertDialogBuilder import info.guardianproject.panic.PanicResponder @@ -30,7 +30,7 @@ class PanicConnectionActivity : MainActivity() { } catch (exc: PackageManager.NameNotFoundException) {} } - AlertDialog.Builder(this) + MaterialAlertDialogBuilder(this) .setTitle(getString(R.string.panic_app_dialog_title)) .setMessage(String.format(getString(R.string.panic_app_dialog_message), app)) .setNegativeButton(R.string.allow) { _, _ -> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index d077459..d65fad4 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -88,13 +88,13 @@ android:layout_height="wrap_content" android:layout_marginVertical="16dp" /> - + android:valueFrom="0" + android:valueTo="10" + android:stepSize="1.0" />