|
@@ -1,39 +1,39 @@
|
|
|
/**
|
|
|
- * ownCloud Android client application
|
|
|
+ * ownCloud Android client application
|
|
|
*
|
|
|
- * @author masensio
|
|
|
- * @author David A. Velasco
|
|
|
- * @author Mario Danic
|
|
|
- * Copyright (C) 2015 ownCloud Inc.
|
|
|
- * Copyright (C) 2017 Mario Danic
|
|
|
- * Copyright (C) 2017 Nextcloud GmbH
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License version 2,
|
|
|
- * as published by the Free Software Foundation.
|
|
|
- *
|
|
|
- * This program is distributed in the hope that it will be useful,
|
|
|
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
- * GNU General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
- *
|
|
|
- * All changes by Mario Danic are under AGPL3+
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU Affero General Public License as published by
|
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
|
|
- * at your option) any later version.
|
|
|
- *
|
|
|
- * This program is distributed in the hope that it will be useful,
|
|
|
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
- * GNU Affero General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU Affero General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
+ * @author masensio
|
|
|
+ * @author David A. Velasco
|
|
|
+ * @author Mario Danic
|
|
|
+ * Copyright (C) 2015 ownCloud Inc.
|
|
|
+ * Copyright (C) 2017 Mario Danic
|
|
|
+ * Copyright (C) 2017 Nextcloud GmbH
|
|
|
+ * <p>
|
|
|
+ * This program is free software: you can redistribute it and/or modify
|
|
|
+ * it under the terms of the GNU General Public License version 2,
|
|
|
+ * as published by the Free Software Foundation.
|
|
|
+ * <p>
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+ * GNU General Public License for more details.
|
|
|
+ * <p>
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
+ * <p>
|
|
|
+ * All changes by Mario Danic are under AGPL3+
|
|
|
+ * <p>
|
|
|
+ * This program is free software: you can redistribute it and/or modify
|
|
|
+ * it under the terms of the GNU Affero General Public License as published by
|
|
|
+ * the Free Software Foundation, either version 3 of the License, or
|
|
|
+ * at your option) any later version.
|
|
|
+ * <p>
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+ * GNU Affero General Public License for more details.
|
|
|
+ * <p>
|
|
|
+ * You should have received a copy of the GNU Affero General Public License
|
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
|
|
|
import android.app.Activity;
|
|
@@ -49,11 +49,8 @@ import android.os.Bundle;
|
|
|
import android.os.Environment;
|
|
|
import android.os.IBinder;
|
|
|
import android.preference.PreferenceManager;
|
|
|
-import android.text.TextUtils;
|
|
|
|
|
|
-import com.google.android.gms.analytics.GoogleAnalytics;
|
|
|
-import com.google.android.gms.analytics.HitBuilders;
|
|
|
-import com.google.android.gms.analytics.Tracker;
|
|
|
+import com.google.firebase.analytics.FirebaseAnalytics;
|
|
|
import com.owncloud.android.BuildConfig;
|
|
|
import com.owncloud.android.R;
|
|
|
import com.owncloud.android.authentication.PassCodeManager;
|
|
@@ -70,7 +67,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
|
|
|
|
/**
|
|
|
* Main Application of the project
|
|
|
- *
|
|
|
+ *
|
|
|
* Contains methods to build the "static" strings. These strings were before constants in different
|
|
|
* classes
|
|
|
*/
|
|
@@ -93,19 +90,22 @@ public class MainApp extends Application {
|
|
|
|
|
|
private static SyncedFolderObserverService mObserverService;
|
|
|
|
|
|
+ private FirebaseAnalytics mFirebaseAnalytics;
|
|
|
+
|
|
|
+ private boolean analyticsEnabled;
|
|
|
+
|
|
|
@SuppressWarnings("unused")
|
|
|
private boolean mBound;
|
|
|
|
|
|
- private Tracker mTracker;
|
|
|
-
|
|
|
- @SuppressFBWarnings("ST") public void onCreate(){
|
|
|
+ @SuppressFBWarnings("ST")
|
|
|
+ public void onCreate() {
|
|
|
super.onCreate();
|
|
|
MainApp.mContext = getApplicationContext();
|
|
|
|
|
|
SharedPreferences appPrefs =
|
|
|
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
|
|
MainApp.storagePath = appPrefs.getString(Preferences.PreferenceKeys.STORAGE_PATH, Environment.
|
|
|
- getExternalStorageDirectory().getAbsolutePath());
|
|
|
+ getExternalStorageDirectory().getAbsolutePath());
|
|
|
|
|
|
boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
|
|
|
|
|
@@ -118,7 +118,7 @@ public class MainApp extends Application {
|
|
|
|
|
|
// initialise thumbnails cache on background thread
|
|
|
new ThumbnailsCacheManager.InitDiskCacheTask().execute();
|
|
|
-
|
|
|
+
|
|
|
if (BuildConfig.DEBUG) {
|
|
|
|
|
|
String dataFolder = getDataFolder();
|
|
@@ -135,38 +135,30 @@ public class MainApp extends Application {
|
|
|
startService(i);
|
|
|
bindService(i, syncedFolderObserverServiceConnection, Context.BIND_AUTO_CREATE);
|
|
|
|
|
|
- boolean analyticsEnabled = false;
|
|
|
- String analyticsId;
|
|
|
-
|
|
|
- if (!TextUtils.isEmpty(analyticsId = getAppContext().getResources().getString(R.string.analytics_tracking_id))) {
|
|
|
+ if ((analyticsEnabled = getAppContext().getResources().getBoolean(R.bool.firebase_analytics_enabled))) {
|
|
|
analyticsEnabled = true;
|
|
|
- mTracker = getDefaultTracker(analyticsId);
|
|
|
+ mFirebaseAnalytics = getFirebaseAnalytics();
|
|
|
}
|
|
|
|
|
|
// register global protection with pass code
|
|
|
- final boolean finalAnalyticsEnabled = analyticsEnabled;
|
|
|
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
|
|
|
|
|
|
@Override
|
|
|
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
|
|
- Log_OC.d(activity.getClass().getSimpleName(), "onCreate(Bundle) starting" );
|
|
|
+ Log_OC.d(activity.getClass().getSimpleName(), "onCreate(Bundle) starting");
|
|
|
WhatsNewActivity.runIfNeeded(activity);
|
|
|
PassCodeManager.getPassCodeManager().onActivityCreated(activity);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onActivityStarted(Activity activity) {
|
|
|
- Log_OC.d(activity.getClass().getSimpleName(), "onStart() starting" );
|
|
|
+ Log_OC.d(activity.getClass().getSimpleName(), "onStart() starting");
|
|
|
PassCodeManager.getPassCodeManager().onActivityStarted(activity);
|
|
|
- if (finalAnalyticsEnabled) {
|
|
|
- mTracker.setScreenName(activity.getClass().getSimpleName());
|
|
|
- mTracker.send(new HitBuilders.ScreenViewBuilder().build());
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onActivityResumed(Activity activity) {
|
|
|
- Log_OC.d(activity.getClass().getSimpleName(), "onResume() starting" );
|
|
|
+ Log_OC.d(activity.getClass().getSimpleName(), "onResume() starting");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -176,45 +168,31 @@ public class MainApp extends Application {
|
|
|
|
|
|
@Override
|
|
|
public void onActivityStopped(Activity activity) {
|
|
|
- Log_OC.d(activity.getClass().getSimpleName(), "onStop() ending" );
|
|
|
+ Log_OC.d(activity.getClass().getSimpleName(), "onStop() ending");
|
|
|
PassCodeManager.getPassCodeManager().onActivityStopped(activity);
|
|
|
- if (finalAnalyticsEnabled) {
|
|
|
- mTracker.setScreenName(activity.getClass().getSimpleName());
|
|
|
- mTracker.send(new HitBuilders.ScreenViewBuilder().build());
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
|
|
|
- Log_OC.d(activity.getClass().getSimpleName(), "onSaveInstanceState(Bundle) starting" );
|
|
|
+ Log_OC.d(activity.getClass().getSimpleName(), "onSaveInstanceState(Bundle) starting");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onActivityDestroyed(Activity activity) {
|
|
|
- Log_OC.d(activity.getClass().getSimpleName(), "onDestroy() ending" );
|
|
|
+ Log_OC.d(activity.getClass().getSimpleName(), "onDestroy() ending");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- synchronized public Tracker getDefaultTracker(String analyticsID) {
|
|
|
- if (mTracker == null) {
|
|
|
- GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
|
|
|
- // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
|
|
|
- mTracker = analytics.newTracker(analyticsID);
|
|
|
- }
|
|
|
- return mTracker;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
public static Context getAppContext() {
|
|
|
return MainApp.mContext;
|
|
|
}
|
|
|
|
|
|
- public static String getStoragePath(){
|
|
|
+ public static String getStoragePath() {
|
|
|
return MainApp.storagePath;
|
|
|
}
|
|
|
|
|
|
- public static void setStoragePath(String path){
|
|
|
+ public static void setStoragePath(String path) {
|
|
|
MainApp.storagePath = path;
|
|
|
}
|
|
|
|
|
@@ -241,42 +219,42 @@ public class MainApp extends Application {
|
|
|
public static String getAuthority() {
|
|
|
return getAppContext().getResources().getString(R.string.authority);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// From AccountAuthenticator
|
|
|
// public static final String AUTH_TOKEN_TYPE = "org.owncloud";
|
|
|
public static String getAuthTokenType() {
|
|
|
return getAppContext().getResources().getString(R.string.authority);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// From ProviderMeta
|
|
|
// public static final String DB_FILE = "owncloud.db";
|
|
|
public static String getDBFile() {
|
|
|
return getAppContext().getResources().getString(R.string.db_file);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// From ProviderMeta
|
|
|
// private final String mDatabaseName = "ownCloud";
|
|
|
public static String getDBName() {
|
|
|
return getAppContext().getResources().getString(R.string.db_name);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* name of data_folder, e.g., "owncloud"
|
|
|
*/
|
|
|
public static String getDataFolder() {
|
|
|
return getAppContext().getResources().getString(R.string.data_folder);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// log_name
|
|
|
public static String getLogName() {
|
|
|
return getAppContext().getResources().getString(R.string.log_name);
|
|
|
}
|
|
|
|
|
|
- public static void showOnlyFilesOnDevice(boolean state){
|
|
|
+ public static void showOnlyFilesOnDevice(boolean state) {
|
|
|
mOnlyOnDevice = state;
|
|
|
}
|
|
|
|
|
|
- public static boolean isOnlyOnDevice(){
|
|
|
+ public static boolean isOnlyOnDevice() {
|
|
|
return mOnlyOnDevice;
|
|
|
}
|
|
|
|
|
@@ -322,4 +300,16 @@ public class MainApp extends Application {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ public FirebaseAnalytics getFirebaseAnalytics() {
|
|
|
+ if (analyticsEnabled) {
|
|
|
+ if (mFirebaseAnalytics != null) {
|
|
|
+ return mFirebaseAnalytics;
|
|
|
+ } else {
|
|
|
+ mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
|
|
|
+ return mFirebaseAnalytics;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|