Skip to content

Commit a42fe80

Browse files
authored
Support for targeting Android 13 (#22)
* Target update to API 33 * Added notifications permission handling (API 33) * Updated libraries * Removed Crashlytics * Fixed camera access when targetting Android 13 * Fixed styling definitions when targetting Android 13 * Updated documentation reflecting these changes
1 parent e99faca commit a42fe80

22 files changed

+312
-130
lines changed

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
# Changelog
22

3+
## 3.7.0 - Released 19 Oct 2022
4+
5+
**IMPORTANT**: Parley now targets Android 13 and requests notifications permission when needed.
6+
7+
### Upgrading:
8+
9+
- *DEPRECATION (styling)*: In the style `ParleyNotificationView`, the attribute `parley_icon` has been renamed to `parley_icon_connection`.
10+
11+
### Changes:
12+
13+
- Added requesting notifications permission when the `ParleyView` is visible to the user while the app doesn't this permissions yet.
14+
- Added message when the notifications permission is missing. The user will not receive chat notifications.
15+
- Updated source to target API 33.
16+
- Updated dependencies
17+
- *Addition (styling)*: Added attribute `parley_notification_icon_notifications` to styling `ParleyNotificationView` to configure the icon when user denied the notifications permission.
18+
319
## 3.6.1 - Released 18 Oct 2022
420

5-
Parley now targets Android 12
21+
**IMPORTANT**: Parley now targets Android 12.
622

723
- Added support for targeting Android 12 and higher.
824
- Notification channels are now created when showing the `ParleyView`, causing Android 12 to request notifications permission if needed.
25+
- Updated source to target API 32.
926

1027
## 3.6.0 - Released 29 Jul 2022
1128

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ Easily setup a secure chat with the Parley Messaging Android library. The Parley
88

99
## Requirements
1010

11+
- Java 11
1112
- Android 4.1+ (API 16+)
1213
- Android Studio 4.2+ (Android Gradle Plugin 4.2+)
1314
- Using AndroidX artifacts
1415
- Permissions (automatically added by the library)
1516
- android.permission.INTERNET - Required for chatting
1617
- android.permission.ACCESS_NETWORK_STATE - Required for detecting network changes
18+
- android.permission.POST_NOTIFICATIONS - Required for showing notifications on API >= 33
1719
- android.permission.WRITE_EXTERNAL_STORAGE **(API < 19)** - Required for supporting images in the chat. *Only applied in API 18 and lower.*
1820

1921
**Firebase**
@@ -44,7 +46,7 @@ allprojects {
4446
To integrate Parley, specify the following in your `app/build.gradle` file:
4547

4648
```groovy
47-
implementation 'com.github.parley-messaging:android-library:3.6.1'
49+
implementation 'com.github.parley-messaging:android-library:3.7.0'
4850
```
4951

5052
### Upgrading

app/build.gradle

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
apply plugin: 'com.android.application'
2-
apply plugin: 'io.fabric'
32

43
android {
5-
compileSdkVersion 32
4+
compileSdkVersion 33
65
defaultConfig {
76
applicationId "nu.parley"
87
minSdkVersion 16
9-
targetSdkVersion 32
8+
targetSdkVersion 33
109
versionCode 1
11-
versionName "1.0"
10+
versionName "1.0.0"
1211
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1312
}
1413
buildTypes {
@@ -18,35 +17,29 @@ android {
1817
}
1918
}
2019
compileOptions {
21-
sourceCompatibility 1.8
22-
targetCompatibility 1.8
20+
sourceCompatibility JavaVersion.VERSION_1_8
21+
targetCompatibility JavaVersion.VERSION_1_8
2322
}
2423
}
2524

2625
dependencies {
2726
implementation fileTree(dir: 'libs', include: ['*.jar'])
2827

29-
// Android X
30-
implementation 'androidx.appcompat:appcompat:1.1.0'
31-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
32-
33-
implementation "com.android.support:design:28.0.0"
28+
// AndroidX
29+
implementation 'androidx.appcompat:appcompat:1.4.0'
3430

3531
// Firebase
36-
implementation 'com.google.firebase:firebase-core:17.5.1'
32+
implementation 'com.google.firebase:firebase-core:19.0.0'
3733
implementation "com.google.firebase:firebase-messaging:22.0.0"
3834

39-
// Crashlytics
40-
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
41-
4235
// Library
43-
// implementation 'com.github.parley-messaging:android-library:3.6.1' // Remote
36+
// implementation 'com.github.parley-messaging:android-library:3.7.0' // Remote
4437
implementation project(':parley') // Local
4538

4639
// Tests
47-
testImplementation 'junit:junit:4.12'
48-
androidTestImplementation 'androidx.test:runner:1.2.0'
49-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
40+
testImplementation 'junit:junit:4.13.2'
41+
androidTestImplementation 'androidx.test:runner:1.4.0'
42+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
5043
}
5144

5245
apply plugin: 'com.google.gms.google-services'

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package="nu.parley">
55

66
<application
7-
android:allowBackup="true"
7+
android:allowBackup="false"
88
android:icon="@mipmap/ic_launcher"
99
android:label="@string/app_name"
1010
android:networkSecurityConfig="@xml/parley_network_security_config"
@@ -15,8 +15,8 @@
1515

1616
<activity
1717
android:name=".ui.SplashActivity"
18-
android:noHistory="true"
1918
android:exported="true"
19+
android:noHistory="true"
2020
android:screenOrientation="portrait"
2121
android:theme="@style/AppTheme.FullScreen">
2222

app/src/main/java/nu/parley/ui/BaseActivity.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
11
package nu.parley.ui;
22

33
import android.content.Context;
4-
import android.os.Bundle;
54
import android.view.MenuItem;
65
import android.view.View;
76
import android.view.inputmethod.InputMethodManager;
8-
9-
import androidx.annotation.Nullable;
107
import androidx.annotation.StringRes;
118
import androidx.appcompat.app.AlertDialog;
129
import androidx.appcompat.app.AppCompatActivity;
1310
import androidx.appcompat.widget.Toolbar;
1411

15-
import com.crashlytics.android.Crashlytics;
16-
17-
import io.fabric.sdk.android.Fabric;
1812
import nu.parley.R;
19-
import nu.parley.repository.PreferenceRepository;
2013

2114
public abstract class BaseActivity extends AppCompatActivity {
2215

23-
@Override
24-
protected void onCreate(@Nullable Bundle savedInstanceState) {
25-
super.onCreate(savedInstanceState);
26-
27-
Fabric.with(this, new Crashlytics());
28-
}
29-
3016
protected void setupToolbar() {
3117
Toolbar toolbar = findViewById(R.id.toolbar);
3218

app/src/main/java/nu/parley/ui/IdentifierActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ private void setOfflineMessagingEnabled() {
198198
* Registers a user for the chat with the provided customer id.
199199
* Here, the user authorization is generated by the device itself. However, generation of it
200200
* should be done elsewhere, as noted in {@link ParleyCustomerAuthorization}.
201-
*
201+
* <p>
202202
* Check out `setUserInformation()` for a simple example when the user authorization is known.
203+
* </p>
203204
*/
204205
private void registerUserWithCustomerId() {
205206
String customerId = new PreferenceRepository().getCustomerId(this);

build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ buildscript {
22
repositories {
33
google()
44
jcenter()
5-
maven { url 'https://maven.fabric.io/public' }
65
}
76
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.5.1'
7+
classpath 'com.android.tools.build:gradle:3.5.4'
98
classpath 'com.google.gms:google-services:4.3.2'
10-
classpath 'io.fabric.tools:gradle:1.31.1'
119
classpath 'com.novoda:bintray-release:0.9.1'
1210
}
1311
}

parley/build.gradle

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'com.novoda.bintray-release'
44

55
ext {
66
libraryPackageIdentifier = 'nu.parley.android'
7-
libraryVersion = '3.6.1'
7+
libraryVersion = '3.7.0'
88
}
99

1010
publish {
@@ -33,11 +33,11 @@ group = libraryPackageIdentifier
3333
version = libraryVersion
3434

3535
android {
36-
compileSdkVersion 32
36+
compileSdkVersion 33
3737

3838
defaultConfig {
3939
minSdkVersion 16
40-
targetSdkVersion 32
40+
targetSdkVersion 33
4141
versionCode 1
4242
versionName libraryVersion
4343

@@ -47,19 +47,18 @@ android {
4747
}
4848

4949
ext {
50-
versionRetrofit = '2.6.0'
51-
versionGlide = '4.10.0'
50+
versionRetrofit = '2.9.0'
51+
versionGlide = '4.14.1'
5252
versionMarkwon = '4.0.2'
5353
}
5454

5555
dependencies {
5656
implementation fileTree(dir: 'libs', include: ['*.jar'])
5757

5858
// AndroidX artifacts
59-
implementation 'androidx.annotation:annotation:1.2.0'
60-
implementation 'androidx.appcompat:appcompat:1.1.0'
61-
implementation 'androidx.recyclerview:recyclerview:1.1.0'
62-
implementation 'androidx.cardview:cardview:1.0.0'
59+
implementation 'androidx.appcompat:appcompat:1.4.0'
60+
implementation 'androidx.recyclerview:recyclerview:1.2.1'
61+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
6362

6463
// Android Material
6564
implementation 'com.google.android.material:material:1.0.0'
@@ -77,18 +76,17 @@ dependencies {
7776

7877
// Markdown support
7978
implementation "io.noties.markwon:core:${versionMarkwon}"
80-
implementation "io.noties.markwon:linkify:${versionMarkwon}"
79+
implementation "io.noties.markwon:linkify:${versionMarkwon}"
8180

8281
// Image Viewer
8382
implementation 'com.github.MikeOrtiz:TouchImageView:3.1.1'
84-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
8583

86-
testImplementation 'junit:junit:4.12'
87-
androidTestImplementation 'junit:junit:4.12'
84+
testImplementation 'junit:junit:4.13.2'
85+
androidTestImplementation 'junit:junit:4.13.2'
8886

89-
androidTestImplementation 'androidx.test:runner:1.2.0'
90-
androidTestImplementation 'androidx.test:rules:1.2.0'
91-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
87+
androidTestImplementation 'androidx.test:runner:1.4.0'
88+
androidTestImplementation 'androidx.test:rules:1.4.0'
89+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
9290
androidTestImplementation 'com.novoda:espresso-support:1.0.0'
9391
androidTestImplementation('tools.fastlane:screengrab:2.1.0')
9492
}

parley/src/main/AndroidManifest.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
<uses-permission android:name="android.permission.INTERNET" />
55
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
7+
68
<uses-permission
79
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
810
android:maxSdkVersion="18" />
@@ -11,6 +13,12 @@
1113
android:name="android.hardware.camera"
1214
android:required="false" />
1315

16+
<queries>
17+
<intent>
18+
<action android:name="android.media.action.IMAGE_CAPTURE" />
19+
</intent>
20+
</queries>
21+
1422
<application>
1523
<provider
1624
android:name=".util.TakePictureFileProvider"

parley/src/main/java/nu/parley/android/Parley.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package nu.parley.android;
22

3+
import static nu.parley.android.data.model.Message.SEND_STATUS_FAILED;
4+
import static nu.parley.android.notification.PushNotificationHandler.EVENT_START_TYPING;
5+
import static nu.parley.android.notification.PushNotificationHandler.EVENT_STOP_TYPING;
6+
37
import android.content.Context;
48
import android.content.Intent;
59
import android.os.Handler;
610
import android.os.Looper;
7-
import android.provider.Settings;
811
import android.util.Log;
912

1013
import androidx.annotation.NonNull;
@@ -34,10 +37,6 @@
3437
import nu.parley.android.view.ParleyView;
3538
import nu.parley.android.view.chat.MessageViewHolderFactory;
3639

37-
import static nu.parley.android.data.model.Message.SEND_STATUS_FAILED;
38-
import static nu.parley.android.notification.PushNotificationHandler.EVENT_START_TYPING;
39-
import static nu.parley.android.notification.PushNotificationHandler.EVENT_STOP_TYPING;
40-
4140
public final class Parley {
4241

4342
public enum State {
@@ -150,8 +149,9 @@ public static void reset() {
150149

151150
/**
152151
* Resets Parley back to its initial state (clearing the user information). Useful when logging out a user for example. Ensures that no user and chat data is left in memory.
153-
*
152+
* <p>
154153
* Leaves the network, offline messaging and referrer settings as is, these can be altered via the corresponding methods.
154+
* </p>
155155
*
156156
* <b>Note</b>: Requires calling the `configure()` method again to use Parley.
157157
*/
@@ -403,7 +403,7 @@ public void run() {
403403
* @return `true` if Parley handled this request, `false` otherwise
404404
*/
405405
public static boolean onRequestPermissionsResult(final int requestCode, final @NonNull String[] permissions, @NonNull final int[] grantResults) {
406-
if (requestCode == ParleyView.REQUEST_PERMISSION_ACCESS_CAMERA) {
406+
if (requestCode == ParleyView.REQUEST_PERMISSION_ACCESS_CAMERA || requestCode == ParleyView.REQUEST_PERMISSION_NOTIFICATIONS) {
407407
if (getInstance().listener == null) {
408408
// We will handle it when the listener is attached
409409
new Handler().postDelayed(new Runnable() {

0 commit comments

Comments
 (0)