diff --git a/app/src/main/java/io/github/soclear/oneuix/ui/SettingScreen.kt b/app/src/main/java/io/github/soclear/oneuix/ui/SettingScreen.kt index 583e3786..4a86ca7d 100644 --- a/app/src/main/java/io/github/soclear/oneuix/ui/SettingScreen.kt +++ b/app/src/main/java/io/github/soclear/oneuix/ui/SettingScreen.kt @@ -29,6 +29,7 @@ import io.github.soclear.oneuix.ui.category.DetailPaneCamera import io.github.soclear.oneuix.ui.category.DetailPaneDualApp import io.github.soclear.oneuix.ui.category.DetailPaneGalaxyStore import io.github.soclear.oneuix.ui.category.DetailPaneMyFiles +import io.github.soclear.oneuix.ui.category.DetailPaneWallpaper import io.github.soclear.oneuix.ui.category.DetailPaneGallery import io.github.soclear.oneuix.ui.category.DetailPaneSamsungHealth import io.github.soclear.oneuix.ui.category.DetailPaneHealthMonitor @@ -60,6 +61,7 @@ import io.github.soclear.oneuix.ui.category.onCameraEvent import io.github.soclear.oneuix.ui.category.onDualAppEvent import io.github.soclear.oneuix.ui.category.onGalaxyStoreEvent import io.github.soclear.oneuix.ui.category.onMyFilesEvent +import io.github.soclear.oneuix.ui.category.onWallpaperEvent import io.github.soclear.oneuix.ui.category.onGalleryEvent import io.github.soclear.oneuix.ui.category.onSamsungHealthEvent import io.github.soclear.oneuix.ui.category.onHealthMonitorEvent @@ -242,6 +244,11 @@ fun SettingScreen(viewModel: SettingViewModel, modifier: Modifier = Modifier) { onEvent = viewModel::onMyFilesEvent ) + Category.Wallpaper -> DetailPaneWallpaper( + uiState = preference.other, + onEvent = viewModel::onWallpaperEvent + ) + Category.NFC -> DetailPaneNFC( onNavigateToNfcCards = { navigateToExtra(SettingDestination.Extra.NfcCards) diff --git a/app/src/main/java/io/github/soclear/oneuix/ui/category/Category.kt b/app/src/main/java/io/github/soclear/oneuix/ui/category/Category.kt index c791d282..e6968ade 100644 --- a/app/src/main/java/io/github/soclear/oneuix/ui/category/Category.kt +++ b/app/src/main/java/io/github/soclear/oneuix/ui/category/Category.kt @@ -26,6 +26,7 @@ enum class Category(val packageName: String) { SPen(Package.TRANSLATION), ThemeCenter(Package.THEME_CENTER), Video(Package.VIDEO), + Wallpaper(Package.WALLPAPER), WatchManager(Package.WATCH_MANAGER), Weather(Package.WEATHER), Other(""); diff --git a/app/src/main/java/io/github/soclear/oneuix/ui/category/DetailPaneWallpaper.kt b/app/src/main/java/io/github/soclear/oneuix/ui/category/DetailPaneWallpaper.kt new file mode 100644 index 00000000..24ff56ab --- /dev/null +++ b/app/src/main/java/io/github/soclear/oneuix/ui/category/DetailPaneWallpaper.kt @@ -0,0 +1,41 @@ +package io.github.soclear.oneuix.ui.category + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.res.vectorResource +import io.github.soclear.oneuix.R +import io.github.soclear.oneuix.common.Preference +import io.github.soclear.oneuix.ui.SettingViewModel +import io.github.soclear.oneuix.ui.component.SwitchItem + +@Composable +fun DetailPaneWallpaper( + uiState: Preference.Other, + onEvent: (WallpaperEvent) -> Unit, + modifier: Modifier = Modifier +) { + PackagePane(modifier) { + SwitchItem( + icon = ImageVector.vectorResource(id = R.drawable.wallpaper_live), + title = stringResource(id = R.string.restoreLiveWallpaperEntry_title), + summary = stringResource(id = R.string.restoreLiveWallpaperEntry_summary), + checked = uiState.restoreLiveWallpaperEntry, + onCheckedChange = { onEvent(WallpaperEvent.RestoreLiveWallpaperEntry(it)) } + ) + } +} + +sealed interface WallpaperEvent { + @JvmInline + value class RestoreLiveWallpaperEntry(val value: Boolean) : WallpaperEvent +} + +fun SettingViewModel.onWallpaperEvent(event: WallpaperEvent) { + updateData { preference -> + preference.copy(other = when (event) { + is WallpaperEvent.RestoreLiveWallpaperEntry -> preference.other.copy(restoreLiveWallpaperEntry = event.value) + }) + } +} diff --git a/app/src/main/res/drawable/wallpaper_live.xml b/app/src/main/res/drawable/wallpaper_live.xml new file mode 100644 index 00000000..563733e8 --- /dev/null +++ b/app/src/main/res/drawable/wallpaper_live.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index f2550aaa..871f5c62 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -255,4 +255,6 @@ Utilisable jusqu’à 1 % sans extinction automatique due à la batterie faible. La protection thermique est conservée Corriger la redirection du stockage réseau dans Mes fichiers Pour la version internationale de Mes fichiers sur une ROM chinoise : empêche le stockage réseau de rediriger vers la page de mise à jour du Galaxy Store. La dernière version en cache est alignée sur la version installée + Restaurez l'entrée du fond d'écran animé dans le menu "\u22EE" de l'application de fond d'écran + Restaurez l'option d'entrée "Live Wallpaper" dans le menu "\u22EE" des "Fonds d'écran et styles" de Samsung diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 54666b60..83cc339b 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -255,4 +255,6 @@ 배터리 부족으로 자동으로 꺼지지 않고 1%까지 사용합니다. 과열 보호는 유지됩니다 내 파일 네트워크 저장소 이동 문제 수정 중국 ROM에서 국제판 내 파일을 사용할 때 네트워크 저장소를 누르면 Galaxy Store 업데이트 페이지로 이동하는 문제를 막습니다. 캐시된 최신 버전을 설치된 버전과 동일하게 유지합니다 + 배경화면 애플리케이션의 "\u22EE" 메뉴에서 라이브 배경화면 항목을 복원합니다. + 삼성 '배경화면 및 스타일'의 "\u22EE" 메뉴에서 '라이브 배경화면' 항목 옵션을 복원합니다. diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 631909fd..dec66342 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -255,4 +255,6 @@ Работа до 1 % без автоматического отключения из-за низкого заряда. Защита от перегрева сохраняется Исправить переход «Сетевого хранилища» в «Моих файлах» Для международной версии «Моих файлов» на китайской прошивке: не даёт «Сетевому хранилищу» перенаправлять на страницу обновления в Galaxy Store. Кэшированная последняя версия приравнивается к установленной + Восстановите запись о живых обоях в меню «\u22EE» приложения обоев. + Восстановите опцию записи «Живые обои» в меню «\u22EE» меню «Обои и стили» Samsung. diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 9178497f..935165e1 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -255,4 +255,6 @@ 电量低至 1% 时仍可使用,不因低电量自动关闭;保留过热保护 修复我的文件网络存储跳转 适用于国行系统上使用国际版“我的文件”:点击网络存储时不再跳转到应用商店更新页面。让缓存的最新版本与已安装版本保持一致 + 恢复壁纸应用“\u22EE”菜单的动态壁纸入口 + 恢复三星“壁纸和风格”的“\u22EE”菜单中“动态壁纸”入口选项 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8fbf438a..354e5093 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -255,4 +255,6 @@ Allow use down to 1% without automatic shutoff due to low battery. Thermal protection is retained Fix My Files network storage redirect For the international My Files on a China ROM: stop Network storage from jumping to the Galaxy Store update page. Keeps the cached latest version equal to the installed version + Restore the live wallpaper entry in the "\u22EE" menu of the wallpaper application + Restore the "Live Wallpaper" entry option in the "\u22EE" menu of Samsung's "Wallpapers and Styles" diff --git a/common/src/main/java/io/github/soclear/oneuix/common/Package.kt b/common/src/main/java/io/github/soclear/oneuix/common/Package.kt index d78dca54..bc86a3b0 100644 --- a/common/src/main/java/io/github/soclear/oneuix/common/Package.kt +++ b/common/src/main/java/io/github/soclear/oneuix/common/Package.kt @@ -17,6 +17,7 @@ object Package { const val MDEC_SERVICE = "com.samsung.android.mdecservice" const val MESSAGING = "com.samsung.android.messaging" const val MY_FILES = "com.sec.android.app.myfiles" + const val WALLPAPER = "com.samsung.android.app.dressroom" const val NFC = "com.android.nfc" const val NOTES = "com.samsung.android.app.notes" const val PHOTO_RETOUCHING = "com.sec.android.mimage.photoretouching" diff --git a/common/src/main/java/io/github/soclear/oneuix/common/Preference.kt b/common/src/main/java/io/github/soclear/oneuix/common/Preference.kt index 5ccb35d1..d8004165 100644 --- a/common/src/main/java/io/github/soclear/oneuix/common/Preference.kt +++ b/common/src/main/java/io/github/soclear/oneuix/common/Preference.kt @@ -211,6 +211,7 @@ data class Preference( val setGalaxyStoreSimOperator: Boolean = false, val galaxyStoreSimOperator: String = "", val fixMyFilesNetworkStorage: Boolean = false, + val restoreLiveWallpaperEntry: Boolean = false, val makeAllUserAppsAvailable: Boolean = true, val setWeatherProviderCN: Boolean = false, val showMemoryUsageInRecents: Boolean = false, diff --git a/hook/src/main/java/io/github/soclear/oneuix/hook/Main.kt b/hook/src/main/java/io/github/soclear/oneuix/hook/Main.kt index 22f6e6fc..b24f6144 100644 --- a/hook/src/main/java/io/github/soclear/oneuix/hook/Main.kt +++ b/hook/src/main/java/io/github/soclear/oneuix/hook/Main.kt @@ -536,6 +536,12 @@ class Main : XposedModule() { } } + Package.WALLPAPER -> { + if (preference.other.restoreLiveWallpaperEntry) { + Wallpaper.restoreLiveWallpaperEntry() + } + } + Package.WATCH_MANAGER -> { if (preference.other.bypassWatchPairingRegionCheck || preference.other.watchPairingConnectionMode != WatchPairing.MODE_NONE diff --git a/hook/src/main/java/io/github/soclear/oneuix/hook/Wallpaper.kt b/hook/src/main/java/io/github/soclear/oneuix/hook/Wallpaper.kt new file mode 100644 index 00000000..62a001e8 --- /dev/null +++ b/hook/src/main/java/io/github/soclear/oneuix/hook/Wallpaper.kt @@ -0,0 +1,57 @@ +package io.github.soclear.oneuix.hook + +import android.app.Activity +import android.content.Intent +import android.view.Menu +import android.view.MenuItem +import io.github.libxposed.api.XposedModule +import io.github.soclear.oneuix.hook.util.afterAttachTry + +object Wallpaper { + private const val LIBRARY_ACTIVITY = + "com.samsung.android.app.dressroom.presentation.library.ui.WallpaperLibraryActivity" + private const val MENU_ID_LIVE_WALLPAPER = 0x4C575001 + private const val ACTION_LIVE_WALLPAPER_CHOOSER = "android.service.wallpaper.LIVE_WALLPAPER_CHOOSER" + + /** + * 三星壁纸应用在国行系统上,三点菜单里没有“动态壁纸”入口(菜单资源里没有,处理代码也被删了)。 + * 这里在菜单创建后补一项,点击时打开系统的动态壁纸选择器。不改 APK,只依赖 + * WallpaperLibraryActivity 里两个标准的菜单回调,更新壁纸应用后一般无需适配。 + */ + context(xposedModule: XposedModule) + fun restoreLiveWallpaperEntry() = afterAttachTry { + val activityClass = classLoader.loadClass(LIBRARY_ACTIVITY) + + xposedModule.hook( + activityClass.getDeclaredMethod("onCreateOptionsMenu", Menu::class.java) + ).intercept { chain -> + val result = chain.proceed() + runCatching { + val activity = chain.thisObject as Activity + val menu = chain.args[0] as Menu + // 菜单为空说明库页面当前不显示三点菜单,此时不添加 + if (menu.size() > 0 && menu.findItem(MENU_ID_LIVE_WALLPAPER) == null) { + val titleRes = activity.resources.getIdentifier( + "options_menu_title_live_wallpapers", "string", activity.packageName + ) + val title = if (titleRes != 0) activity.getString(titleRes) else "Live wallpapers" + menu.add(Menu.NONE, MENU_ID_LIVE_WALLPAPER, Menu.NONE, title) + } + } + result + } + + xposedModule.hook( + activityClass.getDeclaredMethod("onOptionsItemSelected", MenuItem::class.java) + ).intercept { chain -> + val item = chain.args[0] as MenuItem + if (item.itemId == MENU_ID_LIVE_WALLPAPER) { + val activity = chain.thisObject as Activity + runCatching { activity.startActivity(Intent(ACTION_LIVE_WALLPAPER_CHOOSER)) } + true + } else { + chain.proceed() + } + } + } +} diff --git a/hook/src/main/resources/META-INF/xposed/scope.list b/hook/src/main/resources/META-INF/xposed/scope.list index 85cff79b..aa456423 100644 --- a/hook/src/main/resources/META-INF/xposed/scope.list +++ b/hook/src/main/resources/META-INF/xposed/scope.list @@ -28,3 +28,4 @@ com.sec.android.app.shealth com.sec.android.daemonapp com.sec.android.gallery3d com.sec.android.mimage.photoretouching +com.samsung.android.app.dressroom