浏览代码

Push work

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 年之前
父节点
当前提交
8931f36bda
共有 5 个文件被更改,包括 17 次插入40 次删除
  1. 2 2
      .gitignore
  2. 2 0
      app/gplay.gradle
  3. 10 28
      app/src/main/java/com/nextcloud/talk/utils/DeviceUtils.java
  4. 0 10
      app/src/main/res/values/setup.xml
  5. 3 0
      build.gradle

+ 2 - 2
.gitignore

@@ -47,8 +47,8 @@ captures/
 .externalNativeBuild
 
 # Google Services (e.g. APIs or Firebase)
-google-services.json
-app/google-services.json
+#google-services.json
+#app/google-services.json
 
 # Freeline
 freeline.py

+ 2 - 0
app/gplay.gradle

@@ -6,3 +6,5 @@ dependencies {
   implementation "com.google.android.gms:play-services-gcm:${googleLibraryVersion}"
   implementation "com.google.firebase:firebase-messaging:${googleLibraryVersion}"
 }
+
+apply plugin: 'com.google.gms.google-services'

+ 10 - 28
app/src/main/java/com/nextcloud/talk/utils/DeviceUtils.java

@@ -40,21 +40,12 @@ public class DeviceUtils {
             try {
                 @SuppressLint("PrivateApi") Class<?> appOpsUtilsClass = Class.forName("android.miui.AppOpsUtils");
                 if (appOpsUtilsClass != null) {
-                    Method getApplicationAutoStart = appOpsUtilsClass.getDeclaredMethod("getApplicationAutoStart", Context.class, String.class);
-                    if (getApplicationAutoStart != null) {
+                    Method setApplicationAutoStartMethod = appOpsUtilsClass.getDeclaredMethod("setApplicationAutoStart", Context.class, String
+                            .class, Boolean.TYPE);
+                    if (setApplicationAutoStartMethod != null) {
                         Context applicationContext = NextcloudTalkApplication.getSharedApplication().getApplicationContext();
-                        Object result = getApplicationAutoStart.invoke(appOpsUtilsClass, applicationContext, applicationContext.getPackageName());
-                        if (result instanceof Integer) {
-                            Integer integerResult = (Integer) result;
-                            if (integerResult == 0) {
-                                Method setApplicationAutoStartMethod = appOpsUtilsClass.getDeclaredMethod("setApplicationAutoStart",
-                                        Context.class, String.class, Boolean.TYPE);
-                                if (setApplicationAutoStartMethod != null) {
-                                    setApplicationAutoStartMethod.invoke(appOpsUtilsClass, applicationContext, applicationContext.getPackageName(),
-                                            Boolean.TRUE);
-                                }
-                            }
-                        }
+                        setApplicationAutoStartMethod.invoke(appOpsUtilsClass, applicationContext, applicationContext
+                                .getPackageName(), Boolean.TRUE);
                     }
                 }
             } catch (ClassNotFoundException e) {
@@ -78,20 +69,11 @@ public class DeviceUtils {
                     if (getInstanceMethod != null) {
                         Object protectAppControlInstance = getInstanceMethod.invoke(null, applicationContext);
 
-                        Method isProtectedMethod = protectAppControlClass.getDeclaredMethod("isProtect", String.class);
-                        if (isProtectedMethod != null) {
-                            Object result = isProtectedMethod.invoke(protectAppControlInstance, applicationContext.getPackageName());
-                            if (result instanceof Boolean) {
-                                boolean booleanResult = (boolean) result;
-                                if (!booleanResult) {
-                                    Method setProtectMethod = protectAppControlClass.getDeclaredMethod("setProtect", List.class);
-                                    if (setProtectMethod != null) {
-                                        List<String> appsList = new ArrayList<>();
-                                        appsList.add(applicationContext.getPackageName());
-                                        setProtectMethod.invoke(protectAppControlInstance, appsList);
-                                    }
-                                }
-                            }
+                        Method setProtectMethod = protectAppControlClass.getDeclaredMethod("setProtect", List.class);
+                        if (setProtectMethod != null) {
+                            List<String> appsList = new ArrayList<>();
+                            appsList.add(applicationContext.getPackageName());
+                            setProtectMethod.invoke(protectAppControlInstance, appsList);
                         }
                     }
                 }

+ 0 - 10
app/src/main/res/values/setup.xml

@@ -19,14 +19,4 @@
     <string name="nc_import_accounts_from" translatable="false">com.nextcloud.client</string>
     <string name="nc_import_account_type" translatable="false">nextcloud</string>
 
-    <!-- Push notifications -->
-    <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:54b65087c544d819</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>

+ 3 - 0
build.gradle

@@ -12,6 +12,9 @@ buildscript {
     dependencies {
         classpath 'com.android.tools.build:gradle:3.0.1'
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
+        if (getGradle().getStartParameter().getTaskRequests().toString().contains("GPlay")){
+            classpath 'com.google.gms:google-services:3.1.0'
+        }
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files