Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ android {
signingConfig signingConfigs.releaseConfig
}
}

flavorDimensions "edition"
productFlavors {
free {
dimension "edition"
}
proprietary {
dimension "edition"
}
}

lintOptions {
checkReleaseBuilds false
abortOnError false
Expand All @@ -65,7 +76,7 @@ apply plugin: 'com.getkeepsafe.dexcount'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
proprietaryCompile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
transitive = true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.blogspot.e_kanivets.moneytracker.util;

import android.content.Context;
import android.support.annotation.Nullable;


/**
* In free software builds, this class does nothing as Crashlytics can't be used.
* Created on 28/8/19.
*
* @author Fynn Godau
*/

public class CrashlyticsProxy {
private static CrashlyticsProxy instance;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This singleton implementation is not thread safe. Could be improved with double-checked locking.


public static CrashlyticsProxy get() {
if (instance == null) {
instance = new CrashlyticsProxy();
}
return instance;
}

private CrashlyticsProxy() {

}

public static void startCrashlytics(Context context) {

}

public void setEnabled(boolean enabled) {

}

public boolean isEnabled() {
return false;
}

public boolean logEvent(@Nullable String eventName) {
return false;
}

public boolean logButton(@Nullable String buttonName) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import com.blogspot.e_kanivets.moneytracker.di.DaggerAppComponent;
import com.blogspot.e_kanivets.moneytracker.di.module.ControllerModule;
import com.blogspot.e_kanivets.moneytracker.di.module.repo.CachedRepoModule;
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy;
import com.crashlytics.android.Crashlytics;
import com.blogspot.e_kanivets.moneytracker.util.CrashlyticsProxy;

import io.fabric.sdk.android.Fabric;
import timber.log.Timber;

/**
Expand All @@ -36,11 +34,11 @@ public void onCreate() {

if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
AnswersProxy.get().setEnabled(false);
CrashlyticsProxy.get().setEnabled(false);
} else {
Timber.plant(new ReleaseTree());
Fabric.with(this, new Crashlytics());
AnswersProxy.get().setEnabled(true);
CrashlyticsProxy.startCrashlytics(this);
CrashlyticsProxy.get().setEnabled(true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.blogspot.e_kanivets.moneytracker.controller.data.AccountController;
import com.blogspot.e_kanivets.moneytracker.entity.data.Account;
import com.blogspot.e_kanivets.moneytracker.ui.presenter.AccountsSummaryPresenter;
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy;
import com.blogspot.e_kanivets.moneytracker.util.CrashlyticsProxy;

import javax.inject.Inject;

Expand Down Expand Up @@ -82,13 +82,13 @@ public void onAccountClick(int position) {
}

public void makeTransfer() {
AnswersProxy.get().logButton("Add Transfer");
CrashlyticsProxy.get().logButton("Add Transfer");
startActivityForResult(new Intent(AccountsActivity.this, TransferActivity.class), REQUEST_TRANSFER);
}

@OnClick(R.id.btn_add_account)
public void addAccount() {
AnswersProxy.get().logButton("Add Account");
CrashlyticsProxy.get().logButton("Add Account");
Intent intent = new Intent(AccountsActivity.this, AddAccountActivity.class);
startActivityForResult(intent, REQUEST_ADD_ACCOUNT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.blogspot.e_kanivets.moneytracker.controller.data.AccountController;
import com.blogspot.e_kanivets.moneytracker.controller.CurrencyController;
import com.blogspot.e_kanivets.moneytracker.entity.data.Account;
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy;
import com.blogspot.e_kanivets.moneytracker.util.CrashlyticsProxy;
import com.blogspot.e_kanivets.moneytracker.util.validator.AccountValidator;
import com.blogspot.e_kanivets.moneytracker.util.validator.IValidator;

Expand Down Expand Up @@ -83,9 +83,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

private void tryAddAccount() {
AnswersProxy.get().logButton("Done Account");
CrashlyticsProxy.get().logButton("Done Account");
if (addAccount()) {
AnswersProxy.get().logEvent("Done Account");
CrashlyticsProxy.get().logEvent("Done Account");
setResult(RESULT_OK);
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.blogspot.e_kanivets.moneytracker.controller.data.TransferController;
import com.blogspot.e_kanivets.moneytracker.entity.data.Account;
import com.blogspot.e_kanivets.moneytracker.entity.data.Transfer;
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy;
import com.blogspot.e_kanivets.moneytracker.util.CrashlyticsProxy;
import com.blogspot.e_kanivets.moneytracker.util.validator.IValidator;
import com.blogspot.e_kanivets.moneytracker.util.validator.TransferValidator;

Expand Down Expand Up @@ -104,9 +104,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

private void tryTransfer() {
AnswersProxy.get().logButton("Done Transfer");
CrashlyticsProxy.get().logButton("Done Transfer");
if (doTransfer()) {
AnswersProxy.get().logEvent("Done Transfer");
CrashlyticsProxy.get().logEvent("Done Transfer");
setResult(RESULT_OK);
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.blogspot.e_kanivets.moneytracker.activity.base.BaseFragment
import com.blogspot.e_kanivets.moneytracker.controller.FormatController
import com.blogspot.e_kanivets.moneytracker.controller.data.AccountController
import com.blogspot.e_kanivets.moneytracker.entity.data.Account
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy
import com.blogspot.e_kanivets.moneytracker.util.CrashlyticsProxy
import com.blogspot.e_kanivets.moneytracker.util.validator.EditAccountValidator
import com.blogspot.e_kanivets.moneytracker.util.validator.IValidator
import kotlinx.android.synthetic.main.fragment_edit_account.*
Expand Down Expand Up @@ -46,7 +46,7 @@ class EditAccountFragment : BaseFragment() {
}

private fun done() {
AnswersProxy.get().logButton("Edit Account")
CrashlyticsProxy.get().logButton("Edit Account")
if (accountValidator.validate()) {
val title = etTitle.text.toString().trim { it <= ' ' }
val goal = etGoal.text.toString().toDouble()
Expand All @@ -57,7 +57,7 @@ class EditAccountFragment : BaseFragment() {
)
val updated = accountController.update(newAccount) != null
if (updated) {
AnswersProxy.get().logEvent("Edit Account")
CrashlyticsProxy.get().logEvent("Edit Account")
activity?.setResult(Activity.RESULT_OK)
activity?.finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.blogspot.e_kanivets.moneytracker.activity.SettingsActivity;
import com.blogspot.e_kanivets.moneytracker.activity.account.AccountsActivity;
import com.blogspot.e_kanivets.moneytracker.activity.exchange_rate.ExchangeRatesActivity;
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy;
import com.blogspot.e_kanivets.moneytracker.util.CrashlyticsProxy;

import butterknife.BindView;

Expand Down Expand Up @@ -134,36 +134,36 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}

private void showAccounts() {
AnswersProxy.get().logButton("Show Accounts");
CrashlyticsProxy.get().logButton("Show Accounts");
startActivityForResult(new Intent(BaseDrawerActivity.this, AccountsActivity.class),
REQUEST_ACCOUNTS);
}

private void showRates() {
AnswersProxy.get().logButton("Show Rates");
CrashlyticsProxy.get().logButton("Show Rates");
startActivityForResult(new Intent(BaseDrawerActivity.this, ExchangeRatesActivity.class),
REQUEST_RATES);
}

private void showCharts() {
AnswersProxy.get().logButton("Show Charts");
CrashlyticsProxy.get().logButton("Show Charts");
startActivity(new Intent(BaseDrawerActivity.this, ChartsActivity.class));
}

private void showBackup() {
AnswersProxy.get().logButton("Show Backup");
CrashlyticsProxy.get().logButton("Show Backup");
startActivityForResult(new Intent(BaseDrawerActivity.this, BackupActivity.class),
REQUEST_BACKUP);
}

private void showImportExport() {
AnswersProxy.get().logButton("Show Import Export");
CrashlyticsProxy.get().logButton("Show Import Export");
startActivityForResult(new Intent(BaseDrawerActivity.this, ImportExportActivity.class),
REQUEST_IMPORT_EXPORT);
}

private void showSettings() {
AnswersProxy.get().logButton("Show Settings");
CrashlyticsProxy.get().logButton("Show Settings");
startActivityForResult(new Intent(BaseDrawerActivity.this, SettingsActivity.class),
REQUEST_SETTINGS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.blogspot.e_kanivets.moneytracker.controller.FormatController;
import com.blogspot.e_kanivets.moneytracker.controller.data.ExchangeRateController;
import com.blogspot.e_kanivets.moneytracker.entity.ExchangeRatePair;
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy;
import com.blogspot.e_kanivets.moneytracker.util.CrashlyticsProxy;
import com.blogspot.e_kanivets.moneytracker.util.validator.ExchangeRatePairValidator;
import com.blogspot.e_kanivets.moneytracker.util.validator.IValidator;

Expand Down Expand Up @@ -126,9 +126,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

private void tryAddExchangeRate() {
AnswersProxy.get().logButton("Done Exchange Rate");
CrashlyticsProxy.get().logButton("Done Exchange Rate");
if (addExchangeRate()) {
AnswersProxy.get().logEvent("Done Exchange Rate");
CrashlyticsProxy.get().logEvent("Done Exchange Rate");
setResult(RESULT_OK);
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.blogspot.e_kanivets.moneytracker.adapter.ExchangeRateAdapter;
import com.blogspot.e_kanivets.moneytracker.controller.data.ExchangeRateController;
import com.blogspot.e_kanivets.moneytracker.entity.ExchangeRatePair;
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy;
import com.blogspot.e_kanivets.moneytracker.util.CrashlyticsProxy;
import com.blogspot.e_kanivets.moneytracker.util.ExchangeRatesSummarizer;

import java.util.Collections;
Expand Down Expand Up @@ -80,22 +80,22 @@ public boolean onContextItemSelected(MenuItem item) {
}

public void deleteExchangeRate(int position) {
AnswersProxy.get().logButton("Delete Exchange Rate");
CrashlyticsProxy.get().logButton("Delete Exchange Rate");
rateController.deleteExchangeRatePair(exchangeRateList.get(position));
update();
setResult(RESULT_OK);
}

@OnClick(R.id.btn_add_exchange_rate)
public void addExchangeRate() {
AnswersProxy.get().logButton("Add Exchange Rate");
CrashlyticsProxy.get().logButton("Add Exchange Rate");
Intent intent = new Intent(ExchangeRatesActivity.this, AddExchangeRateActivity.class);
startActivityForResult(intent, REQUEST_ADD_EXCHANGE_RATE);
}

@OnItemClick(R.id.listView)
public void addExchangeRateOnBaseOfExisted(int position) {
AnswersProxy.get().logButton("Edit Exchange Rate");
CrashlyticsProxy.get().logButton("Edit Exchange Rate");
if (position < 0 || position >= exchangeRateList.size()) return;
Intent intent = new Intent(ExchangeRatesActivity.this, AddExchangeRateActivity.class);
intent.putExtra(AddExchangeRateActivity.KEY_EXCHANGE_RATE, exchangeRateList.get(position));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.blogspot.e_kanivets.moneytracker.adapter.BackupAdapter;
import com.blogspot.e_kanivets.moneytracker.controller.backup.BackupController;
import com.blogspot.e_kanivets.moneytracker.controller.PreferenceController;
import com.blogspot.e_kanivets.moneytracker.util.AnswersProxy;
import com.blogspot.e_kanivets.moneytracker.util.CrashlyticsProxy;
import com.dropbox.core.DbxRequestConfig;
import com.dropbox.core.android.Auth;
import com.dropbox.core.v2.DbxClientV2;
Expand Down Expand Up @@ -105,7 +105,7 @@ public class BackupActivity extends BaseBackActivity
}

@Override public void onBackupSuccess() {
AnswersProxy.get().logEvent("Backup success");
CrashlyticsProxy.get().logEvent("Backup success");
Timber.d("Backup success.");
if (isFinishing()) return;

Expand All @@ -114,7 +114,7 @@ public class BackupActivity extends BaseBackActivity
}

@Override public void onBackupFailure(String reason) {
AnswersProxy.get().logEvent("Backup failure");
CrashlyticsProxy.get().logEvent("Backup failure");
Timber.d("Backup failure.");
if (isFinishing()) return;

Expand All @@ -125,7 +125,7 @@ public class BackupActivity extends BaseBackActivity
}

@Override public void onRestoreSuccess(@NonNull String backupName) {
AnswersProxy.get().logEvent("Restore Success");
CrashlyticsProxy.get().logEvent("Restore Success");
Timber.d("Restore success.");
if (isFinishing()) return;

Expand All @@ -146,7 +146,7 @@ public class BackupActivity extends BaseBackActivity
}

@Override public void onRestoreFailure(String reason) {
AnswersProxy.get().logEvent("Restore Failure");
CrashlyticsProxy.get().logEvent("Restore Failure");
Timber.d("Restore failure.");
if (isFinishing()) return;

Expand All @@ -157,7 +157,7 @@ public class BackupActivity extends BaseBackActivity
}

@Override public void onRemoveSuccess() {
AnswersProxy.get().logEvent("Remove Success");
CrashlyticsProxy.get().logEvent("Remove Success");
Timber.d("Remove success.");
if (isFinishing()) return;

Expand All @@ -166,7 +166,7 @@ public class BackupActivity extends BaseBackActivity
}

@Override public void onRemoveFailure(@Nullable String reason) {
AnswersProxy.get().logEvent("Remove Failure");
CrashlyticsProxy.get().logEvent("Remove Failure");
Timber.d("Remove failure.");
if (isFinishing()) return;

Expand All @@ -175,13 +175,13 @@ public class BackupActivity extends BaseBackActivity
}

@OnClick(R.id.btn_backup_now) public void backupNow() {
AnswersProxy.get().logButton("Make Backup");
CrashlyticsProxy.get().logButton("Make Backup");
startProgress(getString(R.string.making_backup));
backupController.makeBackup(dbClient);
}

@OnItemClick(R.id.listView) public void restoreBackupClicked(int position) {
AnswersProxy.get().logButton("Restore backup");
CrashlyticsProxy.get().logButton("Restore backup");
final String backupName = listView.getAdapter().getItem(position).toString();

AlertDialog.Builder builder = new AlertDialog.Builder(BackupActivity.this);
Expand Down
Loading