Add files to draft edited within 3 minutes

pull/204/head
M66B 3 years ago
parent 228b1092f2
commit 501686111f

@ -22,6 +22,7 @@ package eu.faircode.email;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html; import android.text.Html;
@ -35,15 +36,19 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleOwner;
import androidx.preference.PreferenceManager;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class ActivityCompose extends ActivityBase implements FragmentManager.OnBackStackChangedListener { public class ActivityCompose extends ActivityBase implements FragmentManager.OnBackStackChangedListener {
static final int PI_REPLY = 1; static final int PI_REPLY = 1;
private static final long APPEND_ATTACHMENT_INTERVAL = 3 * 60 * 1000L;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -207,8 +212,13 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
args = intent.getExtras(); args = intent.getExtras();
FragmentManager fm = getSupportFragmentManager(); FragmentManager fm = getSupportFragmentManager();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
long now = new Date().getTime();
long last = prefs.getLong("last_composed", 0L);
if (!create && if (!create &&
now - last < APPEND_ATTACHMENT_INTERVAL &&
args.size() == 1 && args.containsKey("attachments")) { args.size() == 1 && args.containsKey("attachments")) {
List<Fragment> fragments = fm.getFragments(); List<Fragment> fragments = fm.getFragments();
if (fragments.size() == 1) { if (fragments.size() == 1) {

@ -1419,13 +1419,18 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
public void onPause() { public void onPause() {
final Context context = getContext();
if (state == State.LOADED) { if (state == State.LOADED) {
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putBoolean("autosave", true); extras.putBoolean("autosave", true);
onAction(R.id.action_save, extras, "pause"); onAction(R.id.action_save, extras, "pause");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putLong("last_composed", new Date().getTime()).apply();
} }
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
cm.unregisterNetworkCallback(networkCallback); cm.unregisterNetworkCallback(networkCallback);
super.onPause(); super.onPause();

Loading…
Cancel
Save