Skip to content
This repository has been archived by the owner on Jul 25, 2020. It is now read-only.

Commit

Permalink
Fixed settings tile fix, removed print tile summary
Browse files Browse the repository at this point in the history
  • Loading branch information
wasdennnoch committed Mar 28, 2016
1 parent d9ed031 commit a8d1e19
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedHelpers;
import tk.wasdennnoch.androidn_ify.XposedHook;
import tk.wasdennnoch.androidn_ify.settings.summaries.SummaryTweaks;
import tk.wasdennnoch.androidn_ify.ui.SettingsActivity;

public class DoubleTapHwKeys extends DoubleTapBase {
Expand Down Expand Up @@ -48,12 +47,6 @@ public void run() {
public void onReceive(Context context, Intent intent) {
XposedHook.logD(TAG, "Broadcast received: " + intent);
switch (intent.getAction()) {
// Needs to be here because the settings don't get informed about changes when
// they aren't open (the BroadcastReceiver gets unregistered in onDestroy)
case SettingsActivity.ACTION_SETTINGS_CHANGED:
if (intent.hasExtra(SettingsActivity.EXTRA_SETTINGS_FIX_SOUND_NOTIF_TILE))
SummaryTweaks.setFixSoundNotifTile(intent.getBooleanExtra(SettingsActivity.EXTRA_SETTINGS_FIX_SOUND_NOTIF_TILE, false));
break;
case SettingsActivity.ACTION_RECENTS_CHANGED:
if (intent.hasExtra(SettingsActivity.EXTRA_RECENTS_DOUBLE_TAP_SPEED))
mDoubletapSpeed = intent.getIntExtra(SettingsActivity.EXTRA_RECENTS_DOUBLE_TAP_SPEED, 400);
Expand All @@ -74,7 +67,6 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mHandler = (Handler) XposedHelpers.getObjectField(mPhoneWindowManager, "mHandler");
// No need to unregister this because the system process will last "forever"
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(SettingsActivity.ACTION_SETTINGS_CHANGED);
intentFilter.addAction(SettingsActivity.ACTION_RECENTS_CHANGED);
intentFilter.addAction(SettingsActivity.ACTION_GENERAL);
mContext.registerReceiver(sBroadcastReceiver, intentFilter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,30 @@
public class SettingsHooks {

private static final String TAG = "SettingsHooks";
private static XSharedPreferences sPrefs;

/*private static XC_MethodHook onCreateHook = new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
SummaryTweaks.afterOnCreate(param);
}
};*/
private static XC_MethodHook loadCategoriesFromResourceHook = new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
SummaryTweaks.afterLoadCategoriesFromResource(param);
SummaryTweaks.afterLoadCategoriesFromResource(param, sPrefs);
}
};

public static void hook(ClassLoader classLoader, XSharedPreferences prefs) {
try {
sPrefs = prefs;
prefs.reload();
if (prefs.getBoolean("enable_settings_tweaks", true)) {

Class<?> classSettingsActivity = XposedHelpers.findClass("com.android.settings.SettingsActivity", classLoader);

SummaryTweaks.setFixSoundNotifTile(prefs.getBoolean("fix_sound_notif_tile", false));
//XposedHelpers.findAndHookMethod(classSettingsActivity, "onCreate", Bundle.class, onCreateHook);

if (Build.VERSION.SDK_INT >= 23)
XposedHelpers.findAndHookMethod(classSettingsActivity, "loadCategoriesFromResource", int.class, List.class, Context.class, loadCategoriesFromResourceHook);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedHelpers;
import tk.wasdennnoch.androidn_ify.XposedHook;
import tk.wasdennnoch.androidn_ify.settings.summaries.categories.DeviceTweaks;
Expand All @@ -18,8 +19,8 @@
public class SummaryTweaks {

private static final String TAG = "SummaryTweaks";
private static boolean sFixSoundNotifTile = false;

private static boolean sFixSoundNotifTile;
//private static Handler sHandler;

// All tiles. Tiles without a subtitle are commented out to improve performance.
// They will be removed completely in the near future.
Expand Down Expand Up @@ -55,7 +56,7 @@ public class SummaryTweaks {
// SYSTEM
private static int date_time_settings;
//private static int accessibility_settings;
private static int print_settings;
//private static int print_settings; // TODO Temporary disabled, takes very long time to process, async required
//private static int development_settings;
private static int about_settings;

Expand All @@ -75,10 +76,17 @@ public class SummaryTweaks {
//private static int privacy_settings_cyanogenmod;
//private static int supersu_settings;

public static void afterLoadCategoriesFromResource(XC_MethodHook.MethodHookParam param) {
/*public static void afterOnCreate(XC_MethodHook.MethodHookParam param) {
sHandler = (Handler) XposedHelpers.getObjectField(param.thisObject, "mHandler");
}*/

public static void afterLoadCategoriesFromResource(XC_MethodHook.MethodHookParam param, XSharedPreferences prefs) {
try {
long startTime = System.currentTimeMillis();

prefs.reload();
sFixSoundNotifTile = prefs.getBoolean("fix_sound_notif_tile", false);

Context context;
if (Build.VERSION.SDK_INT >= 23)
context = (Context) param.args[2];
Expand All @@ -100,10 +108,6 @@ public static void afterLoadCategoriesFromResource(XC_MethodHook.MethodHookParam
}
}

public static void setFixSoundNotifTile(boolean fix) {
sFixSoundNotifTile = fix;
}

private static void setupIds(Context context) {
long startTime = System.currentTimeMillis();

Expand Down Expand Up @@ -134,7 +138,7 @@ private static void setupIds(Context context) {

date_time_settings = getId(context, "date_time_settings");
//accessibility_settings = getId(context, "accessibility_settings");
print_settings = getId(context, "print_settings");
//print_settings = getId(context, "print_settings");
//development_settings = getId(context, "development_settings");
about_settings = getId(context, "about_settings");

Expand Down Expand Up @@ -236,9 +240,9 @@ private static void setSummaries(List tiles, Context context) {
SystemTweaks.hookDateTimeTile(tile);
//} else if (id == accessibility_settings) {
// XposedHelpers.setObjectField(tile, "summary", "accessibility_settings");
} else if (id == print_settings) {
tileId = "print_settings";
SystemTweaks.hookPrintTile(tile, context);
//} else if (id == print_settings) {
// tileId = "print_settings";
// SystemTweaks.hookPrintTile(tile, context);
//} else if (id == development_settings) {
// XposedHelpers.setObjectField(tile, "summary", "development_settings");
} else if (id == about_settings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

public class SettingsActivity extends Activity {

public static final String ACTION_SETTINGS_CHANGED = "an.action.ACTION_SETTINGS_CHANGED";
public static final String EXTRA_SETTINGS_FIX_SOUND_NOTIF_TILE = "an.extra.settings.FIX_SOUND_NOTIF_TILE";
//public static final String ACTION_SETTINGS_CHANGED = "an.action.ACTION_SETTINGS_CHANGED";
//public static final String EXTRA_SETTINGS_FIX_SOUND_NOTIF_TILE = "an.extra.settings.FIX_SOUND_NOTIF_TILE";

public static final String ACTION_RECENTS_CHANGED = "an.action.ACTION_RECENTS_CHANGED";
public static final String EXTRA_RECENTS_DOUBLE_TAP_SPEED = "an.extra.recents.DOUBLE_TAP_SPEED";
Expand Down Expand Up @@ -78,10 +78,6 @@ public void onPause() {
private void sendUpdateBroadcast(SharedPreferences prefs, String key) {
Intent intent = new Intent();
switch (key) {
case "fix_sound_notif_tile":
intent.setAction(ACTION_SETTINGS_CHANGED);
intent.putExtra(EXTRA_SETTINGS_FIX_SOUND_NOTIF_TILE, prefs.getBoolean(key, false));
break;
case "double_tap_speed":
intent.setAction(ACTION_RECENTS_CHANGED);
intent.putExtra(EXTRA_RECENTS_DOUBLE_TAP_SPEED, prefs.getInt(key, 400));
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
monitorBoxEnabled="true"
monitorBoxUnit="ms"
android:defaultValue="400"
android:dependency="enable_recents_tweaks"
android:key="double_tap_speed"
android:title="@string/double_tap_speed_title"/>

Expand Down
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
v0.1.2:

- Fixed double-tap recents - again.
- Fixed settings tile fix
- Removed print tile summary (was huge performance issue)

v0.1.1:

Expand Down

0 comments on commit a8d1e19

Please sign in to comment.