generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 612
feat(Custom branding): Add in-app settings to change icon and name #6059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+923
−215
Merged
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
d272ff4
feat(Custom branding): Use SVG for adaptive ReVanced icon
MarcaDian 8b30f38
refactor
MarcaDian 35b7362
fix resourses for new targets
MarcaDian 78d0be4
List legacy icons in description
LisoUseInAIKyrios 6f0a111
Copy xml during patching
LisoUseInAIKyrios 123d152
remove launcher_round.png that is missing in recent YT targets
LisoUseInAIKyrios 5f2f61a
Allow custom icon to be only for specific resolutions (same behavior …
LisoUseInAIKyrios b34a1ab
Revert commit until it's fixed
LisoUseInAIKyrios ac90528
allow only specific resolutions for custom icons
LisoUseInAIKyrios 4c91f57
refactor
LisoUseInAIKyrios 19c7dc8
refactor
LisoUseInAIKyrios 7a32683
Use a resource patch to change the manifest instead of modifying xml …
LisoUseInAIKyrios 4937dff
improve error message
LisoUseInAIKyrios 6f2e9f4
improve error message
LisoUseInAIKyrios d1d2b8c
use consistent naming of "folder" over "directory"
LisoUseInAIKyrios 5b34826
use "correct" scaling, add other resources
MarcaDian e14fe5b
use black/transparent background for scale
MarcaDian 13beee6
fix: Remove legacy Android 7.0 icons to make patch options simpler. I…
LisoUseInAIKyrios 504c3e5
remove duplicate monochrome resource
LisoUseInAIKyrios 97d2e29
use pure black background for scale
MarcaDian 58bda68
use branding color background for minimal & rounded
MarcaDian 3444922
fix scaling for rounded icon to prevent ~1px padding to launcher mask
MarcaDian bbe129e
work in progress: In app setting to change branding
LisoUseInAIKyrios 8bc82ee
cleanup
LisoUseInAIKyrios 91cc333
add custom icon option
LisoUseInAIKyrios dd1dd91
use 50% scaling for rounded icon
MarcaDian b3963fe
Add in app setting to change name. Change patch to default included.
LisoUseInAIKyrios d2823a2
Update default setting value
LisoUseInAIKyrios 1369220
string refactor
LisoUseInAIKyrios be5eb6b
add app name option
LisoUseInAIKyrios 13948b2
Fix app name option not selectable
LisoUseInAIKyrios 745f187
fix custom app name not showing in launcher
LisoUseInAIKyrios 05b9bd3
apply changes faster
LisoUseInAIKyrios a6f4d27
fix app shutting down and not restarting
LisoUseInAIKyrios 9405f3d
refactor
LisoUseInAIKyrios ab16358
Update revanced_adaptive_monochrome_rounded.xml
MarcaDian 921b0d1
fix app won't startup if bad settings name index is imported
LisoUseInAIKyrios 04cd4b3
fix broken app if custom icon/name is in use and the app is repatched…
LisoUseInAIKyrios ce8958f
cleanup
LisoUseInAIKyrios d5790ee
comments
LisoUseInAIKyrios e0965d2
Consolidate error handling paths
LisoUseInAIKyrios 89f3ea2
Update patches/src/main/kotlin/app/revanced/patches/shared/layout/bra…
LisoUseInAIKyrios 73c1fa9
Update patches/src/main/resources/custom-branding/mipmap-anydpi/revan…
LisoUseInAIKyrios 6be6548
fix startup error toast if custom branding patch is included with roo…
LisoUseInAIKyrios 30ffeb7
fix scaling for monochrome icons
MarcaDian fe898c7
Add a disclaimer
LisoUseInAIKyrios c923831
Do not add in app settings for root installation
LisoUseInAIKyrios a162e03
Use same names as the same icon styles in change header patch
LisoUseInAIKyrios 6fd59b9
Fix YT Music missing setting
LisoUseInAIKyrios 8ed3b3b
refactor
LisoUseInAIKyrios 206769a
refactor
LisoUseInAIKyrios d238ee7
Show what went wrong in the exception
LisoUseInAIKyrios 954c90d
fix day launcher not showing splash screen background
LisoUseInAIKyrios 332681a
organize files
LisoUseInAIKyrios 533885a
comments
LisoUseInAIKyrios cf5ba27
fix about screen showing an error if backed out before it can show
LisoUseInAIKyrios 109bab7
retain long press actions
LisoUseInAIKyrios 17dc4a0
removing the existing default does not seem to be required
LisoUseInAIKyrios 45b3737
comments
LisoUseInAIKyrios 9140194
fix YT Music
LisoUseInAIKyrios ece15d7
update revanced header logo minimal
MarcaDian 07c5f3c
Change template icons to inverted color, to make future diagnosing ea…
LisoUseInAIKyrios 17623b0
refactor
LisoUseInAIKyrios a8b9dc3
cleanup
LisoUseInAIKyrios e828cb5
png lossless recompression
LisoUseInAIKyrios eb80e15
refactor
LisoUseInAIKyrios c0f063f
Merge remote-tracking branch 'upstream/dev' into adaptive-icons
LisoUseInAIKyrios 1db46e4
refactor
LisoUseInAIKyrios File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
...ared/library/src/main/java/app/revanced/extension/shared/patches/CustomBrandingPatch.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| package app.revanced.extension.shared.patches; | ||
|
|
||
| import android.content.ComponentName; | ||
| import android.content.Context; | ||
| import android.content.pm.PackageManager; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import app.revanced.extension.shared.GmsCoreSupport; | ||
| import app.revanced.extension.shared.Logger; | ||
| import app.revanced.extension.shared.Utils; | ||
| import app.revanced.extension.shared.settings.BaseSettings; | ||
|
|
||
| /** | ||
| * Patch shared by YouTube and YT Music. | ||
| */ | ||
| @SuppressWarnings("unused") | ||
| public class CustomBrandingPatch { | ||
|
|
||
| // Important: In the future, additional branding themes can be added but all existing and prior | ||
| // themes cannot be removed or renamed. | ||
| // | ||
| // This is because if a user has a branding theme selected, then only that launch alias is enabled. | ||
| // If a future update removes or renames that alias, then after updating the app is effectively | ||
| // broken and it cannot be opened and not even clearing the app data will fix it. | ||
| // In that situation the only fix is to completely uninstall and reinstall again. | ||
| // | ||
| // The most that can be done is to hide a theme from the UI and keep the alias with dummy data. | ||
| public enum BrandingTheme { | ||
| /** | ||
| * Original unpatched icon. Must be first enum. | ||
| */ | ||
| ORIGINAL("revanced_original"), | ||
| ROUNDED("revanced_rounded"), | ||
| MINIMAL("revanced_minimal"), | ||
| SCALED("revanced_scaled"), | ||
| /** | ||
| * User provided custom icon. Must be the last enum. | ||
| */ | ||
| CUSTOM("revanced_custom"); | ||
|
|
||
| public final String themeAlias; | ||
|
|
||
| BrandingTheme(String themeAlias) { | ||
| this.themeAlias = themeAlias; | ||
| } | ||
|
|
||
| private String packageAndNameIndexToClassAlias(String packageName, int appIndex) { | ||
| if (appIndex <= 0) { | ||
| throw new IllegalArgumentException("App index starts at index 1"); | ||
| } | ||
| return packageName + '.' + themeAlias + '_' + appIndex; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Injection point. | ||
| * | ||
| * The total number of app name aliases, including dummy aliases. | ||
| */ | ||
| private static int numberOfPresetAppNames() { | ||
| // Modified during patching. | ||
| throw new IllegalStateException(); | ||
| } | ||
|
|
||
| /** | ||
| * Injection point. | ||
| */ | ||
| @SuppressWarnings("ConstantConditions") | ||
| public static void setBranding() { | ||
| try { | ||
| if (GmsCoreSupport.isPackageNameOriginal()) { | ||
| Logger.printInfo(() -> "App is root mounted. Cannot dynamically change app icon"); | ||
| return; | ||
| } | ||
|
|
||
| Context context = Utils.getContext(); | ||
| PackageManager pm = context.getPackageManager(); | ||
| String packageName = context.getPackageName(); | ||
|
|
||
| BrandingTheme selectedBranding = BaseSettings.CUSTOM_BRANDING_ICON.get(); | ||
| final int selectedNameIndex = BaseSettings.CUSTOM_BRANDING_NAME.get(); | ||
| ComponentName componentToEnable = null; | ||
| ComponentName defaultComponent = null; | ||
| List<ComponentName> componentsToDisable = new ArrayList<>(); | ||
|
|
||
| for (BrandingTheme theme : BrandingTheme.values()) { | ||
| // Must always update all aliases including custom alias (last index). | ||
| final int numberOfPresetAppNames = numberOfPresetAppNames(); | ||
|
|
||
| // App name indices starts at 1. | ||
| for (int index = 1; index <= numberOfPresetAppNames; index++) { | ||
| String aliasClass = theme.packageAndNameIndexToClassAlias(packageName, index); | ||
| ComponentName component = new ComponentName(packageName, aliasClass); | ||
| if (defaultComponent == null) { | ||
| // Default is always the first alias. | ||
| defaultComponent = component; | ||
| } | ||
|
|
||
| if (index == selectedNameIndex && theme == selectedBranding) { | ||
| componentToEnable = component; | ||
| } else { | ||
| componentsToDisable.add(component); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (componentToEnable == null) { | ||
| // User imported a bad app name index value. Either the imported data | ||
| // was corrupted, or they previously had custom name enabled and the app | ||
| // no longer has a custom name specified. | ||
| Utils.showToastLong("Custom branding reset"); | ||
| BaseSettings.CUSTOM_BRANDING_ICON.resetToDefault(); | ||
| BaseSettings.CUSTOM_BRANDING_NAME.resetToDefault(); | ||
|
|
||
| componentToEnable = defaultComponent; | ||
| componentsToDisable.remove(defaultComponent); | ||
| } | ||
|
|
||
| for (ComponentName disable : componentsToDisable) { | ||
| // Use info logging because if the alias status become corrupt the app cannot launch. | ||
| Logger.printInfo(() -> "Disabling: " + disable.getClassName()); | ||
| pm.setComponentEnabledSetting(disable, | ||
| PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); | ||
| } | ||
|
|
||
| ComponentName componentToEnableFinal = componentToEnable; | ||
| Logger.printInfo(() -> "Enabling: " + componentToEnableFinal.getClassName()); | ||
| pm.setComponentEnabledSetting(componentToEnable, | ||
| PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0); | ||
| } catch (Exception ex) { | ||
| Logger.printException(() -> "setBranding failure", ex); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
patches/src/main/kotlin/app/revanced/patches/music/misc/gms/Constants.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| package app.revanced.patches.music.misc.gms | ||
|
|
||
| object Constants { | ||
| internal const val MUSIC_MAIN_ACTIVITY_NAME = "com.google.android.apps.youtube.music.activities.MusicActivity" | ||
|
|
||
| internal const val REVANCED_MUSIC_PACKAGE_NAME = "app.revanced.android.apps.youtube.music" | ||
| internal const val MUSIC_PACKAGE_NAME = "com.google.android.apps.youtube.music" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.