Quellcode durchsuchen

add push values to setup.xml
automatically uncomment google deps for lint, gplay and findbugs
npe check
disable analytics

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>

tobiasKaminsky vor 6 Jahren
Ursprung
Commit
449f82aa2c

+ 0 - 4
.drone.yml

@@ -2,8 +2,6 @@ pipeline:
   compile:
     image: nextcloudci/android:android-35
     commands:
-      # uncomment gplay for Gplay
-      - sh -c "if [ '${FLAVOR}' = 'Gplay' ]; then sed -i '/.*com.google.*/s/^.*\\/\\///g' build.gradle; fi"
       # build app and assemble APK
       - sh -c "if [ '${FLAVOR}' != 'Analysis' ]; then ./gradlew assemble${FLAVOR}; fi"
     when:
@@ -31,8 +29,6 @@ pipeline:
   analysis:
     image: nextcloudci/android:android-37
     commands:
-      # needs gplay
-      - sed -i '/.*com.google.*/s/^.*\\/\\///g' build.gradle
       - export BRANCH=$(scripts/analysis/getBranchName.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST)
       - scripts/analysis/analysis-wrapper.sh $GIT_USERNAME $GIT_TOKEN $BRANCH $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST
     secrets: [ GIT_USERNAME, GIT_TOKEN, LOG_USERNAME, LOG_PASSWORD ]

+ 5 - 9
build.gradle

@@ -15,7 +15,6 @@ buildscript {
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:3.1.3'
-        classpath 'com.google.gms:google-services:3.0.0'
         classpath 'org.codehaus.groovy:groovy-all:2.4.12' 
         classpath('com.dicedmelon.gradle:jacoco-android:0.1.2') { 
             exclude group: 'org.codehaus.groovy', module: 'groovy-all' 
@@ -36,8 +35,6 @@ configurations.all {
 
 ext {
     supportLibraryVersion = '27.1.1'
-    googleLibraryVersion = '12.0.1'
-    androidLibraryVersion = '1.0.40'
     jacocoVersion = "0.7.4.201502262128"
 
     travisBuild = System.getenv("TRAVIS") == "true"
@@ -63,6 +60,11 @@ def versionMinor = 3
 def versionPatch = 0
 def versionBuild = 0 // 0-49=Alpha / 50-98=RC / 99=stable
 
+def taskRequest = getGradle().getStartParameter().getTaskRequests().toString();
+if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
+    apply from: 'gplay.gradle'
+}
+
 android {
     lintOptions {
         abortOnError false
@@ -232,9 +234,6 @@ dependencies {
     implementation 'com.github.chrisbanes:PhotoView:2.1.3'
     implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.12'
 
-    // uncomment for gplay
-    // implementation "com.google.firebase:firebase-messaging:${googleLibraryVersion}"
-    // implementation "com.google.android.gms:play-services-gcm:${googleLibraryVersion}"
     implementation 'org.parceler:parceler-api:1.1.9'
     annotationProcessor 'org.parceler:parceler:1.1.9'
     implementation ('com.github.bumptech.glide:glide:3.7.0') {
@@ -310,6 +309,3 @@ task combinedTestReport(type: JacocoReport) {
             'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
     ])
 }
-
-    // uncomment for gplay (must be at the bottom)
-    // apply plugin: 'com.google.gms.google-services'

+ 4 - 0
gplay.gradle

@@ -0,0 +1,4 @@
+dependencies {
+    implementation "com.google.firebase:firebase-messaging:17.1.0"
+    implementation "com.google.android.gms:play-services-gcm:15.0.1"
+}

+ 6 - 2
src/gplay/AndroidManifest.xml

@@ -28,8 +28,12 @@
         android:theme="@style/Theme.ownCloud.Toolbar"
         android:manageSpaceActivity="com.owncloud.android.ui.activity.ManageSpaceActivity">
 
-        <meta-data android:name="com.google.android.gms.version"
-                   android:value="@integer/google_play_services_version" />
+        <meta-data
+            android:name="firebase_analytics_collection_deactivated"
+            android:value="true"/>
+        <meta-data
+            android:name="google_analytics_adid_collection_enabled"
+            android:value="false"/>
 
         <activity
             android:name=".authentication.ModifiedAuthenticatorActivity"

+ 1 - 1
src/gplay/java/com/owncloud/android/services/firebase/NCFirebaseMessagingService.java

@@ -29,7 +29,7 @@ public class NCFirebaseMessagingService extends FirebaseMessagingService {
 
     @Override
     public void onMessageReceived(RemoteMessage remoteMessage) {
-        if (remoteMessage.getData() != null) {
+        if (remoteMessage != null && remoteMessage.getData() != null) {
             PersistableBundleCompat persistableBundleCompat = new PersistableBundleCompat();
             persistableBundleCompat.putString(NotificationJob.KEY_NOTIFICATION_SUBJECT, remoteMessage.getData().get
                     (NotificationJob.KEY_NOTIFICATION_SUBJECT));

+ 9 - 0
src/gplay/res/values/setup.xml

@@ -2,6 +2,15 @@
 <resources>
     <!-- Push server url -->
     <string name="push_server_url" translatable="false">https://push-notifications.nextcloud.com</string>
+
+    <string name="default_web_client_id" translatable="false">829118773643-cq33cmhv7mnv7iq8mjv6rt7t15afc70k.apps.googleusercontent.com</string>
+    <string name="firebase_database_url" translatable="false">https://nextcloud-a7dea.firebaseio.com</string>
+    <string name="gcm_defaultSenderId" translatable="false">829118773643</string>
+    <string name="google_api_key" translatable="false">AIzaSyAWIyOcLafaFp8PFL61h64cy1NNZW2cU_s</string>
+    <string name="google_app_id" translatable="false">1:829118773643:android:512449826e931d0e</string>
+    <string name="google_crash_reporting_api_key" translatable="false">AIzaSyAWIyOcLafaFp8PFL61h64cy1NNZW2cU_s</string>
+    <string name="google_storage_bucket" translatable="false">nextcloud-a7dea.appspot.com</string>
+    <string name="project_id" translatable="false">nextcloud-a7dea</string>
 </resources>