diff --git a/PRIVACY.md b/PRIVACY.md
index 6ed3eae..9071878 100644
--- a/PRIVACY.md
+++ b/PRIVACY.md
@@ -9,4 +9,9 @@ please read them at:
Signal: https://signal.org/legal/#privacy-policy
Telegram: https://telegram.org/privacy
-Threema: https://threema.ch/privacy_policy/
+Threema: https://threema.ch/privacy_policy/
+
+Fallback services:
+
+WhatsApp: https://www.whatsapp.com/privacy
+Viber: https://www.viber.com/en/terms/viber-privacy-policy/
diff --git a/app/build.gradle b/app/build.gradle
index 3643d4d..6991672 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -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"
}
diff --git a/app/src/main/java/me/lucky/red/CallRedirectionService.kt b/app/src/main/java/me/lucky/red/CallRedirectionService.kt
index 37a0448..8584237 100644
--- a/app/src/main/java/me/lucky/red/CallRedirectionService.kt
+++ b/app/src/main/java/me/lucky/red/CallRedirectionService.kt
@@ -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
})
}
diff --git a/app/src/main/java/me/lucky/red/MainActivity.kt b/app/src/main/java/me/lucky/red/MainActivity.kt
index 14f1564..c9e3fd3 100644
--- a/app/src/main/java/me/lucky/red/MainActivity.kt
+++ b/app/src/main/java/me/lucky/red/MainActivity.kt
@@ -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
diff --git a/app/src/main/java/me/lucky/red/Preferences.kt b/app/src/main/java/me/lucky/red/Preferences.kt
index e75288e..33b11b1 100644
--- a/app/src/main/java/me/lucky/red/Preferences.kt
+++ b/app/src/main/java/me/lucky/red/Preferences.kt
@@ -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) }
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index b24c9e1..3753d2f 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -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 @@
@@ -64,6 +66,33 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 1008539..d130df9 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -8,4 +8,8 @@
Threema
Задержка до того, как звонок будет перенаправлен.
Позиция всплывающего окна
+ Обратная совместимость
+ Перенаправлять в WhatsApp/Viber, если другие недоступны.
+ WhatsApp
+ Viber
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bb96707..ed314bc 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -8,4 +8,8 @@
Threema
Delay before a call will be redirected.
Popup position
+ Fallback
+ Redirect to WhatsApp/Viber if no other available.
+ WhatsApp
+ Viber
\ No newline at end of file
diff --git a/fastlane/metadata/android/en-US/changelogs/7.txt b/fastlane/metadata/android/en-US/changelogs/7.txt
new file mode 100644
index 0000000..ef26257
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/7.txt
@@ -0,0 +1 @@
+fallback mode
diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png
index fba57b5..a4f81f7 100644
Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png differ