mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 09:47:13 +00:00
Added sync more
This commit is contained in:
parent
ba6af044c3
commit
b0cb4d7100
5 changed files with 118 additions and 21 deletions
3
FAQ.md
3
FAQ.md
|
@ -50,8 +50,7 @@ Related questions:
|
|||
* Go to the next/previous message on archive/delete: in the behavior settings disable *Automatically close conversations* and select *Go to next/previous conversation* for *On closing a conversation*
|
||||
* Add a folder to the unified inbox: long press the folder in the folder list and check *Show in unified inbox*
|
||||
* Add a folder to the navigation menu: long press the folder in the folder list and check *Show in navigation menu*
|
||||
* Load all messages: long press a folder in the folder list, select *Synchronize all messages*; this will fetch all messages once
|
||||
* Load older messages: long press a folder in the folder list, select *Edit properties* and change the number of days to sync/keep messages for; please [read this FAQ](#user-content-faq39)
|
||||
* Load all messages: long press a folder in the folder list, select *Synchronize all/more messages*
|
||||
* Delete a message, skipping trash: in the 3-dots menu of the action bar just above the message text *Delete* or alternatively, unselect the trash folder in the account settings
|
||||
* Delete an account/identity: Setup step 1/2, Manage, tap account/identity, three-dots menu, Delete
|
||||
* Delete a folder: long press the folder in the folder list, Edit properties, three-dots menu, Delete
|
||||
|
|
|
@ -19,9 +19,11 @@ package eu.faircode.email;
|
|||
Copyright 2018-2020 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
|
@ -42,12 +44,15 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
@ -419,7 +424,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
popupMenu.getMenu().add(Menu.NONE, R.string.title_synchronize_now, 1, R.string.title_synchronize_now);
|
||||
|
||||
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP) {
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_synchronize_all, 2, R.string.title_synchronize_all);
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_synchronize_more, 2, R.string.title_synchronize_more);
|
||||
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete_local, 3, R.string.title_delete_local);
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete_browsed, 4, R.string.title_delete_browsed);
|
||||
|
@ -482,8 +487,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
onActionSync();
|
||||
return true;
|
||||
|
||||
case R.string.title_synchronize_all:
|
||||
onActionSynAll();
|
||||
case R.string.title_synchronize_more:
|
||||
onActionSyncMore();
|
||||
return true;
|
||||
|
||||
case R.string.title_unified_folder:
|
||||
|
@ -548,23 +553,21 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
private void onActionSync() {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("folder", folder.id);
|
||||
args.putBoolean("all", false);
|
||||
args.putInt("months", -1);
|
||||
Intent data = new Intent();
|
||||
data.putExtra("args", args);
|
||||
parentFragment.onActivityResult(FragmentFolders.REQUEST_SYNC, RESULT_OK, data);
|
||||
}
|
||||
|
||||
private void onActionSynAll() {
|
||||
Bundle aargs = new Bundle();
|
||||
aargs.putString("question",
|
||||
context.getString(R.string.title_ask_sync_all, folder.getDisplayName(context)));
|
||||
aargs.putLong("folder", folder.id);
|
||||
aargs.putBoolean("all", true);
|
||||
private void onActionSyncMore() {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("folder", folder.id);
|
||||
args.putString("name", folder.getDisplayName(context));
|
||||
|
||||
FragmentDialogAsk ask = new FragmentDialogAsk();
|
||||
ask.setArguments(aargs);
|
||||
ask.setTargetFragment(parentFragment, FragmentFolders.REQUEST_SYNC);
|
||||
ask.show(parentFragment.getParentFragmentManager(), "folder:sync");
|
||||
FragmentDialogSync sync = new FragmentDialogSync();
|
||||
sync.setArguments(args);
|
||||
sync.setTargetFragment(parentFragment, FragmentFolders.REQUEST_SYNC);
|
||||
sync.show(parentFragment.getParentFragmentManager(), "folder:sync");
|
||||
}
|
||||
|
||||
private void onActionProperty(int property, boolean enabled) {
|
||||
|
@ -1023,4 +1026,39 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
interface IFolderSelectedListener {
|
||||
void onFolderSelected(TupleFolderEx folder);
|
||||
}
|
||||
|
||||
public static class FragmentDialogSync extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
String name = getArguments().getString("name");
|
||||
|
||||
View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_sync, null);
|
||||
final TextView tvFolder = view.findViewById(R.id.tvFolder);
|
||||
final EditText etMonths = view.findViewById(R.id.etMonths);
|
||||
|
||||
tvFolder.setText(name);
|
||||
etMonths.setText(null);
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(view)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String months = etMonths.getText().toString();
|
||||
if (TextUtils.isEmpty(months))
|
||||
getArguments().putInt("months", 0);
|
||||
else
|
||||
try {
|
||||
getArguments().putInt("months", Integer.parseInt(months));
|
||||
} catch (NumberFormatException ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
sendResult(RESULT_OK);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -523,10 +523,10 @@ public class FragmentFolders extends FragmentBase {
|
|||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) {
|
||||
boolean all = args.getBoolean("all");
|
||||
int months = args.getInt("months", -1);
|
||||
long fid = args.getLong("folder");
|
||||
|
||||
if (!ConnectionHelper.getNetworkState(context).isSuitable())
|
||||
if (months < 0 && !ConnectionHelper.getNetworkState(context).isSuitable())
|
||||
throw new IllegalStateException(context.getString(R.string.title_no_internet));
|
||||
|
||||
boolean now = true;
|
||||
|
@ -539,9 +539,12 @@ public class FragmentFolders extends FragmentBase {
|
|||
if (folder == null)
|
||||
return null;
|
||||
|
||||
if (all) {
|
||||
if (months == 0) {
|
||||
db.folder().setFolderInitialize(folder.id, Integer.MAX_VALUE);
|
||||
db.folder().setFolderKeep(folder.id, Integer.MAX_VALUE);
|
||||
} else if (months > 0) {
|
||||
db.folder().setFolderInitialize(folder.id, months * 31);
|
||||
db.folder().setFolderKeep(folder.id, months * 31);
|
||||
}
|
||||
|
||||
EntityOperation.sync(context, folder.id, true);
|
||||
|
|
56
app/src/main/res/layout/dialog_sync.xml
Normal file
56
app/src/main/res/layout/dialog_sync.xml
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="24dp">
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvFolder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@+id/etKeyword"
|
||||
android:text="Folder"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvSync"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:labelFor="@+id/etKeyword"
|
||||
android:text="@string/title_synchronize_more"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvFolder" />
|
||||
|
||||
<eu.faircode.email.EditTextPlain
|
||||
android:id="@+id/etMonths"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:hint="@string/title_months_all"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="number"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvMonths"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSync">
|
||||
|
||||
<requestFocus />
|
||||
</eu.faircode.email.EditTextPlain>
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvMonths"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@+id/etMonths"
|
||||
android:text="@string/title_months"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@id/etMonths"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/etMonths" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -606,7 +606,7 @@
|
|||
<string name="title_advanced_expand_read">Mark messages read on expanding</string>
|
||||
|
||||
<string name="title_synchronize_now">Synchronize now</string>
|
||||
<string name="title_synchronize_all">Synchronize all messages</string>
|
||||
<string name="title_synchronize_more">Synchronize more messages</string>
|
||||
<string name="title_synchronize_enabled">Synchronize</string>
|
||||
<string name="title_delete_local">Delete local messages</string>
|
||||
<string name="title_delete_browsed">Delete browsed/searched messages</string>
|
||||
|
@ -649,6 +649,8 @@
|
|||
<string name="title_folder_name_missing">Folder name missing</string>
|
||||
<string name="title_folder_exists">Folder %1$s exists</string>
|
||||
<string name="title_folder_delete">Permanently delete this folder and any messages it contains?</string>
|
||||
<string name="title_months">Months</string>
|
||||
<string name="title_months_all">All</string>
|
||||
|
||||
<string name="title_folder_unified">Unified inbox</string>
|
||||
<string name="title_folder_inbox">Inbox</string>
|
||||
|
@ -762,7 +764,6 @@
|
|||
<string name="title_ask_show_html_images">Always show images on showing original messages</string>
|
||||
<string name="title_ask_show_image">Showing images can leak privacy sensitive information</string>
|
||||
<string name="title_ask_show_image_hint">Images recognized as tracking images will not be shown</string>
|
||||
<string name="title_ask_sync_all">Synchronize all messages in %1$s?</string>
|
||||
<string name="title_ask_delete_local">Delete local messages? Messages will remain on the remote server.</string>
|
||||
<string name="title_ask_help">Help improve FairEmail</string>
|
||||
<string name="title_ask_reporting">Send error reports?</string>
|
||||
|
|
Loading…
Reference in a new issue