Fix for old devices

They can't use vector drawables in notifications. Also, groups can not
be used, see http://stackoverflow.com/a/34953411.
This commit is contained in:
mvp76 2017-02-28 15:10:05 +01:00
parent 583ea96816
commit 40a061ae73
21 changed files with 21 additions and 5 deletions

View File

@ -184,6 +184,7 @@ android {
versionCode 102050
versionName getVersionName()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
testOptions {

View File

@ -37,6 +37,7 @@ import android.os.Build;
import android.os.Environment;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatDelegate;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@ -78,6 +79,10 @@ import sun.net.www.protocol.bluetooth.Handler;
)
public class FDroidApp extends Application {
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
private static final String TAG = "FDroidApp";
public static final String SYSTEM_DIR_NAME = Environment.getRootDirectory().getAbsolutePath();

View File

@ -15,6 +15,7 @@ import android.os.Build;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@ -251,14 +252,14 @@ class NotificationHelper {
if (entry.intent != null) {
switch (entry.status) {
case UpdateAvailable:
return new NotificationCompat.Action(R.drawable.ic_notify_update_24dp, context.getString(R.string.notification_action_update), entry.intent);
return new NotificationCompat.Action(R.drawable.ic_file_download, context.getString(R.string.notification_action_update), entry.intent);
case Downloading:
case Installing:
return new NotificationCompat.Action(R.drawable.ic_notify_cancel_24dp, context.getString(R.string.notification_action_cancel), entry.intent);
return new NotificationCompat.Action(R.drawable.ic_cancel, context.getString(R.string.notification_action_cancel), entry.intent);
case ReadyToInstall:
return new NotificationCompat.Action(R.drawable.ic_notify_install_24dp, context.getString(R.string.notification_action_install), entry.intent);
return new NotificationCompat.Action(R.drawable.ic_file_install, context.getString(R.string.notification_action_install), entry.intent);
}
}
return null;
@ -333,9 +334,15 @@ class NotificationHelper {
.setLargeIcon(iconLarge)
.setLocalOnly(true)
.setVisibility(NotificationCompat.VISIBILITY_SECRET)
.setGroup(GROUP_UPDATES)
.setContentIntent(entry.intent);
/* If using stacked notifications, use groups. Note that this would not work prior to Lollipop,
because of http://stackoverflow.com/a/34953411, but currently not an issue since stacked
notifications are used only on >= Nougat.
*/
if (useStackedNotifications()) {
builder.setGroup(GROUP_UPDATES);
}
// Handle actions
//
@ -430,9 +437,12 @@ class NotificationHelper {
.setContentText(context.getString(R.string.notification_content_single_installed))
.setLocalOnly(true)
.setVisibility(NotificationCompat.VISIBILITY_SECRET)
.setGroup(GROUP_INSTALLED)
.setContentIntent(entry.intent);
if (useStackedNotifications()) {
builder.setGroup(GROUP_INSTALLED);
}
Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_INSTALLED_CLEARED);
intentDeleted.putExtra(EXTRA_NOTIFICATION_KEY, entry.getUniqueKey());
PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, 0);

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB