Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustments to meet Android 12 (SDK 31) needs to avoid crashes, also adjusted gradle for tech debt needs :) #104

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:4.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -30,8 +31,8 @@ task clean(type: Delete) {

ext {
minSdkVersion = 16
targetSdkVersion = 26
compileSdkVersion = 26
targetSdkVersion = 30
compileSdkVersion = 30
buildToolsVersion = '26.0.1'

supportLibVersion = '25.3.1'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
2 changes: 1 addition & 1 deletion library-no-op/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
}

dependencies {
compile "com.squareup.okhttp3:okhttp:$okhttp3Version"
api "com.squareup.okhttp3:okhttp:$okhttp3Version"
}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ android {
}

dependencies {
compile 'com.google.code.gson:gson:2.8.0'
compile "com.squareup.okhttp3:okhttp:$okhttp3Version"
compile 'nl.qbusict:cupboard:2.2.0'
compile "com.android.support:design:$supportLibVersion"
api 'com.google.code.gson:gson:2.8.0'
api "com.squareup.okhttp3:okhttp:$okhttp3Version"
api 'nl.qbusict:cupboard:2.2.0'
api "com.android.support:design:$supportLibVersion"
}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,24 @@ public NotificationHelper(Context context) {

public synchronized void show(HttpTransaction transaction) {
addToBuffer(transaction);
NotificationCompat.Builder builder;
if (!BaseChuckActivity.isInForeground()) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentIntent(PendingIntent.getActivity(context, 0, Chuck.getLaunchIntent(context), 0))
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1){
builder = new NotificationCompat.Builder(context)
.setContentIntent(PendingIntent.getActivity(context, 0, Chuck.getLaunchIntent(context), PendingIntent.FLAG_IMMUTABLE))
.setLocalOnly(true)
.setSmallIcon(R.drawable.chuck_ic_notification_white_24dp)
.setColor(ContextCompat.getColor(context, R.color.chuck_colorPrimary))
.setContentTitle(context.getString(R.string.chuck_notification_title));
}
else {
builder = new NotificationCompat.Builder(context)
.setContentIntent(PendingIntent.getActivity(context, 0, Chuck.getLaunchIntent(context), 0))
.setLocalOnly(true)
.setSmallIcon(R.drawable.chuck_ic_notification_white_24dp)
.setColor(ContextCompat.getColor(context, R.color.chuck_colorPrimary))
.setContentTitle(context.getString(R.string.chuck_notification_title));
}
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
if (setChannelId != null) {
try { setChannelId.invoke(builder, CHANNEL_ID); } catch (Exception ignored) {}
Expand Down Expand Up @@ -113,7 +124,13 @@ public synchronized void show(HttpTransaction transaction) {
private NotificationCompat.Action getClearAction() {
CharSequence clearTitle = context.getString(R.string.chuck_clear);
Intent deleteIntent = new Intent(context, ClearTransactionsService.class);
PendingIntent intent = PendingIntent.getService(context, 11, deleteIntent, PendingIntent.FLAG_ONE_SHOT);
PendingIntent intent;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1){
intent = PendingIntent.getService(context, 11, deleteIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_ONE_SHOT);
}
else {
intent = PendingIntent.getService(context, 11, deleteIntent, PendingIntent.FLAG_ONE_SHOT);
}
return new NotificationCompat.Action(R.drawable.chuck_ic_delete_white_24dp,
clearTitle, intent);
}
Expand Down
14 changes: 7 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ android {
}

dependencies {
debugCompile project(':library')
releaseCompile project(':library-no-op')
compile "com.android.support:design:26.0.0"
compile "com.android.support:appcompat-v7:26.0.0"
compile "com.squareup.okhttp3:logging-interceptor:$okhttp3Version"
compile "com.squareup.retrofit2:retrofit:2.2.0"
compile "com.squareup.retrofit2:converter-gson:2.2.0"
debugImplementation project(':library')
releaseImplementation project(':library-no-op')
implementation "com.android.support:design:26.0.0"
implementation "com.android.support:appcompat-v7:26.0.0"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3Version"
implementation "com.squareup.retrofit2:retrofit:2.2.0"
implementation "com.squareup.retrofit2:converter-gson:2.2.0"
}
3 changes: 2 additions & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.readystatesoftware.chuck.sample.MainActivity">
<activity android:name="com.readystatesoftware.chuck.sample.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down