android: restart and shutdown the app with buttons (#2578)
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
5a0c7c34bf
commit
91b77b6d63
@@ -170,6 +170,7 @@ dependencies {
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
|
||||
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
|
||||
implementation "com.jakewharton:process-phoenix:2.1.2"
|
||||
}
|
||||
|
||||
// Don't do anything if no compression is needed
|
||||
|
||||
@@ -10,6 +10,7 @@ import chat.simplex.app.ui.theme.DefaultTheme
|
||||
import chat.simplex.app.views.helpers.*
|
||||
import chat.simplex.app.views.onboarding.OnboardingStage
|
||||
import chat.simplex.app.views.usersettings.NotificationsMode
|
||||
import com.jakewharton.processphoenix.ProcessPhoenix
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import java.io.*
|
||||
@@ -101,6 +102,9 @@ class SimplexApp: Application(), LifecycleEventObserver {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
if (ProcessPhoenix.isPhoenixProcess(this)) {
|
||||
return;
|
||||
}
|
||||
context = this
|
||||
context.getDir("temp", MODE_PRIVATE).deleteRecursively()
|
||||
withBGApi {
|
||||
|
||||
@@ -166,7 +166,6 @@ class SimplexService: Service() {
|
||||
it.setPackage(packageName)
|
||||
};
|
||||
val restartServicePendingIntent: PendingIntent = PendingIntent.getService(this, 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE);
|
||||
applicationContext.getSystemService(Context.ALARM_SERVICE);
|
||||
val alarmService: AlarmManager = applicationContext.getSystemService(Context.ALARM_SERVICE) as AlarmManager;
|
||||
alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 1000, restartServicePendingIntent);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import SectionItemView
|
||||
import SectionItemViewWithIcon
|
||||
import SectionView
|
||||
import TextIconSpaced
|
||||
import android.content.Context
|
||||
import android.content.*
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
@@ -25,16 +25,16 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.*
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.work.WorkManager
|
||||
import chat.simplex.app.*
|
||||
import chat.simplex.app.R
|
||||
import chat.simplex.app.model.*
|
||||
import chat.simplex.app.ui.theme.*
|
||||
import chat.simplex.app.views.database.DatabaseView
|
||||
import chat.simplex.app.views.helpers.*
|
||||
import chat.simplex.app.views.newchat.CreateLinkTab
|
||||
import chat.simplex.app.views.newchat.CreateLinkView
|
||||
import chat.simplex.app.views.onboarding.SimpleXInfo
|
||||
import chat.simplex.app.views.onboarding.WhatsNewView
|
||||
import com.jakewharton.processphoenix.ProcessPhoenix
|
||||
|
||||
@Composable
|
||||
fun SettingsView(chatModel: ChatModel, setPerformLA: (Boolean, FragmentActivity) -> Unit) {
|
||||
@@ -181,7 +181,9 @@ fun SettingsLayout(
|
||||
}
|
||||
SectionDividerSpaced()
|
||||
|
||||
SectionView(stringResource(R.string.settings_section_title_develop)) {
|
||||
SectionView(stringResource(R.string.settings_section_title_app)) {
|
||||
SettingsActionItem(painterResource(R.drawable.ic_restart_alt), stringResource(R.string.settings_restart_app), ::restartApp, extraPadding = true)
|
||||
SettingsActionItem(painterResource(R.drawable.ic_power_settings_new), stringResource(R.string.settings_shutdown), { shutdownAppAlert(::shutdownApp) }, extraPadding = true)
|
||||
SettingsActionItem(painterResource(R.drawable.ic_code), stringResource(R.string.settings_developer_tools), showSettingsModal { DeveloperView(it, showCustomModal, withAuth) }, extraPadding = true)
|
||||
AppVersionItem(showVersion)
|
||||
}
|
||||
@@ -490,6 +492,26 @@ private fun runAuth(title: String, desc: String, context: Context, onFinish: (su
|
||||
)
|
||||
}
|
||||
|
||||
private fun restartApp() {
|
||||
ProcessPhoenix.triggerRebirth(SimplexApp.context)
|
||||
shutdownApp()
|
||||
}
|
||||
|
||||
private fun shutdownApp() {
|
||||
WorkManager.getInstance(SimplexApp.context).cancelAllWork()
|
||||
SimplexService.safeStopService(SimplexApp.context)
|
||||
Runtime.getRuntime().exit(0)
|
||||
}
|
||||
|
||||
private fun shutdownAppAlert(onConfirm: () -> Unit) {
|
||||
AlertManager.shared.showAlertDialog(
|
||||
title = generalGetString(R.string.shutdown_alert_question),
|
||||
text = generalGetString(R.string.shutdown_alert_desc),
|
||||
destructive = true,
|
||||
onConfirm = onConfirm
|
||||
)
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Preview(
|
||||
uiMode = Configuration.UI_MODE_NIGHT_YES,
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<vector android:height="24dp" android:viewportHeight="960"
|
||||
android:viewportWidth="960" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M479.83,521.5q-12.32,0 -20.33,-8.38t-8,-20.63v-344q0,-11.68 8.18,-20.09 8.18,-8.41 20.5,-8.41 12.32,0 20.58,8.41Q509,136.83 509,148.5v344q0,12.25 -8.43,20.63 -8.43,8.38 -20.75,8.38ZM480.07,837.5q-74.07,0 -138.82,-28 -64.75,-28 -112.75,-76t-76,-112.7q-28,-64.7 -28,-138.8 0,-70 27.73,-133.75 27.73,-63.75 77.17,-114.06 9.1,-9.19 22.16,-9.69 13.06,-0.5 21.78,8.32 9.16,9.3 7.41,21.24Q279,266 270.5,274.5 228,316 205,369.36q-23,53.36 -23,112.76 0,124.23 86.94,211.05Q355.88,780 480.12,780t211.06,-86.93Q778,606.13 778,481.9q0,-59.4 -22.39,-112.74Q733.21,315.82 691.5,274q-9,-9 -10.25,-21.25T689,232.5q9.5,-9.5 22.75,-7.75T735,236.19q48,50.31 74.25,113.35t26.25,132.49q0,73.97 -28,138.72 -28,64.75 -76,112.75t-112.68,76q-64.68,28 -138.75,28Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,4 @@
|
||||
<vector android:height="24dp" android:viewportHeight="960"
|
||||
android:viewportWidth="960" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M421,830q-110,-20 -183.25,-107.25T164.5,520.5q0,-71 30.5,-134.25t86,-106.75q7.5,-5.5 18.25,-4.75T317.5,283q9.5,9.5 8.5,22t-13,22q-43.5,35 -67.25,86T222,520.5q0,93.5 58,163T427,772q10.5,2 18,10.5t7.5,19.5q0,13.5 -9.75,21.75T421,830ZM541,830q-12,2 -21.5,-6.25T510,802q0,-10.5 7.25,-19.25T535.5,772q90,-19 147,-88.5t57,-163q0,-108 -75,-183.25T481,262h-21l41,41q8,8 8,20.25T501,343q-9,9 -21.25,9T460,343l-91,-89.5q-5,-4.5 -7,-9.25t-2,-10.75q0,-6 2,-10.75t7,-9.25l91,-91q7.5,-8 19.75,-8t21.25,8q8,9 8,21.25t-8,19.75l-41,41h21q132,0 224,92.5t92,223.5q0,115 -73,202.25T541,830Z"/>
|
||||
</vector>
|
||||
@@ -723,7 +723,6 @@
|
||||
\n3. Spojení je kompromitováno.</string>
|
||||
<string name="settings_section_title_you">VY</string>
|
||||
<string name="settings_section_title_support">PODPOŘIT SIMPLEX CHAT</string>
|
||||
<string name="settings_section_title_develop">VÝVOJ</string>
|
||||
<string name="settings_developer_tools">Nástroje pro vývojáře</string>
|
||||
<string name="settings_section_title_incognito">inkognito mód</string>
|
||||
<string name="your_chat_database">Chat databáze</string>
|
||||
|
||||
@@ -564,7 +564,6 @@
|
||||
<string name="settings_section_title_settings">EINSTELLUNGEN</string>
|
||||
<string name="settings_section_title_help">HILFE</string>
|
||||
<string name="settings_section_title_support">UNTERSTÜTZUNG VON SIMPLEX CHAT</string>
|
||||
<string name="settings_section_title_develop">ENTWICKLUNG</string>
|
||||
<string name="settings_section_title_device">GERÄT</string>
|
||||
<string name="settings_section_title_chats">CHATS</string>
|
||||
<string name="settings_developer_tools">Entwicklertools</string>
|
||||
|
||||
@@ -114,7 +114,6 @@
|
||||
<string name="encrypted_audio_call">Llamada con cifrado de extremo a extremo</string>
|
||||
<string name="status_e2e_encrypted">cifrado de extremo a extremo</string>
|
||||
<string name="integrity_msg_duplicate">mensaje duplicado</string>
|
||||
<string name="settings_section_title_develop">DESARROLLO</string>
|
||||
<string name="settings_developer_tools">Herramientas desarrollo</string>
|
||||
<string name="delete_files_and_media_for_all_users">Eliminar los archivos de todos los perfiles</string>
|
||||
<string name="delete_messages">Eliminar mensaje</string>
|
||||
|
||||
@@ -535,7 +535,6 @@
|
||||
<string name="call_already_ended">Appel déjà terminé !</string>
|
||||
<string name="settings_audio_video_calls">Appels audio et vidéo</string>
|
||||
<string name="status_e2e_encrypted">chiffré de bout en bout</string>
|
||||
<string name="settings_section_title_develop">DEVELOPPER</string>
|
||||
<string name="settings_experimental_features">Fonctionnalités expérimentales</string>
|
||||
<string name="settings_section_title_socks">SOCKS PROXY</string>
|
||||
<string name="settings_section_title_themes">THEMES</string>
|
||||
|
||||
@@ -271,7 +271,6 @@
|
||||
<string name="snd_conn_event_switch_queue_phase_changing_for_member">%s के लिए पता बदल रहा है…</string>
|
||||
<string name="dont_show_again">दोबारा मत दिखाओ</string>
|
||||
<string name="both_you_and_your_contact_can_send_voice">आप और आपका संपर्क दोनों ध्वनि संदेश भेज सकते हैं।</string>
|
||||
<string name="settings_section_title_develop">विकास करना</string>
|
||||
<string name="user_mute">आवाज़ बंद करना</string>
|
||||
<string name="allow_your_contacts_to_send_disappearing_messages">अपने संपर्कों को गायब होने वाले संदेश भेजने की अनुमति दें।</string>
|
||||
<string name="v4_6_audio_video_calls">ऑडियो और वीडियो कॉल</string>
|
||||
|
||||
@@ -395,7 +395,6 @@
|
||||
<string name="database_passphrase">Password del database</string>
|
||||
<string name="delete_chat_profile_question">Eliminare il profilo di chat\?</string>
|
||||
<string name="delete_database">Elimina database</string>
|
||||
<string name="settings_section_title_develop">SVILUPPA</string>
|
||||
<string name="settings_developer_tools">Strumenti di sviluppo</string>
|
||||
<string name="settings_section_title_device">DISPOSITIVO</string>
|
||||
<string name="error_deleting_database">Errore nell\'eliminazione del database della chat</string>
|
||||
|
||||
@@ -328,7 +328,6 @@
|
||||
<string name="button_delete_group">מחק קבוצה</string>
|
||||
<string name="delete_group_question">למחוק קבוצה\?</string>
|
||||
<string name="desktop_scan_QR_code_from_app_via_scan_QR_code">💻 שולחן עבודה: סירקו את קוד ה־QR המוצג באפליקציה, באמצעות <b>סריקת קוד QR</b>.</string>
|
||||
<string name="settings_section_title_develop">פיתוח</string>
|
||||
<string name="settings_section_title_device">מכשיר</string>
|
||||
<string name="auth_device_authentication_is_disabled_turning_off">נעילת המכשיר מושבתת. מכבה נעילת SimpleX.</string>
|
||||
<string name="auth_device_authentication_is_not_enabled_you_can_turn_on_in_settings_once_enabled">נעילת המכשיר אינה מופעלת. ניתן להפעיל את נעילת SimpleX, לאחר שתפעילו את נעילת המכשיר.</string>
|
||||
|
||||
@@ -349,7 +349,6 @@
|
||||
<string name="icon_descr_flip_camera">カメラ切り替え</string>
|
||||
<string name="icon_descr_call_missed">不在着信</string>
|
||||
<string name="icon_descr_call_rejected">拒否した通話</string>
|
||||
<string name="settings_section_title_develop">開発</string>
|
||||
<string name="integrity_msg_duplicate">重複メッセージ</string>
|
||||
<string name="settings_section_title_help">ヘルプ</string>
|
||||
<string name="protect_app_screen">アプリ画面を守る</string>
|
||||
|
||||
@@ -232,7 +232,6 @@
|
||||
<string name="delete_address__question">주소를 삭제할까요\?</string>
|
||||
<string name="delete_image">이미지 삭제</string>
|
||||
<string name="decentralized">탈중앙화</string>
|
||||
<string name="settings_section_title_develop">개발</string>
|
||||
<string name="settings_developer_tools">개발자 도구</string>
|
||||
<string name="settings_section_title_device">기기</string>
|
||||
<string name="database_passphrase">데이터베이스 비밀번호</string>
|
||||
|
||||
@@ -242,7 +242,6 @@
|
||||
<string name="full_deletion">Verwijderen voor iedereen</string>
|
||||
<string name="delete_link">Link verwijderen</string>
|
||||
<string name="conn_level_desc_direct">direct</string>
|
||||
<string name="settings_section_title_develop">ONTWIKKELEN</string>
|
||||
<string name="settings_section_title_device">APPARAAT</string>
|
||||
<string name="delete_files_and_media_all">Verwijder alle bestanden</string>
|
||||
<string name="delete_messages_after">Berichten verwijderen na</string>
|
||||
|
||||
@@ -515,7 +515,6 @@
|
||||
<string name="settings_section_title_chats">CZATY</string>
|
||||
<string name="database_passphrase">Hasło do bazy danych</string>
|
||||
<string name="delete_database">Usuń bazę danych</string>
|
||||
<string name="settings_section_title_develop">DEWELOPERSKIE</string>
|
||||
<string name="settings_developer_tools">Narzędzia deweloperskie</string>
|
||||
<string name="settings_section_title_device">URZĄDZENIE</string>
|
||||
<string name="error_starting_chat">Błąd uruchamiania czatu</string>
|
||||
|
||||
@@ -745,7 +745,6 @@
|
||||
<string name="callstatus_missed">chamada perdida</string>
|
||||
<string name="you_can_use_markdown_to_format_messages__prompt">Você pode usar markdown para formatar mensagens:</string>
|
||||
<string name="callstatus_rejected">chamada rejeitada</string>
|
||||
<string name="settings_section_title_develop">DESENVOLVER</string>
|
||||
<string name="rcv_group_event_member_left">saiu</string>
|
||||
<string name="incompatible_database_version">Versão do banco de dados incompatível</string>
|
||||
<string name="button_remove_member">Remover membro</string>
|
||||
|
||||
@@ -568,7 +568,6 @@
|
||||
<string name="settings_section_title_settings">НАСТРОЙКИ</string>
|
||||
<string name="settings_section_title_help">ПОМОЩЬ</string>
|
||||
<string name="settings_section_title_support">ПОДДЕРЖАТЬ SIMPLEX CHAT</string>
|
||||
<string name="settings_section_title_develop">ДЛЯ РАЗРАБОТЧИКОВ</string>
|
||||
<string name="settings_section_title_device">УСТРОЙСТВО</string>
|
||||
<string name="settings_section_title_chats">ЧАТЫ</string>
|
||||
<string name="settings_developer_tools">Инструменты разработчика</string>
|
||||
|
||||
@@ -378,7 +378,6 @@
|
||||
<string name="encrypt_database_question">加密数据库?</string>
|
||||
<string name="encrypted_with_random_passphrase">数据库使用随机密码进行加密,您可以更改它。</string>
|
||||
<string name="database_passphrase_is_required">打开聊天需要数据库密码。</string>
|
||||
<string name="settings_section_title_develop">开发</string>
|
||||
<string name="error_stopping_chat">停止聊天错误</string>
|
||||
<string name="import_database_question">导入聊天数据库?</string>
|
||||
<string name="error_deleting_database">删除聊天数据库错误</string>
|
||||
|
||||
@@ -681,7 +681,6 @@
|
||||
<string name="integrity_msg_duplicate">重覆的訊息</string>
|
||||
<string name="protect_app_screen">保護應用程式螢幕</string>
|
||||
<string name="send_link_previews">傳送可以預覽的連結</string>
|
||||
<string name="settings_section_title_develop">開發</string>
|
||||
<string name="settings_section_title_device">裝置</string>
|
||||
<string name="settings_section_title_help">幫助</string>
|
||||
<string name="settings_section_title_settings">設定</string>
|
||||
|
||||
@@ -602,6 +602,8 @@
|
||||
<string name="hide_dev_options">Hide:</string>
|
||||
<string name="show_developer_options">Show developer options</string>
|
||||
<string name="developer_options">Database IDs and Transport isolation option.</string>
|
||||
<string name="shutdown_alert_question">Shutdown?</string>
|
||||
<string name="shutdown_alert_desc">Notifications will stop working until you re-launch the app</string>
|
||||
|
||||
<!-- Address Items - UserAddressView.kt -->
|
||||
<string name="create_address">Create address</string>
|
||||
@@ -851,9 +853,11 @@
|
||||
<string name="settings_section_title_settings">SETTINGS</string>
|
||||
<string name="settings_section_title_help">HELP</string>
|
||||
<string name="settings_section_title_support">SUPPORT SIMPLEX CHAT</string>
|
||||
<string name="settings_section_title_develop">DEVELOP</string>
|
||||
<string name="settings_section_title_app">APP</string>
|
||||
<string name="settings_section_title_device">DEVICE</string>
|
||||
<string name="settings_section_title_chats">CHATS</string>
|
||||
<string name="settings_restart_app">Restart</string>
|
||||
<string name="settings_shutdown">Shutdown</string>
|
||||
<string name="settings_developer_tools">Developer tools</string>
|
||||
<string name="settings_experimental_features">Experimental features</string>
|
||||
<string name="settings_section_title_socks">SOCKS PROXY</string>
|
||||
|
||||
Reference in New Issue
Block a user