Skip to content

Commit

Permalink
Merge pull request #13 from crimera/dev
Browse files Browse the repository at this point in the history
chore: Merge branch `dev` to `main`
  • Loading branch information
crimera authored Mar 27, 2024
2 parents ecd2b0a + d440909 commit aaa19f2
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 3 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# [1.7.0](https://github.com/crimera/revanced-integrations/compare/v1.6.0...v1.7.0) (2024-03-22)
# [1.8.0-dev.1](https://github.com/crimera/revanced-integrations/compare/v1.7.0...v1.8.0-dev.1) (2024-03-27)


### Features

* **Twitter:** Added `App Icon and NavBar Customisation` settings ([796a33d](https://github.com/crimera/revanced-integrations/commit/796a33dca86a31a96c268c9fb8fe6122d98b3d65))
* **Twitter:** Added `Undo Post Patch` in mod settings ([e82d8bf](https://github.com/crimera/revanced-integrations/commit/e82d8bfcdd38c7d7de4b4bf2702c4a2982c9be94))

# [1.7.0-dev.2](https://github.com/crimera/revanced-integrations/compare/v1.7.0-dev.1...v1.7.0-dev.2) (2024-03-27)


### Features

* **Twitter:** Added `App Icon and NavBar Customisation` settings ([796a33d](https://github.com/crimera/revanced-integrations/commit/796a33dca86a31a96c268c9fb8fe6122d98b3d65))
* **Twitter:** Added `Undo Post Patch` in mod settings ([e82d8bf](https://github.com/crimera/revanced-integrations/commit/e82d8bfcdd38c7d7de4b4bf2702c4a2982c9be94))

# [1.7.0-dev.1](https://github.com/crimera/revanced-integrations/compare/v1.6.0...v1.7.0-dev.1) (2024-03-22)


### Features
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/app/revanced/integrations/twitter/Pref.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public static boolean hideRPinnedPosts() {
public static boolean hideDetailedPosts() {
return Utils.getBooleanPerf(Settings.ADS_HIDE_DETAILED_POSTS);
}
public static boolean enableReaderMode() {
return Utils.getBooleanPerf(Settings.PREMIUM_READER_MODE);
}
public static boolean enableUndoPosts() {
return Utils.getBooleanPerf(Settings.PREMIUM_UNDO_POSTS);
}

//end
}
20 changes: 20 additions & 0 deletions app/src/main/java/app/revanced/integrations/twitter/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,30 @@ private static void startActivity(Class cls) {
ctx.startActivity(intent);
}

private static void startActivityFromClassName(String className){
try {
Class<?> clazz = Class.forName(className);
startActivity(clazz);
}catch (Exception unused) {

}
}


public static void startSettingsActivity(){
startActivity(SettingsActivity.class);
}

public static void startUndoPostActivity(){
String className = "com.twitter.feature.subscriptions.settings.undotweet.UndoTweetSettingsActivity";
startActivityFromClassName(className);
}

public static void startAppIconNNavIconActivity(){
String className = "com.twitter.feature.subscriptions.settings.extras.ExtrasSettingsActivity";
startActivityFromClassName(className);
}

@SuppressWarnings("deprecation")
public static String getStringPref(Setting<String> setting) {
String value = sp.getString(setting.key, setting.defaultValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public class Settings extends BaseSettings {
public static final BooleanSetting TIMELINE_HIDE_LIVETHREADS = new BooleanSetting("timeline_hide_livethreads", true);
public static final BooleanSetting TIMELINE_HIDE_BANNER = new BooleanSetting("timeline_hide_banner", true);
public static final BooleanSetting TIMELINE_HIDE_FORYOU = new BooleanSetting("timeline_hide_foryou", false);

public static final BooleanSetting PREMIUM_READER_MODE = new BooleanSetting("premium_reader_mode", false);
public static final BooleanSetting PREMIUM_UNDO_POSTS = new BooleanSetting("premium_undo_posts", false);
public static final String PREMIUM_ICONS = "premium_app_icon_n_nav_icon";
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void onCreate(Bundle savedInstanceState) {
getFragmentManager().beginTransaction().add(Utils.getResourceIdentifier("fragment_container", "id"), new Screen()).commit();
}

public static class Screen extends PreferenceFragment {
public static class Screen extends PreferenceFragment implements Preference.OnPreferenceClickListener{
private Context context;

@Override
Expand All @@ -38,6 +38,44 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(context);
// SettingsStatus.load();
if (SettingsStatus.enablePremiumSection()) {
LegacyTwitterPreferenceCategory premiumPrefs = preferenceCategory("Premium", screen);
if (SettingsStatus.enableReaderMode) {
premiumPrefs.addPreference(
switchPreference(
"Enable reader mode",
"Enables \"reader mode\" on long threads",
Settings.PREMIUM_READER_MODE
)
);
}
if (SettingsStatus.enableUndoPosts) {
premiumPrefs.addPreference(
switchPreference(
"Enable undo posts",
"Enables ability to undo posts before posting",
Settings.PREMIUM_UNDO_POSTS
)
);

premiumPrefs.addPreference(
buttonPreference(
"Undo posts settings",
"",
Settings.PREMIUM_UNDO_POSTS.key
)
);
}
if (SettingsStatus.enableAppIconNNavIcon) {
premiumPrefs.addPreference(
buttonPreference(
"App icon and navbar customisation settings",
"",
Settings.PREMIUM_ICONS
)
);
}
}

if (SettingsStatus.changeDownloadEnabled) {
LegacyTwitterPreferenceCategory downloadPrefs = preferenceCategory("Download", screen);
Expand All @@ -51,6 +89,16 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
"The subfolder to download videos to ([PublicFolder]/[Subfolder])",
Settings.VID_SUBFOLDER
));
downloadPrefs.addPreference(listPreference(
"Public folder",
"The public folder to use for video downloads",
Settings.VID_PUBLIC_FOLDER
));
downloadPrefs.addPreference(editTextPreference(
"Download subfolder",
"The subfolder to download videos to ([PublicFolder]/[Subfolder])",
Settings.VID_SUBFOLDER
));
}

if(SettingsStatus.enableAdsSection()){
Expand Down Expand Up @@ -255,6 +303,16 @@ private Preference switchPreference(String title, String summary, BooleanSetting
return preference;
}

private Preference buttonPreference(String title, String summary, String key) {
Preference preference = new Preference(context);
preference.setKey(key);
preference.setTitle(title);
preference.setSummary(summary);
preference.setOnPreferenceClickListener(this);

return preference;
}

private Preference listPreference(String title, String summary, StringSetting setting) {
ListPreference preference = new ListPreference(context);
preference.setTitle(title);
Expand All @@ -274,5 +332,19 @@ private LegacyTwitterPreferenceCategory preferenceCategory(String title, Prefere
screen.addPreference(preferenceCategory);
return preferenceCategory;
}

@Override
public boolean onPreferenceClick(Preference preference) {
String key = preference.getKey();
if(key.equals(Settings.PREMIUM_UNDO_POSTS.key.toString())){
app.revanced.integrations.twitter.Utils.startUndoPostActivity();
}
else if(key.equals(Settings.PREMIUM_ICONS)){
app.revanced.integrations.twitter.Utils.startAppIconNNavIconActivity();
}
return true;
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class SettingsStatus {
public static boolean hideRBMK = false;
public static boolean hideRPinnedPosts = false;

public static boolean enableReaderMode = false;
public static boolean enableUndoPosts = false;
public static boolean enableAppIconNNavIcon = false;


public static void enableDownloadFolder() { changeDownloadEnabled = true; }
public static void enableFont() { enableFontMod = true; }
Expand All @@ -43,9 +47,15 @@ public class SettingsStatus {
public static void hideRevistPinnedPost() { hideRPinnedPosts = true; }
public static void hidePromotedTrends() { hidePromotedTrend = true; }

public static void enableReaderMode() { enableReaderMode = true; }
public static void enableUndoPosts() { enableUndoPosts = true; }
public static void enableAppIconNNavIcon() { enableAppIconNNavIcon = true; }

public static boolean enableTimelineSection(){ return (hideLiveThreads || hideBanner || hideForyou); }
public static boolean enableMiscSection() { return (enableFontMod || hideRecommendedUsers || hideFAB || hideViewCount || hideCommunityNote); }
public static boolean enableAdsSection() {return (hideAds|| hideGAds || hideWTF || hideCTS || hideCTJ || hideDetailedPosts || hideRBMK ||hidePromotedTrend); }

public static boolean enablePremiumSection() {return (enableReaderMode || enableUndoPosts || enableAppIconNNavIcon); }

public static void load() {}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
android.useAndroidX = true
version = 1.7.0
version = 1.8.0-dev.1

0 comments on commit aaa19f2

Please sign in to comment.