Moved notification icons to their own module, so they don't crash old Android versions

This commit is contained in:
ByteHamster 2021-04-17 11:57:27 +02:00
parent bd7793ffd4
commit 74c8dc9c14
19 changed files with 90 additions and 5 deletions

View File

@ -60,7 +60,7 @@ public class ChaptersFragment extends Fragment {
EmptyViewHandler emptyView = new EmptyViewHandler(getContext());
emptyView.attachToRecyclerView(recyclerView);
//emptyView.setIcon(R.attr.ic_bookmark); TODO
emptyView.setIcon(R.drawable.ic_bookmark);
emptyView.setTitle(R.string.no_chapters_head_label);
emptyView.setMessage(R.string.no_chapters_label);

View File

@ -76,6 +76,7 @@ dependencies {
implementation project(':net:ssl')
implementation project(':ui:app-start-intent')
implementation project(':ui:common')
implementation project(':ui:png-icons')
annotationProcessor "androidx.annotation:annotation:$annotationVersion"
implementation "androidx.appcompat:appcompat:$appcompatVersion"

7
core/lint.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="VectorPath">
<ignore path="res/drawable/ic_settings.xml" />
<ignore path="res/drawable/ic_settings_white.xml" />
</issue>
</lint>

View File

@ -205,7 +205,7 @@ public class DownloadServiceNotification {
.setContentText(context.getText(R.string.authentication_notification_msg))
.setStyle(new NotificationCompat.BigTextStyle().bigText(context.getText(R.string.authentication_notification_msg)
+ ": " + resourceTitle))
.setSmallIcon(R.drawable.ic_key)
.setSmallIcon(R.drawable.ic_notification_key)
.setAutoCancel(true)
.setContentIntent(ClientConfig.downloadServiceCallbacks.getAuthentificationNotificationContentIntent(context, downloadRequest));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

View File

@ -613,17 +613,17 @@ public class PlaybackService extends MediaBrowserServiceCompat {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this,
NotificationUtils.CHANNEL_ID_USER_ACTION)
.setSmallIcon(R.drawable.ic_stream)
.setSmallIcon(R.drawable.ic_notification_stream)
.setContentTitle(getString(R.string.confirm_mobile_streaming_notification_title))
.setContentText(getString(R.string.confirm_mobile_streaming_notification_message))
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(getString(R.string.confirm_mobile_streaming_notification_message)))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(pendingIntentAllowThisTime)
.addAction(R.drawable.ic_stream,
.addAction(R.drawable.ic_notification_stream,
getString(R.string.confirm_mobile_streaming_button_once),
pendingIntentAllowThisTime)
.addAction(R.drawable.ic_stream,
.addAction(R.drawable.ic_notification_stream,
getString(R.string.confirm_mobile_streaming_button_always),
pendingIntentAlwaysAllow)
.setAutoCancel(true);

View File

@ -3,3 +3,4 @@ include ':core'
include ':net:ssl'
include ':ui:app-start-intent'
include ':ui:common'
include ':ui:png-icons'

3
ui/png-icons/README.md Normal file
View File

@ -0,0 +1,3 @@
# :ui:png-icons
This module provides icon resources. It is necessary to support old Android versions that do not support VectorDrawables. The module generates png versions of all contained icons automatically. This is only needed for notification icons - for the icons within the app, appcompat handles drawing the vectors.

52
ui/png-icons/build.gradle Normal file
View File

@ -0,0 +1,52 @@
apply plugin: "com.android.library"
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
vectorDrawables.useSupportLibrary false
multiDexEnabled false
testApplicationId "de.danoeh.antennapod.core.tests"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android.txt")
}
debug {
// debug build has method count over 64k single-dex threshold.
// For building debug build to use on Android < 21 (pre-Android 5) devices,
// you need to manually change class
// de.danoeh.antennapod.PodcastApp to extend MultiDexApplication .
// See Issue #2813
multiDexEnabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
lintOptions {
disable 'GradleDependency'
warningsAsErrors true
abortOnError true
}
}
dependencies {
annotationProcessor "androidx.annotation:annotation:$annotationVersion"
implementation "androidx.appcompat:appcompat:$appcompatVersion"
}

View File

@ -0,0 +1 @@
<manifest package="de.danoeh.antennapod.ui.pngicons" />

View File

@ -0,0 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="24dp">
<path android:fillColor="#FFFFFFFF"
android:pathData="M12.65,10C11.83,7.67 9.61,6 7,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c2.61,0 4.83,-1.67 5.65,-4H17v4h4v-4h2v-4H12.65zM7,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</vector>

View File

@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="m20.5099,12.0219c0,-1.41 -1.143,-2.553 -2.553,-2.553h-1.2765v-0.4255c0,-2.5849 -2.0955,-4.6804 -4.6804,-4.6804 -2.1275,0 -3.9401,1.4382 -4.5017,3.4039H6.8941c-1.8799,0 -3.4039,1.524 -3.4039,3.4039 0,1.8799 1.524,3.4039 3.4039,3.4039h2.553v1.702H6.8941c-2.8199,0 -5.1059,-2.286 -5.1059,-5.1059 0,-2.6381 1.9913,-4.7996 4.5528,-5.0719C7.4047,4.0566 9.5407,2.661 12,2.661c3.0976,0 5.6761,2.2041 6.2633,5.14 2.2041,0.1532 3.9486,1.9743 3.9486,4.2209 0,1.4041 -0.6445,2.3463 -1.5471,3.1885 -0.4185,-0.2876 -0.8313,-0.5368 -1.3724,-0.8908 1.092,-0.8808 1.2175,-1.8722 1.2175,-2.2977z"
android:strokeWidth="0.85098612"/>
<path
android:fillColor="#FFFFFFFF"
android:pathData="m12.2085,13.3476v9.4907l7.4569,-4.7453z"
android:strokeWidth="0.67790419"/>
</vector>