Allow user to edit number of update history days in prefs.

Instead of using hardcoded 14 days.
This commit is contained in:
Paul Sokolovsky 2013-03-17 00:35:12 +02:00
parent 249e7319ec
commit b71fcab896
3 changed files with 17 additions and 1 deletions

View File

@ -19,6 +19,8 @@
<string name="notify_updates_available">Notify when new updates are available</string> <string name="notify_updates_available">Notify when new updates are available</string>
<string name="update_apps_list">Update app list from repositories automatically <string name="update_apps_list">Update app list from repositories automatically
</string> </string>
<string name="update_history">Update history</string>
<string name="update_history_desc">Days to show new/updated apps</string>
<string name="last_update_check">Last repo scan: %s</string> <string name="last_update_check">Last repo scan: %s</string>
<string name="never">never</string> <string name="never">never</string>
<string name="automatic_repo_scan">Automatic repo scan</string> <string name="automatic_repo_scan">Automatic repo scan</string>

View File

@ -18,6 +18,13 @@
<CheckBoxPreference android:title="@string/notify" <CheckBoxPreference android:title="@string/notify"
android:defaultValue="true" android:summary="@string/notify_updates_available" android:defaultValue="true" android:summary="@string/notify_updates_available"
android:key="updateNotify" /> android:key="updateNotify" />
<EditTextPreference
android:defaultValue="14"
android:key="updateHistoryDays"
android:maxLength="2"
android:numeric="integer"
android:summary="@string/update_history_desc"
android:title="@string/update_history" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/antifeatures"> <PreferenceCategory android:title="@string/antifeatures">
<CheckBoxPreference android:title="@string/antiads" <CheckBoxPreference android:title="@string/antiads"

View File

@ -37,10 +37,12 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.ResultReceiver; import android.os.ResultReceiver;
import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -384,8 +386,13 @@ public class FDroid extends TabActivity implements OnItemClickListener,
// Calculate the cutoff date we'll use for What's New and Recently // Calculate the cutoff date we'll use for What's New and Recently
// Updated... // Updated...
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
String sint = prefs.getString("updateHistoryDays", "14");
int history_days = Integer.parseInt(sint);
Calendar recent = Calendar.getInstance(); Calendar recent = Calendar.getInstance();
recent.add(Calendar.DAY_OF_YEAR, -14); recent.add(Calendar.DAY_OF_YEAR, -history_days);
Date recentDate = recent.getTime(); Date recentDate = recent.getTime();
AppFilter appfilter = new AppFilter(this); AppFilter appfilter = new AppFilter(this);