feat: add calculator to app
This commit is contained in:
parent
0008da200a
commit
143eed8cb2
14 changed files with 776 additions and 5 deletions
|
@ -129,6 +129,8 @@
|
||||||
<data android:scheme="file" />
|
<data android:scheme="file" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".others.calc.CalcActivity"
|
||||||
|
android:parentActivityName=".MainActivity" />
|
||||||
<activity android:name=".settings.FAQActivity" />
|
<activity android:name=".settings.FAQActivity" />
|
||||||
<activity android:name=".settings.ReaderSettingsActivity" />
|
<activity android:name=".settings.ReaderSettingsActivity" />
|
||||||
<activity android:name=".settings.UserInterfaceSettingsActivity" />
|
<activity android:name=".settings.UserInterfaceSettingsActivity" />
|
||||||
|
|
|
@ -48,6 +48,7 @@ import ani.dantotsu.home.NoInternet
|
||||||
import ani.dantotsu.media.MediaDetailsActivity
|
import ani.dantotsu.media.MediaDetailsActivity
|
||||||
import ani.dantotsu.notifications.TaskScheduler
|
import ani.dantotsu.notifications.TaskScheduler
|
||||||
import ani.dantotsu.others.CustomBottomDialog
|
import ani.dantotsu.others.CustomBottomDialog
|
||||||
|
import ani.dantotsu.others.calc.CalcActivity
|
||||||
import ani.dantotsu.profile.ProfileActivity
|
import ani.dantotsu.profile.ProfileActivity
|
||||||
import ani.dantotsu.profile.activity.FeedActivity
|
import ani.dantotsu.profile.activity.FeedActivity
|
||||||
import ani.dantotsu.profile.activity.NotificationActivity
|
import ani.dantotsu.profile.activity.NotificationActivity
|
||||||
|
@ -100,6 +101,20 @@ class MainActivity : AppCompatActivity() {
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
TaskScheduler.scheduleSingleWork(this)
|
TaskScheduler.scheduleSingleWork(this)
|
||||||
|
if (!CalcActivity.hasPermission) {
|
||||||
|
val pin: String = PrefManager.getVal(PrefName.AppPassword)
|
||||||
|
if (pin.isNotEmpty()) {
|
||||||
|
ContextCompat.startActivity(
|
||||||
|
this@MainActivity,
|
||||||
|
Intent(this@MainActivity, CalcActivity::class.java)
|
||||||
|
.putExtra("code", pin)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val action = intent.action
|
val action = intent.action
|
||||||
val type = intent.type
|
val type = intent.type
|
||||||
|
|
|
@ -148,7 +148,11 @@ class SubscriptionHelper {
|
||||||
val name: String,
|
val name: String,
|
||||||
val image: String?,
|
val image: String?,
|
||||||
val banner: String? = null
|
val banner: String? = null
|
||||||
) : java.io.Serializable
|
) : java.io.Serializable {
|
||||||
|
companion object {
|
||||||
|
private const val serialVersionUID = 1L
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private const val SUBSCRIPTIONS = "subscriptions"
|
private const val SUBSCRIPTIONS = "subscriptions"
|
||||||
|
|
||||||
|
|
120
app/src/main/java/ani/dantotsu/others/calc/CalcActivity.kt
Normal file
120
app/src/main/java/ani/dantotsu/others/calc/CalcActivity.kt
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
package ani.dantotsu.others.calc
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.Spannable
|
||||||
|
import android.text.SpannableString
|
||||||
|
import android.text.style.ForegroundColorSpan
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.updateLayoutParams
|
||||||
|
import ani.dantotsu.MainActivity
|
||||||
|
import ani.dantotsu.R
|
||||||
|
import ani.dantotsu.databinding.ActivityCalcBinding
|
||||||
|
import ani.dantotsu.getThemeColor
|
||||||
|
import ani.dantotsu.initActivity
|
||||||
|
import ani.dantotsu.navBarHeight
|
||||||
|
import ani.dantotsu.statusBarHeight
|
||||||
|
import ani.dantotsu.themes.ThemeManager
|
||||||
|
import ani.dantotsu.util.NumberConverter.Companion.toBinary
|
||||||
|
import ani.dantotsu.util.NumberConverter.Companion.toHex
|
||||||
|
|
||||||
|
class CalcActivity : AppCompatActivity() {
|
||||||
|
private lateinit var binding: ActivityCalcBinding
|
||||||
|
private lateinit var code: String
|
||||||
|
private val stack = CalcStack()
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
ThemeManager(this).applyTheme()
|
||||||
|
initActivity(this)
|
||||||
|
binding = ActivityCalcBinding.inflate(layoutInflater)
|
||||||
|
binding.mainContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
|
topMargin += statusBarHeight
|
||||||
|
bottomMargin = navBarHeight
|
||||||
|
}
|
||||||
|
setContentView(binding.root)
|
||||||
|
code = intent.getStringExtra("code") ?: "0"
|
||||||
|
|
||||||
|
binding.apply {
|
||||||
|
button0.setOnClickListener { stack.add('0'); updateDisplay() }
|
||||||
|
button1.setOnClickListener { stack.add('1'); updateDisplay() }
|
||||||
|
button2.setOnClickListener { stack.add('2'); updateDisplay() }
|
||||||
|
button3.setOnClickListener { stack.add('3'); updateDisplay() }
|
||||||
|
button4.setOnClickListener { stack.add('4'); updateDisplay() }
|
||||||
|
button5.setOnClickListener { stack.add('5'); updateDisplay() }
|
||||||
|
button6.setOnClickListener { stack.add('6'); updateDisplay() }
|
||||||
|
button7.setOnClickListener { stack.add('7'); updateDisplay() }
|
||||||
|
button8.setOnClickListener { stack.add('8'); updateDisplay() }
|
||||||
|
button9.setOnClickListener { stack.add('9'); updateDisplay() }
|
||||||
|
buttonDot.setOnClickListener { stack.add('.'); updateDisplay() }
|
||||||
|
buttonAdd.setOnClickListener { stack.add('+'); updateDisplay() }
|
||||||
|
buttonSubtract.setOnClickListener { stack.add('-'); updateDisplay() }
|
||||||
|
buttonMultiply.setOnClickListener { stack.add('*'); updateDisplay() }
|
||||||
|
buttonDivide.setOnClickListener { stack.add('/'); updateDisplay() }
|
||||||
|
buttonEquals.setOnClickListener {
|
||||||
|
try {
|
||||||
|
val ans = stack.evaluate()
|
||||||
|
updateDisplay()
|
||||||
|
binding.displayBinary.text = ans.toBinary()
|
||||||
|
binding.displayHex.text = ans.toHex()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
display.text = getString(R.string.error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buttonClear.setOnClickListener {
|
||||||
|
stack.clear()
|
||||||
|
binding.displayBinary.text = ""
|
||||||
|
binding.displayHex.text = ""
|
||||||
|
binding.display.text = "0"
|
||||||
|
}
|
||||||
|
buttonBackspace.setOnClickListener {
|
||||||
|
stack.remove()
|
||||||
|
updateDisplay()
|
||||||
|
}
|
||||||
|
display.text = "0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun success() {
|
||||||
|
hasPermission = true
|
||||||
|
ContextCompat.startActivity(
|
||||||
|
this,
|
||||||
|
Intent(this, MainActivity::class.java)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateDisplay() {
|
||||||
|
if (stack.getExpression().isEmpty()) {
|
||||||
|
binding.display.text = "0"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val expression = stack.getExpression().replace("*", "×").replace("/", "÷")
|
||||||
|
val spannable = SpannableString(expression)
|
||||||
|
|
||||||
|
val operators = arrayOf('+', '-', '×', '÷')
|
||||||
|
|
||||||
|
expression.forEachIndexed { index, char ->
|
||||||
|
if (char in operators) {
|
||||||
|
val color = getThemeColor(com.google.android.material.R.attr.colorSecondary)
|
||||||
|
spannable.setSpan(
|
||||||
|
ForegroundColorSpan(color),
|
||||||
|
index,
|
||||||
|
index + 1,
|
||||||
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.display.text = spannable
|
||||||
|
val text = binding.display.text.toString()
|
||||||
|
if (text == code) {
|
||||||
|
success()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
var hasPermission = false
|
||||||
|
}
|
||||||
|
}
|
103
app/src/main/java/ani/dantotsu/others/calc/CalcStack.kt
Normal file
103
app/src/main/java/ani/dantotsu/others/calc/CalcStack.kt
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
package ani.dantotsu.others.calc
|
||||||
|
|
||||||
|
import java.util.Stack
|
||||||
|
|
||||||
|
class CalcStack {
|
||||||
|
private var expression: String = ""
|
||||||
|
private val maxExpressionLength = 256
|
||||||
|
|
||||||
|
fun evaluate(): Double {
|
||||||
|
val ops = Stack<Char>()
|
||||||
|
val values = Stack<Double>()
|
||||||
|
|
||||||
|
var i = 0
|
||||||
|
while (i < expression.length) {
|
||||||
|
when {
|
||||||
|
expression[i] == ' ' -> i++
|
||||||
|
expression[i].isDigit() || expression[i] == '.' -> {
|
||||||
|
var value = 0.0
|
||||||
|
var isDecimal = false
|
||||||
|
var decimalFactor = 0.1
|
||||||
|
while (i < expression.length && (expression[i].isDigit() || expression[i] == '.' && !isDecimal)) {
|
||||||
|
if (expression[i] == '.') {
|
||||||
|
isDecimal = true
|
||||||
|
} else if (!isDecimal) {
|
||||||
|
value = value * 10 + (expression[i] - '0')
|
||||||
|
} else {
|
||||||
|
value += (expression[i] - '0') * decimalFactor
|
||||||
|
decimalFactor *= 0.1
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
values.push(value)
|
||||||
|
i-- // to compensate the additional i++ in the loop
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
while (!ops.isEmpty() && precedence(ops.peek()) >= precedence(expression[i])) {
|
||||||
|
val val2 = values.pop()
|
||||||
|
val val1 = values.pop()
|
||||||
|
val op = ops.pop()
|
||||||
|
values.push(applyOp(val1, val2, op))
|
||||||
|
}
|
||||||
|
ops.push(expression[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!ops.isEmpty()) {
|
||||||
|
val val2 = values.pop()
|
||||||
|
val val1 = values.pop()
|
||||||
|
val op = ops.pop()
|
||||||
|
values.push(applyOp(val1, val2, op))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val ans = values.pop()
|
||||||
|
expression = ans.toString()
|
||||||
|
return ans
|
||||||
|
}
|
||||||
|
|
||||||
|
fun add(c: Char) {
|
||||||
|
if (expression.length >= maxExpressionLength) return
|
||||||
|
expression += c
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clear() {
|
||||||
|
expression = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
fun remove() {
|
||||||
|
if (expression.isNotEmpty()) {
|
||||||
|
expression = expression.substring(0, expression.length - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getExpression(): String {
|
||||||
|
return expression
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun precedence(op: Char): Int {
|
||||||
|
return when (op) {
|
||||||
|
'+', '-' -> 1
|
||||||
|
'*', '/' -> 2
|
||||||
|
else -> -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun applyOp(a: Double, b: Double, op: Char): Double {
|
||||||
|
return when (op) {
|
||||||
|
'+' -> a + b
|
||||||
|
'-' -> a - b
|
||||||
|
'*' -> a * b
|
||||||
|
'/' -> {
|
||||||
|
if (b == 0.0) throw UnsupportedOperationException("Cannot divide by zero.")
|
||||||
|
a / b
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,12 +4,11 @@ import android.app.AlertDialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.TextView
|
import android.widget.EditText
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
|
@ -41,6 +40,7 @@ import kotlinx.coroutines.launch
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
|
|
||||||
class SettingsCommonActivity : AppCompatActivity() {
|
class SettingsCommonActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivitySettingsCommonBinding
|
private lateinit var binding: ActivitySettingsCommonBinding
|
||||||
private lateinit var launcher: LauncherWrapper
|
private lateinit var launcher: LauncherWrapper
|
||||||
|
@ -169,6 +169,51 @@ class SettingsCommonActivity : AppCompatActivity() {
|
||||||
dialog.window?.setDimAmount(0.8f)
|
dialog.window?.setDimAmount(0.8f)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
Settings(
|
||||||
|
type = 1,
|
||||||
|
name = getString(R.string.app_lock),
|
||||||
|
desc = getString(R.string.app_lock_desc),
|
||||||
|
icon = R.drawable.ic_round_lock_open_24,
|
||||||
|
onClick = {
|
||||||
|
val passwordDialog = AlertDialog.Builder(context, R.style.MyPopup)
|
||||||
|
.setTitle(R.string.download_manager)
|
||||||
|
.setView(R.layout.dialog_set_password)
|
||||||
|
.setPositiveButton(R.string.ok) { dialog, _ ->
|
||||||
|
val passwordInput =
|
||||||
|
(dialog as AlertDialog).findViewById<EditText>(R.id.passwordInput)
|
||||||
|
val confirmPasswordInput =
|
||||||
|
dialog.findViewById<EditText>(R.id.confirmPasswordInput)
|
||||||
|
|
||||||
|
val password = passwordInput?.text.toString()
|
||||||
|
val confirmPassword = confirmPasswordInput?.text.toString()
|
||||||
|
|
||||||
|
if (password == confirmPassword && password.isNotEmpty()) {
|
||||||
|
PrefManager.setVal(PrefName.AppPassword, password)
|
||||||
|
toast(R.string.success)
|
||||||
|
dialog.dismiss()
|
||||||
|
} else {
|
||||||
|
toast(R.string.password_mismatch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.setNegativeButton(R.string.cancel) { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
.setNeutralButton(R.string.remove) { dialog, _ ->
|
||||||
|
PrefManager.setVal(PrefName.AppPassword, "")
|
||||||
|
toast(R.string.success)
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
.create()
|
||||||
|
|
||||||
|
passwordDialog.window?.setDimAmount(0.8f)
|
||||||
|
passwordDialog.setOnShowListener {
|
||||||
|
passwordDialog.findViewById<EditText>(R.id.passwordInput)
|
||||||
|
?.requestFocus()
|
||||||
|
}
|
||||||
|
passwordDialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
),
|
||||||
Settings(
|
Settings(
|
||||||
type = 1,
|
type = 1,
|
||||||
name = getString(R.string.backup_restore),
|
name = getString(R.string.backup_restore),
|
||||||
|
|
|
@ -201,4 +201,5 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
|
||||||
AnilistUserId(Pref(Location.Protected, String::class, "")),
|
AnilistUserId(Pref(Location.Protected, String::class, "")),
|
||||||
MALCodeChallenge(Pref(Location.Protected, String::class, "")),
|
MALCodeChallenge(Pref(Location.Protected, String::class, "")),
|
||||||
MALToken(Pref(Location.Protected, MAL.ResponseToken::class, "")),
|
MALToken(Pref(Location.Protected, MAL.ResponseToken::class, "")),
|
||||||
|
AppPassword(Pref(Location.Protected, String::class, "")),
|
||||||
}
|
}
|
51
app/src/main/java/ani/dantotsu/util/NumberConverter.kt
Normal file
51
app/src/main/java/ani/dantotsu/util/NumberConverter.kt
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
package ani.dantotsu.util
|
||||||
|
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
class NumberConverter {
|
||||||
|
companion object {
|
||||||
|
fun Number.toBinary(): String {
|
||||||
|
return when (this) {
|
||||||
|
is Int -> Integer.toBinaryString(this)
|
||||||
|
is Long -> java.lang.Long.toBinaryString(this)
|
||||||
|
is Short -> Integer.toBinaryString(this.toInt())
|
||||||
|
is Byte -> Integer.toBinaryString(this.toInt())
|
||||||
|
is Double -> doubleToBinary(this)
|
||||||
|
is Float -> floatToBinary(this)
|
||||||
|
else -> throw IllegalArgumentException("Unsupported number type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Number.toHex(): String {
|
||||||
|
return when (this) {
|
||||||
|
is Int -> Integer.toHexString(this)
|
||||||
|
is Long -> java.lang.Long.toHexString(this)
|
||||||
|
is Short -> Integer.toHexString(this.toInt())
|
||||||
|
is Byte -> Integer.toHexString(this.toInt())
|
||||||
|
is Double -> doubleToHex(this)
|
||||||
|
is Float -> floatToHex(this)
|
||||||
|
else -> throw IllegalArgumentException("Unsupported number type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doubleToHex(number: Double): String {
|
||||||
|
val longBits = java.lang.Double.doubleToLongBits(number)
|
||||||
|
return "0x" + java.lang.Long.toHexString(longBits).uppercase(Locale.ROOT)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun floatToHex(number: Float): String {
|
||||||
|
val intBits = java.lang.Float.floatToIntBits(number)
|
||||||
|
return "0x" + Integer.toHexString(intBits).uppercase(Locale.ROOT)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doubleToBinary(number: Double): String {
|
||||||
|
val longBits = java.lang.Double.doubleToLongBits(number)
|
||||||
|
return java.lang.Long.toBinaryString(longBits)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun floatToBinary(number: Float): String {
|
||||||
|
val intBits = java.lang.Float.floatToIntBits(number)
|
||||||
|
return Integer.toBinaryString(intBits)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
app/src/main/res/drawable/rounded_bottom_corners.xml
Normal file
9
app/src/main/res/drawable/rounded_bottom_corners.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="?attr/colorSurfaceVariant" />
|
||||||
|
<corners
|
||||||
|
android:topLeftRadius="0dp"
|
||||||
|
android:topRightRadius="0dp"
|
||||||
|
android:bottomLeftRadius="16dp"
|
||||||
|
android:bottomRightRadius="16dp" />
|
||||||
|
</shape>
|
9
app/src/main/res/drawable/rounded_top_corners.xml
Normal file
9
app/src/main/res/drawable/rounded_top_corners.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="?attr/colorSurfaceVariant" />
|
||||||
|
<corners
|
||||||
|
android:topLeftRadius="16dp"
|
||||||
|
android:topRightRadius="16dp"
|
||||||
|
android:bottomLeftRadius="0dp"
|
||||||
|
android:bottomRightRadius="0dp" />
|
||||||
|
</shape>
|
383
app/src/main/res/layout/activity_calc.xml
Normal file
383
app/src/main/res/layout/activity_calc.xml
Normal file
|
@ -0,0 +1,383 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/bg">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/mainContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
|
android:background="@color/bg"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="8dp"
|
||||||
|
android:layout_marginBottom="32dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/display"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:background="@drawable/rounded_top_corners"
|
||||||
|
android:gravity="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
android:textSize="48sp"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/displayBinary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:background="?attr/colorSurfaceVariant"
|
||||||
|
android:gravity="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
android:textSize="28sp"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/displayHex"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:background="@drawable/rounded_bottom_corners"
|
||||||
|
android:gravity="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
android:textSize="28sp"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fillerLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal|bottom"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button7"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="7"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button8"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="8"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button9"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="9"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonDivide"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:backgroundTint="?attr/colorPrimary"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="÷"
|
||||||
|
android:textColor="?attr/colorOnPrimary"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button4"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="4"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button5"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="5"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button6"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="6"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonMultiply"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:backgroundTint="?attr/colorPrimary"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="×"
|
||||||
|
android:textColor="?attr/colorOnPrimary"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button1"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="1"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button2"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="2"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button3"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="3"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonSubtract"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:backgroundTint="?attr/colorPrimary"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="−"
|
||||||
|
android:textColor="?attr/colorOnPrimary"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button0"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="0"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonDot"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="."
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonBackspace"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="⌫"
|
||||||
|
android:textColor="?attr/colorOnSurfaceVariant"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonAdd"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:backgroundTint="?attr/colorPrimary"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="+"
|
||||||
|
android:textColor="?attr/colorOnPrimary"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonClear"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:backgroundTint="?attr/colorPrimary"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="C"
|
||||||
|
android:textColor="?attr/colorOnPrimary"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonEquals"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:backgroundTint="?attr/colorPrimary"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:text="="
|
||||||
|
android:textColor="?attr/colorOnPrimary"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="ButtonStyle,HardcodedText" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</FrameLayout>
|
25
app/src/main/res/layout/dialog_set_password.xml
Normal file
25
app/src/main/res/layout/dialog_set_password.xml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/passwordInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/enter_password"
|
||||||
|
android:maxLength="32"
|
||||||
|
android:inputType="numberPassword" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/confirmPasswordInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/confirm_password"
|
||||||
|
android:inputType="numberPassword"
|
||||||
|
android:maxLength="32"
|
||||||
|
android:layout_marginTop="16dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -557,7 +557,7 @@
|
||||||
<!-- theme 9 -->
|
<!-- theme 9 -->
|
||||||
<color name="seed_9">#c9000b</color>
|
<color name="seed_9">#c9000b</color>
|
||||||
<color name="md_theme_light_9_primary">#FF9800</color>
|
<color name="md_theme_light_9_primary">#FF9800</color>
|
||||||
<color name="md_theme_light_9_onPrimary">#FFFFFF</color>
|
<color name="md_theme_light_9_onPrimary">#201A19</color>
|
||||||
<color name="md_theme_light_9_primaryContainer">#FFCF87</color>
|
<color name="md_theme_light_9_primaryContainer">#FFCF87</color>
|
||||||
<color name="md_theme_light_9_onPrimaryContainer">#410001</color>
|
<color name="md_theme_light_9_onPrimaryContainer">#410001</color>
|
||||||
<color name="md_theme_light_9_secondary">#FF5722</color>
|
<color name="md_theme_light_9_secondary">#FF5722</color>
|
||||||
|
@ -587,7 +587,7 @@
|
||||||
<color name="md_theme_light_9_outlineVariant">#D8C2BE</color>
|
<color name="md_theme_light_9_outlineVariant">#D8C2BE</color>
|
||||||
<color name="md_theme_light_9_scrim">#000000</color>
|
<color name="md_theme_light_9_scrim">#000000</color>
|
||||||
<color name="md_theme_dark_9_primary">#FFB343</color>
|
<color name="md_theme_dark_9_primary">#FFB343</color>
|
||||||
<color name="md_theme_dark_9_onPrimary">#FAE965</color>
|
<color name="md_theme_dark_9_onPrimary">#322E0A</color>
|
||||||
<color name="md_theme_dark_9_primaryContainer">#FF6600</color>
|
<color name="md_theme_dark_9_primaryContainer">#FF6600</color>
|
||||||
<color name="md_theme_dark_9_onPrimaryContainer">#FFDAD5</color>
|
<color name="md_theme_dark_9_onPrimaryContainer">#FFDAD5</color>
|
||||||
<color name="md_theme_dark_9_secondary">#FF7700</color>
|
<color name="md_theme_dark_9_secondary">#FF7700</color>
|
||||||
|
|
|
@ -1020,4 +1020,8 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
||||||
<string name="failed_to_fix">Failed to fix</string>
|
<string name="failed_to_fix">Failed to fix</string>
|
||||||
<string name="running_fixes">Running Fixes…</string>
|
<string name="running_fixes">Running Fixes…</string>
|
||||||
<string name="test_search">Test Search</string>
|
<string name="test_search">Test Search</string>
|
||||||
|
<string name="app_lock">App Lock</string>
|
||||||
|
<string name="app_lock_desc">Lock the app with a password\n( ͡° ͜ʖ ͡°)</string>
|
||||||
|
<string name="confirm_password">Confirm Password</string>
|
||||||
|
<string name="password_mismatch">Passwords do not match or are empty!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue