Merge branch 'master' into newnavigation

Conflicts:
	mobile/src/com/cradle/iitc_mobile/IITC_ActionBarHelper.java
This commit is contained in:
fkloft
2013-09-23 11:01:03 +02:00
8 changed files with 137 additions and 31 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

@ -16,6 +16,8 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Comparator;
public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnNavigationListener, OnItemClickListener {
// Show/hide the up arrow on the very left
// getActionBar().setDisplayHomeAsUpEnabled(enabled);
@ -30,6 +32,22 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnNa
// getActionBar().setHomeButtonEnabled(enabled);
private class HighlighterAdapter extends ArrayAdapter<String> {
// Move "No Highlights" on top. Sort the rest alphabetically
private class HighlighterComparator implements Comparator<String> {
@Override
public int compare(String lhs, String rhs) {
if (lhs.equals("No Highlights"))
return -1000;
else if (rhs.equals("No Highlights"))
return 1000;
else
return lhs.compareTo(rhs);
}
}
private HighlighterComparator mComparator = new HighlighterComparator();
public HighlighterAdapter() {
super(mIitc, android.R.layout.simple_list_item_1);
clear();
@ -39,6 +57,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnNa
public void add(String object) {
super.remove(object); // to avoid duplicates
super.add(object);
super.sort(mComparator);
}
@Override
@ -177,8 +196,8 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnNa
if (mHighlighters.getCount() < 2) // there should always be "No Highlights"
showHighlighter = false;
if(mDrawerOpened)
if (mDrawerOpened)
showHighlighter = false;
if (showHighlighter) {
@ -240,7 +259,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnNa
public void onDrawerOpened(View drawerView) {
// TODO change menu? (via invalidateOptionsMenu)
super.onDrawerOpened(drawerView);
mDrawerOpened=true;
mDrawerOpened = true;
updateActionBar();
}

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;
@ -30,6 +32,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
// we use a tree map to have a map with alphabetical order
private static TreeMap<String, ArrayList<IITC_PluginPreference>> sPlugins = null;
public static final String USER_PLUGIN = "00000";
private static int mDeletedPlugins = 0;
@Override
public void setListAdapter(ListAdapter adapter) {
@ -57,6 +60,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()) {
@ -106,7 +139,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
for (Map.Entry<String, ArrayList<IITC_PluginPreference>> entry : sPlugins.entrySet()) {
numPlugins += entry.getValue().size();
}
if ((user.length + official.length) != numPlugins) {
if ((user.length + official.length) != (numPlugins + mDeletedPlugins)) {
Log.d("iitcm", "new or less plugins found since last start, rebuild preferences");
sPlugins.clear();
setUpPluginPreferenceScreen();
@ -188,6 +221,7 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
// do not add deleted plugins
if (plugin_cat.equals("Deleted")) {
mDeletedPlugins++;
return;
}

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);
}
}