fix(YouTube Music): Prevent crash on bold icons loading (#6712)
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package app.revanced.extension.music;
|
||||
|
||||
import app.revanced.extension.shared.Utils;
|
||||
|
||||
public class VersionCheckUtils {
|
||||
private static boolean isVersionOrGreater(String version) {
|
||||
return Utils.getAppVersionName().compareTo(version) >= 0;
|
||||
}
|
||||
|
||||
public static final boolean IS_8_40_OR_GREATER = isVersionOrGreater("8.40.00");
|
||||
}
|
||||
|
||||
+29
@@ -8,6 +8,7 @@ import android.preference.PreferenceFragment;
|
||||
import android.view.View;
|
||||
import android.widget.Toolbar;
|
||||
|
||||
import app.revanced.extension.music.VersionCheckUtils;
|
||||
import app.revanced.extension.music.settings.preference.MusicPreferenceFragment;
|
||||
import app.revanced.extension.music.settings.search.MusicSearchViewController;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
@@ -23,6 +24,24 @@ public class MusicActivityHook extends BaseActivityHook {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static MusicSearchViewController searchViewController;
|
||||
|
||||
/**
|
||||
* How much time has passed since the first launch of the app. Simple check to prevent
|
||||
* forcing bold icons on first launch where the settings menu is partially broken
|
||||
* due to missing icon resources the client has not yet received.
|
||||
*
|
||||
* @see app.revanced.extension.youtube.settings.YouTubeActivityHook#MINIMUM_TIME_AFTER_FIRST_LAUNCH_BEFORE_ALLOWING_BOLD_ICONS
|
||||
*/
|
||||
private static final long MINIMUM_TIME_AFTER_FIRST_LAUNCH_BEFORE_ALLOWING_BOLD_ICONS = 30 * 1000; // 30 seconds.
|
||||
|
||||
static {
|
||||
final boolean useBoldIcons = VersionCheckUtils.IS_8_40_OR_GREATER
|
||||
&& !Settings.SETTINGS_DISABLE_BOLD_ICONS.get()
|
||||
&& (System.currentTimeMillis() - Settings.FIRST_TIME_APP_LAUNCHED.get())
|
||||
> MINIMUM_TIME_AFTER_FIRST_LAUNCH_BEFORE_ALLOWING_BOLD_ICONS;
|
||||
|
||||
Utils.setAppIsUsingBoldIcons(useBoldIcons);
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
@@ -116,4 +135,14 @@ public class MusicActivityHook extends BaseActivityHook {
|
||||
public static boolean handleFinish() {
|
||||
return MusicSearchViewController.handleFinish(searchViewController);
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
* <p>
|
||||
* Decides whether to use bold icons.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static boolean useBoldIcons(boolean original) {
|
||||
return Utils.appIsUsingBoldIcons();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user