From 6261b704f65758f27e1b9e7a6bf42e14e5da43f2 Mon Sep 17 00:00:00 2001 From: Levin Li Date: Thu, 11 Jul 2024 22:47:05 -0700 Subject: [PATCH] Huawei AppGallery tweaks --- .../celestia/mobilecelestia/MainActivity.kt | 12 ++++++- huawei.patch | 32 +++++++++++++++++++ jobs/build.yml | 5 +++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 huawei.patch diff --git a/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt b/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt index 61409045..a507ae83 100644 --- a/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt +++ b/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt @@ -190,6 +190,7 @@ class MainActivity : AppCompatActivity(R.layout.activity_main), private var bottomSheetCommitIds = arrayListOf() private var initialURLCheckPerformed = false + private var isAskingForExit = false override fun onCreate(savedInstanceState: Bundle?) { val factory = EntryPointAccessors.fromApplication(this, AppStatusInterface::class.java) @@ -480,10 +481,19 @@ class MainActivity : AppCompatActivity(R.layout.activity_main), frag.popLast() } else if (self.canPopBottomSheetFragment()) { self.popBottomSheetFragment() - } else { + } else if (frag != null || drawerLayout.isDrawerOpen(GravityCompat.END)) { self.lifecycleScope.launch { self.hideOverlay(true) } + } else if (!self.isAskingForExit) { + self.isAskingForExit = true + self.showAlert(self.getString(R.string.exit_celestia_alert_title), self.getString(R.string.exit_celestia_alert_message), handler = { + self.isAskingForExit = false + self.finishAndRemoveTask() + exitProcess(0) + }, cancelHandler = { + self.isAskingForExit = false + }) } } }) diff --git a/huawei.patch b/huawei.patch new file mode 100644 index 00000000..a72ba153 --- /dev/null +++ b/huawei.patch @@ -0,0 +1,32 @@ +diff --git a/android/values-zh-rCN/strings.xml b/android/values-zh-rCN/strings.xml +index 6c03140..8c1269f 100644 +--- a/android/values-zh-rCN/strings.xml ++++ b/android/values-zh-rCN/strings.xml +@@ -10,11 +10,13 @@ + --> + + +- Celestia ++ 天际遨游 + zh_CN + 暂不同意 + 查看协议 + 隐私政策与服务协议 + 请您务必仔细阅读,充分理解服务协议和隐私政策各条款。如果您同意,请点击下方的\"同意\"按钮。 + 同意 +- +\ No newline at end of file ++ 退出天际遨游 ++ 确认需要退出? ++ +diff --git a/android/values/strings.xml b/android/values/strings.xml +index eb222a9..742e351 100644 +--- a/android/values/strings.xml ++++ b/android/values/strings.xml +@@ -17,4 +17,6 @@ + View Policy + Agree + Not Now ++ Exit Celestia ++ Are you sure you want to exit? + diff --git a/jobs/build.yml b/jobs/build.yml index 48323796..564c3728 100644 --- a/jobs/build.yml +++ b/jobs/build.yml @@ -51,6 +51,11 @@ jobs: git checkout $(contentCommitHash) displayName: 'Checkout Content' + - script: | + cd CelestiaLocalization + git apply ../AndroidCelestia/huawei.patch --ignore-whitespace --whitespace=nowarn + displayName: 'Apply Localization Patch' + - script: | sh $(System.DefaultWorkingDirectory)/AndroidCelestia/app/run_gperf.sh $(System.DefaultWorkingDirectory)/Celestia displayName: 'Running gperf'