Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in capacity for a SortableListPreference #1

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions demo/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application android:label="@string/app_name"
android:allowBackup="true"
android:icon="@drawable/dslv_launcher" >

<activity android:name="Launcher"
Expand Down Expand Up @@ -46,5 +47,6 @@

<activity android:name="SingleChoiceListView"
android:label="Single-choice list" />
<activity android:name="MainSettingsActivity"></activity>
</application>
</manifest>
2 changes: 1 addition & 1 deletion demo/res/layout/checkable_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mobeta.android.dslv.DragSortListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/com.mobeta.android.demodslv"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
2 changes: 1 addition & 1 deletion demo/res/layout/cursor_main.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mobeta.android.dslv.DragSortListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/com.mobeta.android.demodslv"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
2 changes: 1 addition & 1 deletion demo/res/layout/dslv_fragment_main.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mobeta.android.dslv.DragSortListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/com.mobeta.android.demodslv"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
2 changes: 1 addition & 1 deletion demo/res/layout/hetero_main.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mobeta.android.dslv.DragSortListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/com.mobeta.android.demodslv"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
1 change: 1 addition & 0 deletions demo/res/layout/jazz_artist_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</LinearLayout>
<ImageView
android:id="@id/drag_handle"
android:contentDescription="@string/drag_item"
android:background="@drawable/drag"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
Expand Down
2 changes: 2 additions & 0 deletions demo/res/layout/list_item_checkable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
android:orientation="horizontal">
<ImageView
android:id="@id/drag_handle"
android:contentDescription="@string/drag_item"
android:background="@drawable/drag"
android:layout_width="wrap_content"
android:layout_height="@dimen/item_height"
Expand All @@ -21,6 +22,7 @@
android:paddingLeft="8dp" />
<ImageView
android:id="@id/click_remove"
android:contentDescription="@string/remove_item"
android:background="@drawable/delete_x"
android:layout_width="@dimen/item_height"
android:layout_height="@dimen/item_height"
Expand Down
2 changes: 2 additions & 0 deletions demo/res/layout/list_item_click_remove.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:background="@drawable/drag"
android:layout_width="wrap_content"
android:layout_height="@dimen/item_height"
android:contentDescription="@string/drag_item"
android:layout_weight="0" />
<TextView
android:id="@+id/text"
Expand All @@ -20,6 +21,7 @@
android:paddingLeft="8dp" />
<ImageView
android:id="@id/click_remove"
android:contentDescription="@string/remove_item"
android:background="@drawable/delete_x"
android:layout_width="@dimen/item_height"
android:layout_height="@dimen/item_height"
Expand Down
1 change: 1 addition & 0 deletions demo/res/layout/list_item_handle_left.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
android:layout_height="@dimen/item_height"
android:orientation="horizontal">
<ImageView
android:contentDescription="@string/drag_item"
android:id="@id/drag_handle"
android:background="@drawable/drag"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions demo/res/layout/list_item_handle_right.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
android:paddingLeft="8dp" />
<ImageView
android:id="@id/drag_handle"
android:contentDescription="@string/drag_item"
android:background="@drawable/drag"
android:layout_width="wrap_content"
android:layout_height="@dimen/item_height"
Expand Down
1 change: 1 addition & 0 deletions demo/res/layout/list_item_radio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
android:orientation="horizontal">
<ImageView
android:id="@id/drag_handle"
android:contentDescription="@string/drag_item"
android:background="@drawable/drag"
android:layout_width="wrap_content"
android:layout_height="@dimen/item_height"
Expand Down
23 changes: 23 additions & 0 deletions demo/res/layout/list_item_simple_checkable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mobeta.android.demodslv.CheckableLinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="@dimen/item_height"
android:orientation="horizontal">
<ImageView
android:id="@id/drag_handle"
android:background="@drawable/drag"
android:layout_width="wrap_content"
android:layout_height="@dimen/item_height"
android:contentDescription="@string/drag_item"
android:layout_weight="0" />
<CheckedTextView
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="@dimen/item_height"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="center_vertical"
android:paddingLeft="8dp" />
</com.mobeta.android.demodslv.CheckableLinearLayout>
1 change: 1 addition & 0 deletions demo/res/layout/section_div.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:contentDescription="@null"
android:background="@drawable/section_div"
android:id="@+id/section_div"
android:layout_width="fill_parent"
Expand Down
2 changes: 1 addition & 1 deletion demo/res/layout/sections_main.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mobeta.android.dslv.DragSortListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/com.mobeta.android.demodslv"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
11 changes: 11 additions & 0 deletions demo/res/layout/sort_list_array_dialog_preference.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mobeta.android.dslv.DragSortListView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:id="@android:id/list" android:focusable="false"
android:focusableInTouchMode="false" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_margin="3dp"
android:choiceMode="multipleChoice" dslv:sort_enabled="true"
dslv:remove_enabled="false" dslv:drag_handle_id="@id/drag_handle" />



2 changes: 1 addition & 1 deletion demo/res/layout/warp_main.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mobeta.android.dslv.DragSortListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/com.mobeta.android.demodslv"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
5 changes: 5 additions & 0 deletions demo/res/menu/activity_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_settings" android:title="@string/settings" />
</menu>

20 changes: 20 additions & 0 deletions demo/res/values/preferences_strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="pref_name_values">
<item>Bob</item>
<item>Fred</item>
<item>George</item>
</string-array>
<string-array name="pref_name_titles">
<item>Bob Menwaldo</item>
<item>Fred Frankfurd</item>
<item>George Stephanopolis</item>
</string-array>
<string-array name="pref_name_defaults">
<item>George</item>
<item>Fred</item>
<item>Bob</item>
</string-array>
<string name="pref_name_selection">Name Order Preference</string>
<string name="pref_header_test">Test</string>
</resources>
5 changes: 4 additions & 1 deletion demo/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<item>Mark Turner</item>
</string-array>
<string-array name="jazz_artist_albums">
<item>Largo, Art of the Trio 1-4, Highway Rider, Songs</item>
<item>Largo, Art of the Trio 1&#8211;4, Highway Rider, Songs</item>
<item>Elastic, Momentum, Mood Swing, Back East</item>
<item>Light as a Feather, Akoustic Band, My Spanish Heart</item>
<item>Deep Song, Heartcore, Our Secret World, Reflections, The Remedy: Live at the Village Vanguard, The Enemies of Energy, The Next Step</item>
Expand Down Expand Up @@ -301,4 +301,7 @@
<item>Zambia</item>
<item>Zimbabwe</item>
</string-array>
<string name="settings">Settings</string>
<string name="drag_item">Drag Item</string>
<string name="remove_item">Remove Item</string>
</resources>
9 changes: 9 additions & 0 deletions demo/res/xml/pref_headers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<preference-headers
xmlns:android="http://schemas.android.com/apk/res/android">

<!-- These settings headers are only used on tablets. -->

<header
android:fragment="com.mobeta.android.demodslv.MainSettingsActivity$NameSelectionPreferenceFragment"
android:title="@string/pref_header_test"/>
</preference-headers>
9 changes: 9 additions & 0 deletions demo/res/xml/pref_name.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<com.mobeta.android.demodslv.SortableListPreference
android:defaultValue="@array/pref_name_defaults"
android:entries="@array/pref_name_titles"
android:entryValues="@array/pref_name_values"
android:key="name_order"
android:persistent="true"
android:title="@string/pref_name_selection" />
</PreferenceScreen>
6 changes: 5 additions & 1 deletion demo/src/com/mobeta/android/demodslv/DSLVFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ protected void setListAdapter() {
String[] array = getResources().getStringArray(R.array.jazz_artist_names);
List<String> list = new ArrayList<String>(Arrays.asList(array));


mAdapter = new ArrayAdapter<String>(getActivity(), getItemLayout(), R.id.text, list);
setListAdapter(mAdapter);
}
Expand Down Expand Up @@ -129,7 +130,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
return mDslv;
}

@Override
@SuppressWarnings("unchecked")
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

Expand All @@ -145,6 +147,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
headers = args.getInt("headers", 0);
footers = args.getInt("footers", 0);
}


for (int i = 0; i < headers; i++) {
addHeader(getActivity(), mDslv);
Expand All @@ -154,6 +157,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
}

setListAdapter();
mAdapter=(ArrayAdapter<String>) getListAdapter();
}


Expand Down
12 changes: 7 additions & 5 deletions demo/src/com/mobeta/android/demodslv/DSLVFragmentClicks.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mobeta.android.demodslv;

import java.util.Locale;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
Expand All @@ -19,25 +21,25 @@ public static DSLVFragmentClicks newInstance(int headers, int footers) {
return f;
}

@Override
@Override
public void onActivityCreated(Bundle savedState) {
super.onActivityCreated(savedState);

ListView lv = getListView();
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
String message = String.format("Clicked item %d", arg2);
String message = String.format(Locale.getDefault(),"Clicked item %d", arg2);
Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();

}
});
lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
String message = String.format("Long-clicked item %d", arg2);
String message = String.format(Locale.getDefault(),"Long-clicked item %d", arg2);
Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();
return true;
}
Expand Down
Loading