Skip to content
Browse files

Merge pull request #1 from vonloxley/sort_preference

Add sort-order preference
  • Loading branch information...
2 parents 4b9080e + 1d0d1d9 commit e7f81a301f310d0e3d4618eb595e3b3cbb51be43 @friedger friedger committed Jan 9, 2013
View
8 Countdown/res/values/strings.xml
@@ -167,5 +167,13 @@
</string-array>
+ <string-array name="preference_sortorder_entries">
+ <item >Creation</item>
+ <item >Modification</item>
+ <item >Title</item>
+ </string-array>
+ <string name="sort_by">Sort by</string>
+ <string name="sort_order_summary">Takes effect after restart</string>
<string name="no_permission">OI Countdown doesn\'t have the permission for this task.</string>
+
</resources>
View
5 Countdown/res/values/strings_not_for_translation.xml
@@ -59,5 +59,10 @@
<item>300</item>
<item>600</item>
</string-array>
+ <string-array name="preference_sortorder_entryvalues">
+ <item >created asc</item>
+ <item >modified desc</item>
+ <item >title asc</item>
+ </string-array>
</resources>
View
1 Countdown/res/xml/preferences.xml
@@ -29,6 +29,7 @@
android:entries="@array/preference_notification_timeout_entries"
android:entryValues="@array/preference_notification_timeout_entryvalues"
android:dialogTitle="@string/preference_notification_timeout_dialog_title" />
+ <ListPreference android:entries="@array/preference_sortorder_entries" android:dialogTitle="@string/sort_by" android:entryValues="@array/preference_sortorder_entryvalues" android:title="@string/sort_by" android:key="sort_order" android:summary="@string/sort_order_summary" android:defaultValue="modified desc"/>
</PreferenceCategory>
View
6 Countdown/src/org/openintents/countdown/PreferenceActivity.java
@@ -16,6 +16,7 @@
package org.openintents.countdown;
+import org.openintents.countdown.db.Countdown.Durations;
import org.openintents.util.IntentUtils;
import android.content.Context;
@@ -29,6 +30,7 @@
public static final String PREFS_NOTIFICATION_TIMEOUT = "notification_timeout";
public static final String PREFS_NOTIFICATION_TIMEOUT_DEFAULT = "300";
+ public static final String PREFS_SORT_ORDER = "sort_order";
public static final String PREFS_EXTENSIONS_MARKET = "preference_extensions_market";
@Override
@@ -70,4 +72,8 @@ static public long getNotificationTimeoutFromPrefs(Context context) {
}
return notificationTimeout;
}
+
+ static public String getSortOrderFromPrefs(Context context){
+ return PreferenceManager.getDefaultSharedPreferences(context).getString(PREFS_SORT_ORDER, Durations.DEFAULT_SORT_ORDER);
+ }
}
View
5 Countdown/src/org/openintents/countdown/list/CountdownListActivity.java
@@ -39,6 +39,8 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
@@ -142,7 +144,8 @@ protected void onCreate(Bundle savedInstanceState) {
// Perform a managed query. The Activity will handle closing and requerying the cursor
// when needed.
mCursor = managedQuery(getIntent().getData(), PROJECTION, null, null,
- Durations.DEFAULT_SORT_ORDER);
+ PreferenceActivity.getSortOrderFromPrefs(this)
+ );
if (mCursor.getCount() == 0) {
// Create a new timer immediately

0 comments on commit e7f81a3

Please sign in to comment.
Something went wrong with that request. Please try again.