fallback mode
This commit is contained in:
parent
539bb9397e
commit
e8001df6ee
10 changed files with 71 additions and 6 deletions
|
@ -10,3 +10,8 @@ please read them at:
|
|||
Signal: https://signal.org/legal/#privacy-policy
|
||||
Telegram: https://telegram.org/privacy
|
||||
Threema: https://threema.ch/privacy_policy/
|
||||
|
||||
Fallback services:
|
||||
|
||||
WhatsApp: https://www.whatsapp.com/privacy
|
||||
Viber: https://www.viber.com/en/terms/viber-privacy-policy/
|
||||
|
|
|
@ -10,8 +10,8 @@ android {
|
|||
applicationId "me.lucky.red"
|
||||
minSdk 29
|
||||
targetSdk 32
|
||||
versionCode 6
|
||||
versionName "1.0.5"
|
||||
versionCode 7
|
||||
versionName "1.0.6"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
|
|
@ -15,10 +15,18 @@ class CallRedirectionService : CallRedirectionService() {
|
|||
private const val SIGNAL_MIMETYPE = "$PREFIX.org.thoughtcrime.securesms.call"
|
||||
private const val TELEGRAM_MIMETYPE = "$PREFIX.org.telegram.messenger.android.call"
|
||||
private const val THREEMA_MIMETYPE = "$PREFIX.ch.threema.app.call"
|
||||
private const val WHATSAPP_MIMETYPE = "$PREFIX.com.whatsapp.voip.call"
|
||||
private const val VIBER_MIMETYPE = "$PREFIX.com.viber.voip.call"
|
||||
private val MIMETYPES = mapOf(
|
||||
SIGNAL_MIMETYPE to 0,
|
||||
TELEGRAM_MIMETYPE to 1,
|
||||
THREEMA_MIMETYPE to 2,
|
||||
WHATSAPP_MIMETYPE to 48,
|
||||
VIBER_MIMETYPE to 49,
|
||||
)
|
||||
private val FALLBACK_MIMETYPES = arrayOf(
|
||||
WHATSAPP_MIMETYPE,
|
||||
VIBER_MIMETYPE,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -59,7 +67,7 @@ class CallRedirectionService : CallRedirectionService() {
|
|||
return
|
||||
}
|
||||
val record = records.minByOrNull { MIMETYPES[it.mimetype] ?: 0 }
|
||||
if (record == null) {
|
||||
if (record == null || (record.mimetype in FALLBACK_MIMETYPES && !prefs.isFallbackChecked)) {
|
||||
placeCallUnmodified()
|
||||
return
|
||||
}
|
||||
|
@ -67,6 +75,8 @@ class CallRedirectionService : CallRedirectionService() {
|
|||
SIGNAL_MIMETYPE -> R.string.destination_signal
|
||||
TELEGRAM_MIMETYPE -> R.string.destination_telegram
|
||||
THREEMA_MIMETYPE -> R.string.destination_threema
|
||||
WHATSAPP_MIMETYPE -> R.string.fallback_destination_whatsapp
|
||||
VIBER_MIMETYPE -> R.string.fallback_destination_viber
|
||||
else -> return
|
||||
})
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ class MainActivity : AppCompatActivity() {
|
|||
binding.apply {
|
||||
redirectionDelay.value = (prefs.redirectionDelay / 1000).toFloat()
|
||||
popupPosition.editText?.setText(prefs.popupPosition.toString())
|
||||
fallback.isChecked = prefs.isFallbackChecked
|
||||
toggle.isChecked = prefs.isServiceEnabled
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +66,9 @@ class MainActivity : AppCompatActivity() {
|
|||
prefs.popupPosition = it?.toString()?.toInt() ?: return@doAfterTextChanged
|
||||
} catch (exc: NumberFormatException) {}
|
||||
}
|
||||
fallback.setOnCheckedChangeListener { _, isChecked ->
|
||||
prefs.isFallbackChecked = isChecked
|
||||
}
|
||||
toggle.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked && !hasPermissions()) {
|
||||
toggle.isChecked = false
|
||||
|
|
|
@ -9,6 +9,10 @@ class Preferences(ctx: Context) {
|
|||
private const val SERVICE_ENABLED = "service_enabled"
|
||||
private const val REDIRECTION_DELAY = "redirection_delay"
|
||||
private const val POPUP_POSITION = "popup_position_y"
|
||||
private const val FALLBACK_CHECKED = "fallback_checked"
|
||||
|
||||
private const val DEFAULT_REDIRECTION_DELAY = 2000L
|
||||
private const val DEFAULT_POPUP_POSITION = 333
|
||||
}
|
||||
|
||||
private val prefs = PreferenceManager.getDefaultSharedPreferences(ctx)
|
||||
|
@ -18,10 +22,14 @@ class Preferences(ctx: Context) {
|
|||
set(value) = prefs.edit { putBoolean(SERVICE_ENABLED, value) }
|
||||
|
||||
var redirectionDelay: Long
|
||||
get() = prefs.getLong(REDIRECTION_DELAY, 2000L)
|
||||
get() = prefs.getLong(REDIRECTION_DELAY, DEFAULT_REDIRECTION_DELAY)
|
||||
set(value) = prefs.edit { putLong(REDIRECTION_DELAY, value) }
|
||||
|
||||
var popupPosition: Int
|
||||
get() = prefs.getInt(POPUP_POSITION, 333)
|
||||
get() = prefs.getInt(POPUP_POSITION, DEFAULT_POPUP_POSITION)
|
||||
set(value) = prefs.edit { putInt(POPUP_POSITION, value) }
|
||||
|
||||
var isFallbackChecked: Boolean
|
||||
get() = prefs.getBoolean(FALLBACK_CHECKED, false)
|
||||
set(value) = prefs.edit { putBoolean(FALLBACK_CHECKED, value) }
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
android:id="@+id/scrollView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:padding="16dp"
|
||||
android:layout_marginVertical="16dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/toggle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
@ -42,6 +43,7 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/description2"
|
||||
android:textSize="12sp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/redirection_delay_description" />
|
||||
|
@ -64,6 +66,33 @@
|
|||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<Space
|
||||
android:layout_marginVertical="8dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/fallback"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layoutDirection="rtl"
|
||||
android:text="@string/fallback"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/fallback_description"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
|
|
@ -8,4 +8,8 @@
|
|||
<string name="destination_threema">Threema</string>
|
||||
<string name="redirection_delay_description">Задержка до того, как звонок будет перенаправлен.</string>
|
||||
<string name="popup_position">Позиция всплывающего окна</string>
|
||||
<string name="fallback">Обратная совместимость</string>
|
||||
<string name="fallback_description">Перенаправлять в WhatsApp/Viber, если другие недоступны.</string>
|
||||
<string name="fallback_destination_whatsapp">WhatsApp</string>
|
||||
<string name="fallback_destination_viber">Viber</string>
|
||||
</resources>
|
|
@ -8,4 +8,8 @@
|
|||
<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>
|
||||
<string name="fallback">Fallback</string>
|
||||
<string name="fallback_description">Redirect to WhatsApp/Viber if no other available.</string>
|
||||
<string name="fallback_destination_whatsapp">WhatsApp</string>
|
||||
<string name="fallback_destination_viber">Viber</string>
|
||||
</resources>
|
1
fastlane/metadata/android/en-US/changelogs/7.txt
Normal file
1
fastlane/metadata/android/en-US/changelogs/7.txt
Normal file
|
@ -0,0 +1 @@
|
|||
fallback mode
|
Binary file not shown.
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 93 KiB |
Loading…
Add table
Add a link
Reference in a new issue