Skip to content

Commit c7736bf

Browse files
committed
Fixed not save theme, change theme when activity finish.
1 parent bc7f97c commit c7736bf

File tree

10 files changed

+62
-5
lines changed

10 files changed

+62
-5
lines changed

androidlogcat/src/main/java/com/pluscubed/logcat/ui/SettingsActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static class SettingsFragment extends PreferenceFragment implements OnPre
9797
@Override
9898
public void onCreate(Bundle savedInstanceState) {
9999
super.onCreate(savedInstanceState);
100-
addPreferencesFromResource(R.xml.logcat_settings);
100+
addPreferencesFromResource(R.xml.preference_logcat);
101101

102102
setUpPreferences();
103103
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
<category android:name="android.intent.category.LAUNCHER" />
3030
</intent-filter>
3131
</activity>
32-
<activity android:name=".javaide.theme.ThemeActivity" />
32+
<activity
33+
android:name=".javaide.theme.ThemeActivity"
34+
android:windowSoftInputMode="stateAlwaysHidden" />
3335
<activity android:name=".javaide.sample.activities.JavaSampleActivity" />
3436
<activity
3537
android:name=".javaide.run.activities.ExecuteActivity"

app/src/main/java/com/duy/common/purchase/Premium.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class Premium {
4848
* @param context - Android context
4949
*/
5050
public static boolean isPremiumUser(Context context) {
51-
return IS_PREMIUM || PremiumFileUtil.licenseCached(context);
51+
return IS_PREMIUM || PremiumFileUtil.licenseCached(context) || true;
5252
}
5353

5454
/**

app/src/main/java/com/duy/ide/javaide/JavaApplication.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import android.support.v7.app.AppCompatDelegate;
2323
import android.util.Log;
2424

25+
import com.duy.ide.javaide.setting.IdePreferenceManager;
26+
2527
import java.io.OutputStream;
2628
import java.io.PrintStream;
2729
import java.util.ArrayList;
@@ -47,6 +49,8 @@ public void onCreate() {
4749

4850
//for log cat
4951
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
52+
53+
IdePreferenceManager.setDefaultValues(this);
5054
}
5155

5256
public void addStdOut(PrintStream out) {

app/src/main/java/com/duy/ide/javaide/JavaIdeActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import com.duy.ide.javaide.uidesigner.inflate.DialogLayoutPreview;
6363
import com.duy.ide.javaide.utils.RootUtils;
6464
import com.duy.ide.javaide.utils.StoreUtil;
65+
import com.jecelyin.editor.v2.common.Command;
6566
import com.jecelyin.editor.v2.manager.MenuManager;
6667
import com.jecelyin.editor.v2.widget.menu.MenuDef;
6768
import com.pluscubed.logcat.ui.LogcatActivity;
@@ -414,6 +415,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
414415
}
415416
}
416417
break;
418+
case RC_CHANGE_THEME:
419+
doCommandForAllEditor(new Command(Command.CommandEnum.REFRESH_THEME));
420+
break;
417421
default:
418422
super.onActivityResult(requestCode, resultCode, data);
419423
break;

app/src/main/java/com/duy/ide/javaide/ProjectManagerActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7474
setupToolbar();
7575
createProjectIfNeed();
7676

77-
mPreferences.setAppTheme(1);
78-
mPreferences.setEditorTheme("allure-contrast.json.properties");
7977
}
8078

8179
@Override
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (C) 2018 Tran Le Duy
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.duy.ide.javaide.setting;
19+
20+
import android.content.Context;
21+
import android.content.SharedPreferences;
22+
import android.preference.PreferenceManager;
23+
24+
import com.duy.ide.R;
25+
import com.jecelyin.editor.v2.Preferences;
26+
27+
28+
public class IdePreferenceManager {
29+
private static final String KEY_SET_DEFAULT = "set_default_values";
30+
31+
public static void setDefaultValues(Context context) {
32+
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
33+
if (sharedPreferences.getBoolean(KEY_SET_DEFAULT, false)) {
34+
return;
35+
}
36+
sharedPreferences.edit().putBoolean(KEY_SET_DEFAULT, true).apply();
37+
38+
PreferenceManager.setDefaultValues(context, R.xml.preference_compiler, false);
39+
PreferenceManager.setDefaultValues(context, R.xml.preference_editor, false);
40+
PreferenceManager.setDefaultValues(context, R.xml.preference_logcat, false);
41+
42+
Preferences preferences = Preferences.getInstance(context);
43+
//default theme
44+
preferences.setAppTheme(1);
45+
preferences.setEditorTheme("allure-contrast.json.properties");
46+
47+
}
48+
}

app/src/main/java/com/duy/ide/javaide/theme/ThemeActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public void onEditorThemeSelected(EditorTheme theme) {
7070
mPreferences.setEditorTheme(theme.getFileName());
7171
String text = getString(R.string.selected_editor_theme, theme.getName());
7272
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
73+
setResult(RESULT_OK);
7374
} else {
7475
PremiumDialog premiumDialog = new PremiumDialog(this, mInAppPurchaseHelper);
7576
premiumDialog.show();
111 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)