Skip to content

Commit fbfd496

Browse files
committed
UI: Add community links and update confirmations
1 parent a7103d5 commit fbfd496

9 files changed

Lines changed: 141 additions & 2 deletions

File tree

app/src/main/java/top/uwu/mikubox/ui/AboutActivity.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package top.uwu.mikubox.ui
22

3+
import android.content.Intent
4+
import android.net.Uri
35
import android.os.Bundle
46
import android.widget.ImageView
57
import android.widget.TextView
@@ -44,5 +46,19 @@ class AboutActivity : EdgeToEdgeActivity() {
4446
view.findViewById<TextView>(R.id.fact_summary).setText(fact.summary)
4547
binding.mikuFacts.addView(view)
4648
}
49+
50+
binding.linkGithub.setOnClickListener {
51+
openLink("https://github.com/HatsuneMikuUwU/MikuBoxForAndroid")
52+
}
53+
binding.linkTelegram.setOnClickListener {
54+
openLink("https://t.me/uwuowoumuchannel")
55+
}
56+
binding.linkTelegramChinese.setOnClickListener {
57+
openLink("https://t.me/np_nbcn")
58+
}
59+
}
60+
61+
private fun openLink(url: String) {
62+
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
4763
}
4864
}

app/src/main/java/top/uwu/mikubox/ui/MainActivity.kt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import androidx.core.view.WindowInsetsCompat
2020
import androidx.core.view.updatePadding
2121
import androidx.lifecycle.lifecycleScope
2222
import androidx.recyclerview.widget.LinearLayoutManager
23+
import com.google.android.material.dialog.MaterialAlertDialogBuilder
2324
import kotlinx.coroutines.Dispatchers
2425
import kotlinx.coroutines.launch
2526
import kotlinx.coroutines.withContext
@@ -67,7 +68,7 @@ class MainActivity : EdgeToEdgeActivity(), AddProfileBottomSheet.Listener {
6768
MihomoProfileStore.select(this, profile.id)
6869
refresh()
6970
},
70-
onUpdate = { profile -> pull(profile) },
71+
onUpdate = { profile -> confirmUpdate(profile) },
7172
onDelete = { profile ->
7273
MihomoProfileStore.remove(this, profile.id)
7374
refresh()
@@ -83,7 +84,7 @@ class MainActivity : EdgeToEdgeActivity(), AddProfileBottomSheet.Listener {
8384
AddProfileBottomSheet().show(supportFragmentManager, AddProfileBottomSheet.TAG)
8485
}
8586
binding.btnHome.setOnClickListener { openDrawer() }
86-
binding.btnMoreMenu.setOnClickListener { refreshAllSubscriptions() }
87+
binding.btnMoreMenu.setOnClickListener { confirmRefreshAllSubscriptions() }
8788
binding.etSearch.doAfterTextChanged {
8889
query = it?.toString().orEmpty()
8990
refresh()
@@ -158,6 +159,20 @@ class MainActivity : EdgeToEdgeActivity(), AddProfileBottomSheet.Listener {
158159
}
159160
}
160161

162+
private fun confirmRefreshAllSubscriptions() {
163+
val count = MihomoProfileStore.profiles(this).count { it.isSubscription }
164+
if (count == 0) {
165+
toast(getString(R.string.toast_no_subscriptions))
166+
return
167+
}
168+
MaterialAlertDialogBuilder(this)
169+
.setTitle(R.string.dialog_refresh_subscriptions_title)
170+
.setMessage(getString(R.string.dialog_refresh_subscriptions_message, count))
171+
.setNegativeButton(android.R.string.cancel, null)
172+
.setPositiveButton(R.string.action_update) { _, _ -> refreshAllSubscriptions() }
173+
.show()
174+
}
175+
161176
private fun showSortMenu(anchor: View) {
162177
PopupMenu(this, anchor).apply {
163178
menu.add(0, 0, 0, R.string.sort_by_name)
@@ -233,6 +248,15 @@ class MainActivity : EdgeToEdgeActivity(), AddProfileBottomSheet.Listener {
233248
pull(profile)
234249
}
235250

251+
private fun confirmUpdate(profile: MihomoProfileStore.Profile) {
252+
MaterialAlertDialogBuilder(this)
253+
.setTitle(R.string.dialog_update_subscription_title)
254+
.setMessage(getString(R.string.dialog_update_subscription_message, profile.name))
255+
.setNegativeButton(android.R.string.cancel, null)
256+
.setPositiveButton(R.string.action_update) { _, _ -> pull(profile) }
257+
.show()
258+
}
259+
236260
override fun onImportClipboard(name: String) {
237261
val clip = (getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager)
238262
.primaryClip?.getItemAt(0)?.coerceToText(this)?.toString()?.trim().orEmpty()

app/src/main/res/layout/activity_about.xml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,57 @@
207207
android:orientation="horizontal" />
208208
</HorizontalScrollView>
209209

210+
<com.google.android.material.card.MaterialCardView
211+
android:layout_width="match_parent"
212+
android:layout_height="wrap_content"
213+
android:layout_marginHorizontal="16dp"
214+
android:layout_marginBottom="12dp"
215+
app:cardBackgroundColor="?attr/colorCard"
216+
app:cardCornerRadius="28dp"
217+
app:cardElevation="0dp"
218+
app:strokeWidth="0dp">
219+
220+
<LinearLayout
221+
android:layout_width="match_parent"
222+
android:layout_height="wrap_content"
223+
android:orientation="vertical"
224+
android:padding="20dp">
225+
226+
<TextView
227+
android:layout_width="wrap_content"
228+
android:layout_height="wrap_content"
229+
android:text="@string/about_links_title"
230+
android:textColor="?attr/colorOnSurface"
231+
android:textSize="15sp"
232+
android:textStyle="bold" />
233+
234+
<com.google.android.material.button.MaterialButton
235+
android:id="@+id/link_github"
236+
style="@style/Widget.Material3.Button.TextButton"
237+
android:layout_width="match_parent"
238+
android:layout_height="wrap_content"
239+
android:layout_marginTop="8dp"
240+
android:gravity="start|center_vertical"
241+
android:text="@string/about_link_github" />
242+
243+
<com.google.android.material.button.MaterialButton
244+
android:id="@+id/link_telegram"
245+
style="@style/Widget.Material3.Button.TextButton"
246+
android:layout_width="match_parent"
247+
android:layout_height="wrap_content"
248+
android:gravity="start|center_vertical"
249+
android:text="@string/about_link_telegram" />
250+
251+
<com.google.android.material.button.MaterialButton
252+
android:id="@+id/link_telegram_chinese"
253+
style="@style/Widget.Material3.Button.TextButton"
254+
android:layout_width="match_parent"
255+
android:layout_height="wrap_content"
256+
android:gravity="start|center_vertical"
257+
android:text="@string/about_link_telegram_chinese" />
258+
</LinearLayout>
259+
</com.google.android.material.card.MaterialCardView>
260+
210261
<com.google.android.material.card.MaterialCardView
211262
android:layout_width="match_parent"
212263
android:layout_height="wrap_content"

app/src/main/res/values-fr/strings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
<string name="action_refresh">Actualiser les abonnements</string>
6565
<string name="toast_no_subscriptions">Aucun abonnement à actualiser</string>
6666
<string name="toast_subscriptions_updated">%1$d/%2$d abonnements mis à jour</string>
67+
<string name="dialog_refresh_subscriptions_title">Actualiser les abonnements ?</string>
68+
<string name="dialog_refresh_subscriptions_message">Actualiser %1$d abonnements maintenant ?</string>
69+
<string name="dialog_update_subscription_title">Mettre à jour l’abonnement ?</string>
70+
<string name="dialog_update_subscription_message">Mettre à jour %1$s depuis son URL d’abonnement ?</string>
6771

6872
<!-- Core / connection settings -->
6973
<string name="settings_section_core">Cœur</string>
@@ -83,4 +87,8 @@
8387
<string name="greeting_afternoon">Bon après-midi…</string>
8488
<string name="greeting_evening">Bonsoir…</string>
8589
<string name="greeting_night">Bonne nuit…</string>
90+
<string name="about_links_title">Liens</string>
91+
<string name="about_link_github">Dépôt GitHub</string>
92+
<string name="about_link_telegram">Canal Telegram</string>
93+
<string name="about_link_telegram_chinese">Canal Telegram chinois</string>
8694
</resources>

app/src/main/res/values-in/strings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@
166166
<string name="action_refresh">Segarkan langganan</string>
167167
<string name="toast_no_subscriptions">Tidak ada langganan untuk disegarkan</string>
168168
<string name="toast_subscriptions_updated">%1$d/%2$d langganan diperbarui</string>
169+
<string name="dialog_refresh_subscriptions_title">Segarkan langganan?</string>
170+
<string name="dialog_refresh_subscriptions_message">Segarkan %1$d langganan sekarang?</string>
171+
<string name="dialog_update_subscription_title">Perbarui langganan?</string>
172+
<string name="dialog_update_subscription_message">Perbarui %1$s dari URL langganannya?</string>
169173

170174
<!-- Core / connection settings -->
171175
<string name="settings_section_core">Inti</string>
@@ -185,4 +189,8 @@
185189
<string name="greeting_afternoon">Selamat siang…</string>
186190
<string name="greeting_evening">Selamat sore…</string>
187191
<string name="greeting_night">Selamat malam…</string>
192+
<string name="about_links_title">Tautan</string>
193+
<string name="about_link_github">Repositori GitHub</string>
194+
<string name="about_link_telegram">Kanal Telegram</string>
195+
<string name="about_link_telegram_chinese">Kanal Telegram Tionghoa</string>
188196
</resources>

app/src/main/res/values-ru/strings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@
168168
<string name="action_refresh">Обновить подписки</string>
169169
<string name="toast_no_subscriptions">Нет подписок для обновления</string>
170170
<string name="toast_subscriptions_updated">Обновлено %1$d/%2$d подписок</string>
171+
<string name="dialog_refresh_subscriptions_title">Обновить подписки?</string>
172+
<string name="dialog_refresh_subscriptions_message">Обновить %1$d подписок сейчас?</string>
173+
<string name="dialog_update_subscription_title">Обновить подписку?</string>
174+
<string name="dialog_update_subscription_message">Обновить «%1$s» по URL подписки?</string>
171175

172176
<!-- Core / connection settings -->
173177
<string name="settings_section_core">Ядро</string>
@@ -187,4 +191,8 @@
187191
<string name="greeting_afternoon">Добрый день…</string>
188192
<string name="greeting_evening">Добрый вечер…</string>
189193
<string name="greeting_night">Спокойной ночи…</string>
194+
<string name="about_links_title">Ссылки</string>
195+
<string name="about_link_github">Репозиторий GitHub</string>
196+
<string name="about_link_telegram">Канал Telegram</string>
197+
<string name="about_link_telegram_chinese">Китайский канал Telegram</string>
190198
</resources>

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
<string name="action_refresh">刷新订阅</string>
161161
<string name="toast_no_subscriptions">没有可刷新的订阅</string>
162162
<string name="toast_subscriptions_updated">已更新 %1$d/%2$d 个订阅</string>
163+
<string name="dialog_refresh_subscriptions_title">要刷新订阅吗?</string>
164+
<string name="dialog_refresh_subscriptions_message">要立即刷新 %1$d 个订阅吗?</string>
165+
<string name="dialog_update_subscription_title">要更新订阅吗?</string>
166+
<string name="dialog_update_subscription_message">要从订阅网址更新“%1$s”吗?</string>
163167

164168
<!-- Core / connection settings -->
165169
<string name="settings_section_core">核心</string>
@@ -185,4 +189,8 @@
185189
<string name="drawer_subtitle">一起加油吧!</string>
186190
<string name="drawer_section_manage">管理</string>
187191
<string name="drawer_section_tools">工具与信息</string>
192+
<string name="about_links_title">相关链接</string>
193+
<string name="about_link_github">GitHub 源代码</string>
194+
<string name="about_link_telegram">Telegram 频道</string>
195+
<string name="about_link_telegram_chinese">Telegram 中文频道</string>
188196
</resources>

app/src/main/res/values-zh-rTW/strings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
<string name="action_refresh">刷新訂閱</string>
161161
<string name="toast_no_subscriptions">沒有可刷新的訂閱</string>
162162
<string name="toast_subscriptions_updated">已更新 %1$d/%2$d 個訂閱</string>
163+
<string name="dialog_refresh_subscriptions_title">要刷新訂閱嗎?</string>
164+
<string name="dialog_refresh_subscriptions_message">要立即刷新 %1$d 個訂閱嗎?</string>
165+
<string name="dialog_update_subscription_title">要更新訂閱嗎?</string>
166+
<string name="dialog_update_subscription_message">要從訂閱網址更新「%1$s」嗎?</string>
163167

164168
<!-- Core / connection settings -->
165169
<string name="settings_section_core">核心</string>
@@ -185,4 +189,8 @@
185189
<string name="drawer_subtitle">一起加油吧!</string>
186190
<string name="drawer_section_manage">管理</string>
187191
<string name="drawer_section_tools">工具與資訊</string>
192+
<string name="about_links_title">相關連結</string>
193+
<string name="about_link_github">GitHub 原始碼</string>
194+
<string name="about_link_telegram">Telegram 頻道</string>
195+
<string name="about_link_telegram_chinese">Telegram 中文頻道</string>
188196
</resources>

app/src/main/res/values/strings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@
170170
<string name="action_refresh">Refresh subscriptions</string>
171171
<string name="toast_no_subscriptions">No subscriptions to refresh</string>
172172
<string name="toast_subscriptions_updated">Updated %1$d/%2$d subscriptions</string>
173+
<string name="dialog_refresh_subscriptions_title">Refresh subscriptions?</string>
174+
<string name="dialog_refresh_subscriptions_message">Refresh %1$d subscriptions now?</string>
175+
<string name="dialog_update_subscription_title">Update subscription?</string>
176+
<string name="dialog_update_subscription_message">Update %1$s from its subscription URL?</string>
173177

174178
<!-- Core / connection settings -->
175179
<string name="settings_section_core">Core</string>
@@ -206,4 +210,8 @@
206210
<string name="drawer_subtitle">Let\'s do our best!</string>
207211
<string name="drawer_section_manage">Manage</string>
208212
<string name="drawer_section_tools">Tools &amp; info</string>
213+
<string name="about_links_title">Links</string>
214+
<string name="about_link_github">GitHub repository</string>
215+
<string name="about_link_telegram">Telegram channel</string>
216+
<string name="about_link_telegram_chinese">Telegram Chinese channel</string>
209217
</resources>

0 commit comments

Comments
 (0)