From d4a393d7571e1f747178c2807abab883733e650f Mon Sep 17 00:00:00 2001 From: Shobhit Agarwal Date: Sat, 24 Jun 2017 21:57:30 +0530 Subject: [PATCH] Replaces nested preference screens with preference headers --- build.gradle | 2 +- collect_app/src/main/AndroidManifest.xml | 7 +- .../fragments/FormEntryAccessPreferences.java | 52 ++++ .../fragments/MainMenuAccessPreferences.java | 53 ++++ .../android/fragments/ShowQRCodeFragment.java | 23 +- .../UserSettingsAccessPreferences.java | 53 ++++ .../android/preferences/AdminKeys.java | 58 +++-- .../preferences/AdminPreferencesActivity.java | 23 +- .../preferences/AdminPreferencesFragment.java | 45 ++-- .../preferences/BasePreferenceFragment.java | 66 ++--- .../DisabledPreferencesRemover.java | 13 +- .../FormManagementPreferences.java | 92 +++++++ .../preferences/FormMetadataActivity.java | 17 -- .../preferences/IdentityPreferences.java | 67 +++++ .../preferences/PreferencesActivity.java | 143 ++++++----- .../preferences/SplashClickListener.java | 22 +- ...ent.java => UserInterfacePreferences.java} | 229 ++++++------------ .../main/res/layout/show_qrcode_fragment.xml | 15 +- .../src/main/res/xml/admin_preferences.xml | 158 +----------- .../res/xml/form_entry_access_preferences.xml | 35 +++ .../form_management_preference_headers.xml | 8 + .../res/xml/form_management_preferences.xml | 57 +++++ .../res/xml/general_preference_headers.xml | 23 ++ .../src/main/res/xml/identity_preferences.xml | 18 ++ .../res/xml/main_menu_access_preferences.xml | 30 +++ .../res/xml/server_preference_headers.xml | 8 + ...user_device_identity_preference_header.xml | 8 + .../xml/user_interface_preference_headers.xml | 8 + .../res/xml/user_interface_preferences.xml | 59 +++++ .../xml/user_settings_access_preferences.xml | 80 ++++++ .../preferences/FormMetadataMigratorTest.java | 2 +- 31 files changed, 949 insertions(+), 525 deletions(-) create mode 100644 collect_app/src/main/java/org/odk/collect/android/fragments/FormEntryAccessPreferences.java create mode 100644 collect_app/src/main/java/org/odk/collect/android/fragments/MainMenuAccessPreferences.java create mode 100644 collect_app/src/main/java/org/odk/collect/android/fragments/UserSettingsAccessPreferences.java create mode 100644 collect_app/src/main/java/org/odk/collect/android/preferences/FormManagementPreferences.java delete mode 100644 collect_app/src/main/java/org/odk/collect/android/preferences/FormMetadataActivity.java create mode 100644 collect_app/src/main/java/org/odk/collect/android/preferences/IdentityPreferences.java rename collect_app/src/main/java/org/odk/collect/android/preferences/{PreferencesFragment.java => UserInterfacePreferences.java} (56%) create mode 100644 collect_app/src/main/res/xml/form_entry_access_preferences.xml create mode 100644 collect_app/src/main/res/xml/form_management_preference_headers.xml create mode 100644 collect_app/src/main/res/xml/form_management_preferences.xml create mode 100644 collect_app/src/main/res/xml/general_preference_headers.xml create mode 100644 collect_app/src/main/res/xml/identity_preferences.xml create mode 100644 collect_app/src/main/res/xml/main_menu_access_preferences.xml create mode 100644 collect_app/src/main/res/xml/server_preference_headers.xml create mode 100644 collect_app/src/main/res/xml/user_device_identity_preference_header.xml create mode 100644 collect_app/src/main/res/xml/user_interface_preference_headers.xml create mode 100644 collect_app/src/main/res/xml/user_interface_preferences.xml create mode 100644 collect_app/src/main/res/xml/user_settings_access_preferences.xml diff --git a/build.gradle b/build.gradle index 54d92c4fb46..11325cdf4c8 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.2' + classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.google.gms:google-services:3.0.0' } } diff --git a/collect_app/src/main/AndroidManifest.xml b/collect_app/src/main/AndroidManifest.xml index dc77c730faa..a6e36797da7 100644 --- a/collect_app/src/main/AndroidManifest.xml +++ b/collect_app/src/main/AndroidManifest.xml @@ -191,14 +191,9 @@ the specific language governing permissions and limitations under the License. android:name=".preferences.AboutPreferencesActivity" android:theme="@style/AppTheme.SettingsTheme" android:label="@string/app_name" /> - - serverKeys = Collections.singletonList( + AdminKeys.KEY_CHANGE_SERVER + ); + + static Collection identityKeys = Arrays.asList( + AdminKeys.KEY_CHANGE_FORM_METADATA, + AdminKeys.KEY_ANALYTICS + ); + + static Collection formManagementKeys = Arrays.asList( + AdminKeys.KEY_AUTOSEND, + AdminKeys.KEY_DELETE_AFTER_SEND, + AdminKeys.KEY_DEFAULT_TO_FINALIZED, + AdminKeys.KEY_CONSTRAINT_BEHAVIOR, + AdminKeys.KEY_HIGH_RESOLUTION, + AdminKeys.KEY_INSTANCE_FORM_SYNC + ); + + static Collection userInterfaceKeys = Arrays.asList( + AdminKeys.KEY_APP_LANGUAGE, + AdminKeys.KEY_CHANGE_FONT_SIZE, + AdminKeys.KEY_NAVIGATION, + AdminKeys.KEY_SHOW_SPLASH_SCREEN, + AdminKeys.KEY_SHOW_MAP_BASEMAP, + AdminKeys.KEY_SHOW_MAP_SDK + ); + private static Collection allKeys() { Collection keys = new ArrayList<>(); for (AdminAndGeneralKeys atg : adminToGeneral) { diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/AdminPreferencesActivity.java b/collect_app/src/main/java/org/odk/collect/android/preferences/AdminPreferencesActivity.java index a4fd1e415f3..91827a97079 100644 --- a/collect_app/src/main/java/org/odk/collect/android/preferences/AdminPreferencesActivity.java +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/AdminPreferencesActivity.java @@ -17,10 +17,13 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; +import android.preference.PreferenceActivity; import android.preference.PreferenceManager; -import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; import org.odk.collect.android.R; import org.odk.collect.android.application.Collect; @@ -40,7 +43,7 @@ * @author Thomas Smyth, Sassafras Tech Collective (tom@sassafrastech.com; constraint behavior * option) */ -public class AdminPreferencesActivity extends AppCompatActivity { +public class AdminPreferencesActivity extends PreferenceActivity { public static final String ADMIN_PREFERENCES = "admin_prefs"; public static final String TAG = "AdminPreferencesFragment"; private static final int SAVE_PREFS_MENU = Menu.FIRST; @@ -75,14 +78,28 @@ public static boolean saveSharedPreferencesToFile(File dst, Context context) { return res; } + @Override + protected boolean isValidFragment(String fragmentName) { + return true; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + ViewGroup root = (ViewGroup) findViewById(android.R.id.content); + ViewGroup parent = (ViewGroup) root.getParent(); + Toolbar toolbar = (Toolbar) View.inflate(this, R.layout.toolbar, null); + toolbar.setTitle(R.string.admin_preferences); + View shadow = View.inflate(this, R.layout.toolbar_action_bar_shadow, null); + + parent.addView(toolbar, 0); + parent.addView(shadow, 1); + if (savedInstanceState == null) { getFragmentManager() .beginTransaction() - .replace(android.R.id.content, new AdminPreferencesFragment(), TAG) + .add(android.R.id.content, new AdminPreferencesFragment(), TAG) .commit(); } } diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/AdminPreferencesFragment.java b/collect_app/src/main/java/org/odk/collect/android/preferences/AdminPreferencesFragment.java index dfac7f9c39e..bffbb7f27af 100644 --- a/collect_app/src/main/java/org/odk/collect/android/preferences/AdminPreferencesFragment.java +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/AdminPreferencesFragment.java @@ -19,13 +19,11 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.Preference; +import android.preference.PreferenceFragment; import android.preference.PreferenceManager; -import android.support.v4.view.ViewConfigurationCompat; -import android.support.v7.app.AppCompatActivity; import android.text.InputType; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewConfiguration; import android.view.WindowManager; import android.widget.CheckBox; import android.widget.CompoundButton; @@ -33,7 +31,10 @@ import org.odk.collect.android.R; import org.odk.collect.android.application.Collect; +import org.odk.collect.android.fragments.FormEntryAccessPreferences; +import org.odk.collect.android.fragments.MainMenuAccessPreferences; import org.odk.collect.android.fragments.ShowQRCodeFragment; +import org.odk.collect.android.fragments.UserSettingsAccessPreferences; import org.odk.collect.android.utilities.ToastUtils; import static android.content.Context.MODE_PRIVATE; @@ -43,25 +44,13 @@ import static org.odk.collect.android.preferences.AdminKeys.KEY_IMPORT_SETTINGS; -public class AdminPreferencesFragment extends BasePreferenceFragment implements Preference.OnPreferenceClickListener { +public class AdminPreferencesFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener { public static final String ADMIN_PREFERENCES = "admin_prefs"; - @Override - public void onResume() { - super.onResume(); - toolbar.setTitle(getString(R.string.admin_preferences)); - boolean hasHardwareMenu = - ViewConfigurationCompat.hasPermanentMenuKey(ViewConfiguration.get(getActivity())); - if (!hasHardwareMenu) { - ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); - } - } - @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setRetainInstance(true); PreferenceManager prefMgr = getPreferenceManager(); prefMgr.setSharedPreferencesName(ADMIN_PREFERENCES); prefMgr.setSharedPreferencesMode(MODE_WORLD_READABLE); @@ -70,6 +59,9 @@ public void onCreate(final Bundle savedInstanceState) { findPreference(KEY_CHANGE_ADMIN_PASSWORD).setOnPreferenceClickListener(this); findPreference(KEY_IMPORT_SETTINGS).setOnPreferenceClickListener(this); + findPreference("main_menu").setOnPreferenceClickListener(this); + findPreference("user_settings").setOnPreferenceClickListener(this); + findPreference("form_entry").setOnPreferenceClickListener(this); } @Override @@ -138,7 +130,26 @@ public void onClick(DialogInterface dialog, int which) { case KEY_IMPORT_SETTINGS: getActivity().getFragmentManager().beginTransaction() - .replace(android.R.id.content, new ShowQRCodeFragment()) + .add(android.R.id.content, new ShowQRCodeFragment()) + .addToBackStack(null) + .commit(); + break; + + case "main_menu": + getActivity().getFragmentManager().beginTransaction() + .replace(android.R.id.content, new MainMenuAccessPreferences()) + .addToBackStack(null) + .commit(); + break; + case "user_settings": + getActivity().getFragmentManager().beginTransaction() + .replace(android.R.id.content, new UserSettingsAccessPreferences()) + .addToBackStack(null) + .commit(); + break; + case "form_entry": + getActivity().getFragmentManager().beginTransaction() + .replace(android.R.id.content, new FormEntryAccessPreferences()) .addToBackStack(null) .commit(); break; diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/BasePreferenceFragment.java b/collect_app/src/main/java/org/odk/collect/android/preferences/BasePreferenceFragment.java index 6d4b9f1c3fc..abd728a29c5 100644 --- a/collect_app/src/main/java/org/odk/collect/android/preferences/BasePreferenceFragment.java +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/BasePreferenceFragment.java @@ -1,70 +1,40 @@ package org.odk.collect.android.preferences; -import android.app.Dialog; -import android.os.Build; import android.os.Bundle; -import android.preference.Preference; import android.preference.PreferenceFragment; -import android.preference.PreferenceScreen; import android.support.annotation.Nullable; import android.support.v7.widget.Toolbar; -import android.view.LayoutInflater; import android.view.View; -import android.widget.LinearLayout; - -import org.odk.collect.android.R; +import android.view.ViewGroup; +import static org.odk.collect.android.preferences.PreferencesActivity.INTENT_KEY_ADMIN_MODE; public class BasePreferenceFragment extends PreferenceFragment { protected Toolbar toolbar; - @SuppressWarnings("deprecation") - @Override - public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { - super.onPreferenceTreeClick(preferenceScreen, preference); - - if (preference != null) { - if (preference instanceof PreferenceScreen) { - if (((PreferenceScreen) preference).getDialog() != null) { - ((PreferenceScreen) preference).getDialog().getWindow().getDecorView().setBackgroundDrawable(getActivity().getWindow().getDecorView().getBackground().getConstantState().newDrawable()); - setUpNestedScreen((PreferenceScreen) preference, null); - } - } - } - - return false; + private void removeAllDisabledPrefs() { + DisabledPreferencesRemover preferencesRemover = new DisabledPreferencesRemover((PreferencesActivity) getActivity(), this); + preferencesRemover.remove(AdminKeys.adminToGeneral); + preferencesRemover.removeEmptyCategories(); } + @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { - setUpNestedScreen(getPreferenceScreen(), view); - toolbar.setTitle(R.string.general_preferences); - super.onViewCreated(view, savedInstanceState); - } - - public void setUpNestedScreen(PreferenceScreen preferenceScreen, View view) { - LinearLayout root = null; - Dialog dialog = preferenceScreen.getDialog(); - - if (view != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - root = (LinearLayout) view.findViewById(android.R.id.list).getParent().getParent(); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - root = (LinearLayout) view.findViewById(android.R.id.list).getParent(); - } - } else { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent().getParent(); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent(); + final ViewGroup viewGroup = (ViewGroup) getActivity().findViewById(android.R.id.content).getParent(); + toolbar = (Toolbar) viewGroup.getChildAt(0); + + if (getActivity() instanceof PreferencesActivity) { + Bundle args = getArguments(); + if (args != null) { + final boolean adminMode = getArguments().getBoolean(INTENT_KEY_ADMIN_MODE, false); + if (!adminMode) { + removeAllDisabledPrefs(); + } } } - toolbar = (Toolbar) LayoutInflater.from(getActivity()).inflate(R.layout.toolbar, root, false); - toolbar.setTitle(preferenceScreen.getTitle()); - root.addView(toolbar, 0); - View shadow = LayoutInflater.from(getActivity()).inflate(R.layout.toolbar_action_bar_shadow, root, false); - root.addView(shadow, 1); + super.onViewCreated(view, savedInstanceState); } } diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/DisabledPreferencesRemover.java b/collect_app/src/main/java/org/odk/collect/android/preferences/DisabledPreferencesRemover.java index fcca3b28787..913ea9b8ccd 100644 --- a/collect_app/src/main/java/org/odk/collect/android/preferences/DisabledPreferencesRemover.java +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/DisabledPreferencesRemover.java @@ -24,6 +24,7 @@ import static org.odk.collect.android.preferences.PreferencesActivity.INTENT_KEY_ADMIN_MODE; + class DisabledPreferencesRemover { private PreferencesActivity pa; @@ -40,15 +41,17 @@ class DisabledPreferencesRemover { * @param keyPairs one or more AdminAndGeneralKeys objects. */ void remove(AdminAndGeneralKeys... keyPairs) { - final boolean adminMode = pa.getIntent().getBooleanExtra(INTENT_KEY_ADMIN_MODE, false); - for (AdminAndGeneralKeys agKeys : keyPairs) { boolean prefAllowed = (boolean) AdminSharedPreferences.getInstance().get(agKeys.adminKey); - if (!prefAllowed && !adminMode) { - + if (!prefAllowed) { Preference preference = pf.findPreference(agKeys.generalKey); + if (preference == null) { + // preference not found in the current preference fragment, so ignore + continue; + } + PreferenceGroup parent = getParent(pf.getPreferenceScreen(), preference); if (parent == null) { throw new RuntimeException("Couldn't find preference"); @@ -91,7 +94,7 @@ void removeEmptyCategories() { private void removeEmptyCategories(PreferenceGroup pc) { final boolean adminMode = pa.getIntent().getBooleanExtra(INTENT_KEY_ADMIN_MODE, false); - if (adminMode) { + if (adminMode || pc == null) { return; } diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/FormManagementPreferences.java b/collect_app/src/main/java/org/odk/collect/android/preferences/FormManagementPreferences.java new file mode 100644 index 00000000000..07750887dcf --- /dev/null +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/FormManagementPreferences.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2017 Shobhit + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package org.odk.collect.android.preferences; + +import android.os.Bundle; +import android.preference.ListPreference; +import android.preference.Preference; +import android.support.annotation.Nullable; +import android.view.View; + +import org.odk.collect.android.R; + +import static org.odk.collect.android.preferences.PreferenceKeys.KEY_AUTOSEND; +import static org.odk.collect.android.preferences.PreferenceKeys.KEY_CONSTRAINT_BEHAVIOR; + +public class FormManagementPreferences extends BasePreferenceFragment { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.form_management_preferences); + + initConstraintBehaviorPref(); + initAutoSendPrefs(); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + toolbar.setTitle(R.string.form_management_preferences); + } + + @Override + public void onDetach() { + super.onDetach(); + if (toolbar != null) { + toolbar.setTitle(R.string.general_preferences); + } + } + + + private void initConstraintBehaviorPref() { + final ListPreference pref = (ListPreference) findPreference(KEY_CONSTRAINT_BEHAVIOR); + + if (pref != null) { + pref.setSummary(pref.getEntry()); + pref.setOnPreferenceChangeListener( + new Preference.OnPreferenceChangeListener() { + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + int index = ((ListPreference) preference).findIndexOfValue( + newValue.toString()); + CharSequence entry = ((ListPreference) preference).getEntries()[index]; + preference.setSummary(entry); + return true; + } + }); + } + } + + private void initAutoSendPrefs() { + final ListPreference autosend = (ListPreference) findPreference(KEY_AUTOSEND); + + if (autosend == null) { + return; + } + + autosend.setSummary(autosend.getEntry()); + autosend.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + int index = ((ListPreference) preference).findIndexOfValue(newValue.toString()); + String entry = (String) ((ListPreference) preference).getEntries()[index]; + preference.setSummary(entry); + return true; + } + }); + } +} diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/FormMetadataActivity.java b/collect_app/src/main/java/org/odk/collect/android/preferences/FormMetadataActivity.java deleted file mode 100644 index 62b8754747f..00000000000 --- a/collect_app/src/main/java/org/odk/collect/android/preferences/FormMetadataActivity.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.odk.collect.android.preferences; - -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; - -public class FormMetadataActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - getFragmentManager() - .beginTransaction() - .replace(android.R.id.content, new FormMetadataFragment()) - .commit(); - } -} diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/IdentityPreferences.java b/collect_app/src/main/java/org/odk/collect/android/preferences/IdentityPreferences.java new file mode 100644 index 00000000000..89e950f9f67 --- /dev/null +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/IdentityPreferences.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2017 Shobhit + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package org.odk.collect.android.preferences; + +import android.os.Bundle; +import android.preference.CheckBoxPreference; +import android.preference.Preference; +import android.support.annotation.Nullable; +import android.view.View; + +import com.google.android.gms.analytics.GoogleAnalytics; + +import org.odk.collect.android.R; + +import static org.odk.collect.android.preferences.PreferenceKeys.KEY_ANALYTICS; + +public class IdentityPreferences extends BasePreferenceFragment { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.identity_preferences); + + initAnalyticsPref(); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + toolbar.setTitle(R.string.user_and_device_identity_title); + } + + @Override + public void onDetach() { + super.onDetach(); + if (toolbar != null) { + toolbar.setTitle(R.string.general_preferences); + } + } + + private void initAnalyticsPref() { + final CheckBoxPreference analyticsPreference = (CheckBoxPreference) findPreference(KEY_ANALYTICS); + + if (analyticsPreference != null) { + analyticsPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(getActivity().getApplicationContext()); + googleAnalytics.setAppOptOut(!analyticsPreference.isChecked()); + return true; + } + }); + } + } +} diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/PreferencesActivity.java b/collect_app/src/main/java/org/odk/collect/android/preferences/PreferencesActivity.java index 58e45e48006..df6fef943d5 100644 --- a/collect_app/src/main/java/org/odk/collect/android/preferences/PreferencesActivity.java +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/PreferencesActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 University of Washington + * Copyright (C) 2017 Shobhit * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -14,115 +14,108 @@ package org.odk.collect.android.preferences; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceActivity; -import android.preference.PreferenceManager; -import android.preference.PreferenceScreen; -import android.provider.MediaStore.Images; -import android.support.annotation.Nullable; +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.view.ViewGroup; import org.javarosa.core.services.IPropertyManager; import org.odk.collect.android.R; import org.odk.collect.android.logic.FormController; import org.odk.collect.android.logic.PropertyManager; -import org.odk.collect.android.utilities.MediaUtils; -import timber.log.Timber; - -import static org.odk.collect.android.preferences.PreferenceKeys.KEY_SPLASH_PATH; +import java.util.Collection; +import java.util.List; /** * Handles general preferences. - * - * @author Thomas Smyth, Sassafras Tech Collective (tom@sassafrastech.com; - * constraint behavior option) */ public class PreferencesActivity extends PreferenceActivity { public static final String INTENT_KEY_ADMIN_MODE = "adminMode"; - protected static final int IMAGE_CHOOSER = 0; - private PreferencesFragment fragment; - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - fragment = new PreferencesFragment(); - getFragmentManager() - .beginTransaction() - .replace(android.R.id.content, fragment) - .commit(); - } + private AdminSharedPreferences sharedPreferences; @Override - public void onStart() { - Timber.d("onStart"); - super.onStart(); - } + public void onBuildHeaders(List
target) { + super.onBuildHeaders(target); - @Override - protected void onPause() { - Timber.d("onPause"); - super.onPause(); + sharedPreferences = AdminSharedPreferences.getInstance(); - // the property manager should be re-assigned, as properties - // may have changed. - IPropertyManager mgr = new PropertyManager(this); - FormController.initializeJavaRosa(mgr); - } + final boolean adminMode = getIntent().getBooleanExtra(INTENT_KEY_ADMIN_MODE, false); - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent intent) { - Timber.d("onActivityResult %d %d", requestCode, resultCode); - super.onActivityResult(requestCode, resultCode, intent); - if (resultCode == RESULT_CANCELED) { - // request was canceled, so do nothing - return; - } + if (adminMode) { + loadHeadersFromResource(R.xml.general_preference_headers, target); + } else { + + if (hasAtleastOneSettingEnabled(AdminKeys.serverKeys)) { + loadHeadersFromResource(R.xml.server_preference_headers, target); + } - switch (requestCode) { - case IMAGE_CHOOSER: + if (hasAtleastOneSettingEnabled(AdminKeys.userInterfaceKeys)) { + loadHeadersFromResource(R.xml.user_interface_preference_headers, target); + } - // get gp of chosen file - Uri selectedMedia = intent.getData(); - String sourceMediaPath = MediaUtils.getPathFromUri(this, selectedMedia, - Images.Media.DATA); + if (hasAtleastOneSettingEnabled(AdminKeys.formManagementKeys)) { + loadHeadersFromResource(R.xml.form_management_preference_headers, target); + } - // setting image path - setSplashPath(sourceMediaPath); - break; + if (hasAtleastOneSettingEnabled(AdminKeys.identityKeys)) { + loadHeadersFromResource(R.xml.user_device_identity_preference_header, target); + } } } @Override - protected void onStop() { - Timber.d("onStop"); - super.onStop(); + public void onHeaderClick(Header header, int position) { + final boolean adminMode = getIntent().getBooleanExtra(INTENT_KEY_ADMIN_MODE, false); + + if (adminMode) { + Bundle bundle = new Bundle(); + bundle.putBoolean(INTENT_KEY_ADMIN_MODE, true); + header.fragmentArguments = bundle; + } + + super.onHeaderClick(header, position); + } + + private boolean hasAtleastOneSettingEnabled(Collection keys) { + for (String key : keys) { + boolean value = (boolean) sharedPreferences.get(key); + if (value) { + return true; + } + } + return false; } @Override - protected void onRestart() { - Timber.d("onRestart"); - super.onRestart(); + protected boolean isValidFragment(String fragmentName) { + return true; } @Override - protected void onDestroy() { - Timber.d("onDestroy"); - super.onDestroy(); + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + + ViewGroup root = (ViewGroup) findViewById(android.R.id.content); + ViewGroup parent = (ViewGroup) root.getParent(); + Toolbar toolbar = (Toolbar) View.inflate(this, R.layout.toolbar, null); + toolbar.setTitle(R.string.general_preferences); + View shadow = View.inflate(this, R.layout.toolbar_action_bar_shadow, null); + + parent.addView(toolbar, 0); + parent.addView(shadow, 1); } - void setSplashPath(String path) { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - Editor editor = sharedPreferences.edit(); - editor.putString(KEY_SPLASH_PATH, path); - editor.apply(); + @Override + protected void onPause() { + super.onPause(); - PreferenceScreen splashPathPreference = (PreferenceScreen) fragment.findPreference(KEY_SPLASH_PATH); - String summary = splashPathPreference.getSharedPreferences().getString( - KEY_SPLASH_PATH, getString(R.string.default_splash_path)); - splashPathPreference.setSummary(summary); + // the property manager should be re-assigned, as properties + // may have changed. + IPropertyManager mgr = new PropertyManager(this); + FormController.initializeJavaRosa(mgr); } } diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/SplashClickListener.java b/collect_app/src/main/java/org/odk/collect/android/preferences/SplashClickListener.java index 5df79725f15..7ca192fa8b1 100644 --- a/collect_app/src/main/java/org/odk/collect/android/preferences/SplashClickListener.java +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/SplashClickListener.java @@ -9,18 +9,18 @@ import org.odk.collect.android.R; class SplashClickListener implements Preference.OnPreferenceClickListener { - private PreferencesActivity pa; + private UserInterfacePreferences preferencesFragment; private PreferenceScreen splashPathPreference; - SplashClickListener(PreferencesActivity pa, PreferenceScreen splashPathPreference) { - this.pa = pa; + SplashClickListener(UserInterfacePreferences preferenceFragment, PreferenceScreen splashPathPreference) { + this.preferencesFragment = preferenceFragment; this.splashPathPreference = splashPathPreference; } private void launchImageChooser() { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("image/*"); - pa.startActivityForResult(i, PreferencesActivity.IMAGE_CHOOSER); + preferencesFragment.startActivityForResult(i, UserInterfacePreferences.IMAGE_CHOOSER); } @Override @@ -29,12 +29,12 @@ public boolean onPreferenceClick(Preference preference) { CharSequence cs = splashPathPreference.getSummary(); if (cs != null && cs.toString().contains("/")) { - final CharSequence[] items = {pa.getString(R.string.select_another_image), - pa.getString(R.string.use_odk_default)}; + final CharSequence[] items = {preferencesFragment.getString(R.string.select_another_image), + preferencesFragment.getString(R.string.use_odk_default)}; - AlertDialog.Builder builder = new AlertDialog.Builder(pa); - builder.setTitle(pa.getString(R.string.change_splash_path)); - builder.setNeutralButton(pa.getString(R.string.cancel), + AlertDialog.Builder builder = new AlertDialog.Builder(preferencesFragment.getActivity()); + builder.setTitle(preferencesFragment.getString(R.string.change_splash_path)); + builder.setNeutralButton(preferencesFragment.getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { @@ -44,10 +44,10 @@ public void onClick(DialogInterface dialog, int id) { builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { - if (items[item].equals(pa.getString(R.string.select_another_image))) { + if (items[item].equals(preferencesFragment.getString(R.string.select_another_image))) { launchImageChooser(); } else { - pa.setSplashPath(pa.getString(R.string.default_splash_path)); + preferencesFragment.setSplashPath(preferencesFragment.getString(R.string.default_splash_path)); } } }); diff --git a/collect_app/src/main/java/org/odk/collect/android/preferences/PreferencesFragment.java b/collect_app/src/main/java/org/odk/collect/android/preferences/UserInterfacePreferences.java similarity index 56% rename from collect_app/src/main/java/org/odk/collect/android/preferences/PreferencesFragment.java rename to collect_app/src/main/java/org/odk/collect/android/preferences/UserInterfacePreferences.java index 1eaa59368eb..90ab36a6020 100644 --- a/collect_app/src/main/java/org/odk/collect/android/preferences/PreferencesFragment.java +++ b/collect_app/src/main/java/org/odk/collect/android/preferences/UserInterfacePreferences.java @@ -1,173 +1,101 @@ +/* + * Copyright (C) 2017 Shobhit + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + package org.odk.collect.android.preferences; import android.content.Intent; import android.content.SharedPreferences; +import android.net.Uri; import android.os.Bundle; -import android.preference.CheckBoxPreference; -import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceManager; import android.preference.PreferenceScreen; - -import com.google.android.gms.analytics.GoogleAnalytics; +import android.provider.MediaStore; +import android.support.annotation.Nullable; +import android.view.View; import org.odk.collect.android.R; import org.odk.collect.android.activities.MainMenuActivity; import org.odk.collect.android.utilities.LocaleHelper; +import org.odk.collect.android.utilities.MediaUtils; import java.util.ArrayList; import java.util.TreeMap; import timber.log.Timber; +import static android.app.Activity.RESULT_CANCELED; import static org.odk.collect.android.preferences.PreferenceKeys.ARRAY_INDEX_GOOGLE_MAPS; import static org.odk.collect.android.preferences.PreferenceKeys.GOOGLE_MAPS_BASEMAP_DEFAULT; -import static org.odk.collect.android.preferences.PreferenceKeys.KEY_ANALYTICS; import static org.odk.collect.android.preferences.PreferenceKeys.KEY_APP_LANGUAGE; -import static org.odk.collect.android.preferences.PreferenceKeys.KEY_AUTOSEND; -import static org.odk.collect.android.preferences.PreferenceKeys.KEY_CONSTRAINT_BEHAVIOR; import static org.odk.collect.android.preferences.PreferenceKeys.KEY_FONT_SIZE; -import static org.odk.collect.android.preferences.PreferenceKeys.KEY_FORM_METADATA; import static org.odk.collect.android.preferences.PreferenceKeys.KEY_MAP_BASEMAP; import static org.odk.collect.android.preferences.PreferenceKeys.KEY_MAP_SDK; import static org.odk.collect.android.preferences.PreferenceKeys.KEY_NAVIGATION; -import static org.odk.collect.android.preferences.PreferenceKeys.KEY_PASSWORD; -import static org.odk.collect.android.preferences.PreferenceKeys.KEY_PROTOCOL; -import static org.odk.collect.android.preferences.PreferenceKeys.KEY_SELECTED_GOOGLE_ACCOUNT; import static org.odk.collect.android.preferences.PreferenceKeys.KEY_SPLASH_PATH; -import static org.odk.collect.android.preferences.PreferenceKeys.KEY_USERNAME; import static org.odk.collect.android.preferences.PreferenceKeys.OSM_BASEMAP_KEY; import static org.odk.collect.android.preferences.PreferenceKeys.OSM_MAPS_BASEMAP_DEFAULT; +public class UserInterfacePreferences extends BasePreferenceFragment { -public class PreferencesFragment extends BasePreferenceFragment implements Preference.OnPreferenceChangeListener { + protected static final int IMAGE_CHOOSER = 0; @Override - public void onCreate(final Bundle savedInstanceState) { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.preferences); - - removeAllDisabledPrefs(); + addPreferencesFromResource(R.xml.user_interface_preferences); - initPlatformSettings(); - initFormMetadata(); initNavigationPrefs(); - initConstraintBehaviorPref(); initFontSizePref(); initLanguagePrefs(); - initAnalyticsPref(); initSplashPrefs(); initMapPrefs(); - initAutoSendPrefs(); - } - - private void initPlatformSettings() { - final Preference protocol = findPreference(KEY_PROTOCOL); - - if (protocol == null) { - return; - } - - protocol.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - - getFragmentManager() - .beginTransaction() - .addToBackStack(null) - .replace(android.R.id.content, new ServerPreferences()) - .commit(); - - return true; - } - }); } - private void initAutoSendPrefs() { - final ListPreference autosend = (ListPreference) findPreference(KEY_AUTOSEND); - - if (autosend == null) { - return; - } - - autosend.setSummary(autosend.getEntry()); - autosend.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - int index = ((ListPreference) preference).findIndexOfValue(newValue.toString()); - String entry = (String) ((ListPreference) preference).getEntries()[index]; - preference.setSummary(entry); - return true; - } - }); + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + toolbar.setTitle(R.string.client); } @Override - public void onResume() { - Timber.d("onResume"); - super.onResume(); - - // has to go in onResume because it may get updated by - // a sub-preference screen - // this just keeps the widgets in sync - GeneralSharedPreferences sp = GeneralSharedPreferences.getInstance(); - - ListPreference googleAccountPreference = (ListPreference) findPreference(KEY_SELECTED_GOOGLE_ACCOUNT); - if (googleAccountPreference != null) { - String account = (String) sp.get(KEY_SELECTED_GOOGLE_ACCOUNT); - googleAccountPreference.setSummary(account); - googleAccountPreference.setValue(account); - } - - final EditTextPreference usernamePreference = (EditTextPreference) findPreference(KEY_USERNAME); - if (usernamePreference != null) { - String user = (String) sp.get(KEY_USERNAME); - usernamePreference.setSummary(user); - usernamePreference.setText(user); - } - - final EditTextPreference passwordPreference = (EditTextPreference) findPreference(KEY_PASSWORD); - if (passwordPreference != null) { - String pw = (String) sp.get(KEY_PASSWORD); - if (pw.length() > 0) { - passwordPreference.setSummary("********"); - passwordPreference.setText(pw); - } + public void onDetach() { + super.onDetach(); + if (toolbar != null) { + toolbar.setTitle(R.string.general_preferences); } } - private void removeAllDisabledPrefs() { - DisabledPreferencesRemover preferencesRemover = new DisabledPreferencesRemover((PreferencesActivity) getActivity(), this); - preferencesRemover.remove(AdminKeys.adminToGeneral); - preferencesRemover.removeEmptyCategories(); - } + private void initNavigationPrefs() { + final ListPreference pref = (ListPreference) findPreference(KEY_NAVIGATION); - private void initAnalyticsPref() { - final CheckBoxPreference analyticsPreference = (CheckBoxPreference) findPreference(KEY_ANALYTICS); + if (pref != null) { + pref.setSummary(pref.getEntry()); + pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - if (analyticsPreference != null) { - analyticsPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override - public boolean onPreferenceClick(Preference preference) { - GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(getActivity().getApplicationContext()); - googleAnalytics.setAppOptOut(!analyticsPreference.isChecked()); + public boolean onPreferenceChange(Preference preference, Object newValue) { + int index = ((ListPreference) preference).findIndexOfValue(newValue.toString()); + String entry = (String) ((ListPreference) preference).getEntries()[index]; + preference.setSummary(entry); return true; } }); } } - private void initSplashPrefs() { - final PreferenceScreen pref = (PreferenceScreen) findPreference(KEY_SPLASH_PATH); - - if (pref != null) { - pref.setOnPreferenceClickListener(new SplashClickListener((PreferencesActivity) getActivity(), pref)); - pref.setSummary(pref.getSharedPreferences().getString( - KEY_SPLASH_PATH, getString(R.string.default_splash_path))); - } - } - private void initFontSizePref() { final ListPreference pref = (ListPreference) findPreference(KEY_FONT_SIZE); @@ -232,23 +160,13 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } } - private void initConstraintBehaviorPref() { - final ListPreference pref = (ListPreference) findPreference(KEY_CONSTRAINT_BEHAVIOR); + private void initSplashPrefs() { + final PreferenceScreen pref = (PreferenceScreen) findPreference(KEY_SPLASH_PATH); if (pref != null) { - pref.setSummary(pref.getEntry()); - pref.setOnPreferenceChangeListener( - new Preference.OnPreferenceChangeListener() { - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - int index = ((ListPreference) preference).findIndexOfValue( - newValue.toString()); - CharSequence entry = ((ListPreference) preference).getEntries()[index]; - preference.setSummary(entry); - return true; - } - }); + pref.setOnPreferenceClickListener(new SplashClickListener(this, pref)); + pref.setSummary(pref.getSharedPreferences().getString( + KEY_SPLASH_PATH, getString(R.string.default_splash_path))); } } @@ -305,39 +223,38 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { }); } - private void initNavigationPrefs() { - final ListPreference pref = (ListPreference) findPreference(KEY_NAVIGATION); - - if (pref != null) { - pref.setSummary(pref.getEntry()); - pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - int index = ((ListPreference) preference).findIndexOfValue(newValue.toString()); - String entry = (String) ((ListPreference) preference).getEntries()[index]; - preference.setSummary(entry); - return true; - } - }); + @Override + public void onActivityResult(int requestCode, int resultCode, Intent intent) { + Timber.d("onActivityResult %d %d", requestCode, resultCode); + super.onActivityResult(requestCode, resultCode, intent); + if (resultCode == RESULT_CANCELED) { + // request was canceled, so do nothing + return; } - } - private void initFormMetadata() { - final Preference pref = findPreference(KEY_FORM_METADATA); + switch (requestCode) { + case IMAGE_CHOOSER: - if (pref != null) { - final Intent intent = new Intent(getActivity(), FormMetadataActivity.class); - pref.setIntent(intent); + // get gp of chosen file + Uri selectedMedia = intent.getData(); + String sourceMediaPath = MediaUtils.getPathFromUri(getActivity(), selectedMedia, + MediaStore.Images.Media.DATA); + + // setting image path + setSplashPath(sourceMediaPath); + break; } } - /** - * Generic listener that sets the summary to the newly selected/entered value - */ - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - preference.setSummary((CharSequence) newValue); - return true; + void setSplashPath(String path) { + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(KEY_SPLASH_PATH, path); + editor.apply(); + + PreferenceScreen splashPathPreference = (PreferenceScreen) findPreference(KEY_SPLASH_PATH); + String summary = splashPathPreference.getSharedPreferences().getString( + KEY_SPLASH_PATH, getString(R.string.default_splash_path)); + splashPathPreference.setSummary(summary); } } diff --git a/collect_app/src/main/res/layout/show_qrcode_fragment.xml b/collect_app/src/main/res/layout/show_qrcode_fragment.xml index 20ffc128ac9..36dd8bab73d 100644 --- a/collect_app/src/main/res/layout/show_qrcode_fragment.xml +++ b/collect_app/src/main/res/layout/show_qrcode_fragment.xml @@ -1,4 +1,5 @@ - - - - - + android:textStyle="bold"/> \ No newline at end of file diff --git a/collect_app/src/main/res/xml/admin_preferences.xml b/collect_app/src/main/res/xml/admin_preferences.xml index a540e9b55ce..d768661797b 100644 --- a/collect_app/src/main/res/xml/admin_preferences.xml +++ b/collect_app/src/main/res/xml/admin_preferences.xml @@ -27,168 +27,28 @@ android:positiveButtonText="@string/reset_settings_button_reset" android:title="@string/reset_settings_dialog" /> - - - - - - - - - + android:title="@string/main_menu_settings" /> - - - - - - - - - - - - - - - - - - - + android:title="@string/user_settings" /> - - - - - - - - - + android:title="@string/form_entry_setting" /> + \ No newline at end of file diff --git a/collect_app/src/main/res/xml/form_entry_access_preferences.xml b/collect_app/src/main/res/xml/form_entry_access_preferences.xml new file mode 100644 index 00000000000..91018ccb371 --- /dev/null +++ b/collect_app/src/main/res/xml/form_entry_access_preferences.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/collect_app/src/main/res/xml/form_management_preference_headers.xml b/collect_app/src/main/res/xml/form_management_preference_headers.xml new file mode 100644 index 00000000000..15fccc2f9b1 --- /dev/null +++ b/collect_app/src/main/res/xml/form_management_preference_headers.xml @@ -0,0 +1,8 @@ + + +
+ \ No newline at end of file diff --git a/collect_app/src/main/res/xml/form_management_preferences.xml b/collect_app/src/main/res/xml/form_management_preferences.xml new file mode 100644 index 00000000000..01f2fde9f9b --- /dev/null +++ b/collect_app/src/main/res/xml/form_management_preferences.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/collect_app/src/main/res/xml/general_preference_headers.xml b/collect_app/src/main/res/xml/general_preference_headers.xml new file mode 100644 index 00000000000..cbd65a2811d --- /dev/null +++ b/collect_app/src/main/res/xml/general_preference_headers.xml @@ -0,0 +1,23 @@ + + +
+
+
+
+ \ No newline at end of file diff --git a/collect_app/src/main/res/xml/identity_preferences.xml b/collect_app/src/main/res/xml/identity_preferences.xml new file mode 100644 index 00000000000..3c40444d440 --- /dev/null +++ b/collect_app/src/main/res/xml/identity_preferences.xml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file diff --git a/collect_app/src/main/res/xml/main_menu_access_preferences.xml b/collect_app/src/main/res/xml/main_menu_access_preferences.xml new file mode 100644 index 00000000000..01a1553204a --- /dev/null +++ b/collect_app/src/main/res/xml/main_menu_access_preferences.xml @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/collect_app/src/main/res/xml/server_preference_headers.xml b/collect_app/src/main/res/xml/server_preference_headers.xml new file mode 100644 index 00000000000..987cd067d45 --- /dev/null +++ b/collect_app/src/main/res/xml/server_preference_headers.xml @@ -0,0 +1,8 @@ + + +
+ \ No newline at end of file diff --git a/collect_app/src/main/res/xml/user_device_identity_preference_header.xml b/collect_app/src/main/res/xml/user_device_identity_preference_header.xml new file mode 100644 index 00000000000..4990c9cbb6c --- /dev/null +++ b/collect_app/src/main/res/xml/user_device_identity_preference_header.xml @@ -0,0 +1,8 @@ + + +
+ \ No newline at end of file diff --git a/collect_app/src/main/res/xml/user_interface_preference_headers.xml b/collect_app/src/main/res/xml/user_interface_preference_headers.xml new file mode 100644 index 00000000000..58f5e3ad507 --- /dev/null +++ b/collect_app/src/main/res/xml/user_interface_preference_headers.xml @@ -0,0 +1,8 @@ + + +
+ \ No newline at end of file diff --git a/collect_app/src/main/res/xml/user_interface_preferences.xml b/collect_app/src/main/res/xml/user_interface_preferences.xml new file mode 100644 index 00000000000..7bd406926f3 --- /dev/null +++ b/collect_app/src/main/res/xml/user_interface_preferences.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/collect_app/src/main/res/xml/user_settings_access_preferences.xml b/collect_app/src/main/res/xml/user_settings_access_preferences.xml new file mode 100644 index 00000000000..1b3563afac7 --- /dev/null +++ b/collect_app/src/main/res/xml/user_settings_access_preferences.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/collect_app/src/test/java/org/odk/collect/android/preferences/FormMetadataMigratorTest.java b/collect_app/src/test/java/org/odk/collect/android/preferences/FormMetadataMigratorTest.java index 41961fa784f..fbec998c817 100644 --- a/collect_app/src/test/java/org/odk/collect/android/preferences/FormMetadataMigratorTest.java +++ b/collect_app/src/test/java/org/odk/collect/android/preferences/FormMetadataMigratorTest.java @@ -30,7 +30,7 @@ import static org.odk.collect.android.preferences.PreferenceKeys.KEY_SELECTED_GOOGLE_ACCOUNT; import static org.odk.collect.android.preferences.PreferenceKeys.KEY_USERNAME; -/** Tests the FormMetadataActivity */ +/** Tests the FormMetadataFragment */ @Config(constants = BuildConfig.class) @RunWith(RobolectricTestRunner.class) public class FormMetadataMigratorTest {