Make number of recent calls configurable
This commit is contained in:
parent
6599e71225
commit
3dc63ee45b
|
@ -219,7 +219,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
= new AsyncTask<Void, Void, List<CallLogItem>>() {
|
||||
@Override
|
||||
protected List<CallLogItem> doInBackground(Void... voids) {
|
||||
List<CallLogItem> items = CallLogHelper.getRecentCalls(MainActivity.this, 20);
|
||||
List<CallLogItem> items = CallLogHelper.getRecentCalls(
|
||||
MainActivity.this, settings.getNumberOfRecentCalls());
|
||||
|
||||
for (CallLogItem item : items) {
|
||||
if (DatabaseSingleton.getCommunityDatabase().isOperational()) {
|
||||
|
|
|
@ -12,6 +12,7 @@ public class Settings extends GenericSettings {
|
|||
public static final String PREF_INCOMING_CALL_NOTIFICATIONS = "incomingCallNotifications";
|
||||
public static final String PREF_BLOCK_CALLS = "blockCalls";
|
||||
public static final String PREF_USE_CONTACTS = "useContacts";
|
||||
public static final String PREF_NUMBER_OF_RECENT_CALLS = "numberOfRecentCalls";
|
||||
public static final String PREF_NOTIFICATIONS_KNOWN = "showNotificationsForKnownCallers";
|
||||
public static final String PREF_NOTIFICATIONS_UNKNOWN = "showNotificationsForUnknownCallers";
|
||||
public static final String PREF_LAST_UPDATE_TIME = "lastUpdateTime";
|
||||
|
@ -83,6 +84,14 @@ public class Settings extends GenericSettings {
|
|||
setBoolean(PREF_USE_CONTACTS, use);
|
||||
}
|
||||
|
||||
public int getNumberOfRecentCalls() {
|
||||
return getInt(PREF_NUMBER_OF_RECENT_CALLS, 20);
|
||||
}
|
||||
|
||||
public void setNumberOfRecentCalls(int number) {
|
||||
setInt(PREF_NUMBER_OF_RECENT_CALLS, number);
|
||||
}
|
||||
|
||||
public boolean getNotificationsForKnownCallers() {
|
||||
return getBoolean(PREF_NOTIFICATIONS_KNOWN);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package dummydomain.yetanothercallblocker.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.preference.EditTextPreference;
|
||||
|
||||
public class IntEditTextPreference extends EditTextPreference {
|
||||
|
||||
public IntEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
setListener();
|
||||
}
|
||||
|
||||
public IntEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setListener();
|
||||
}
|
||||
|
||||
public IntEditTextPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setListener();
|
||||
}
|
||||
|
||||
public IntEditTextPreference(Context context) {
|
||||
super(context);
|
||||
setListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object onGetDefaultValue(TypedArray a, int index) {
|
||||
return a.getInt(index, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSetInitialValue(Object defaultValue) {
|
||||
int defaultInt = defaultValue != null ? (int) defaultValue : 0;
|
||||
setText(String.valueOf(getPersistedInt(defaultInt)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean persistString(String value) {
|
||||
return persistInt(!TextUtils.isEmpty(value) ? Integer.parseInt(value) : 0);
|
||||
}
|
||||
|
||||
private void setListener() {
|
||||
setOnBindEditTextListener(editText -> editText.setInputType(InputType.TYPE_CLASS_NUMBER));
|
||||
}
|
||||
|
||||
}
|
|
@ -75,6 +75,8 @@
|
|||
<string name="notification_background_operation">Выполняется процесс в фоне…</string>
|
||||
<string name="use_contacts">Отображать имена контактов</string>
|
||||
<string name="use_contacts_summary">Номера из телефонной книги никогда не блокируются, и имя контакта отображается рядом/вместо номера</string>
|
||||
<string name="number_of_recent_calls">Кол-во недавних вызовов</string>
|
||||
<string name="number_of_recent_calls_summary">Количество недавних вызовов на основном экране</string>
|
||||
<string name="notification_incoming_call_contact">Контакт</string>
|
||||
<string name="open_settings_activity">Настройки</string>
|
||||
<string name="title_settings_activity">Настройки</string>
|
||||
|
|
|
@ -98,6 +98,8 @@
|
|||
<string name="auto_updates_summary">Automatically receive daily DB updates (these are incremental/delta updates, so they consume very little traffic)</string>
|
||||
<string name="use_contacts">Use contacts</string>
|
||||
<string name="use_contacts_summary">Numbers present in the phone book are never blocked and the contact name is displayed next to/instead of a number throughout the app</string>
|
||||
<string name="number_of_recent_calls">Number of recent calls</string>
|
||||
<string name="number_of_recent_calls_summary">The number of recent calls to display on the main screen</string>
|
||||
|
||||
<string name="settings_screen_advanced">Advanced settings</string>
|
||||
<string name="settings_category_country_codes">Country codes</string>
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
app:key="useContacts"
|
||||
app:summary="@string/use_contacts_summary"
|
||||
app:title="@string/use_contacts" />
|
||||
<dummydomain.yetanothercallblocker.preference.IntEditTextPreference
|
||||
app:defaultValue="20"
|
||||
app:key="numberOfRecentCalls"
|
||||
app:summary="@string/number_of_recent_calls_summary"
|
||||
app:title="@string/number_of_recent_calls" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/settings_category_call_blocking">
|
||||
|
|
Loading…
Reference in New Issue