made the plugin prefs container static. finished plugin headers. this has multiple advantages:
1) it is enough to parse the plugins only on first start of this activity (not on every start of the preferences or this activity) 2) actionbar control (not possible with nested preferences) 3) it looks more fancy on tablets
This commit is contained in:
@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
|
||||
import com.cradle.iitc_mobile.IITC_PluginPreference;
|
||||
import com.cradle.iitc_mobile.IITC_PluginPreferenceActivity;
|
||||
import com.cradle.iitc_mobile.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -15,28 +16,25 @@ public class PluginsFragment extends PreferenceFragment {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// just a dummy to get the preferenceScreen
|
||||
addPreferencesFromResource(R.xml.pluginspreference);
|
||||
|
||||
// alphabetical order
|
||||
getPreferenceScreen().setOrderingAsAdded(false);
|
||||
|
||||
// add plugin checkboxes
|
||||
ArrayList<String> ids = getArguments().getStringArrayList("ids");
|
||||
for (String id : ids) {
|
||||
String title = getArguments().getStringArrayList(id).get(0);
|
||||
String desc = getArguments().getStringArrayList(id).get(1);
|
||||
IITC_PluginPreference plugin_pref = new IITC_PluginPreference(getActivity());
|
||||
plugin_pref.setKey(id);
|
||||
plugin_pref.setTitle(title);
|
||||
plugin_pref.setSummary(desc);
|
||||
plugin_pref.setDefaultValue(false);
|
||||
plugin_pref.setPersistent(true);
|
||||
getPreferenceScreen().addPreference(plugin_pref);
|
||||
// get plugins category for this fragments and plugins list
|
||||
String category = getArguments().getString("category");
|
||||
ArrayList<IITC_PluginPreference> prefs =
|
||||
IITC_PluginPreferenceActivity.getPluginPreference(category);
|
||||
|
||||
// add plugin checkbox preferences
|
||||
for (IITC_PluginPreference pref : prefs) {
|
||||
getPreferenceScreen().addPreference(pref);
|
||||
}
|
||||
|
||||
// set action bar stuff
|
||||
ActionBar bar = getActivity().getActionBar();
|
||||
String actionBarTitle = getArguments().getString("title");
|
||||
bar.setTitle("IITC Plugins: " + actionBarTitle);
|
||||
bar.setTitle("IITC Plugins: " + category);
|
||||
bar.setDisplayHomeAsUpEnabled(true);
|
||||
getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user