Cleanup STANDARD_DSE_SHORTNAME shared pref
This commit is contained in:
+11
-9
@@ -23,17 +23,20 @@ public class BraveSearchEngineAdapter extends SearchEngineAdapter {
|
||||
private static final String TAG = "BraveSearchEngineAdapter";
|
||||
|
||||
public static final String PRIVATE_DSE_SHORTNAME = "private_dse_shortname";
|
||||
public static final String STANDARD_DSE_SHORTNAME = "standard_dse_shortname";
|
||||
|
||||
private boolean mIsPrivate;
|
||||
|
||||
static public void setDSEPrefs(TemplateUrl templateUrl, boolean isPrivate) {
|
||||
SharedPreferences.Editor sharedPreferencesEditor =
|
||||
ContextUtils.getAppSharedPreferences().edit();
|
||||
sharedPreferencesEditor.putString(
|
||||
isPrivate ? PRIVATE_DSE_SHORTNAME : STANDARD_DSE_SHORTNAME,
|
||||
templateUrl.getShortName());
|
||||
sharedPreferencesEditor.apply();
|
||||
if (isPrivate) {
|
||||
SharedPreferences.Editor sharedPreferencesEditor =
|
||||
ContextUtils.getAppSharedPreferences().edit();
|
||||
sharedPreferencesEditor.putString(PRIVATE_DSE_SHORTNAME, templateUrl.getShortName());
|
||||
sharedPreferencesEditor.apply();
|
||||
} else {
|
||||
// For the regular tab we save DSE in native code
|
||||
String keyword = templateUrl.getKeyword();
|
||||
TemplateUrlServiceFactory.get().setSearchEngine(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
static public void updateActiveDSE(boolean isPrivate) {
|
||||
@@ -72,8 +75,7 @@ public class BraveSearchEngineAdapter extends SearchEngineAdapter {
|
||||
}
|
||||
|
||||
return ContextUtils.getAppSharedPreferences().getString(
|
||||
isPrivate ? PRIVATE_DSE_SHORTNAME : STANDARD_DSE_SHORTNAME,
|
||||
defaultSearchEngineName);
|
||||
PRIVATE_DSE_SHORTNAME, defaultSearchEngineName);
|
||||
}
|
||||
|
||||
static public TemplateUrl getTemplateUrlByShortName(String name) {
|
||||
|
||||
@@ -36,18 +36,17 @@ public class BraveSearchEngineUtils {
|
||||
}
|
||||
|
||||
static private void initializeDSEPrefs() {
|
||||
// At first run, we should set initial default prefs to each standard/private DSE prefs.
|
||||
// Those pref values will be used until user change DES options explicitly.
|
||||
// At first run, we should set initial default prefs to private DSE pref.
|
||||
// Those pref values will be used until user change DSE options explicitly.
|
||||
// DSE for normal tab will be managed by native code, TemplateUrlService.
|
||||
final String notInitialized = "notInitialized";
|
||||
if (notInitialized.equals(ContextUtils.getAppSharedPreferences().getString(
|
||||
BraveSearchEngineAdapter.STANDARD_DSE_SHORTNAME, notInitialized))) {
|
||||
BraveSearchEngineAdapter.PRIVATE_DSE_SHORTNAME, notInitialized))) {
|
||||
TemplateUrl templateUrl =
|
||||
TemplateUrlServiceFactory.get().getDefaultSearchEngineTemplateUrl();
|
||||
|
||||
SharedPreferences.Editor sharedPreferencesEditor =
|
||||
ContextUtils.getAppSharedPreferences().edit();
|
||||
sharedPreferencesEditor.putString(
|
||||
BraveSearchEngineAdapter.STANDARD_DSE_SHORTNAME, templateUrl.getShortName());
|
||||
sharedPreferencesEditor.putString(
|
||||
BraveSearchEngineAdapter.PRIVATE_DSE_SHORTNAME, templateUrl.getShortName());
|
||||
sharedPreferencesEditor.apply();
|
||||
|
||||
Reference in New Issue
Block a user