Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
popup position changer
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky committed Feb 14, 2022
1 parent ca19155 commit 539bb93
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "me.lucky.red"
minSdk 29
targetSdk 32
versionCode 5
versionName "1.0.4"
versionCode 6
versionName "1.0.5"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/me/lucky/red/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import android.os.Bundle
import android.provider.Settings
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.core.widget.doAfterTextChanged
import java.lang.NumberFormatException

import me.lucky.red.databinding.ActivityMainBinding

Expand Down Expand Up @@ -45,6 +47,7 @@ class MainActivity : AppCompatActivity() {
roleManager = getSystemService(RoleManager::class.java)
binding.apply {
redirectionDelay.value = (prefs.redirectionDelay / 1000).toFloat()
popupPosition.editText?.setText(prefs.popupPosition.toString())
toggle.isChecked = prefs.isServiceEnabled
}
}
Expand All @@ -57,6 +60,11 @@ class MainActivity : AppCompatActivity() {
redirectionDelay.addOnChangeListener { _, value, _ ->
prefs.redirectionDelay = (value * 1000).toLong()
}
popupPosition.editText?.doAfterTextChanged {
try {
prefs.popupPosition = it?.toString()?.toInt() ?: return@doAfterTextChanged
} catch (exc: NumberFormatException) {}
}
toggle.setOnCheckedChangeListener { _, isChecked ->
if (isChecked && !hasPermissions()) {
toggle.isChecked = false
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/me/lucky/red/PopupWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PopupWindow(private val service: CallRedirectionService) {
gravity = Gravity.BOTTOM
width = WindowManager.LayoutParams.WRAP_CONTENT
height = WindowManager.LayoutParams.WRAP_CONTENT
y = 333
y = service.prefs.popupPosition
}
private var timer: Timer? = null

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/me/lucky/red/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Preferences(ctx: Context) {
companion object {
private const val SERVICE_ENABLED = "service_enabled"
private const val REDIRECTION_DELAY = "redirection_delay"
private const val POPUP_POSITION = "popup_position_y"
}

private val prefs = PreferenceManager.getDefaultSharedPreferences(ctx)
Expand All @@ -19,4 +20,8 @@ class Preferences(ctx: Context) {
var redirectionDelay: Long
get() = prefs.getLong(REDIRECTION_DELAY, 2000L)
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) }
}
18 changes: 18 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@
android:layout_height="wrap_content"
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>
</ScrollView>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<string name="destination_telegram">Telegram</string>
<string name="destination_threema">Threema</string>
<string name="redirection_delay_description">Задержка до того, как звонок будет перенаправлен.</string>
<string name="popup_position">Позиция всплывающего окна</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<string name="destination_telegram">Telegram</string>
<string name="destination_threema">Threema</string>
<string name="redirection_delay_description">Delay before a call will be redirected.</string>
<string name="popup_position">Popup position</string>
</resources>
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
popup position changer
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 539bb93

Please sign in to comment.