Skip to content

Commit 4e84f8a

Browse files
committed
+action bar title
=mod customize url edit experience =mod purple color to teal
1 parent ed69944 commit 4e84f8a

10 files changed

Lines changed: 66 additions & 33 deletions

File tree

app/src/main/java/daylemk/xposed/xbridge/action/SearchAction.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ public static void loadPreference(SharedPreferences preferences) {
9292
+ "isShow:" + isShow + "isCustomize:" + isCustomize + "url:" + url);
9393
}
9494

95-
@Override
96-
protected Intent getIntent(Hook hook, Context context, String pkgName) {
97-
Intent intent = new Intent(Intent.ACTION_VIEW);
98-
// check if we should use default url or default url
95+
/**
96+
* get final url search action will use
97+
*
98+
* @return url search action will use
99+
*/
100+
public static String getUrl() {
99101
String str = urlDefault;
100102
if (isCustomize) {
101103
Log.d(TAG, "search url customized: " + url);
@@ -105,6 +107,14 @@ protected Intent getIntent(Hook hook, Context context, String pkgName) {
105107
Log.d(TAG, "new url didn't contain prefix, new:" + str);
106108
}
107109
}
110+
return str;
111+
}
112+
113+
@Override
114+
protected Intent getIntent(Hook hook, Context context, String pkgName) {
115+
Intent intent = new Intent(Intent.ACTION_VIEW);
116+
// check if we should use default url or default url
117+
String str = getUrl();
108118
intent.setData(Uri.parse(str + pkgName));
109119
return intent;
110120
}

app/src/main/java/daylemk/xposed/xbridge/ui/HeaderPreferenceFragment.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package daylemk.xposed.xbridge.ui;
22

3+
import android.app.ActionBar;
34
import android.app.Fragment;
45
import android.os.Bundle;
56
import android.preference.Preference;
6-
import android.preference.SwitchPreference;
77
import android.support.annotation.NonNull;
88
import android.view.LayoutInflater;
99
import android.view.View;
@@ -30,6 +30,7 @@ public abstract class HeaderPreferenceFragment extends AbstractPreferenceFragmen
3030
.OnSwitchChangeListener, Preference
3131
.OnPreferenceChangeListener {
3232
public static final String TAG = "HeaderPreferenceFragment";
33+
public static final String ARGS_TITLE = "title";
3334

3435
// the inflated view
3536
protected View view;
@@ -57,6 +58,13 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
5758
@Override
5859
public void onActivityCreated(Bundle savedInstanceState) {
5960
super.onActivityCreated(savedInstanceState);
61+
Bundle bundle = getArguments();
62+
if (bundle != null && bundle.containsKey(ARGS_TITLE)) {
63+
ActionBar actionBar = this.getActivity().getActionBar();
64+
if (actionBar != null) {
65+
actionBar.setTitle(bundle.getInt(ARGS_TITLE));
66+
}
67+
}
6068
switchBar = (SwitchBar) view.findViewById(R.id.switch_bar);
6169
switchBar.addOnSwitchChangeListener(this);
6270
list = (ListView) view.findViewById(android.R.id.list);
@@ -112,22 +120,9 @@ protected void addPreferences2TheList(Preference... preference) {
112120
Collections.addAll(preferenceList, preference);
113121
}
114122

115-
/**
116-
* will store preference key and value to the disk
117-
*
118-
* @param preference the changed preference
119-
* @param newValue the new value
120-
* @return if we handle it
121-
*/
122123
@Override
123124
public boolean onPreferenceChange(Preference preference, Object newValue) {
124-
Log.d(TAG, "preference key: " + preference.getKey() + ", " + newValue);
125-
if (preference instanceof SwitchPreference) {
126-
MainPreferences.getEditablePreferences(getPreferenceManager()).edit().putBoolean(
127-
preference.getKey(),
128-
(boolean) newValue)
129-
.commit();
130-
}
125+
Log.d(TAG, "changed preference: " + preference + ", newValue: " + newValue);
131126
return true;
132127
}
133128
}

app/src/main/java/daylemk/xposed/xbridge/ui/SearchFragment.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import daylemk.xposed.xbridge.R;
1414
import daylemk.xposed.xbridge.action.SearchAction;
15+
import daylemk.xposed.xbridge.utils.Log;
1516

1617
/**
1718
* Created by DayLemK on 2015/5/14.
@@ -54,6 +55,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
5455
preferenceAppInfo.setOnPreferenceChangeListener(this);
5556
preferenceCustomizeUrl.setOnPreferenceChangeListener(this);
5657
preferenceUrl.setOnPreferenceChangeListener(this);
58+
// set summary on preference created
59+
preferenceUrl.setSummary(SearchAction.getUrl());
5760
// set values
5861
// preferenceStatusBar.setChecked(PlayAction.isShowInStatusBar);
5962
// preferenceRecentTask.setChecked(PlayAction.isShowInRecentTask);
@@ -78,6 +81,13 @@ public void onActivityCreated(Bundle savedInstanceState) {
7881
@Override
7982
public boolean onPreferenceChange(Preference preference, Object newValue) {
8083
super.onPreferenceChange(preference, newValue);
84+
if (preference.equals(preferenceUrl)) {
85+
Log.d(TAG, "url changed: " + newValue);
86+
// set the new value
87+
SearchAction.url = (String) newValue;
88+
// set summary on preference changed
89+
preferenceUrl.setSummary(SearchAction.getUrl());
90+
}
8191
return true;
8292
}
8393

app/src/main/java/daylemk/xposed/xbridge/ui/XBridgeFragment.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package daylemk.xposed.xbridge.ui;
22

3+
import android.app.ActionBar;
34
import android.app.FragmentTransaction;
45
import android.os.Bundle;
56
import android.preference.Preference;
@@ -71,6 +72,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
7172
@Override
7273
public void onStart() {
7374
super.onStart();
75+
// set actionbar name
76+
ActionBar actionBar = this.getActivity().getActionBar();
77+
if (actionBar != null) {
78+
actionBar.setTitle(R.string.app_name);
79+
}
7480
if (need2Load) {
7581
// here should set the preference value???
7682
playPreference.setChecked(PlayAction.isShow);
@@ -94,20 +100,26 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, @NonNull
94100
Log.d(TAG, "clicked preference: " + prefKey);
95101
PreferenceFragment fragment = null;
96102
String tag = null;
103+
Bundle bundle = new Bundle();
97104
if (PlayAction.keyShow.equals(prefKey)) {
98-
fragment = PlayFragment.getFragment(null);
105+
bundle.putInt(HeaderPreferenceFragment.ARGS_TITLE, R.string.title_play);
106+
fragment = PlayFragment.getFragment(bundle);
99107
tag = PlayFragment.TAG;
100108
} else if (AppOpsAction.keyShow.equals(prefKey)) {
101-
fragment = AppOpsFragment.getFragment(null);
109+
bundle.putInt(HeaderPreferenceFragment.ARGS_TITLE, R.string.title_appops);
110+
fragment = AppOpsFragment.getFragment(bundle);
102111
tag = AppOpsFragment.TAG;
103112
} else if (AppSettingsAction.keyShow.equals(prefKey)) {
104-
fragment = AppSettingsFragment.getFragment(null);
113+
bundle.putInt(HeaderPreferenceFragment.ARGS_TITLE, R.string.title_appsettings);
114+
fragment = AppSettingsFragment.getFragment(bundle);
105115
tag = AppSettingsFragment.TAG;
106116
} else if (ClipBoardAction.keyShow.equals(prefKey)) {
107-
fragment = ClipBoardFragment.getFragment(null);
117+
bundle.putInt(HeaderPreferenceFragment.ARGS_TITLE, R.string.title_clipboard);
118+
fragment = ClipBoardFragment.getFragment(bundle);
108119
tag = ClipBoardFragment.TAG;
109120
} else if (SearchAction.keyShow.equals(prefKey)) {
110-
fragment = SearchFragment.getFragment(null);
121+
bundle.putInt(HeaderPreferenceFragment.ARGS_TITLE, R.string.title_search);
122+
fragment = SearchFragment.getFragment(bundle);
111123
tag = SearchFragment.TAG;
112124
}
113125

app/src/main/res/values/colors_brown_indigo.xml renamed to app/src/main/res/values/colors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<color name="primary">#795548</color>
55
<color name="primary_dark">#5D4037</color>
66
<color name="primary_light">#D7CCC8</color>
7-
<color name="accent">#536DFE</color>
7+
<color name="accent">#009688</color>
88
<color name="primary_text">#212121</color>
99
<color name="secondary_text">#727272</color>
1010
<color name="icons">#FFFFFF</color>

app/src/main/res/values/strings.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,19 @@
4646
<string name="title_clipboard">Copy to clipboard</string>
4747
<string name="summary_search">Add search button in the system</string>
4848
<string name="title_search">Search</string>
49-
<string name="summary_appops">Add view in AppOps button in the system</string>
50-
<string name="title_appops">View in AppOps</string>
49+
<string name="summary_appops">Add view in AppOpsXposed button in the system</string>
50+
<string name="title_appops">View in AppOpsXposed</string>
5151
<string name="summary_appsettings">Add view in AppSettings button in the system</string>
5252
<string name="title_appsettings">View in AppSettings</string>
5353
<string name="title_xda">XDA thread</string>
5454
<string name="title_forcestop">Force stop package</string>
5555
<string name="summary_forcestop">In the recent task screen, long press dismiss button(x) to force stop package</string>
5656
<string name="summary_show_dismiss">Show dismiss button immediately when recent task screen show up</string>
5757
<string name="title_show_dismiss">Show dismiss button immediately</string>
58+
<string name="title_search_url">Search url</string>
59+
<string name="title_customize_url">Customize search url</string>
60+
<string name="title_customize">Customize</string>
61+
<string name="summary_appops_show_in_app_info">AppOpsXposed already do itself :)</string>
62+
<string name="title_about">About</string>
5863

5964
</resources>

app/src/main/res/xml/preference_appops.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
<SwitchPreference
1818
android:checked="false"
1919
android:enabled="false"
20-
android:title="Show in app info"
20+
android:summary="@string/summary_appops_show_in_app_info"
21+
android:title="@string/title_show_in_app_info"
2122
>
2223
</SwitchPreference>
2324

app/src/main/res/xml/preference_search.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
android:summary="@string/summary_show_in_app_info"
2020
android:title="@string/title_show_in_app_info">
2121
</SwitchPreference>
22-
<PreferenceCategory android:title="Customize">
22+
<PreferenceCategory android:title="@string/title_customize">
2323
<SwitchPreference
2424
android:defaultValue="@bool/search_customize_default"
2525
android:key="@string/key_search_customize_url"
26-
android:title="Customize search url">
26+
android:title="@string/title_customize_url">
2727
</SwitchPreference>
2828
<EditTextPreference
2929
android:defaultValue="@string/search_url_default"
3030
android:dependency="@string/key_search_customize_url"
3131
android:key="@string/key_search_url"
32-
android:title="search url">
32+
android:title="@string/title_search_url">
3333

3434
</EditTextPreference>
3535
</PreferenceCategory>

app/src/main/res/xml/preference_xbridge.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</SwitchPreference>
4747
</PreferenceCategory>
4848

49-
<PreferenceCategory android:title="About" >
49+
<PreferenceCategory android:title="@string/title_about">
5050
<Preference
5151
android:selectable="false"
5252
android:title="@string/app_name"/>

switchbar/src/main/res/values/colors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
<resources>
1818

1919
<color name="switchbar_background_color">#5D4037</color>
20-
<color name="switch_accent_color">#536DFE</color>
20+
<color name="switch_accent_color">#009688</color>
2121
</resources>

0 commit comments

Comments
 (0)