Skip to content

Commit

Permalink
[VXP]: make conservation mode default on.
Browse files Browse the repository at this point in the history
  • Loading branch information
weishu.tws committed May 9, 2018
1 parent 3cb9d2e commit 1dcc3ce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions VirtualApp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {
applicationId "io.va.exposed"
minSdkVersion 21
targetSdkVersion 22
versionCode 98
versionName "0.9.8"
versionCode 99
versionName "0.9.9"
multiDexEnabled false
android {
defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class SettingsActivity extends Activity {
private static final String INSTALL_GMS_KEY = "advance_settings_install_gms";
public static final String DIRECTLY_BACK_KEY = "advance_settings_directly_back";
private static final String COPY_FILE = "advance_settings_copy_file";
private static final String YIELD_MODE = "advance_settings_yield_mode";
private static final String YIELD_MODE = "advance_settings_yield_mode2";
private static final String RECOMMEND_PLUGIN = "settings_plugin_recommend";

@Override
Expand Down Expand Up @@ -98,8 +98,6 @@ public void onCreate(Bundle savedInstanceState) {
});

recommend.setOnPreferenceClickListener(preference -> {
// Uri uri = Uri.parse("https://github.com/android-hacker/VirtualXposed/wiki/Recommend-Xposed-Module");
// Intent t = new Intent(Intent.ACTION_VIEW, uri);
startActivity(new Intent(getActivity(), RecommendPluginActivity.class));
return false;
});
Expand Down Expand Up @@ -272,15 +270,16 @@ public void onCreate(Bundle savedInstanceState) {
return false;
}));

File yieldFile = getActivity().getFileStreamPath("yieldMode");
yieldMode.setOnPreferenceChangeListener((preference, newValue) -> {

if (!(newValue instanceof Boolean)) {
return false;
}

boolean on = (boolean) newValue;
if (on) {

File yieldFile = getActivity().getFileStreamPath("yieldMode2"); // 文件不存在代表是保守模式
if (!on) {
boolean success;
try {
success = yieldFile.createNewFile();
Expand All @@ -289,7 +288,7 @@ public void onCreate(Bundle savedInstanceState) {
}
return success;
} else {
return yieldFile.delete();
return !yieldFile.exists() || yieldFile.delete();
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions VirtualApp/app/src/main/res/xml/settings_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
android:title="@string/advance_settings_directly_back" />

<SwitchPreference
android:defaultValue="false"
android:key="advance_settings_yield_mode"
android:defaultValue="true"
android:key="advance_settings_yield_mode2"
android:persistent="true"
android:summary="@string/advance_settings_yield_mode_summary"
android:title="@string/advance_settings_yield_mode" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private void bindApplicationNoCheck(String packageName, String processName, Cond
}

private void initForYieldMode() {
if (VirtualCore.get().getContext().getFileStreamPath("yieldMode").exists()) {
if (!VirtualCore.get().getContext().getFileStreamPath("yieldMode2").exists()) {
System.setProperty("yieldMode", "true");
}
}
Expand Down

0 comments on commit 1dcc3ce

Please sign in to comment.