Skip to content

Commit 3d6d13f

Browse files
committed
update library to latest version
1 parent 81fdfdf commit 3d6d13f

File tree

10 files changed

+42
-81
lines changed

10 files changed

+42
-81
lines changed

app/build.gradle

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 26
4+
compileSdkVersion 29
55
defaultConfig {
66
applicationId "com.trenzlr.firebasesample"
77
minSdkVersion 16
8-
targetSdkVersion 26
8+
targetSdkVersion 29
99
versionCode 1
1010
versionName "1.0"
11-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
11+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {
1414
release {
@@ -20,12 +20,9 @@ android {
2020

2121
dependencies {
2222
implementation fileTree(include: ['*.jar'], dir: 'libs')
23-
implementation 'com.android.support:appcompat-v7:26.1.0'
24-
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
25-
implementation 'com.google.firebase:firebase-messaging:11.0.4'
26-
testImplementation 'junit:junit:4.12'
27-
androidTestImplementation 'com.android.support.test:runner:1.0.1'
28-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
23+
implementation 'androidx.appcompat:appcompat:1.0.2'
24+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
25+
implementation 'com.google.firebase:firebase-messaging:20.0.0'
2926
implementation project(':firebasenotificationhelper')
3027
}
3128

app/src/androidTest/java/com/trenzlr/firebasesample/ExampleInstrumentedTest.java

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
package com.trenzlr.firebasesample;
22

3-
import com.google.firebase.iid.FirebaseInstanceId;
4-
import com.google.firebase.iid.FirebaseInstanceIdService;
53

64

75
/**
86
* Created by prabh on 25-10-2017.
97
*/
108

11-
public class FirebaseIDService extends FirebaseInstanceIdService {
12-
private static final String TAG = "FirebaseIDService";
13-
public static final String FIREBASE_TOKEN = "token";
14-
15-
16-
@Override
17-
public void onTokenRefresh() {
18-
// Get updated InstanceID token.
19-
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
20-
SharedPrefUtil.getInstance(this).put(FIREBASE_TOKEN,refreshedToken);
21-
22-
}
23-
24-
25-
}
9+
//public class FirebaseIDService extends FirebaseInstanceId {
10+
// private static final String TAG = "FirebaseIDService";
11+
// public static final String FIREBASE_TOKEN = "token";
12+
//
13+
//
14+
// @Override
15+
// public void onTokenRefresh() {
16+
// // Get updated InstanceID token.
17+
// String refreshedToken = FirebaseInstanceId.getInstance().getToken();
18+
// SharedPrefUtil.getInstance(this).put(FIREBASE_TOKEN,refreshedToken);
19+
//
20+
// }
21+
//
22+
//
23+
//}

app/src/main/java/com/trenzlr/firebasesample/MainActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package com.trenzlr.firebasesample;
22

33
import android.os.Bundle;
4-
import android.support.v7.app.AppCompatActivity;
54
import android.util.Log;
65
import android.view.View;
76
import android.widget.Button;
87
import android.widget.Toast;
98

9+
import androidx.appcompat.app.AppCompatActivity;
10+
1011
import com.trenzlr.firebasenotificationhelper.FirebaseNotiCallBack;
1112
import com.trenzlr.firebasenotificationhelper.FirebaseNotificationHelper;
1213

@@ -15,7 +16,8 @@
1516

1617
import static com.trenzlr.firebasesample.Constants.KEY_TEXT;
1718
import static com.trenzlr.firebasesample.Constants.KEY_TITLE;
18-
import static com.trenzlr.firebasesample.FirebaseIDService.FIREBASE_TOKEN;
19+
import static com.trenzlr.firebasesample.MyFirebaseMessagingService.FIREBASE_TOKEN;
20+
1921

2022
public class MainActivity extends AppCompatActivity implements FirebaseNotiCallBack {
2123
private Button sendMess, sendMess2;

app/src/main/java/com/trenzlr/firebasesample/MyFirebaseMessagingService.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
import android.media.RingtoneManager;
1111
import android.net.Uri;
1212
import android.os.Build;
13-
import android.os.Bundle;
14-
import android.support.v4.app.NotificationCompat;
13+
14+
import androidx.annotation.NonNull;
15+
import androidx.core.app.NotificationCompat;
1516

1617
import com.google.firebase.messaging.FirebaseMessagingService;
1718
import com.google.firebase.messaging.RemoteMessage;
1819

20+
1921
/**
2022
* Created by prabh on 25-10-2017.
2123
*/
@@ -24,6 +26,13 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
2426
private static final String TAG = "FCM Service";
2527
private Bitmap bitmap;
2628
private Context context = this;
29+
public static final String FIREBASE_TOKEN = "token";
30+
31+
@Override
32+
public void onNewToken(@NonNull String refreshedToken) {
33+
super.onNewToken(refreshedToken);
34+
SharedPrefUtil.getInstance(this).put(FIREBASE_TOKEN, refreshedToken);
35+
}
2736

2837
@Override
2938
public void onMessageReceived(RemoteMessage remoteMessage) {

app/src/main/res/layout/activity_main.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
@@ -29,4 +29,4 @@
2929
app:layout_constraintTop_toTopOf="parent"
3030
app:layout_constraintVertical_bias="0.676" />
3131

32-
</android.support.constraint.ConstraintLayout>
32+
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<resources>
22
<string name="app_name">FirebaseSample</string>
3-
<string name="token">db2tlCennF8:APA91bE1YGlIM8-f8UizSumJlJORlI4nITZ_p2g8mtRMXHmy9dYYLcDjzs3EUbglMQ25ritk62C4glDJOhFfqtAeUhBUfWSgWCPXbI0D0xK0vsKXzM_ZvVK1aOa24UFY65Xrh4fNcbH</string>
4-
<string name="server_key">AAAAVRCSZOg:APA91bEhTBNmNFld6cVnn8lHvR2XVO0TQoRtcD8Q_iUelNG9zLH6_p6gPLPd64cpy0issHd_9qo6rzedFleinlTPWu9gPt_NTw-sbo7qGDt41XESLutNXT-8cDnrvy2Ib5emm629atLVeDmhQe8JbmE6IJ1I65Q2vQ</string>
3+
<string name="token">ss</string>
4+
<string name="server_key">sss</string>
55
</resources>

app/src/main/res/xml/backup_descriptor.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<full-backup-content>
3-
<!-- TODO Remove the following "exclude" elements to make them a part of the auto backup -->
43
<!-- Exclude the shared preferences file that contains the GCM registrationId -->
54
<exclude
65
domain="sharedpref"

app/src/test/java/com/trenzlr/firebasesample/ExampleUnitTest.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

firebasenotificationhelper/src/main/java/com/trenzlr/firebasenotificationhelper/NetworkCall.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.io.Writer;
1616
import java.net.HttpURLConnection;
1717
import java.net.URL;
18+
import java.nio.charset.StandardCharsets;
1819

1920
import static android.content.ContentValues.TAG;
2021
import static com.trenzlr.firebasenotificationhelper.Constants.APPLICATION_JSON;
@@ -50,7 +51,7 @@ protected String doInBackground(String... strings) {
5051
urlConnection.setRequestProperty(CONTENT_TYPE, APPLICATION_JSON);
5152
urlConnection.setRequestProperty(AUTHORIZATION, authKey);
5253
//set headers and method
53-
Writer writer = new BufferedWriter(new OutputStreamWriter(urlConnection.getOutputStream(), "UTF-8"));
54+
Writer writer = new BufferedWriter(new OutputStreamWriter(urlConnection.getOutputStream(), StandardCharsets.UTF_8));
5455
writer.write(JsonDATA);
5556
// json data
5657
writer.close();
@@ -90,9 +91,7 @@ protected String doInBackground(String... strings) {
9091
}
9192
}
9293
}
93-
9494
return JsonResponse;
95-
9695
}
9796

9897
@Override

0 commit comments

Comments
 (0)