• R/O
  • SSH
  • HTTPS

androidstudying: Commit


Commit MetaInfo

Revision61 (tree)
Time2020-03-04 03:56:53
Authorpbtdanh

Log Message

* update

Change Summary

Incremental Difference

--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/prefs/AppPreferencesHelper.java (revision 60)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/local/prefs/AppPreferencesHelper.java (revision 61)
@@ -4,6 +4,7 @@
44 import android.content.SharedPreferences;
55 import android.graphics.Point;
66
7+import com.xynotec.dictdroid.di.PreferenceInfo;
78 import com.xynotec.utils.Util;
89
910 import javax.inject.Inject;
@@ -10,7 +11,6 @@
1011
1112 public class AppPreferencesHelper implements PreferencesHelper {
1213
13- final static String APPNAMEREF = "XynotecDictdroid";
1414 final static String FROMLANGSETTING = "FromLangSetting";
1515 final static String TOLANGSETTING = "ToLangSetting";
1616 final static String SWAPDICTSETTING = "SwapDictSetting";
@@ -38,125 +38,149 @@
3838 private final SharedPreferences mPrefs;
3939
4040 @Inject
41- public AppPreferencesHelper(Context context, String prefFileName) {
41+ public AppPreferencesHelper(Context context, @PreferenceInfo String prefFileName) {
4242 mPrefs = context.getSharedPreferences(prefFileName, Context.MODE_PRIVATE);
4343 }
4444
45+ @Override
4546 public void setFromLangRecentIndex(Context context, int index)
4647 {
4748 mPrefs.edit().putInt(FROMLANGSETTING, index).apply();
4849 }
4950
51+ @Override
5052 public int getFromLangRecentIndex(Context context)
5153 {
5254 return mPrefs.getInt(FROMLANGSETTING, 0);
5355 }
5456
57+ @Override
5558 public void setToLangRecentIndex(Context context, int index)
5659 {
5760 mPrefs.edit().putInt(TOLANGSETTING, index).apply();
5861 }
5962
63+ @Override
6064 public int getToLangRecentIndex(Context context)
6165 {
6266 return mPrefs.getInt(TOLANGSETTING, 0);
6367 }
6468
69+ @Override
6570 public void setSwapDict(Context context, boolean bSwap)
6671 {
6772 mPrefs.edit().putBoolean(SWAPDICTSETTING, bSwap).apply();
6873 }
6974
75+ @Override
7076 public boolean getSwapDict(Context context)
7177 {
7278 return mPrefs.getBoolean(SWAPDICTSETTING, false);
7379 }
7480
81+ @Override
7582 public void setRemoveAds(Context context, boolean bRemoved)
7683 {
7784 mPrefs.edit().putBoolean(REMOVEADSSETTING, bRemoved).apply();
7885 }
7986
87+ @Override
8088 public boolean getRemovedAds(Context context)
8189 {
8290 return mPrefs.getBoolean(REMOVEADSSETTING, false);
8391 }
8492
93+ @Override
8594 public void setAppCodeVersion(Context context, int codeVersion)
8695 {
8796 mPrefs.edit().putInt(APPVERSIONSETTING, codeVersion).apply();
8897 }
8998
99+ @Override
90100 public int getAppCodeVersion(Context context)
91101 {
92102 return mPrefs.getInt(APPVERSIONSETTING, 0);
93103 }
94104
105+ @Override
95106 public void setTTSEngine(Context context, boolean bTTS)
96107 {
97108 mPrefs.edit().putBoolean(TTS_ENGINE_SETTING, bTTS).apply();
98109 }
99110
111+ @Override
100112 public boolean getTTSEngine(Context context)
101113 {
102114 return mPrefs.getBoolean(TTS_ENGINE_SETTING, true);
103115 }
104116
117+ @Override
105118 public void setZoomScale(Context context, int scale)
106119 {
107120 mPrefs.edit().putInt(ZOOM_SCALE_SETTING, scale).apply();
108121 }
109122
123+ @Override
110124 public int getZoomScale(Context context)
111125 {
112126 return mPrefs.getInt(ZOOM_SCALE_SETTING, 150);
113127 }
114128
129+ @Override
115130 public void setQSZoomScale(Context context, int scale)
116131 {
117132 mPrefs.edit().putInt(QS_ZOOM_SCALE_SETTING, scale).apply();
118133 }
119134
135+ @Override
120136 public int getQSZoomScale(Context context)
121137 {
122- mPrefs.getInt(QS_ZOOM_SCALE_SETTING, 100);
138+ return mPrefs.getInt(QS_ZOOM_SCALE_SETTING, 100);
123139 }
124140
141+ @Override
125142 public void setAutoLookup(Context context, boolean bAutoLookup)
126143 {
127144 mPrefs.edit().putBoolean(AUTO_LOOKUP_SETTING, bAutoLookup).apply();
128145 }
129146
147+ @Override
130148 public boolean getAutoLookup(Context context)
131149 {
132150 return mPrefs.getBoolean(AUTO_LOOKUP_SETTING, false);
133151 }
134152
153+ @Override
135154 public void setPopUpPosX(Context context, int posX)
136155 {
137156 mPrefs.edit().putInt(POPUP_POS_X_SETTING, posX).apply();
138157 }
139158
159+ @Override
140160 public int getPopUpPosX(Context context)
141161 {
142162 return mPrefs.getInt(POPUP_POS_X_SETTING, 0);
143163 }
144164
165+ @Override
145166 public void setPopUpPosY(Context context, int posY)
146167 {
147168 mPrefs.edit().putInt(POPUP_POS_Y_SETTING, posY).apply();
148169 }
149170
171+ @Override
150172 public int getPopUpPosY(Context context)
151173 {
152174 return mPrefs.getInt(POPUP_POS_X_SETTING, 0);
153175 }
154176
177+ @Override
155178 public void setPopUpSizeWidth(Context context, int width)
156179 {
157180 mPrefs.edit().putInt(POPUP_SIZE_W_SETTING, width).apply();
158181 }
159182
183+ @Override
160184 public int getPopUpSizeWidth(Context context)
161185 {
162186 Point sizeScreen = Util.getDisplaySize(context);
@@ -168,11 +192,13 @@
168192 return mPrefs.getInt(POPUP_SIZE_W_SETTING, defaultWidth);
169193 }
170194
195+ @Override
171196 public void setPopUpSizeHeight(Context context, int height)
172197 {
173198 mPrefs.edit().putInt(POPUP_SIZE_H_SETTING, height).apply();
174199 }
175200
201+ @Override
176202 public int getPopUpSizeHeight(Context context)
177203 {
178204 Point sizeScreen = Util.getDisplaySize(context);
--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/AppDataManager.java (revision 60)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/AppDataManager.java (revision 61)
@@ -3,6 +3,7 @@
33 import android.content.Context;
44
55 import com.google.gson.Gson;
6+import com.xynotec.dictdroid.data.local.prefs.PreferencesHelper;
67 import com.xynotec.dictdroid.data.remote.ApiHelper;
78 //import com.xynotec.coinmarketcap.data.remote.cryptocurrency.listting.latest.CryptocurrencyListingsLatestResponse;
89 //import com.xynotec.coinmarketcap.data.remote.cryptocurrency.quotes.latest.CryptocurrencyQuotesLatestResponse;
@@ -20,14 +21,147 @@
2021 private final Gson mGson;
2122 private final ApiHelper mApiHelper;
2223
24+ private final PreferencesHelper mPreferencesHelper;
25+
2326 @Inject
24- public AppDataManager(Context context, ApiHelper apiHelper, Gson gson) {
27+ public AppDataManager(Context context, PreferencesHelper preferencesHelper, ApiHelper apiHelper, Gson gson) {
2528 mContext = context;
29+ mPreferencesHelper = preferencesHelper;
2630 mApiHelper = apiHelper;
2731 mGson = gson;
2832 }
2933
30-// @Override
34+ @Override
35+ public void setFromLangRecentIndex(Context context, int index) {
36+ mPreferencesHelper.setFromLangRecentIndex(context, index);
37+ }
38+
39+ @Override
40+ public int getFromLangRecentIndex(Context context) {
41+ return mPreferencesHelper.getFromLangRecentIndex(context);
42+ }
43+
44+ @Override
45+ public void setToLangRecentIndex(Context context, int index) {
46+ mPreferencesHelper.setToLangRecentIndex(context, index);
47+ }
48+
49+ @Override
50+ public int getToLangRecentIndex(Context context) {
51+ return mPreferencesHelper.getToLangRecentIndex(context);
52+ }
53+
54+ @Override
55+ public void setSwapDict(Context context, boolean bSwap) {
56+ mPreferencesHelper.setSwapDict(context, bSwap);
57+ }
58+
59+ @Override
60+ public boolean getSwapDict(Context context) {
61+ return mPreferencesHelper.getSwapDict(context);
62+ }
63+
64+ @Override
65+ public void setRemoveAds(Context context, boolean bRemovedAds) {
66+ mPreferencesHelper.setRemoveAds(context, bRemovedAds);
67+ }
68+
69+ @Override
70+ public boolean getRemovedAds(Context context) {
71+ return mPreferencesHelper.getRemovedAds(context);
72+ }
73+
74+ @Override
75+ public void setAppCodeVersion(Context context, int codeVersion) {
76+ mPreferencesHelper.setAppCodeVersion(context, codeVersion);
77+ }
78+
79+ @Override
80+ public int getAppCodeVersion(Context context) {
81+ return mPreferencesHelper.getAppCodeVersion(context);
82+ }
83+
84+ @Override
85+ public void setTTSEngine(Context context, boolean bTTS) {
86+ mPreferencesHelper.setTTSEngine(context, bTTS);
87+ }
88+
89+ @Override
90+ public boolean getTTSEngine(Context context) {
91+ return mPreferencesHelper.getTTSEngine(context);
92+ }
93+
94+ @Override
95+ public void setZoomScale(Context context, int scale) {
96+ mPreferencesHelper.setZoomScale(context, scale);
97+ }
98+
99+ @Override
100+ public int getZoomScale(Context context) {
101+ return mPreferencesHelper.getZoomScale(context);
102+ }
103+
104+ @Override
105+ public void setQSZoomScale(Context context, int scale) {
106+ mPreferencesHelper.setQSZoomScale(context, scale);
107+ }
108+
109+ @Override
110+ public int getQSZoomScale(Context context) {
111+ return mPreferencesHelper.getQSZoomScale(context);
112+ }
113+
114+ @Override
115+ public void setAutoLookup(Context context, boolean bAutoLookup) {
116+ mPreferencesHelper.setAutoLookup(context, bAutoLookup);
117+ }
118+
119+ @Override
120+ public boolean getAutoLookup(Context context) {
121+ return mPreferencesHelper.getAutoLookup(context);
122+ }
123+
124+ @Override
125+ public void setPopUpPosX(Context context, int posX) {
126+ mPreferencesHelper.setPopUpPosX(context, posX);
127+ }
128+
129+ @Override
130+ public int getPopUpPosX(Context context) {
131+ return mPreferencesHelper.getPopUpPosX(context);
132+ }
133+
134+ @Override
135+ public void setPopUpPosY(Context context, int posY) {
136+ mPreferencesHelper.setPopUpPosY(context, posY);
137+ }
138+
139+ @Override
140+ public int getPopUpPosY(Context context) {
141+ return mPreferencesHelper.getPopUpPosY(context);
142+ }
143+
144+ @Override
145+ public void setPopUpSizeWidth(Context context, int width) {
146+ mPreferencesHelper.setPopUpSizeWidth(context, width);
147+ }
148+
149+ @Override
150+ public int getPopUpSizeWidth(Context context) {
151+ return mPreferencesHelper.getPopUpSizeWidth(context);
152+ }
153+
154+ @Override
155+ public void setPopUpSizeHeight(Context context, int height) {
156+ mPreferencesHelper.setPopUpSizeHeight(context, height);
157+ }
158+
159+ @Override
160+ public int getPopUpSizeHeight(Context context) {
161+ return mPreferencesHelper.getPopUpSizeHeight(context);
162+ }
163+
164+ // @Override
31165 // public Single<CryptocurrencyListingsLatestResponse> doCryptoCurrencyListingsLatest(CryptocurrencyListingsLatestResponse.LatestRequest request) {
32166 // return mApiHelper.doCryptoCurrencyListingsLatest(request);
33167 // }
--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/DataManager.java (revision 60)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/data/DataManager.java (revision 61)
@@ -1,7 +1,7 @@
11 package com.xynotec.dictdroid.data;
22
33 import com.xynotec.dictdroid.data.local.dao.DbHelper;
4-import com.xynotec.coinmarketcap.data.local.prefs.PreferencesHelper;
4+import com.xynotec.dictdroid.data.local.prefs.PreferencesHelper;
55 import com.xynotec.dictdroid.data.remote.ApiHelper;
66
77 public interface DataManager extends DbHelper, PreferencesHelper, ApiHelper {
--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/di/AppModule.java (revision 60)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/di/AppModule.java (revision 61)
@@ -7,6 +7,8 @@
77
88 import com.google.gson.Gson;
99 import com.google.gson.GsonBuilder;
10+import com.xynotec.dictdroid.data.local.prefs.AppPreferencesHelper;
11+import com.xynotec.dictdroid.data.local.prefs.PreferencesHelper;
1012 import com.xynotec.dictdroid.ende.BuildConfig;
1113 import com.xynotec.dictdroid.ende.R;
1214 import com.xynotec.dictdroid.data.AppDataManager;
@@ -17,6 +19,7 @@
1719 import com.xynotec.coinmarketcap.utils.rx.SchedulerProvider;
1820 import com.xynotec.dictdroid.engine.DictEngine;
1921 import com.xynotec.dictdroid.engine.DictEngineInternal;
22+import com.xynotec.dictdroid.utils.AppConstants;
2023
2124 import dagger.Module;
2225 import dagger.Provides;
@@ -98,21 +101,21 @@
98101 Log.d(TAG, "provideGson");
99102 return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
100103 }
101-//
104+
105+ @Provides
106+ @PreferenceInfo
107+ String providePreferenceName() {
108+ return AppConstants.APP_PREF_NAME;
109+ }
110+
111+ @Provides
112+ @Singleton
113+ PreferencesHelper providePreferencesHelper(AppPreferencesHelper appPreferencesHelper) {
114+ return appPreferencesHelper;
115+ }
116+
102117 // @Provides
103-// @PreferenceInfo
104-// String providePreferenceName() {
105-// return AppConstants.PREF_NAME;
106-// }
107-//
108-// @Provides
109118 // @Singleton
110-// PreferencesHelper providePreferencesHelper(AppPreferencesHelper appPreferencesHelper) {
111-// return appPreferencesHelper;
112-// }
113-//
114-// @Provides
115-// @Singleton
116119 // ApiHeader.ProtectedApiHeader provideProtectedApiHeader(@ApiInfo String apiKey,
117120 // PreferencesHelper preferencesHelper) {
118121 // return new ApiHeader.ProtectedApiHeader(
--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/utils/AppConstants.java (revision 60)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/dictdroid/utils/AppConstants.java (revision 61)
@@ -1,25 +1,27 @@
1-package com.xynotec.coinmarketcap.utils;
1+package com.xynotec.dictdroid.utils;
22
33 public final class AppConstants {
44
5- public static final int API_STATUS_CODE_LOCAL_ERROR = 0;
5+ public final static String APP_PREF_NAME = "XynotecDictdroid";
66
7- public static final String DB_NAME = "mindorks_mvvm.db";
7+// public static final int API_STATUS_CODE_LOCAL_ERROR = 0;
8+//
9+// public static final String DB_NAME = "mindorks_mvvm.db";
10+//
11+// public static final long NULL_INDEX = -1L;
12+//
13+// public static final String PREF_NAME = "mindorks_pref";
14+//
15+// public static final String SEED_DATABASE_OPTIONS = "seed/options.json";
16+//
17+// public static final String SEED_DATABASE_QUESTIONS = "seed/questions.json";
18+//
19+// public static final String STATUS_CODE_FAILED = "failed";
20+//
21+// public static final String STATUS_CODE_SUCCESS = "success";
22+//
23+// public static final String TIMESTAMP_FORMAT = "yyyyMMdd_HHmmss";
824
9- public static final long NULL_INDEX = -1L;
10-
11- public static final String PREF_NAME = "mindorks_pref";
12-
13- public static final String SEED_DATABASE_OPTIONS = "seed/options.json";
14-
15- public static final String SEED_DATABASE_QUESTIONS = "seed/questions.json";
16-
17- public static final String STATUS_CODE_FAILED = "failed";
18-
19- public static final String STATUS_CODE_SUCCESS = "success";
20-
21- public static final String TIMESTAMP_FORMAT = "yyyyMMdd_HHmmss";
22-
2325 private AppConstants() {
2426 // This utility class is not publicly instantiable
2527 }
--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/utils/AppConstants.java (revision 60)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/utils/AppConstants.java (nonexistent)
@@ -1,26 +0,0 @@
1-package com.xynotec.utils;
2-
3-public final class AppConstants {
4-
5- public static final int API_STATUS_CODE_LOCAL_ERROR = 0;
6-
7- public static final String DB_NAME = "mindorks_mvvm.db";
8-
9- public static final long NULL_INDEX = -1L;
10-
11- public static final String PREF_NAME = "mindorks_pref";
12-
13- public static final String SEED_DATABASE_OPTIONS = "seed/options.json";
14-
15- public static final String SEED_DATABASE_QUESTIONS = "seed/questions.json";
16-
17- public static final String STATUS_CODE_FAILED = "failed";
18-
19- public static final String STATUS_CODE_SUCCESS = "success";
20-
21- public static final String TIMESTAMP_FORMAT = "yyyyMMdd_HHmmss";
22-
23- private AppConstants() {
24- // This utility class is not publicly instantiable
25- }
26-}
--- trunk/dictdroid2020/single/app/src/main/java/com/xynotec/utils/CommonUtils.java (revision 60)
+++ trunk/dictdroid2020/single/app/src/main/java/com/xynotec/utils/CommonUtils.java (revision 61)
@@ -29,9 +29,9 @@
2929 return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
3030 }
3131
32- public static String getTimestamp() {
33- return new SimpleDateFormat(AppConstants.TIMESTAMP_FORMAT, Locale.US).format(new Date());
34- }
32+// public static String getTimestamp() {
33+// return new SimpleDateFormat(AppConstants.TIMESTAMP_FORMAT, Locale.US).format(new Date());
34+// }
3535
3636 public static boolean isEmailValid(String email) {
3737 return Patterns.EMAIL_ADDRESS.matcher(email).matches();
Show on old repository browser