mirror of https://github.com/tasks/tasks
Customization of task edit activity layout
parent
36621ab281
commit
1741dd34ee
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<com.commonsware.cwac.tlv.TouchListView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tlv="http://schemas.android.com/apk/res/com.timsu.astrid"
|
||||||
|
|
||||||
|
android:id="@android:id/list"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:cacheColorHint="#00000000"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawSelectorOnTop="false"
|
||||||
|
|
||||||
|
tlv:normal_height="52dip"
|
||||||
|
tlv:grabber="@+id/grabber" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/reset"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="100dip"
|
||||||
|
android:text="@string/EPr_beastMode_reset"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- See the file "LICENSE" for the full license governing this code. -->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:astrid="http://schemas.android.com/apk/res/com.timsu.astrid"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="52dip"
|
||||||
|
android:paddingTop="2dip"
|
||||||
|
android:paddingBottom="2dip"
|
||||||
|
android:paddingLeft="4dip"
|
||||||
|
android:paddingRight="4dip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<!-- grabber -->
|
||||||
|
<ImageView android:id="@+id/grabber"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/grabber"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="right"
|
||||||
|
android:paddingRight="5dip"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||||
|
</LinearLayout>
|
||||||
@ -0,0 +1,96 @@
|
|||||||
|
package com.todoroo.astrid.activity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import android.app.ListActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnTouchListener;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import com.commonsware.cwac.tlv.TouchListView;
|
||||||
|
import com.commonsware.cwac.tlv.TouchListView.DropListener;
|
||||||
|
import com.timsu.astrid.R;
|
||||||
|
import com.todoroo.andlib.utility.Preferences;
|
||||||
|
|
||||||
|
public class BeastModePreferenceActivity extends ListActivity {
|
||||||
|
|
||||||
|
private TouchListView touchList;
|
||||||
|
private ArrayAdapter<String> adapter;
|
||||||
|
|
||||||
|
private ArrayList<String> items;
|
||||||
|
|
||||||
|
public static final String BEAST_MODE_ORDER_PREF = "beast_mode_order"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static final String BEAST_MODE_PREF_ITEM_SEPARATOR = ";"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.beast_mode_pref_activity);
|
||||||
|
setTitle(R.string.EPr_beastMode_desc);
|
||||||
|
|
||||||
|
touchList = (TouchListView) getListView();
|
||||||
|
String order = Preferences.getStringValue(BEAST_MODE_ORDER_PREF);
|
||||||
|
String[] itemsArray;
|
||||||
|
if (order == null) {
|
||||||
|
itemsArray = getResources().getStringArray(R.array.TEA_control_sets);
|
||||||
|
} else {
|
||||||
|
itemsArray = order.split(BEAST_MODE_PREF_ITEM_SEPARATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
items = new ArrayList<String>();
|
||||||
|
for (String s : itemsArray) {
|
||||||
|
items.add(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
adapter = new ArrayAdapter<String>(this, R.layout.preference_draggable_row, R.id.text, items);
|
||||||
|
touchList.setAdapter(adapter);
|
||||||
|
touchList.setOnTouchListener(new OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
touchList.setDropListener(new DropListener() {
|
||||||
|
@Override
|
||||||
|
public void drop(int from, int to) {
|
||||||
|
String s = items.remove(from);
|
||||||
|
items.add(to, s);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button resetButton = (Button) findViewById(R.id.reset);
|
||||||
|
resetButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
resetToDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetToDefault() {
|
||||||
|
String[] itemsArray = getResources().getStringArray(R.array.TEA_control_sets);
|
||||||
|
while (items.size() > 0)
|
||||||
|
items.remove(0);
|
||||||
|
for (String s : itemsArray)
|
||||||
|
items.add(s);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finish() {
|
||||||
|
StringBuilder newSetting = new StringBuilder(30);
|
||||||
|
for (int i = 0; i < adapter.getCount(); i++) {
|
||||||
|
newSetting.append(adapter.getItem(i));
|
||||||
|
newSetting.append(BEAST_MODE_PREF_ITEM_SEPARATOR);
|
||||||
|
}
|
||||||
|
Preferences.setString(BEAST_MODE_ORDER_PREF, newSetting.toString());
|
||||||
|
super.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue