bugfix on multiPane

- use dummy fragment for header category
- never select header category
This commit is contained in:
Philipp Schaefer 2013-09-22 12:53:08 +02:00
parent 3336ca1edc
commit ab76e4f123
3 changed files with 49 additions and 15 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cradle.iitc_mobile"
android:versionCode="48"
android:versionName="0.6.4">
android:versionCode="49"
android:versionName="0.6.5">
<uses-sdk
android:minSdkVersion="14"

View File

@ -15,6 +15,8 @@ import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;
import com.cradle.iitc_mobile.fragments.PluginsFragment;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -57,6 +59,36 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
addHeaders();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
if(onIsMultiPane()) getIntent()
.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, PluginsFragment.class.getName());
super.onCreate(savedInstanceState);
}
@Override
protected void onResume() {
// Call super :
super.onResume();
// Select the displayed fragment in the headers (when using a tablet) :
// This should be done by Android, it is a bug fix
// thx to http://stackoverflow.com/a/16793839
if(mHeaders != null) {
final String displayedFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
if (displayedFragment != null) {
for (final Header header : mHeaders) {
if (displayedFragment.equals(header.fragment)) {
switchToHeader(header);
break;
}
}
}
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {

View File

@ -22,21 +22,23 @@ public class PluginsFragment extends PreferenceFragment {
// alphabetical order
getPreferenceScreen().setOrderingAsAdded(false);
// get plugins category for this fragments and plugins list
String category = getArguments().getString("category");
ArrayList<IITC_PluginPreference> prefs =
IITC_PluginPreferenceActivity.getPluginPreference(category);
if (getArguments() != null) {
// 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);
// add plugin checkbox preferences
for (IITC_PluginPreference pref : prefs) {
getPreferenceScreen().addPreference(pref);
}
// set action bar stuff
ActionBar bar = getActivity().getActionBar();
category = category.replace(IITC_PluginPreferenceActivity.USER_PLUGIN, "User ");
bar.setTitle("IITC Plugins: " + category);
bar.setDisplayHomeAsUpEnabled(true);
}
// set action bar stuff
ActionBar bar = getActivity().getActionBar();
category = category.replace(IITC_PluginPreferenceActivity.USER_PLUGIN, "User ");
bar.setTitle("IITC Plugins: " + category);
bar.setDisplayHomeAsUpEnabled(true);
}
}