fix(YouTube Music): Prevent crash on bold icons loading (#6712)
This commit is contained in:
parent
46fb3669ee
commit
e9bfb7ca9b
2 changed files with 41 additions and 0 deletions
|
|
@ -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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -8,6 +8,7 @@ import android.preference.PreferenceFragment;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toolbar;
|
import android.widget.Toolbar;
|
||||||
|
|
||||||
|
import app.revanced.extension.music.VersionCheckUtils;
|
||||||
import app.revanced.extension.music.settings.preference.MusicPreferenceFragment;
|
import app.revanced.extension.music.settings.preference.MusicPreferenceFragment;
|
||||||
import app.revanced.extension.music.settings.search.MusicSearchViewController;
|
import app.revanced.extension.music.settings.search.MusicSearchViewController;
|
||||||
import app.revanced.extension.shared.Logger;
|
import app.revanced.extension.shared.Logger;
|
||||||
|
|
@ -23,6 +24,24 @@ public class MusicActivityHook extends BaseActivityHook {
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
public static MusicSearchViewController searchViewController;
|
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.
|
* Injection point.
|
||||||
*/
|
*/
|
||||||
|
|
@ -116,4 +135,14 @@ public class MusicActivityHook extends BaseActivityHook {
|
||||||
public static boolean handleFinish() {
|
public static boolean handleFinish() {
|
||||||
return MusicSearchViewController.handleFinish(searchViewController);
|
return MusicSearchViewController.handleFinish(searchViewController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Injection point.
|
||||||
|
* <p>
|
||||||
|
* Decides whether to use bold icons.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public static boolean useBoldIcons(boolean original) {
|
||||||
|
return Utils.appIsUsingBoldIcons();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue