Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 47e7ad4

Browse files
committed
Merge branch 'release/0.8.19'
2 parents d9d8db4 + c990daf commit 47e7ad4

File tree

302 files changed

+5419
-3595
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+5419
-3595
lines changed

CHANGES.rst

Lines changed: 181 additions & 153 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,31 @@ Let says your application is named MyRiot : You have to create your own flavour.
5656
Modify riot-android/vector/build.gradle
5757
---------------------------------------
5858

59-
In "productFlavors" section, duplicate "app" group if you plan to use GCM/FCM or "appfdroid" if don't.
59+
In "productFlavors" section, duplicate "app" group if you plan to use FCM or "appfdroid" if don't.
6060

61-
for example, with GCM, it would give
61+
for example, with FCM, it would give
6262

6363
```
6464
appmyriot {
6565
applicationId "im.myriot"
6666
// use the version name
6767
versionCode rootProject.ext.versionCodeProp
6868
versionName rootProject.ext.versionNameProp
69-
resValue "string", "allow_gcm_use", "true"
70-
resValue "string", "allow_ga_use", "true"
71-
resValue "string", "short_flavor_description", "G"
72-
resValue "string", "flavor_description", "GooglePlay"
69+
buildConfigField "boolean", "ALLOW_FCM_USE", "true"
70+
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\""
71+
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\""
7372
}
7473
```
7574

76-
- if you use GCM, duplicate appCompile at the end of this file and replace appCompile by appmyriotCompile.
75+
- if you use FCM, duplicate appCompile at the end of this file and replace appCompile by appmyriotCompile.
7776
- if you don't, update the "if (!getGradle().getStartParameter().getTaskRequests().toString().contains("fdroid"))" to include your flavor.
7877

7978
Create your flavour directory
8079
-----------------------------
8180

82-
- Copy riot-android/vector/src/app or appfroid if you use GCM or you don’t.
81+
- Copy riot-android/vector/src/app or appfroid if you use FCM or you don’t.
8382
- Rename it to appmyriot.
84-
- If you use GCM, you will need to generate your own google-services.json.
83+
- If you use FCM, you will need to generate your own google-services.json.
8584

8685
Customise your flavour
8786
----------------------

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ buildscript {
2323

2424
// global properties used in sub modules
2525
ext {
26-
versionCodeProp = 81800
27-
versionNameProp = "0.8.18"
26+
versionCodeProp = 81900
27+
versionNameProp = "0.8.19"
2828
versionBuild = System.getenv("BUILD_NUMBER") as Integer ?: 0
2929
buildNumberProp = "${versionBuild}"
3030
}

tools/check/forbidden_strings_in_resources.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ DO NOT COMMIT
6666
### Bad comment format in XML resources. Use <!-- --> instead of //
6767
^\s*\/\/
6868

69+
### Bad RTL support, use attribute with Start and End
70+
layout_constraintRight_
71+
layout_constraintLeft_
72+

vector/build.gradle

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ android {
2424
versionName rootProject.ext.versionNameProp
2525

2626
// custom values
27-
resValue "string", "bug_report_url", "https://riot.im/bugreports/submit"
27+
resValue "string", "bug_report_url", "https://riot.im/bugreports/submit"
2828

2929
ndk {
3030
abiFilters "armeabi-v7a", "x86"
@@ -92,34 +92,51 @@ android {
9292
// use the version name
9393
versionCode rootProject.ext.versionCodeProp
9494
versionName rootProject.ext.versionNameProp
95-
resValue "string", "allow_gcm_use", "true"
96-
resValue "string", "allow_ga_use", "true"
97-
resValue "string", "short_flavor_description", "G"
98-
resValue "string", "flavor_description", "GooglePlay"
95+
buildConfigField "boolean", "ALLOW_FCM_USE", "true"
96+
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\""
97+
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"GooglePlay\""
9998
}
10099

101100
appfdroid {
102101
applicationId "im.vector.alpha"
103102
// use the version name
104103
versionCode rootProject.ext.versionCodeProp
105104
versionName rootProject.ext.versionNameProp
106-
resValue "string", "allow_gcm_use", "false"
107-
resValue "string", "allow_ga_use", "false"
108-
resValue "string", "short_flavor_description", "F"
109-
resValue "string", "flavor_description", "FDroid"
105+
buildConfigField "boolean", "ALLOW_FCM_USE", "false"
106+
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\""
107+
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\""
110108
}
111109
}
112110

113111
lintOptions {
114-
disable 'InvalidPackage'
115-
disable 'MissingTranslation'
116-
disable 'RestrictedApi'
117-
disable 'ImpliedQuantity'
112+
warning 'MissingTranslation'
118113

119114
// Treat some warnings as errors
115+
// Resources
116+
error 'TypographyEllipsis'
117+
error 'ImpliedQuantity'
118+
119+
// UX
120+
error 'ButtonOrder'
121+
122+
// Layout
120123
error 'StringFormatCount'
121124
error 'HardcodedText'
122125
error 'SpUsage'
126+
error 'ObsoleteLayoutParam'
127+
error 'InefficientWeight'
128+
error 'DisableBaselineAlignment'
129+
error 'ScrollViewSize'
130+
131+
// RTL
132+
error 'RtlEnabled'
133+
error 'RtlHardcoded'
134+
error 'RtlSymmetry'
135+
136+
// Code
137+
error 'SetTextI18n'
138+
error 'ViewConstructor'
139+
error 'UseValueOf'
123140
}
124141

125142
repositories {
@@ -159,6 +176,9 @@ dependencies {
159176
// Kotlin KTX
160177
implementation 'androidx.core:core-ktx:0.3'
161178

179+
// Kotlin coroutines
180+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.30.2'
181+
162182
implementation 'com.android.support:multidex:1.0.0'
163183

164184
implementation 'me.leolin:ShortcutBadger:1.1.2@aar'
@@ -221,15 +241,14 @@ dependencies {
221241
implementation(name: 'react-native', ext: 'aar')
222242
implementation(name: 'react-native-locale-detector', ext: 'aar')
223243

224-
225244
// another tracking than GA
226245
implementation 'org.piwik.sdk:piwik-sdk:2.0.0'
227246

228247
/************* flavors management **************/
229248

230249
// app flavor only
231-
appImplementation 'com.google.firebase:firebase-core:16.0.3'
232-
appImplementation 'com.google.firebase:firebase-messaging:17.3.0'
250+
appImplementation 'com.google.firebase:firebase-core:16.0.4'
251+
appImplementation 'com.google.firebase:firebase-messaging:17.3.4'
233252

234253
// fdroid flavor only
235254

vector/libs/matrix-sdk.aar

2.85 KB
Binary file not shown.

vector/src/app/AndroidManifest.xml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,12 @@
88
android:name="firebase_analytics_collection_deactivated"
99
android:value="true" />
1010

11-
<service
12-
android:name="im.vector.gcm.MatrixGcmListenerService">
11+
<service android:name="im.vector.push.fcm.VectorFirebaseMessagingService">
1312
<intent-filter>
1413
<action android:name="com.google.firebase.MESSAGING_EVENT" />
1514
</intent-filter>
1615
</service>
1716

18-
<service
19-
android:name="im.vector.gcm.MatrixInstanceIDListenerService">
20-
<intent-filter>
21-
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
22-
</intent-filter>
23-
</service>
24-
2517
</application>
18+
2619
</manifest>

vector/src/app/java/im/vector/gcm/GCMHelper.java

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

vector/src/app/java/im/vector/gcm/MatrixInstanceIDListenerService.java

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright 2014 OpenMarket Ltd
3+
* Copyright 2017 Vector Creations Ltd
4+
* Copyright 2018 New Vector Ltd
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package im.vector.push.fcm;
19+
20+
import android.app.Activity;
21+
import android.content.Context;
22+
import android.preference.PreferenceManager;
23+
import android.support.annotation.NonNull;
24+
import android.support.annotation.Nullable;
25+
import android.text.TextUtils;
26+
27+
import com.google.android.gms.tasks.OnSuccessListener;
28+
import com.google.firebase.iid.FirebaseInstanceId;
29+
import com.google.firebase.iid.InstanceIdResult;
30+
31+
import org.matrix.androidsdk.util.Log;
32+
33+
/**
34+
* This class store the FCM token in SharedPrefs and ensure this token is retrieved.
35+
* It has an alter ego in the fdroid variant.
36+
*/
37+
public class FcmHelper {
38+
private static final String LOG_TAG = FcmHelper.class.getSimpleName();
39+
40+
private static final String PREFS_KEY_FCM_TOKEN = "FCM_TOKEN";
41+
42+
/**
43+
* Retrieves the FCM registration token.
44+
*
45+
* @return the FCM token or null if not received from FCM
46+
*/
47+
@Nullable
48+
public static String getFcmToken(Context context) {
49+
return PreferenceManager.getDefaultSharedPreferences(context).getString(PREFS_KEY_FCM_TOKEN, null);
50+
}
51+
52+
/**
53+
* Store FCM token to the SharedPrefs
54+
*
55+
* @param context android context
56+
* @param token the token to store
57+
*/
58+
public static void storeFcmToken(@NonNull Context context,
59+
@Nullable String token) {
60+
PreferenceManager.getDefaultSharedPreferences(context)
61+
.edit()
62+
.putString(PREFS_KEY_FCM_TOKEN, token)
63+
.apply();
64+
}
65+
66+
/**
67+
* onNewToken may not be called on application upgrade, so ensure my shared pref is set
68+
*
69+
* @param activity the first launch Activity
70+
*/
71+
public static void ensureFcmTokenIsRetrieved(final Activity activity) {
72+
if (TextUtils.isEmpty(getFcmToken(activity))) {
73+
try {
74+
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(activity, new OnSuccessListener<InstanceIdResult>() {
75+
@Override
76+
public void onSuccess(InstanceIdResult instanceIdResult) {
77+
storeFcmToken(activity, instanceIdResult.getToken());
78+
}
79+
});
80+
} catch (Exception e) {
81+
Log.e(LOG_TAG, "## ensureFcmTokenIsRetrieved() : failed " + e.getMessage(), e);
82+
}
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)