Listen for changes in editing preference settings

This commit gives the ability to listen for changes in
editing preference settings to LibreOfficeMainActivity.
This makes sure that value of mIsExperimentalMode
boolean is correct in any condition.

Change-Id: Ie2a931e63fad30262ad2f870b6c06f707db96618
Reviewed-on: https://gerrit.libreoffice.org/37033
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
brainbreaker
2017-04-27 19:06:43 +05:30
committed by Tomaž Vajngerl
parent 77da7b934d
commit eeb65fabd4

View File

@@ -52,7 +52,7 @@ import java.util.List;
/**
* Main activity of the LibreOffice App. It is started in the UI thread.
*/
public class LibreOfficeMainActivity extends AppCompatActivity {
public class LibreOfficeMainActivity extends AppCompatActivity implements SettingsListenerModel.OnSettingsPreferenceChangedListener {
private static final String LOGTAG = "LibreOfficeMainActivity";
private static final String DEFAULT_DOC_PATH = "/assets/example.odt";
@@ -109,6 +109,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
Log.w(LOGTAG, "onCreate..");
super.onCreate(savedInstanceState);
SettingsListenerModel.getInstance().setListener(this);
SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
mIsExperimentalMode = sPrefs.getBoolean(ENABLE_EXPERIMENTAL_PREFS_KEY, false);
@@ -667,6 +668,14 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
return !isDrawerOpen && !isDrawerLocked;
}
@Override
public void settingsPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.matches(ENABLE_EXPERIMENTAL_PREFS_KEY)) {
Log.d(LOGTAG, "Editing Preference Changed");
mIsExperimentalMode = sharedPreferences.getBoolean(ENABLE_EXPERIMENTAL_PREFS_KEY, false);
}
}
private class DocumentPartClickListener implements android.widget.AdapterView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {