Skip to content

Commit a362e57

Browse files
committed
feat(ui): MikuRay card drawer, title font, circular back, zh strings
- Replace the popup menu with a MikuRay-style card navigation drawer (banner + Manage/Tools sections) wrapping the home screen in a DrawerLayout; drawer entries reuse item_drawer_entry. - Apply the uwu_font_title display font to all large collapsing page titles via a single collapsingToolbarLayoutLargeStyle theme override. - Give secondary screens a circular back button (uwu_circle_back). - Fill in zh-rCN / zh-rTW translations for the new proxies and drawer strings (terminology aligned with the UwU branch).
1 parent f654e61 commit a362e57

14 files changed

Lines changed: 296 additions & 37 deletions

File tree

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

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import android.os.Handler
1111
import android.os.Looper
1212
import android.view.View
1313
import android.widget.Toast
14-
import androidx.appcompat.widget.PopupMenu
1514
import androidx.core.content.ContextCompat
15+
import androidx.core.view.GravityCompat
1616
import androidx.core.view.ViewCompat
1717
import androidx.core.view.WindowInsetsCompat
1818
import androidx.core.view.updatePadding
@@ -24,6 +24,7 @@ import kotlinx.coroutines.withContext
2424
import top.uwu.mikubox.R
2525
import top.uwu.mikubox.core.MihomoCore
2626
import top.uwu.mikubox.databinding.ActivityMainBinding
27+
import top.uwu.mikubox.databinding.ItemDrawerEntryBinding
2728
import top.uwu.mikubox.profile.MihomoProfileImporter
2829
import top.uwu.mikubox.profile.MihomoProfileStore
2930
import top.uwu.mikubox.profile.MihomoSubscriptionUpdater
@@ -75,8 +76,9 @@ class MainActivity : EdgeToEdgeActivity(), AddProfileBottomSheet.Listener {
7576
binding.btnAddProfile.setOnClickListener {
7677
AddProfileBottomSheet().show(supportFragmentManager, AddProfileBottomSheet.TAG)
7778
}
78-
binding.btnHome.setOnClickListener(::showNavigationMenu)
79-
binding.btnMoreMenu.setOnClickListener(::showNavigationMenu)
79+
binding.btnHome.setOnClickListener { openDrawer() }
80+
binding.btnMoreMenu.setOnClickListener { openDrawer() }
81+
setupDrawer()
8082
binding.fab.setOnClickListener { toggleConnection() }
8183
binding.cardBottomStatus.setOnClickListener { toggleConnection() }
8284

@@ -207,23 +209,33 @@ class MainActivity : EdgeToEdgeActivity(), AddProfileBottomSheet.Listener {
207209
binding.fab.postDelayed({ refresh() }, 600)
208210
}
209211

210-
private fun showNavigationMenu(anchor: View) {
211-
PopupMenu(this, anchor).apply {
212-
menuInflater.inflate(R.menu.main_drawer_menu, menu)
213-
setOnMenuItemClickListener { item ->
214-
val target = when (item.itemId) {
215-
R.id.nav_settings -> SettingsActivity::class.java
216-
R.id.nav_proxies -> ProxiesActivity::class.java
217-
R.id.nav_apps -> AppListActivity::class.java
218-
R.id.nav_logcat -> LogcatActivity::class.java
219-
R.id.nav_tools -> ToolsActivity::class.java
220-
R.id.nav_about -> AboutActivity::class.java
221-
else -> null
222-
}
223-
target?.let { startActivity(Intent(this@MainActivity, it)) }
224-
true
225-
}
226-
show()
212+
private fun setupDrawer() {
213+
bindEntry(binding.drawerProxies, R.drawable.ic_lan, R.string.menu_proxies, ProxiesActivity::class.java)
214+
bindEntry(binding.drawerSettings, R.drawable.ic_settings_24dp, R.string.settings, SettingsActivity::class.java)
215+
bindEntry(binding.drawerApps, R.drawable.ic_subscriptions_24dp, R.string.settings_per_app, AppListActivity::class.java)
216+
bindEntry(binding.drawerLogcat, R.drawable.ic_logcat_24dp, R.string.menu_log, LogcatActivity::class.java)
217+
bindEntry(binding.drawerTools, R.drawable.baseline_construction_24, R.string.menu_tools, ToolsActivity::class.java)
218+
bindEntry(binding.drawerAbout, R.drawable.ic_about_24dp, R.string.menu_about, AboutActivity::class.java)
219+
}
220+
221+
private fun bindEntry(entry: ItemDrawerEntryBinding, iconRes: Int, labelRes: Int, target: Class<*>) {
222+
entry.icon.setImageResource(iconRes)
223+
entry.label.setText(labelRes)
224+
entry.root.setOnClickListener {
225+
binding.drawerLayout.closeDrawer(GravityCompat.START)
226+
startActivity(Intent(this, target))
227+
}
228+
}
229+
230+
private fun openDrawer() = binding.drawerLayout.openDrawer(GravityCompat.START)
231+
232+
@Deprecated("Handles drawer close before default back navigation")
233+
override fun onBackPressed() {
234+
if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
235+
binding.drawerLayout.closeDrawer(GravityCompat.START)
236+
} else {
237+
@Suppress("DEPRECATION")
238+
super.onBackPressed()
227239
}
228240
}
229241

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:width="40dp" android:height="40dp" android:gravity="center">
4+
<shape android:shape="oval">
5+
<solid android:color="?attr/colorPrimary" />
6+
</shape>
7+
</item>
8+
<item
9+
android:width="22dp"
10+
android:height="22dp"
11+
android:drawable="@drawable/ic_arrow_back"
12+
android:gravity="center" />
13+
</layer-list>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@
6363
android:layout_width="match_parent"
6464
android:layout_height="?attr/actionBarSize"
6565
app:layout_collapseMode="pin"
66-
app:navigationIcon="@drawable/ic_arrow_back"
67-
app:navigationIconTint="?attr/colorOnSurfaceVariant"
66+
app:navigationIcon="@drawable/uwu_circle_back"
6867
app:titleTextColor="?attr/colorOnSurfaceVariant" />
6968
</com.google.android.material.appbar.CollapsingToolbarLayout>
7069
</com.google.android.material.appbar.AppBarLayout>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
android:layout_width="match_parent"
4444
android:layout_height="?attr/actionBarSize"
4545
app:layout_collapseMode="pin"
46-
app:navigationIcon="@drawable/ic_arrow_back"
47-
app:navigationIconTint="?attr/colorOnSurfaceVariant"
46+
app:navigationIcon="@drawable/uwu_circle_back"
4847
app:titleTextColor="?attr/colorOnSurfaceVariant" />
4948
</com.google.android.material.appbar.CollapsingToolbarLayout>
5049
</com.google.android.material.appbar.AppBarLayout>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
android:layout_width="match_parent"
4444
android:layout_height="?attr/actionBarSize"
4545
app:layout_collapseMode="pin"
46-
app:navigationIcon="@drawable/ic_arrow_back"
47-
app:navigationIconTint="?attr/colorOnSurfaceVariant"
46+
app:navigationIcon="@drawable/uwu_circle_back"
4847
app:titleTextColor="?attr/colorOnSurfaceVariant" />
4948
</com.google.android.material.appbar.CollapsingToolbarLayout>
5049
</com.google.android.material.appbar.AppBarLayout>

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

Lines changed: 121 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
5-
android:id="@+id/main_content"
5+
android:id="@+id/drawer_layout"
66
android:layout_width="match_parent"
7-
android:layout_height="match_parent"
8-
android:background="?attr/colorBg">
7+
android:layout_height="match_parent">
8+
9+
<RelativeLayout
10+
android:id="@+id/main_content"
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
android:background="?attr/colorBg">
914

1015
<FrameLayout
1116
android:id="@+id/banner_home"
@@ -341,4 +346,115 @@
341346
</FrameLayout>
342347
</RelativeLayout>
343348
</com.google.android.material.card.MaterialCardView>
344-
</RelativeLayout>
349+
</RelativeLayout>
350+
351+
<!-- MikuRay-style card navigation drawer -->
352+
<androidx.core.widget.NestedScrollView
353+
android:layout_width="304dp"
354+
android:layout_height="match_parent"
355+
android:layout_gravity="start"
356+
android:background="?attr/colorBg"
357+
android:clipToPadding="false"
358+
android:fitsSystemWindows="true"
359+
android:paddingStart="12dp"
360+
android:paddingTop="24dp"
361+
android:paddingEnd="12dp"
362+
android:paddingBottom="24dp">
363+
364+
<LinearLayout
365+
android:layout_width="match_parent"
366+
android:layout_height="wrap_content"
367+
android:orientation="vertical">
368+
369+
<com.google.android.material.card.MaterialCardView
370+
android:layout_width="match_parent"
371+
android:layout_height="150dp"
372+
app:cardCornerRadius="24dp"
373+
app:cardElevation="0dp">
374+
375+
<ImageView
376+
android:layout_width="match_parent"
377+
android:layout_height="match_parent"
378+
android:contentDescription="@null"
379+
android:scaleType="centerCrop"
380+
android:src="@drawable/uwu_banner_profile" />
381+
382+
<View
383+
android:layout_width="match_parent"
384+
android:layout_height="match_parent"
385+
android:background="@drawable/uwu_bg_fade_bottom" />
386+
387+
<LinearLayout
388+
android:layout_width="match_parent"
389+
android:layout_height="match_parent"
390+
android:gravity="bottom"
391+
android:orientation="vertical"
392+
android:padding="16dp">
393+
394+
<TextView
395+
android:layout_width="wrap_content"
396+
android:layout_height="wrap_content"
397+
android:fontFamily="@font/uwu_font_title"
398+
android:text="@string/drawer_greeting"
399+
android:textColor="@android:color/white"
400+
android:textSize="20sp"
401+
android:textStyle="bold" />
402+
403+
<TextView
404+
android:layout_width="wrap_content"
405+
android:layout_height="wrap_content"
406+
android:fontFamily="@font/uwu_font_summary"
407+
android:text="@string/drawer_subtitle"
408+
android:textColor="@android:color/white"
409+
android:textSize="12sp" />
410+
</LinearLayout>
411+
</com.google.android.material.card.MaterialCardView>
412+
413+
<TextView
414+
android:layout_width="wrap_content"
415+
android:layout_height="wrap_content"
416+
android:layout_marginStart="8dp"
417+
android:layout_marginTop="18dp"
418+
android:layout_marginBottom="4dp"
419+
android:fontFamily="@font/uwu_font_summary"
420+
android:text="@string/drawer_section_manage"
421+
android:textColor="?attr/colorPrimary"
422+
android:textSize="13sp" />
423+
424+
<include
425+
android:id="@+id/drawer_proxies"
426+
layout="@layout/item_drawer_entry" />
427+
428+
<include
429+
android:id="@+id/drawer_settings"
430+
layout="@layout/item_drawer_entry" />
431+
432+
<include
433+
android:id="@+id/drawer_apps"
434+
layout="@layout/item_drawer_entry" />
435+
436+
<TextView
437+
android:layout_width="wrap_content"
438+
android:layout_height="wrap_content"
439+
android:layout_marginStart="8dp"
440+
android:layout_marginTop="18dp"
441+
android:layout_marginBottom="4dp"
442+
android:fontFamily="@font/uwu_font_summary"
443+
android:text="@string/drawer_section_tools"
444+
android:textColor="?attr/colorPrimary"
445+
android:textSize="13sp" />
446+
447+
<include
448+
android:id="@+id/drawer_logcat"
449+
layout="@layout/item_drawer_entry" />
450+
451+
<include
452+
android:id="@+id/drawer_tools"
453+
layout="@layout/item_drawer_entry" />
454+
455+
<include
456+
android:id="@+id/drawer_about"
457+
layout="@layout/item_drawer_entry" />
458+
</LinearLayout>
459+
</androidx.core.widget.NestedScrollView>
460+
</androidx.drawerlayout.widget.DrawerLayout>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
android:layout_height="?attr/actionBarSize"
3636
app:layout_collapseMode="pin"
3737
app:menu="@menu/menu_proxies"
38-
app:navigationIcon="@drawable/ic_arrow_back"
39-
app:navigationIconTint="?attr/colorOnSurfaceVariant"
38+
app:navigationIcon="@drawable/uwu_circle_back"
4039
app:titleTextColor="?attr/colorOnSurfaceVariant" />
4140
</com.google.android.material.appbar.CollapsingToolbarLayout>
4241
</com.google.android.material.appbar.AppBarLayout>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
android:layout_width="match_parent"
4444
android:layout_height="?attr/actionBarSize"
4545
app:layout_collapseMode="pin"
46-
app:navigationIcon="@drawable/ic_arrow_back"
47-
app:navigationIconTint="?attr/colorOnSurfaceVariant"
46+
app:navigationIcon="@drawable/uwu_circle_back"
4847
app:titleTextColor="?attr/colorOnSurfaceVariant" />
4948
</com.google.android.material.appbar.CollapsingToolbarLayout>
5049
</com.google.android.material.appbar.AppBarLayout>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
android:layout_width="match_parent"
4444
android:layout_height="?attr/actionBarSize"
4545
app:layout_collapseMode="pin"
46-
app:navigationIcon="@drawable/ic_arrow_back"
47-
app:navigationIconTint="?attr/colorOnSurfaceVariant"
46+
app:navigationIcon="@drawable/uwu_circle_back"
4847
app:titleTextColor="?attr/colorOnSurfaceVariant" />
4948
</com.google.android.material.appbar.CollapsingToolbarLayout>
5049
</com.google.android.material.appbar.AppBarLayout>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="wrap_content"
7+
android:layout_marginTop="8dp"
8+
android:clickable="true"
9+
android:focusable="true"
10+
app:cardBackgroundColor="?attr/colorCard"
11+
app:cardCornerRadius="20dp"
12+
app:cardElevation="0dp">
13+
14+
<LinearLayout
15+
android:layout_width="match_parent"
16+
android:layout_height="wrap_content"
17+
android:gravity="center_vertical"
18+
android:orientation="horizontal"
19+
android:padding="10dp">
20+
21+
<FrameLayout
22+
android:layout_width="42dp"
23+
android:layout_height="42dp">
24+
25+
<ImageView
26+
android:layout_width="42dp"
27+
android:layout_height="42dp"
28+
android:contentDescription="@null"
29+
android:src="@drawable/uwu_bg_icon"
30+
android:tint="?attr/colorPrimary" />
31+
32+
<ImageView
33+
android:id="@+id/icon"
34+
android:layout_width="22dp"
35+
android:layout_height="22dp"
36+
android:layout_gravity="center"
37+
android:contentDescription="@null"
38+
android:tint="?attr/colorOnPrimary"
39+
tools:src="@drawable/ic_lan" />
40+
</FrameLayout>
41+
42+
<TextView
43+
android:id="@+id/label"
44+
android:layout_width="0dp"
45+
android:layout_height="wrap_content"
46+
android:layout_marginStart="14dp"
47+
android:layout_weight="1"
48+
android:ellipsize="end"
49+
android:maxLines="1"
50+
android:textColor="?attr/colorOnSurface"
51+
android:textSize="16sp"
52+
tools:text="Proxies" />
53+
54+
<ImageView
55+
android:layout_width="18dp"
56+
android:layout_height="18dp"
57+
android:layout_marginEnd="6dp"
58+
android:contentDescription="@null"
59+
android:scaleX="-1"
60+
android:src="@drawable/ic_arrow_back"
61+
android:tint="?attr/colorOnSurfaceVariant" />
62+
</LinearLayout>
63+
</com.google.android.material.card.MaterialCardView>

0 commit comments

Comments
 (0)