Push work

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-02-19 11:34:35 +01:00
parent c48969253f
commit 8931f36bda
5 changed files with 17 additions and 40 deletions

4
.gitignore vendored
View file

@ -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

View file

@ -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'

View file

@ -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) {
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);
Method setApplicationAutoStartMethod = appOpsUtilsClass.getDeclaredMethod("setApplicationAutoStart", Context.class, String
.class, Boolean.TYPE);
if (setApplicationAutoStartMethod != null) {
setApplicationAutoStartMethod.invoke(appOpsUtilsClass, applicationContext, applicationContext.getPackageName(),
Boolean.TRUE);
}
}
}
Context applicationContext = NextcloudTalkApplication.getSharedApplication().getApplicationContext();
setApplicationAutoStartMethod.invoke(appOpsUtilsClass, applicationContext, applicationContext
.getPackageName(), Boolean.TRUE);
}
}
} catch (ClassNotFoundException e) {
@ -78,12 +69,6 @@ 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<>();
@ -92,9 +77,6 @@ public class DeviceUtils {
}
}
}
}
}
}
} catch (ClassNotFoundException e) {
Log.e(TAG, "Class not found");
} catch (NoSuchMethodException e) {

View file

@ -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>

View file

@ -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