forked from getodk/collect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaces nested preference screens with preference headers
- Loading branch information
1 parent
0d8888a
commit d4a393d
Showing
31 changed files
with
949 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
collect_app/src/main/java/org/odk/collect/android/fragments/FormEntryAccessPreferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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.fragments; | ||
|
||
import android.os.Bundle; | ||
import android.preference.PreferenceManager; | ||
import android.support.annotation.Nullable; | ||
import android.view.View; | ||
|
||
import org.odk.collect.android.R; | ||
import org.odk.collect.android.preferences.BasePreferenceFragment; | ||
|
||
import static android.content.Context.MODE_WORLD_READABLE; | ||
import static org.odk.collect.android.preferences.AdminPreferencesFragment.ADMIN_PREFERENCES; | ||
|
||
public class FormEntryAccessPreferences extends BasePreferenceFragment { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
PreferenceManager prefMgr = getPreferenceManager(); | ||
prefMgr.setSharedPreferencesName(ADMIN_PREFERENCES); | ||
prefMgr.setSharedPreferencesMode(MODE_WORLD_READABLE); | ||
|
||
addPreferencesFromResource(R.xml.form_entry_access_preferences); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
toolbar.setTitle(R.string.form_entry_setting); | ||
} | ||
|
||
@Override | ||
public void onDetach() { | ||
super.onDetach(); | ||
if (toolbar != null) { | ||
toolbar.setTitle(R.string.admin_preferences); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
collect_app/src/main/java/org/odk/collect/android/fragments/MainMenuAccessPreferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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.fragments; | ||
|
||
import android.os.Bundle; | ||
import android.preference.PreferenceManager; | ||
import android.support.annotation.Nullable; | ||
import android.view.View; | ||
|
||
import org.odk.collect.android.R; | ||
import org.odk.collect.android.preferences.BasePreferenceFragment; | ||
|
||
import static android.content.Context.MODE_WORLD_READABLE; | ||
import static org.odk.collect.android.preferences.AdminPreferencesFragment.ADMIN_PREFERENCES; | ||
|
||
public class MainMenuAccessPreferences extends BasePreferenceFragment { | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
PreferenceManager prefMgr = getPreferenceManager(); | ||
prefMgr.setSharedPreferencesName(ADMIN_PREFERENCES); | ||
prefMgr.setSharedPreferencesMode(MODE_WORLD_READABLE); | ||
|
||
addPreferencesFromResource(R.xml.main_menu_access_preferences); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
toolbar.setTitle(R.string.main_menu_settings); | ||
} | ||
|
||
@Override | ||
public void onDetach() { | ||
super.onDetach(); | ||
if (toolbar != null) { | ||
toolbar.setTitle(R.string.admin_preferences); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ct_app/src/main/java/org/odk/collect/android/fragments/UserSettingsAccessPreferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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.fragments; | ||
|
||
import android.os.Bundle; | ||
import android.preference.PreferenceManager; | ||
import android.support.annotation.Nullable; | ||
import android.view.View; | ||
|
||
import org.odk.collect.android.R; | ||
import org.odk.collect.android.preferences.BasePreferenceFragment; | ||
|
||
import static android.content.Context.MODE_WORLD_READABLE; | ||
import static org.odk.collect.android.preferences.AdminPreferencesFragment.ADMIN_PREFERENCES; | ||
|
||
public class UserSettingsAccessPreferences extends BasePreferenceFragment { | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
PreferenceManager prefMgr = getPreferenceManager(); | ||
prefMgr.setSharedPreferencesName(ADMIN_PREFERENCES); | ||
prefMgr.setSharedPreferencesMode(MODE_WORLD_READABLE); | ||
|
||
addPreferencesFromResource(R.xml.user_settings_access_preferences); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
toolbar.setTitle(R.string.user_settings); | ||
} | ||
|
||
@Override | ||
public void onDetach() { | ||
super.onDetach(); | ||
if (toolbar != null) { | ||
toolbar.setTitle(R.string.admin_preferences); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ([email protected]; 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(); | ||
} | ||
} | ||
|
Oops, something went wrong.