1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-29 11:15:51 +00:00

Android Q compatibility

This commit is contained in:
M66B 2019-03-14 14:57:24 +00:00
parent 8263742f6c
commit 38fcadab9b
4 changed files with 31 additions and 51 deletions

View file

@ -117,7 +117,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private static NumberFormat nf = NumberFormat.getNumberInstance();
static final int REQUEST_UNIFIED = 1;
static final int REQUEST_THREAD = 2;
static final int REQUEST_WHY = 2;
static final int REQUEST_THREAD = 3;
static final int REQUEST_RAW = 1;
static final int REQUEST_ATTACHMENT = 2;
@ -430,7 +431,22 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if ("unified".equals(action))
init();
else if ("error".equals(action))
else if ("why".equals(action)) {
init();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivityView.this);
boolean why = prefs.getBoolean("why", false);
if (!why) {
prefs.edit().putBoolean("why", true).apply();
Intent iwhy = new Intent(Intent.ACTION_VIEW);
iwhy.setData(Uri.parse(Helper.FAQ_URI + "#user-content-faq2"));
iwhy.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (iwhy.resolveActivity(getPackageManager()) != null)
startActivity(iwhy);
}
} else if ("error".equals(action))
onDebugInfo();
else if (action.startsWith("thread")) {

View file

@ -1519,9 +1519,9 @@ class Core {
messageContact.put(message, ContactInfo.get(context, message.from, false));
// Build pending intents
Intent summary = new Intent(context, ServiceUI.class);
summary.setAction("summary");
PendingIntent piSummary = PendingIntent.getService(context, ServiceUI.PI_SUMMARY, summary, PendingIntent.FLAG_UPDATE_CURRENT);
Intent summary = new Intent(context, ActivityView.class);
summary.setAction("unified");
PendingIntent piSummary = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, summary, PendingIntent.FLAG_UPDATE_CURRENT);
Intent clear = new Intent(context, ServiceUI.class);
clear.setAction("clear");

View file

@ -211,9 +211,9 @@ public class ServiceSynchronize extends LifecycleService {
lastStats = stats;
// Build pending intent
Intent intent = new Intent(this, ServiceUI.class);
intent.setAction("why");
PendingIntent pi = PendingIntent.getService(this, ServiceUI.PI_WHY, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Intent why = new Intent(this, ActivityView.class);
why.setAction("why");
PendingIntent piWhy = PendingIntent.getActivity(this, ActivityView.REQUEST_WHY, why, PendingIntent.FLAG_UPDATE_CURRENT);
// Build notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "service");
@ -222,7 +222,7 @@ public class ServiceSynchronize extends LifecycleService {
.setSmallIcon(R.drawable.baseline_compare_arrows_white_24)
.setContentTitle(getResources().getQuantityString(
R.plurals.title_notification_synchronizing, lastStats.accounts, lastStats.accounts))
.setContentIntent(pi)
.setContentIntent(piWhy)
.setAutoCancel(false)
.setShowWhen(false)
.setPriority(NotificationCompat.PRIORITY_MIN)

View file

@ -2,22 +2,16 @@ package eu.faircode.email;
import android.app.IntentService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.preference.PreferenceManager;
import androidx.annotation.Nullable;
public class ServiceUI extends IntentService {
static final int PI_WHY = 1;
static final int PI_SUMMARY = 2;
static final int PI_CLEAR = 3;
static final int PI_SEEN = 4;
static final int PI_ARCHIVE = 5;
static final int PI_TRASH = 6;
static final int PI_IGNORED = 7;
static final int PI_SNOOZED = 8;
static final int PI_CLEAR = 1;
static final int PI_SEEN = 2;
static final int PI_ARCHIVE = 3;
static final int PI_TRASH = 4;
static final int PI_IGNORED = 5;
static final int PI_SNOOZED = 6;
public ServiceUI() {
this(ServiceUI.class.getName());
@ -57,12 +51,6 @@ public class ServiceUI extends IntentService {
long id = (parts.length > 1 ? Long.parseLong(parts[1]) : -1);
switch (parts[0]) {
case "why":
onWhy();
break;
case "summary":
onSummary();
break;
case "clear":
onClear();
break;
@ -90,30 +78,6 @@ public class ServiceUI extends IntentService {
}
}
private void onWhy() {
Intent why = new Intent(Intent.ACTION_VIEW);
why.setData(Uri.parse(Helper.FAQ_URI + "#user-content-faq2"));
why.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PackageManager pm = getPackageManager();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getBoolean("why", false) || why.resolveActivity(pm) == null) {
Intent view = new Intent(this, ActivityView.class);
view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(view);
} else {
prefs.edit().putBoolean("why", true).apply();
startActivity(why);
}
}
private void onSummary() {
Intent view = new Intent(this, ActivityView.class);
view.setAction("unified");
view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(view);
}
private void onClear() {
DB.getInstance(this).message().ignoreAll();
}