Skip to content

Commit

Permalink
Merge pull request #12 from ahmedtohamy1/master
Browse files Browse the repository at this point in the history
Add icon for freeze last seen in home
  • Loading branch information
Dev4Mod authored May 10, 2024
2 parents 5f6c682 + 05c1acf commit ee911f1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/src/main/java/com/wmods/wppenhacer/xposed/core/ResId.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public static class string {
public static int edited_history;
public static int dnd_message;
public static int dnd_mode_title;
public static int freezelastseen_message;
public static int freezelastseen_title;
public static int activate;
public static int cancel;
public static int message_original;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void doHook() throws Exception {
var strokeButtons = prefs.getBoolean("strokebuttons", false);
var outlinedIcons = prefs.getBoolean("outlinedicons", false);
var showDnd = prefs.getBoolean("show_dndmode", false);
var showFreezeLastSeen = prefs.getBoolean("show_freezeLastSeen", false);
var removechannelRec = prefs.getBoolean("removechannel_rec", false);
var separateGroups = prefs.getBoolean("separategroups", false);
var filterSeen = prefs.getBoolean("filterseen", false);
Expand Down Expand Up @@ -157,6 +158,9 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
itemMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
}
if (showFreezeLastSeen) {
InsertFreezeLastSeenOption(menu, home);
}
if (showDnd) {
InsertDNDOption(menu, home);
} else {
Expand Down Expand Up @@ -311,6 +315,29 @@ private static void InsertDNDOption(Menu menu, Activity home) {
});
}

@SuppressLint({"DiscouragedApi", "UseCompatLoadingForDrawables", "ApplySharedPref"})
private static void InsertFreezeLastSeenOption(Menu menu, Activity home) {
final boolean[] freezelastseen = {WppCore.getPrivBoolean("freezelastseen", false)};
int iconDraw = Utils.getID("ic_status_receipts_disabled_shadow", "drawable");
MenuItem item = menu.add(0, 0, 0, "Freeze Last Seen " + freezelastseen[0]);
item.setIcon(iconDraw);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
item.setOnMenuItemClickListener(menuItem -> {
new AlertDialogWpp(home)
.setTitle(home.getString(ResId.string.freezelastseen_title))
.setMessage(home.getString(ResId.string.freezelastseen_message))
.setPositiveButton(home.getString(ResId.string.activate), (dialog, which) -> {
freezelastseen[0] = !freezelastseen[0]; // Toggle the value
WppCore.setPrivBoolean("freezelastseen", freezelastseen[0]);
item.setTitle("Freeze Last Seen " + freezelastseen[0]);
restartApp(home);
})
.setNegativeButton(home.getString(ResId.string.cancel), (dialog, which) -> dialog.dismiss())
.create().show();
return true;
});
}

@NonNull
@Override
public String getPluginName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.wmods.wppenhacer.xposed.core.Unobfuscator;
import com.wmods.wppenhacer.xposed.core.Feature;
import com.wmods.wppenhacer.xposed.core.WppCore;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
Expand All @@ -21,7 +22,7 @@ public void doHook() throws Exception {
XposedBridge.hookMethod(method, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) {
if (prefs.getBoolean("freezelastseen", false))
if (WppCore.getPrivBoolean("freezelastseen", false))
param.setResult(null);
}
});
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,8 @@
<string name="hideread_group_sum">View messages in groups screen without users knowing</string>
<string name="time_limit_on_status_video">Increase time limit on status video</string>
<string name="time_limit_on_status_video_sum">Increase time limit on status videos from 30 seconds to 1 minute (for everyone)</string>
<string name="show_freezeLastSeen_button">Show Freeze Last Seen Button</string>
<string name="show_freezeLastSeen_sum">Show button for Freezing Last Seen on home screen toolbar </string>
<string name="freezelastseen_message">When Freeze Last Seen is on, you will be unable to see others last seen time or online</string>
<string name="freezelastseen_title">Freeze Last Seen</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/xml/fragment_general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
app:summary="@string/enable_restart_button_sum"
app:title="@string/enable_restart_button" />

<rikka.material.preference.MaterialSwitchPreference
app:key="show_freezeLastSeen"
app:defaultValue="true"
app:summary="@string/show_freezeLastSeen_sum"
app:title="@string/show_freezeLastSeen_button" />

</PreferenceCategory>

<PreferenceCategory
Expand Down

0 comments on commit ee911f1

Please sign in to comment.