|
|
|
@ -1,15 +1,20 @@
|
|
|
|
|
package com.todoroo.astrid.activity;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
|
|
import android.app.ListActivity;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.res.Resources;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.view.MotionEvent;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.View.OnTouchListener;
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import com.commonsware.cwac.tlv.TouchListView;
|
|
|
|
|
import com.commonsware.cwac.tlv.TouchListView.DropListener;
|
|
|
|
@ -27,10 +32,12 @@ public class BeastModePreferenceActivity extends ListActivity {
|
|
|
|
|
|
|
|
|
|
public static final String BEAST_MODE_PREF_ITEM_SEPARATOR = ";"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
private static final String BEAST_MODE_MORE_ITEM_SPECIAL_CHAR = "-*"; //$NON-NLS-1$
|
|
|
|
|
private static final String BEAST_MODE_MORE_ITEM_SPECIAL_CHAR = "-"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
private static final String BEAST_MODE_MIGRATE_PREF = "beast_mode_migrate"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
private HashMap<String, String> prefsToDescriptions;
|
|
|
|
|
|
|
|
|
|
// Migration function to fix the fact that I stupidly chose to use the control
|
|
|
|
|
// set names (which are localized and subject to change) as the values in the beast
|
|
|
|
|
// mode preferences
|
|
|
|
@ -47,8 +54,13 @@ public class BeastModePreferenceActivity extends ListActivity {
|
|
|
|
|
String[] defaultOrder = context.getResources().getStringArray(R.array.TEA_control_sets);
|
|
|
|
|
for (String s : defaultOrder) {
|
|
|
|
|
if (s.contains(BEAST_MODE_MORE_ITEM_SPECIAL_CHAR)) {
|
|
|
|
|
String[] stripped = s.split(BEAST_MODE_MORE_ITEM_SPECIAL_CHAR);
|
|
|
|
|
s = stripped[0];
|
|
|
|
|
String[] split = s.split(BEAST_MODE_MORE_ITEM_SPECIAL_CHAR);
|
|
|
|
|
for (String component : split) {
|
|
|
|
|
if (!TextUtils.isEmpty(component)) {
|
|
|
|
|
s = component;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
defaults.add(s);
|
|
|
|
|
}
|
|
|
|
@ -92,11 +104,14 @@ public class BeastModePreferenceActivity extends ListActivity {
|
|
|
|
|
setContentView(R.layout.beast_mode_pref_activity);
|
|
|
|
|
setTitle(R.string.EPr_beastMode_desc);
|
|
|
|
|
|
|
|
|
|
prefsToDescriptions = new HashMap<String, String>();
|
|
|
|
|
buildDescriptionMap(getResources());
|
|
|
|
|
|
|
|
|
|
touchList = (TouchListView) getListView();
|
|
|
|
|
String order = Preferences.getStringValue(BEAST_MODE_ORDER_PREF);
|
|
|
|
|
String[] itemsArray;
|
|
|
|
|
if (order == null) {
|
|
|
|
|
itemsArray = getResources().getStringArray(R.array.TEA_control_sets);
|
|
|
|
|
itemsArray = getResources().getStringArray(R.array.TEA_control_sets_prefs);
|
|
|
|
|
} else {
|
|
|
|
|
itemsArray = order.split(BEAST_MODE_PREF_ITEM_SEPARATOR);
|
|
|
|
|
}
|
|
|
|
@ -106,7 +121,15 @@ public class BeastModePreferenceActivity extends ListActivity {
|
|
|
|
|
items.add(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
adapter = new ArrayAdapter<String>(this, R.layout.preference_draggable_row, R.id.text, items);
|
|
|
|
|
adapter = new ArrayAdapter<String>(this, R.layout.preference_draggable_row, R.id.text, items) {
|
|
|
|
|
@Override
|
|
|
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
|
|
View v = super.getView(position, convertView, parent);
|
|
|
|
|
TextView display = (TextView) v.findViewById(R.id.text);
|
|
|
|
|
display.setText(prefsToDescriptions.get(getItem(position)));
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
touchList.setAdapter(adapter);
|
|
|
|
|
touchList.setOnTouchListener(new OnTouchListener() {
|
|
|
|
|
@Override
|
|
|
|
@ -133,11 +156,20 @@ public class BeastModePreferenceActivity extends ListActivity {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buildDescriptionMap(Resources r) {
|
|
|
|
|
String[] keys = r.getStringArray(R.array.TEA_control_sets_prefs);
|
|
|
|
|
String[] descriptions = r.getStringArray(R.array.TEA_control_sets);
|
|
|
|
|
for (int i = 0; i < keys.length && i < descriptions.length; i++) {
|
|
|
|
|
prefsToDescriptions.put(keys[i], descriptions[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resetToDefault() {
|
|
|
|
|
String[] itemsArray = getResources().getStringArray(R.array.TEA_control_sets);
|
|
|
|
|
String[] prefsArray = getResources().getStringArray(R.array.TEA_control_sets_prefs);
|
|
|
|
|
String[] descriptionsArray = getResources().getStringArray(R.array.TEA_control_sets);
|
|
|
|
|
while (items.size() > 0)
|
|
|
|
|
items.remove(0);
|
|
|
|
|
for (String s : itemsArray)
|
|
|
|
|
for (String s : prefsArray)
|
|
|
|
|
items.add(s);
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
}
|
|
|
|
|