Skip to content

Commit

Permalink
Merge pull request #696 from frh/fdroid
Browse files Browse the repository at this point in the history
Play Store and F-Droid build flavors
  • Loading branch information
yoh-there authored May 2, 2021
2 parents 2329e2f + bc1bce2 commit 35e3ad3
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 29 deletions.
13 changes: 10 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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'
Expand Down
40 changes: 40 additions & 0 deletions app/src/fdroid/java/lu/fisch/canze/activities/SplashActivity.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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();
}
}
9 changes: 9 additions & 0 deletions app/src/fdroid/java/lu/fisch/canze/classes/Crashlytics.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package lu.fisch.canze.classes;

public class Crashlytics {
public static void logException (Exception e) {
}

public static void logString (String e) {
}
}
3 changes: 2 additions & 1 deletion app/src/main/java/lu/fisch/awt/Color.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/lu/fisch/canze/activities/DtcActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
}
}
Expand Down
13 changes: 2 additions & 11 deletions app/src/main/java/lu/fisch/canze/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -1063,4 +1064,4 @@ private void setSwitchPreferenceStatus(SwitchPreference preference, String setti
editor.putBoolean(setting, status).apply();
}
}
}
}
5 changes: 3 additions & 2 deletions app/src/main/java/lu/fisch/canze/actors/AssetLoadHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.content.res.AssetManager;

import lu.fisch.canze.activities.MainActivity;
import lu.fisch.canze.classes.Crashlytics;

public class AssetLoadHelper {

Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/lu/fisch/canze/actors/Ecus.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.ArrayList;

import lu.fisch.canze.activities.MainActivity;
import lu.fisch.canze.classes.Crashlytics;

/**
* Ecus
Expand Down Expand Up @@ -86,7 +87,7 @@ private void fillFromAsset (String assetName) {
bufferedReader.close();
}
catch (IOException e) {
MainActivity.logExceptionToCrashlytics(e);
Crashlytics.logException(e);
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/lu/fisch/canze/actors/Fields.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -764,7 +765,7 @@ private void fillFromAsset(String assetName) {
fillOneLine(line);
bufferedReader.close();
} catch (IOException e) {
MainActivity.logExceptionToCrashlytics(e);
Crashlytics.logException(e);
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/lu/fisch/canze/actors/Frames.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import lu.fisch.canze.R;
import lu.fisch.canze.activities.MainActivity;
import lu.fisch.canze.classes.Crashlytics;

/**
* Frames
Expand Down Expand Up @@ -97,7 +98,7 @@ private void fillFromAsset (String assetName) {
bufferedReader.close();
}
catch (IOException e) {
MainActivity.logExceptionToCrashlytics(e);
Crashlytics.logException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/lu/fisch/canze/widgets/Plotter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<minValues.get(index)) minValues.set(index,value);
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/lu/fisch/canze/widgets/WidgetView.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import lu.fisch.canze.activities.CanzeActivity;
import lu.fisch.canze.actors.Field;
import lu.fisch.canze.classes.ColorRanges;
import lu.fisch.canze.classes.Crashlytics;
import lu.fisch.canze.classes.Intervals;
import lu.fisch.canze.classes.Options;
import lu.fisch.canze.interfaces.DrawSurfaceInterface;
Expand Down Expand Up @@ -252,7 +253,7 @@ public void init(final Context context, AttributeSet attrs)
}
catch(Exception e)
{
MainActivity.logExceptionToCrashlytics(e);
Crashlytics.logException(e);
}
}

Expand Down Expand Up @@ -368,7 +369,7 @@ public void repaint2() {
}
catch(Exception e)
{
MainActivity.logExceptionToCrashlytics(e);
Crashlytics.logException(e);
// ignore
}
finally
Expand Down
13 changes: 13 additions & 0 deletions app/src/playstore/java/lu/fisch/canze/classes/Crashlytics.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package lu.fisch.canze.classes;

import com.google.firebase.crashlytics.FirebaseCrashlytics;

public class Crashlytics {
public static void logException (Exception e) {
FirebaseCrashlytics.getInstance().recordException(e);
}

public static void logString (String e) {
FirebaseCrashlytics.getInstance().log(e);
}
}

0 comments on commit 35e3ad3

Please sign in to comment.