popup position changer
This commit is contained in:
parent
ca19155cea
commit
539bb9397e
9 changed files with 37 additions and 3 deletions
|
@ -10,8 +10,8 @@ android {
|
||||||
applicationId "me.lucky.red"
|
applicationId "me.lucky.red"
|
||||||
minSdk 29
|
minSdk 29
|
||||||
targetSdk 32
|
targetSdk 32
|
||||||
versionCode 5
|
versionCode 6
|
||||||
versionName "1.0.4"
|
versionName "1.0.5"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import android.os.Bundle
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
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.widget.doAfterTextChanged
|
||||||
|
import java.lang.NumberFormatException
|
||||||
|
|
||||||
import me.lucky.red.databinding.ActivityMainBinding
|
import me.lucky.red.databinding.ActivityMainBinding
|
||||||
|
|
||||||
|
@ -45,6 +47,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
roleManager = getSystemService(RoleManager::class.java)
|
roleManager = getSystemService(RoleManager::class.java)
|
||||||
binding.apply {
|
binding.apply {
|
||||||
redirectionDelay.value = (prefs.redirectionDelay / 1000).toFloat()
|
redirectionDelay.value = (prefs.redirectionDelay / 1000).toFloat()
|
||||||
|
popupPosition.editText?.setText(prefs.popupPosition.toString())
|
||||||
toggle.isChecked = prefs.isServiceEnabled
|
toggle.isChecked = prefs.isServiceEnabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +60,11 @@ class MainActivity : AppCompatActivity() {
|
||||||
redirectionDelay.addOnChangeListener { _, value, _ ->
|
redirectionDelay.addOnChangeListener { _, value, _ ->
|
||||||
prefs.redirectionDelay = (value * 1000).toLong()
|
prefs.redirectionDelay = (value * 1000).toLong()
|
||||||
}
|
}
|
||||||
|
popupPosition.editText?.doAfterTextChanged {
|
||||||
|
try {
|
||||||
|
prefs.popupPosition = it?.toString()?.toInt() ?: return@doAfterTextChanged
|
||||||
|
} catch (exc: NumberFormatException) {}
|
||||||
|
}
|
||||||
toggle.setOnCheckedChangeListener { _, isChecked ->
|
toggle.setOnCheckedChangeListener { _, isChecked ->
|
||||||
if (isChecked && !hasPermissions()) {
|
if (isChecked && !hasPermissions()) {
|
||||||
toggle.isChecked = false
|
toggle.isChecked = false
|
||||||
|
|
|
@ -31,7 +31,7 @@ class PopupWindow(private val service: CallRedirectionService) {
|
||||||
gravity = Gravity.BOTTOM
|
gravity = Gravity.BOTTOM
|
||||||
width = WindowManager.LayoutParams.WRAP_CONTENT
|
width = WindowManager.LayoutParams.WRAP_CONTENT
|
||||||
height = WindowManager.LayoutParams.WRAP_CONTENT
|
height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||||
y = 333
|
y = service.prefs.popupPosition
|
||||||
}
|
}
|
||||||
private var timer: Timer? = null
|
private var timer: Timer? = null
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ class Preferences(ctx: Context) {
|
||||||
companion object {
|
companion object {
|
||||||
private const val SERVICE_ENABLED = "service_enabled"
|
private const val SERVICE_ENABLED = "service_enabled"
|
||||||
private const val REDIRECTION_DELAY = "redirection_delay"
|
private const val REDIRECTION_DELAY = "redirection_delay"
|
||||||
|
private const val POPUP_POSITION = "popup_position_y"
|
||||||
}
|
}
|
||||||
|
|
||||||
private val prefs = PreferenceManager.getDefaultSharedPreferences(ctx)
|
private val prefs = PreferenceManager.getDefaultSharedPreferences(ctx)
|
||||||
|
@ -19,4 +20,8 @@ class Preferences(ctx: Context) {
|
||||||
var redirectionDelay: Long
|
var redirectionDelay: Long
|
||||||
get() = prefs.getLong(REDIRECTION_DELAY, 2000L)
|
get() = prefs.getLong(REDIRECTION_DELAY, 2000L)
|
||||||
set(value) = prefs.edit { putLong(REDIRECTION_DELAY, value) }
|
set(value) = prefs.edit { putLong(REDIRECTION_DELAY, value) }
|
||||||
|
|
||||||
|
var popupPosition: Int
|
||||||
|
get() = prefs.getInt(POPUP_POSITION, 333)
|
||||||
|
set(value) = prefs.edit { putInt(POPUP_POSITION, value) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,24 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/redirection_delay_description" />
|
android:text="@string/redirection_delay_description" />
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_marginVertical="8dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/popupPosition"
|
||||||
|
android:hint="@string/popup_position"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:inputType="number"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
|
|
@ -7,4 +7,5 @@
|
||||||
<string name="destination_telegram">Telegram</string>
|
<string name="destination_telegram">Telegram</string>
|
||||||
<string name="destination_threema">Threema</string>
|
<string name="destination_threema">Threema</string>
|
||||||
<string name="redirection_delay_description">Задержка до того, как звонок будет перенаправлен.</string>
|
<string name="redirection_delay_description">Задержка до того, как звонок будет перенаправлен.</string>
|
||||||
|
<string name="popup_position">Позиция всплывающего окна</string>
|
||||||
</resources>
|
</resources>
|
|
@ -7,4 +7,5 @@
|
||||||
<string name="destination_telegram">Telegram</string>
|
<string name="destination_telegram">Telegram</string>
|
||||||
<string name="destination_threema">Threema</string>
|
<string name="destination_threema">Threema</string>
|
||||||
<string name="redirection_delay_description">Delay before a call will be redirected.</string>
|
<string name="redirection_delay_description">Delay before a call will be redirected.</string>
|
||||||
|
<string name="popup_position">Popup position</string>
|
||||||
</resources>
|
</resources>
|
1
fastlane/metadata/android/en-US/changelogs/6.txt
Normal file
1
fastlane/metadata/android/en-US/changelogs/6.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
popup position changer
|
Binary file not shown.
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 79 KiB |
Loading…
Add table
Add a link
Reference in a new issue