add + - buttons

This commit is contained in:
2024-10-28 21:18:07 +01:00
parent d3fa0900b4
commit d112bc38c5
7 changed files with 55 additions and 16 deletions

View File

@@ -17,11 +17,12 @@ android {
applicationId = "fr.ar2000.ndefemulator"
minSdk = 30
targetSdk = 34
versionCode = 2
versionName = "2.0"
versionCode = 3
versionName = "2.1"
vectorDrawables {
useSupportLibrary = true
}
signingConfig = signingConfigs.getByName("release")
}
@@ -39,6 +40,7 @@ android {
}
getByName("debug") {
versionNameSuffix = ".dev"
signingConfig = signingConfigs.getByName("debug")
}
create("private") {
isDebuggable = false

View File

@@ -21,6 +21,7 @@ import kotlin.math.max
import kotlin.math.min
@Suppress("SameParameterValue")
class MyHostApduService : HostApduService() {
private val TAG = "HostApduService"
@@ -274,6 +275,7 @@ class MyHostApduService : HostApduService() {
return result.toString()
}
@Suppress("unused")
private fun createTextRecord(language: String, text: String, id: ByteArray): NdefRecord {
val languageBytes: ByteArray
val textBytes: ByteArray

View File

@@ -51,7 +51,8 @@ class MainActivity : ComponentActivity(R.layout.main_activity) {
val currentFileId = findViewById<TextView>(R.id.current_file_id)
currentFileId.text = getString(
R.string.current_file_id,
sharedPreferences.getString("ndef_file_id","1")
sharedPreferences.getString("ndef_file_id","1"),
sharedPreferences.getString("ndef_file_id","1")!!.toInt() + 0xE103
)
}
}

View File

@@ -3,7 +3,9 @@ package fr.ar2000.ndefemulator.presentation
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.widget.Button
import android.widget.EditText
import android.widget.ImageButton
import androidx.activity.ComponentActivity
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentContainerView
@@ -22,12 +24,25 @@ class SettingsActivity : FragmentActivity(R.layout.settings_activity) {
//supportFragmentManager.beginTransaction().replace(R.id.fragmentContainerView,MySettingsFragment()).commit()
val fileIdInput = findViewById<EditText>(R.id.ndef_file_id)
fileIdInput.setOnFocusChangeListener { v, hasFocus ->
fileIdInput.setOnFocusChangeListener { _, hasFocus ->
if(!hasFocus){
saveSetting()
}
}
val increaseButton = findViewById<ImageButton>(R.id.increaseButton)
val decreaseButton = findViewById<ImageButton>(R.id.decreaseButton)
increaseButton.setOnClickListener {
fileIdInput.setText(fileIdInput.text.toString().toInt().plus(1).toString())
saveSetting()
}
decreaseButton.setOnClickListener {
fileIdInput.setText(fileIdInput.text.toString().toInt().minus(1).toString())
saveSetting()
}
if(savedInstanceState == null) {
fileIdInput.setText(sharedPreferences.getString("ndef_file_id","1"))
}

View File

@@ -29,16 +29,35 @@
android:inputType="number"
android:text="1"
android:textAlignment="center" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ImageButton
android:id="@+id/decreaseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="?android:attr/homeAsUpIndicator" />
<ImageButton
android:id="@+id/increaseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:rotation="180"
android:src="?android:attr/homeAsUpIndicator" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragmentContainerView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -5,5 +5,5 @@
<string name="servicedesc">Service démulation NFC</string>
<string name="title_activity_settings">Options</string>
<string name="settings">Options</string>
<string name="current_file_id">Fichier NDEF : %S</string>
<string name="current_file_id">Fichier NDEF : %S (%04X)</string>
</resources>

View File

@@ -11,5 +11,5 @@
<!-- Sync Preferences -->
<string name="settings">Settings</string>
<string name="current_file_id">Current file id : %S</string>
<string name="current_file_id">Current file id : %S (%04X)</string>
</resources>