From bc1bce2b034b7e88152f4ecb9bfbc85f3b0ee1a3 Mon Sep 17 00:00:00 2001 From: frh <4987254+frh@users.noreply.github.com> Date: Sat, 1 May 2021 22:47:33 +0200 Subject: [PATCH] playstore and fdroid build flavors --- app/build.gradle | 13 ++++-- .../canze/activities/SplashActivity.java | 40 +++++++++++++++++++ .../lu/fisch/canze/classes/Crashlytics.java | 9 +++++ app/src/main/java/lu/fisch/awt/Color.java | 3 +- .../fisch/canze/activities/DtcActivity.java | 3 +- .../fisch/canze/activities/MainActivity.java | 13 +----- .../canze/activities/SettingsActivity.java | 5 ++- .../fisch/canze/actors/AssetLoadHelper.java | 5 ++- .../main/java/lu/fisch/canze/actors/Ecus.java | 3 +- .../java/lu/fisch/canze/actors/Fields.java | 3 +- .../java/lu/fisch/canze/actors/Frames.java | 3 +- .../fisch/canze/database/CanzeOpenHelper.java | 6 +-- .../java/lu/fisch/canze/widgets/Plotter.java | 3 +- .../lu/fisch/canze/widgets/WidgetView.java | 5 ++- .../canze/activities/SplashActivity.java | 0 .../lu/fisch/canze/classes/Crashlytics.java | 13 ++++++ 16 files changed, 98 insertions(+), 29 deletions(-) create mode 100644 app/src/fdroid/java/lu/fisch/canze/activities/SplashActivity.java create mode 100644 app/src/fdroid/java/lu/fisch/canze/classes/Crashlytics.java rename app/src/{main => playstore}/java/lu/fisch/canze/activities/SplashActivity.java (100%) create mode 100644 app/src/playstore/java/lu/fisch/canze/classes/Crashlytics.java diff --git a/app/build.gradle b/app/build.gradle index b6e110f0..e9fd5d13 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,7 +31,14 @@ android { // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' //} } + flavorDimensions "edition" productFlavors { + playstore { + dimension "edition" + } + fdroid { + dimension "edition" + } } defaultConfig { buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L" @@ -55,11 +62,11 @@ def getGitRevParseInfo() { dependencies { // BoM for the Firebase platform - implementation platform('com.google.firebase:firebase-bom:26.2.0') + playstoreImplementation platform('com.google.firebase:firebase-bom:26.2.0') // Dependencies for the desired Firebase products without specifying versions - implementation 'com.google.firebase:firebase-analytics' - implementation 'com.google.firebase:firebase-crashlytics' + playstoreImplementation 'com.google.firebase:firebase-analytics' + playstoreImplementation 'com.google.firebase:firebase-crashlytics' implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'androidx.legacy:legacy-support-v4:1.0.0' diff --git a/app/src/fdroid/java/lu/fisch/canze/activities/SplashActivity.java b/app/src/fdroid/java/lu/fisch/canze/activities/SplashActivity.java new file mode 100644 index 00000000..0d99fa32 --- /dev/null +++ b/app/src/fdroid/java/lu/fisch/canze/activities/SplashActivity.java @@ -0,0 +1,40 @@ +/* + CanZE + Take a closer look at your ZE car + + Copyright (C) 2015 - The CanZE Team + http://canze.fisch.lu + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or 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 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 . +*/ + +package lu.fisch.canze.activities; + +import android.content.Intent; +import android.os.Bundle; +import androidx.appcompat.app.AppCompatActivity; + +import lu.fisch.canze.BuildConfig; + +public class SplashActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent intent = new Intent(this, MainActivity.class); + startActivity(intent); + finish(); + } +} diff --git a/app/src/fdroid/java/lu/fisch/canze/classes/Crashlytics.java b/app/src/fdroid/java/lu/fisch/canze/classes/Crashlytics.java new file mode 100644 index 00000000..6ced9990 --- /dev/null +++ b/app/src/fdroid/java/lu/fisch/canze/classes/Crashlytics.java @@ -0,0 +1,9 @@ +package lu.fisch.canze.classes; + +public class Crashlytics { + public static void logException (Exception e) { + } + + public static void logString (String e) { + } +} diff --git a/app/src/main/java/lu/fisch/awt/Color.java b/app/src/main/java/lu/fisch/awt/Color.java index 449598c8..01eaa3ce 100644 --- a/app/src/main/java/lu/fisch/awt/Color.java +++ b/app/src/main/java/lu/fisch/awt/Color.java @@ -26,6 +26,7 @@ import java.lang.reflect.Field; import lu.fisch.canze.activities.MainActivity; +import lu.fisch.canze.classes.Crashlytics; public class Color { private int alpha = 0xff; @@ -131,7 +132,7 @@ private static int getAttrId(String resName) { Field idField = android.R.attr.class.getDeclaredField(resName); return idField.getInt(idField); } catch (Exception e) { - MainActivity.logExceptionToCrashlytics(e); + Crashlytics.logException(e); return -1; } } diff --git a/app/src/main/java/lu/fisch/canze/activities/DtcActivity.java b/app/src/main/java/lu/fisch/canze/activities/DtcActivity.java index a466d6b8..851383d7 100644 --- a/app/src/main/java/lu/fisch/canze/activities/DtcActivity.java +++ b/app/src/main/java/lu/fisch/canze/activities/DtcActivity.java @@ -49,6 +49,7 @@ import lu.fisch.canze.actors.Message; import lu.fisch.canze.actors.StoppableThread; import lu.fisch.canze.bluetooth.BluetoothManager; +import lu.fisch.canze.classes.Crashlytics; import static lu.fisch.canze.activities.MainActivity.debug; @@ -212,7 +213,7 @@ private void doQueryEcu(final Ecu ecu) { try { queryThread.join(); } catch (Exception e) { - MainActivity.logExceptionToCrashlytics(e); + Crashlytics.logException(e); MainActivity.debug(e.getMessage()); } } diff --git a/app/src/main/java/lu/fisch/canze/activities/MainActivity.java b/app/src/main/java/lu/fisch/canze/activities/MainActivity.java index 621ec9a4..9ad24e30 100644 --- a/app/src/main/java/lu/fisch/canze/activities/MainActivity.java +++ b/app/src/main/java/lu/fisch/canze/activities/MainActivity.java @@ -67,8 +67,6 @@ import android.widget.ProgressBar; import android.widget.Toast; -import com.google.firebase.crashlytics.FirebaseCrashlytics; - import java.util.Locale; import lu.fisch.canze.BuildConfig; @@ -80,6 +78,7 @@ import lu.fisch.canze.bluetooth.BluetoothManager; import lu.fisch.canze.classes.Activity; import lu.fisch.canze.classes.ActivityRegistry; +import lu.fisch.canze.classes.Crashlytics; import lu.fisch.canze.classes.DataLogger; import lu.fisch.canze.classes.DebugLogger; import lu.fisch.canze.database.CanzeDataSource; @@ -382,7 +381,7 @@ private void loadSettings() { dataExportMode = dataLogger.activate(dataExportMode); } catch (Exception e) { if (BuildConfig.BRANCH.equals("master")) { - logExceptionToCrashlytics(e); + Crashlytics.logException(e); } else { e.printStackTrace(); } @@ -1247,13 +1246,5 @@ public String getExternalFolder() { // - it selects Internal storage instead of SD card. Why is somewhat unclear, but more or less OK for now return getExternalFilesDir(null).getAbsolutePath() + "/"; } - - public static void logExceptionToCrashlytics (Exception e) { - FirebaseCrashlytics.getInstance().recordException(e); - } - - public static void logStringToCrashlitics (String e) { - FirebaseCrashlytics.getInstance().log(e); - } } diff --git a/app/src/main/java/lu/fisch/canze/activities/SettingsActivity.java b/app/src/main/java/lu/fisch/canze/activities/SettingsActivity.java index 7a893906..91b00c0c 100644 --- a/app/src/main/java/lu/fisch/canze/activities/SettingsActivity.java +++ b/app/src/main/java/lu/fisch/canze/activities/SettingsActivity.java @@ -63,6 +63,7 @@ import lu.fisch.canze.actors.Utils; import lu.fisch.canze.classes.Activity; import lu.fisch.canze.classes.ActivityRegistry; +import lu.fisch.canze.classes.Crashlytics; import lu.fisch.canze.database.CanzeDataSource; public class SettingsActivity extends AppCompatActivity { @@ -734,7 +735,7 @@ private void loadInfo() { String version = MainActivity.getStringSingle(R.string.version) + BuildConfig.VERSION_NAME + " (" + BuildConfig.BUILD_TYPE + "-" + BuildConfig.BRANCH + ") " + MainActivity.getStringSingle(R.string.build) + sdf.format(buildDate); versionInfo.setTitle(version); } catch (Exception e) { - MainActivity.logExceptionToCrashlytics(e); + Crashlytics.logException(e); } } @@ -1063,4 +1064,4 @@ private void setSwitchPreferenceStatus(SwitchPreference preference, String setti editor.putBoolean(setting, status).apply(); } } -} \ No newline at end of file +} diff --git a/app/src/main/java/lu/fisch/canze/actors/AssetLoadHelper.java b/app/src/main/java/lu/fisch/canze/actors/AssetLoadHelper.java index 38f9d4bf..c7667889 100644 --- a/app/src/main/java/lu/fisch/canze/actors/AssetLoadHelper.java +++ b/app/src/main/java/lu/fisch/canze/actors/AssetLoadHelper.java @@ -11,6 +11,7 @@ import android.content.res.AssetManager; import lu.fisch.canze.activities.MainActivity; +import lu.fisch.canze.classes.Crashlytics; public class AssetLoadHelper { @@ -30,8 +31,8 @@ public static BufferedReader getBufferedReaderFromAsset (String asset) { } catch (FileNotFoundException e) { // do nothing, so return null } catch (IOException | NullPointerException e) { - MainActivity.logStringToCrashlitics("loading asset:[" + asset + "]"); - MainActivity.logExceptionToCrashlytics(e); + Crashlytics.logString("loading asset:[" + asset + "]"); + Crashlytics.logException(e); } // Catching null is bad practice, but I have seen one thrown by myContext.getAssets(); return null; diff --git a/app/src/main/java/lu/fisch/canze/actors/Ecus.java b/app/src/main/java/lu/fisch/canze/actors/Ecus.java index 90be2910..e70b5aed 100644 --- a/app/src/main/java/lu/fisch/canze/actors/Ecus.java +++ b/app/src/main/java/lu/fisch/canze/actors/Ecus.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import lu.fisch.canze.activities.MainActivity; +import lu.fisch.canze.classes.Crashlytics; /** * Ecus @@ -86,7 +87,7 @@ private void fillFromAsset (String assetName) { bufferedReader.close(); } catch (IOException e) { - MainActivity.logExceptionToCrashlytics(e); + Crashlytics.logException(e); } } diff --git a/app/src/main/java/lu/fisch/canze/actors/Fields.java b/app/src/main/java/lu/fisch/canze/actors/Fields.java index a28418c6..3117ce08 100644 --- a/app/src/main/java/lu/fisch/canze/actors/Fields.java +++ b/app/src/main/java/lu/fisch/canze/actors/Fields.java @@ -34,6 +34,7 @@ import lu.fisch.canze.R; import lu.fisch.canze.activities.MainActivity; +import lu.fisch.canze.classes.Crashlytics; import lu.fisch.canze.classes.FieldLogger; import lu.fisch.canze.classes.Sid; import lu.fisch.canze.database.CanzeDataSource; @@ -764,7 +765,7 @@ private void fillFromAsset(String assetName) { fillOneLine(line); bufferedReader.close(); } catch (IOException e) { - MainActivity.logExceptionToCrashlytics(e); + Crashlytics.logException(e); } } diff --git a/app/src/main/java/lu/fisch/canze/actors/Frames.java b/app/src/main/java/lu/fisch/canze/actors/Frames.java index 71a0565a..e4f38566 100644 --- a/app/src/main/java/lu/fisch/canze/actors/Frames.java +++ b/app/src/main/java/lu/fisch/canze/actors/Frames.java @@ -27,6 +27,7 @@ import lu.fisch.canze.R; import lu.fisch.canze.activities.MainActivity; +import lu.fisch.canze.classes.Crashlytics; /** * Frames @@ -97,7 +98,7 @@ private void fillFromAsset (String assetName) { bufferedReader.close(); } catch (IOException e) { - MainActivity.logExceptionToCrashlytics(e); + Crashlytics.logException(e); } } diff --git a/app/src/main/java/lu/fisch/canze/database/CanzeOpenHelper.java b/app/src/main/java/lu/fisch/canze/database/CanzeOpenHelper.java index 9799b3f7..80384850 100644 --- a/app/src/main/java/lu/fisch/canze/database/CanzeOpenHelper.java +++ b/app/src/main/java/lu/fisch/canze/database/CanzeOpenHelper.java @@ -25,7 +25,7 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; -import lu.fisch.canze.activities.MainActivity; +import lu.fisch.canze.classes.Crashlytics; public class CanzeOpenHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; @@ -44,7 +44,7 @@ public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE INDEX indexSid ON data (sid)"); //db.execSQL("CREATE TABLE data (id_data INTEGER PRIMARY KEY AUTOINCREMENT, sid TEXT NOT NULL, moment INTEGER NOT NULL, value REAL NOT NULL)"); } catch (Exception e) { - MainActivity.logExceptionToCrashlytics(e); + Crashlytics.logException(e); // do nothing } } @@ -58,7 +58,7 @@ public void clear(SQLiteDatabase db) { try { db.execSQL("DROP TABLE IF EXISTS data"); } catch (Exception e) { - MainActivity.logExceptionToCrashlytics(e); + Crashlytics.logException(e); // do nothing } } diff --git a/app/src/main/java/lu/fisch/canze/widgets/Plotter.java b/app/src/main/java/lu/fisch/canze/widgets/Plotter.java index 83f3d5ef..ce48b4d0 100644 --- a/app/src/main/java/lu/fisch/canze/widgets/Plotter.java +++ b/app/src/main/java/lu/fisch/canze/widgets/Plotter.java @@ -37,6 +37,7 @@ import lu.fisch.canze.activities.MainActivity; import lu.fisch.canze.actors.Field; import lu.fisch.canze.actors.Fields; +import lu.fisch.canze.classes.Crashlytics; import lu.fisch.canze.database.CanzeDataSource; import lu.fisch.canze.fragments.MainFragment; import lu.fisch.canze.interfaces.DrawSurfaceInterface; @@ -79,7 +80,7 @@ public void setValue(int index, double value) try { values.set(index, value); } catch (IndexOutOfBoundsException e) { - MainActivity.logExceptionToCrashlytics(e); + Crashlytics.logException(e); // Bail out. Based on Play Console Crash Report } //if(value