...
 
Commits (5)
This diff is collapsed.
package com.fsck.k9.activity.compose;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
......@@ -15,15 +10,22 @@ import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Contacts.Data;
import androidx.annotation.Nullable;
import androidx.loader.content.AsyncTaskLoader;
import androidx.core.content.ContextCompat;
import androidx.loader.content.AsyncTaskLoader;
import com.fsck.k9.R;
import com.fsck.k9.mail.Address;
import com.fsck.k9.view.RecipientSelectView.Recipient;
import com.fsck.k9.view.RecipientSelectView.RecipientCryptoStatus;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static android.Manifest.permission.READ_CONTACTS;
import static android.Manifest.permission.WRITE_CONTACTS;
......@@ -113,29 +115,35 @@ public class RecipientLoader extends AsyncTaskLoader<List<Recipient>> {
@Override
public List<Recipient> loadInBackground() {
List<Recipient> recipients = new ArrayList<>();
Map<String, Recipient> recipientMap = new HashMap<>();
if (addresses != null) {
fillContactDataFromAddresses(addresses, recipients, recipientMap);
} else if (contactUri != null) {
fillContactDataFromEmailContentUri(contactUri, recipients, recipientMap);
} else if (query != null) {
fillContactDataFromQuery(query, recipients, recipientMap);
} else if (lookupKeyUri != null) {
fillContactDataFromLookupKey(lookupKeyUri, recipients, recipientMap);
} else {
throw new IllegalStateException("loader must be initialized with query or list of addresses!");
}
if (recipients.isEmpty()) {
return recipients;
}
int writeContactsPermission = ContextCompat.checkSelfPermission(getContext(), WRITE_CONTACTS);
int readContactsPermission = ContextCompat.checkSelfPermission(getContext(), READ_CONTACTS);
if (writeContactsPermission == PackageManager.PERMISSION_GRANTED &&
readContactsPermission == PackageManager.PERMISSION_GRANTED) {
Map<String, Recipient> recipientMap = new HashMap<>();
if (addresses != null) {
fillContactDataFromAddresses(addresses, recipients, recipientMap);
} else if (contactUri != null) {
fillContactDataFromEmailContentUri(contactUri, recipients, recipientMap);
} else if (query != null) {
fillContactDataFromQuery(query, recipients, recipientMap);
} else if (lookupKeyUri != null) {
fillContactDataFromLookupKey(lookupKeyUri, recipients, recipientMap);
} else {
throw new IllegalStateException("loader must be initialized with query or list of addresses!");
}
if (cryptoProvider != null) {
fillCryptoStatusData(recipientMap);
}
if (recipients.isEmpty()) {
return recipients;
}
if (cryptoProvider != null) {
fillCryptoStatusData(recipientMap);
}
}
return recipients;
}
......@@ -267,13 +275,9 @@ public class RecipientLoader extends AsyncTaskLoader<List<Recipient>> {
String selection = Contacts.DISPLAY_NAME_PRIMARY + " LIKE ? " +
" OR (" + Email.ADDRESS + " LIKE ? AND " + Data.MIMETYPE + " = '" + Email.CONTENT_ITEM_TYPE + "')";
String[] selectionArgs = { query, query };
Cursor cursor = null;
int permissionCheck = ContextCompat.checkSelfPermission(getContext(),
WRITE_CONTACTS);
if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
cursor = contentResolver.query(queryUri, PROJECTION, selection, selectionArgs, SORT_ORDER);
}
String[] selectionArgs = {query, query};
Cursor cursor = contentResolver.query(queryUri, PROJECTION, selection, selectionArgs, SORT_ORDER);
if (cursor == null) {
return false;
......
......@@ -126,13 +126,6 @@ public class AccountSetupBasics extends PEpImporterActivity {
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.account_setup_basic_option, menu);
return true;
}
@Override
protected void refresh() {
}
......
......@@ -4427,8 +4427,9 @@ public class MessagingController implements Sync.MessageToSendCallback, KeyImpor
}
// Do not notify if the user does not have notifications enabled or if the message has
// been read.
if (!account.isNotifyNewMail() || message.isSet(Flag.SEEN)) {
// been read or it is an pep-autoconsume-message.
if (!account.isNotifyNewMail() || message.isSet(Flag.SEEN)
|| PEpUtils.isAutoConsumeMessage(message)) {
return false;
}
......
......@@ -16,6 +16,8 @@ import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
......@@ -143,9 +145,16 @@ public class AccountSetupBasicsFragment extends PEpFragment
mEmailView.setText(email);
mPasswordView.setText(password);
}
setHasOptionsMenu(true);
return rootView;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.account_setup_basic_option, menu);
}
private void setupToolbar() {
((AccountSetupBasics) getActivity()).initializeToolbar(true, R.string.account_setup_basics_title);
((AccountSetupBasics) getActivity()).setStatusBarPepColor(getResources().getColor(R.color.pep_green));
......
......@@ -5,6 +5,7 @@ import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.preference.CheckBoxPreference
import androidx.preference.MultiSelectListPreference
import androidx.preference.Preference
import com.fsck.k9.BuildConfig
......@@ -43,6 +44,7 @@ class GeneralSettingsFragment : PreferenceFragmentCompat() {
initializeNotificationQuickDelete()
initializeExtraKeysManagement()
initializeGlobalpEpKeyReset()
initializeAfterMessageDeleteBehavior()
if (!BuildConfig.WITH_KEY_SYNC) {
hideKeySyncOptions()
......@@ -130,6 +132,22 @@ class GeneralSettingsFragment : PreferenceFragmentCompat() {
}
}
private fun initializeAfterMessageDeleteBehavior() {
val returnToList: CheckBoxPreference? = findPreference(MESSAGEVIEW_RETURN_TO_LIST) as? CheckBoxPreference
val showNextMsg: CheckBoxPreference? = findPreference(MESSAGEVIEW_SHOW_NEXT_MSG) as? CheckBoxPreference
returnToList?.setOnPreferenceChangeListener { _, check ->
showNextMsg?.isChecked = !(check as Boolean)
true
}
showNextMsg?.setOnPreferenceChangeListener { _, check ->
returnToList?.isChecked = !(check as Boolean)
true
}
}
private fun dopEpKeyReset() {
disableKeyResetClickListener()
loading?.visibility = View.VISIBLE
......@@ -194,6 +212,8 @@ class GeneralSettingsFragment : PreferenceFragmentCompat() {
private const val PREFERENCE_PEP_EXTRA_KEYS = "pep_extra_keys"
private const val PREFERENCE_PEP_OWN_IDS_KEY_RESET = "pep_key_reset"
private const val PREFERENCE_PEP_ENABLE_SYNC = "pep_enable_sync"
private const val MESSAGEVIEW_RETURN_TO_LIST = "messageview_return_to_list"
private const val MESSAGEVIEW_SHOW_NEXT_MSG = "messageview_show_next"
fun create(rootKey: String? = null) = GeneralSettingsFragment().withArguments(
......
......@@ -328,6 +328,7 @@
<string name="global_settings_messageview_return_to_list_summary">Return to message list after message deletion</string>
<string name="global_settings_messageview_show_next_label">Show next message after delete</string>
<string name="global_settings_messageview_show_next_summary">Show next message by default after message deletion</string>
<string name="global_settings_messageiew_after_delete_behavior_title">After message deleted behavior</string>
<string name="global_settings_confirm_actions_title">Confirm actions</string>
<string name="global_settings_confirm_actions_summary">Show a dialog whenever you perform selected actions</string>
......
<?xml version="1.0" encoding="utf-8"?>
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
<?xml version="1.0" encoding="utf-8"?><!--suppress AndroidElementNotAllowed -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:title="@string/general_settings_title">
......@@ -198,8 +196,8 @@
android:title="@string/global_settings_messageview_autofit_width_label" />
<PreferenceCategory
android:key="message_view_advanced"
app:initialExpandedChildrenCount="0"
app:allowDividerAbove="false">
app:allowDividerAbove="false"
app:initialExpandedChildrenCount="0">
<CheckBoxPreference
android:key="messageview_fixedwidth_font"
android:summary="@string/global_settings_messageview_fixedwidth_summary"
......@@ -228,28 +226,32 @@
android:key="volume_navigation"
android:title="@string/volume_navigation_title" />
<CheckBoxPreference
android:key="messageview_return_to_list"
android:summary="@string/global_settings_messageview_return_to_list_summary"
android:title="@string/global_settings_messageview_return_to_list_label" />
<PreferenceCategory android:title="@string/global_settings_messageiew_after_delete_behavior_title">
<CheckBoxPreference
android:key="messageview_return_to_list"
android:summary="@string/global_settings_messageview_return_to_list_summary"
android:title="@string/global_settings_messageview_return_to_list_label" />
<CheckBoxPreference
android:key="messageview_show_next"
android:summary="@string/global_settings_messageview_show_next_summary"
android:title="@string/global_settings_messageview_show_next_label" />
<CheckBoxPreference
android:key="messageview_show_next"
android:summary="@string/global_settings_messageview_show_next_summary"
android:title="@string/global_settings_messageview_show_next_label" />
</PreferenceCategory>
<MultiSelectListPreference
android:dialogTitle="@string/global_settings_confirm_actions_title"
android:entries="@array/confirm_action_entries"
android:entryValues="@array/confirm_action_values"
android:key="confirm_actions"
android:summary="@string/global_settings_confirm_actions_summary"
android:title="@string/global_settings_confirm_actions_title" />
<PreferenceCategory>
<MultiSelectListPreference
android:dialogTitle="@string/global_settings_confirm_actions_title"
android:entries="@array/confirm_action_entries"
android:entryValues="@array/confirm_action_values"
android:key="confirm_actions"
android:summary="@string/global_settings_confirm_actions_summary"
android:title="@string/global_settings_confirm_actions_title" />
</PreferenceCategory>
<PreferenceCategory
android:key="advanced_interaction_preferences"
app:initialExpandedChildrenCount="0"
app:allowDividerAbove="false">
app:allowDividerAbove="false"
app:initialExpandedChildrenCount="0">
<CheckBoxPreference
android:key="start_integrated_inbox"
android:title="@string/start_integrated_inbox_title" />
......@@ -258,9 +260,9 @@
</PreferenceScreen>
<PreferenceScreen
android:title="@string/notifications_title"
android:icon="?attr/iconPreferencesNotifications"
android:key="notification_preferences">
android:key="notification_preferences"
android:title="@string/notifications_title">
<CheckBoxPreference
android:key="quiet_time_enabled"
......@@ -306,8 +308,8 @@
</PreferenceScreen>
<PreferenceScreen
android:key="pep_global"
android:icon="?attr/iconpEpShield"
android:key="pep_global"
android:title="@string/privacy_preferences">
<!--<EditTextPreference-->
......@@ -337,23 +339,22 @@
<Preference
android:key="pep_key_reset"
android:title="@string/reset"
android:summary="@string/pep_key_reset_all_own_ids_summary"/>
android:summary="@string/pep_key_reset_all_own_ids_summary"
android:title="@string/reset" />
<Preference
android:persistent="false"
android:key="pep_extra_keys"
android:persistent="false"
android:singleLine="true"
android:title="@string/master_key_management"
android:summary="Encrypt messages with additional keys.">
</Preference>
android:summary="Encrypt messages with additional keys."
android:title="@string/master_key_management"/>
<SwitchPreferenceCompat
android:key="pep_enable_sync"
android:title="@string/pep_sync"
android:summaryOff="@string/pep_sync_is_disabled_global"
android:summaryOn="@string/pep_sync_is_enabled_global"
android:summaryOff="@string/pep_sync_is_disabled_global" />
android:title="@string/pep_sync" />
<PreferenceCategory
android:key="pep_gpg_compatibility"
......@@ -367,7 +368,6 @@
android:title="@string/pep_subject_unprotected" />
<Preference
android:key="pep_gpg_blacklist"
android:title="Blacklist">
......@@ -417,8 +417,6 @@
<!--/>-->
<!--Preference
android:key="pep_manage_keysync"
android:persistent="false"
......@@ -441,12 +439,12 @@
</PreferenceScreen>
<PreferenceScreen
android:icon="@drawable/ic_advanced_light"
android:key="advanced_preferences"
android:title="@string/advanced"
android:icon="@drawable/ic_advanced_light">
android:title="@string/advanced">
<PreferenceCategory
android:title="@string/miscellaneous_preferences"
android:key="misc_preferences">
android:key="misc_preferences"
android:title="@string/miscellaneous_preferences">
<Preference
android:key="attachment_default_path"
......@@ -468,8 +466,8 @@
android:title="@string/debug_preferences">
<CheckBoxPreference
android:key="debug_logging"
android:icon="?attr/iconPreferencesDebug"
android:key="debug_logging"
android:summary="@string/debug_enable_debug_logging_summary"
android:title="@string/debug_enable_debug_logging_title" />
......