mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-09-11 08:46:34 +02:00
feat: remove use of unused class Dialogs
This commit is contained in:
parent
0a0101f35e
commit
5a67ca22b8
@ -1,74 +0,0 @@
|
||||
package app.revanced.integrations.returnyoutubedislike.dialog;
|
||||
|
||||
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.LightingColorFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
public class Dialogs {
|
||||
// Inject call from YT to this
|
||||
public static void showDialogsAtStartup(Activity activity) {
|
||||
rydFirstRun(activity);
|
||||
}
|
||||
|
||||
private static void rydFirstRun(Activity activity) {
|
||||
boolean enabled = SettingsEnum.RYD_ENABLED.getBoolean();
|
||||
boolean hintShown = SettingsEnum.RYD_HINT_SHOWN.getBoolean();
|
||||
|
||||
// If RYD is enabled or hint has been shown, exit
|
||||
if (enabled || hintShown) {
|
||||
// If RYD is enabled but hint hasn't been shown, mark it as shown
|
||||
if (enabled && !hintShown) {
|
||||
SettingsEnum.RYD_HINT_SHOWN.saveValue(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert);
|
||||
} else {
|
||||
builder = new AlertDialog.Builder(activity);
|
||||
}
|
||||
builder.setTitle(str("revanced_ryd"));
|
||||
builder.setIcon(ReVancedUtils.getIdentifier("reel_dislike_icon", "drawable"));
|
||||
builder.setCancelable(false);
|
||||
builder.setMessage(str("revanced_ryd_firstrun"));
|
||||
builder.setPositiveButton(str("revanced_enable"),
|
||||
(dialog, id) -> {
|
||||
SettingsEnum.RYD_HINT_SHOWN.saveValue(true);
|
||||
SettingsEnum.RYD_ENABLED.saveValue(true);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
builder.setNegativeButton(str("revanced_disable"),
|
||||
(dialog, id) -> {
|
||||
SettingsEnum.RYD_HINT_SHOWN.saveValue(true);
|
||||
SettingsEnum.RYD_ENABLED.saveValue(false);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
builder.setNeutralButton(str("revanced_learnmore"), null);
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
// Set black background
|
||||
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, ReVancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
|
||||
|
||||
// Set learn more action (set here so clicking it doesn't dismiss the dialog)
|
||||
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(v -> {
|
||||
Uri uri = Uri.parse("https://www.returnyoutubedislike.com/");
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
activity.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
@ -44,18 +44,6 @@ public class ReturnYouTubeDislikeSettingsFragment extends PreferenceFragment {
|
||||
});
|
||||
}
|
||||
|
||||
// Clear hint
|
||||
if (SettingsEnum.DEBUG.getBoolean()) {
|
||||
SwitchPreference preference = new SwitchPreference(context);
|
||||
preferenceScreen.addPreference(preference);
|
||||
preference.setKey(SettingsEnum.RYD_HINT_SHOWN.getPath());
|
||||
preference.setDefaultValue(false);
|
||||
preference.setChecked(SettingsEnum.RYD_HINT_SHOWN.getBoolean());
|
||||
preference.setTitle("Hint debug");
|
||||
preference.setSummary("Debug toggle for clearing the hint shown preference");
|
||||
preference.setOnPreferenceChangeListener((pref, newValue) -> true);
|
||||
}
|
||||
|
||||
// About category
|
||||
addAboutCategory(context, preferenceScreen);
|
||||
}
|
||||
|
@ -70,18 +70,6 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
});
|
||||
}
|
||||
|
||||
// Clear hint
|
||||
if (SettingsEnum.DEBUG.getBoolean()) {
|
||||
SwitchPreference preference = new SwitchPreference(context);
|
||||
preferenceScreen.addPreference(preference);
|
||||
preference.setKey(SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.getPath());
|
||||
preference.setDefaultValue(false);
|
||||
preference.setChecked(SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.getBoolean());
|
||||
preference.setTitle("Hint debug");
|
||||
preference.setSummary("Debug toggle for clearing the hint shown preference");
|
||||
preference.setOnPreferenceChangeListener((pref, newValue) -> true);
|
||||
}
|
||||
|
||||
{
|
||||
SwitchPreference preference = new SwitchPreference(context);
|
||||
preferenceScreen.addPreference(preference);
|
||||
|
@ -1,76 +0,0 @@
|
||||
package app.revanced.integrations.sponsorblock.dialog;
|
||||
|
||||
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.LightingColorFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
public class Dialogs {
|
||||
// Inject call from YT to this
|
||||
public static void showDialogsAtStartup(Activity activity) {
|
||||
sbFirstRun(activity);
|
||||
}
|
||||
|
||||
private static void sbFirstRun(Activity activity) {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
boolean enabled = SettingsEnum.SB_ENABLED.getBoolean();
|
||||
boolean hintShown = SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.getBoolean();
|
||||
|
||||
// If SB is enabled or hint has been shown, exit
|
||||
if (enabled || hintShown) {
|
||||
// If SB is enabled but hint hasn't been shown, mark it as shown
|
||||
if (enabled && !hintShown) {
|
||||
SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.saveValue(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
builder = new AlertDialog.Builder(activity, android.R.style.Theme_Material_Dialog_Alert);
|
||||
} else {
|
||||
builder = new AlertDialog.Builder(activity);
|
||||
}
|
||||
builder.setTitle(str("vanced_sb"));
|
||||
builder.setIcon(ReVancedUtils.getIdentifier("ic_sb_logo", "drawable"));
|
||||
builder.setCancelable(false);
|
||||
builder.setMessage(str("vanced_sb_firstrun"));
|
||||
builder.setPositiveButton(str("vanced_enable"),
|
||||
(dialog, id) -> {
|
||||
SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.saveValue(true);
|
||||
SettingsEnum.SB_ENABLED.saveValue(true);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
builder.setNegativeButton(str("vanced_disable"),
|
||||
(dialog, id) -> {
|
||||
SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.saveValue(true);
|
||||
SettingsEnum.SB_ENABLED.saveValue(false);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
builder.setNeutralButton(str("vanced_learnmore"), null);
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
// Set black background
|
||||
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, ReVancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
|
||||
|
||||
// Set learn more action (set here so clicking it doesn't dismiss the dialog)
|
||||
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(v -> {
|
||||
Uri uri = Uri.parse("https://sponsor.ajay.app/");
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
activity.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user