Skip to content

Commit

Permalink
Merge pull request #57 from the-reach-trust/master
Browse files Browse the repository at this point in the history
TargetSDK- >33
  • Loading branch information
mandivandermerwe authored May 29, 2023
2 parents 2b67eb9 + 8b96a4e commit 743b5a8
Show file tree
Hide file tree
Showing 35 changed files with 267 additions and 175 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ Book Dash is an Android App for the NPO where you can download books in differen

1. MaterialHelpTutorial - https://github.com/spongebobrf/MaterialIntroTutorial
2. FabButton - https://github.com/ckurtm/FabButton
3. Firebase - https://firebase.google.com/
4. Fabric - https://fabric.io/dashboard
5. Glide Image Loading - https://github.com/bumptech/glide
3. Firebase - https://firebase.google.com/
4. Glide Image Loading - https://github.com/bumptech/glide

# Setup

Expand All @@ -55,8 +54,7 @@ google-services.json file. This must then be placed into the app folder of this

# [OPTIONAL setup]
1. If you wish to build a release version you will need to create your own keystore file and edit the password values in the following file - (create a version of the file without the .sample extension): release-keystore.properties.sample
2. Setup a Fabric Account. https://fabric.io/dashboard
3. Get your Fabric API Key and Client key, change it in the file: /app/fabric-sample.properties and rename the file to fabric.properties
2. If you want to add Firebase Crashlytics to your app: Setup a Firebase Account. https://firebase.google.com/docs/crashlytics

# Contributions
Contributions are welcome. Please read the [contributions guide](CONTRIBUTING.md) for more information.
Expand Down
1 change: 0 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/build
/google-services.json
/fabric.properties
81 changes: 35 additions & 46 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'com.github.triplet.play'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'kotlin-kapt'

repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}



android {
compileSdkVersion rootProject.ext.compileSdkVersion

Expand Down Expand Up @@ -100,14 +88,17 @@ android {
}
}

// Avoid crash on platform method calls that's not mocked. E.g. FirebaseCrashlytics.
testOptions {
unitTests.returnDefaultValues = true
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
ext.enableCrashlytics = true
}
debug {
ext.enableCrashlytics = false
// Run code coverage reports by default on debug builds.
testCoverageEnabled = true
}
Expand All @@ -123,66 +114,64 @@ dependencies {
testImplementation "junit:junit:$rootProject.ext.junitVersion"
testImplementation "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
testImplementation "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"
testImplementation("org.powermock:powermock-module-junit4:$rootProject.ext.powerMockito")
testImplementation("org.powermock:powermock-module-junit4:2.0.7")
testImplementation("org.powermock:powermock-api-mockito:$rootProject.ext.powerMockito")

// Android Testing Library's runner and rules
androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test:rules:1.3.0'

// Espresso UI Testing
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0') {
androidTestImplementation('androidx.test.espresso:espresso-core:3.3.0') {
exclude group: "javax.inject"
}
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
androidTestImplementation 'androidx.appcompat:appcompat:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
androidTestImplementation 'androidx.appcompat:appcompat:1.2.0'
androidTestImplementation "com.google.android.material:material:$rootProject.ext.materialVersion"

implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.palette:palette:1.0.0'
implementation "com.google.android.material:material:$rootProject.ext.materialVersion"
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.preference:preference:1.1.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation "com.github.bumptech.glide:glide:$rootProject.ext.glideVersion"
kapt "com.github.bumptech.glide:compiler:$rootProject.ext.glideVersion"
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.castorflex.smoothprogressbar:library-circular:1.2.0'

implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
transitive = true
}

implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-messaging:20.0.1'
implementation 'com.google.firebase:firebase-config:19.0.3'
implementation 'com.google.firebase:firebase-storage:19.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.github.castorflex.smoothprogressbar:library-circular:1.3.0'

// Import the Firebase Bill of Materials (BoM)
implementation platform('com.google.firebase:firebase-bom:26.0.0')

// Firebase Dependencies
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-config'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-database'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-perf'
implementation 'com.google.firebase:firebase-storage'
implementation 'com.firebaseui:firebase-ui-storage:6.1.0'
implementation 'com.google.firebase:firebase-perf:19.0.2'

implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.2.5'
implementation 'com.jakewharton.threetenabp:threetenabp:1.0.5'
implementation 'com.jakewharton.timber:timber:4.7.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'com.jakewharton.threetenabp:threetenabp:1.3.0'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.multidex:multidex:2.0.1'

implementation project(path: ':materialhelptutorial')
implementation project(':fabbutton')
}




apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
2 changes: 0 additions & 2 deletions app/fabric-sample.properties

This file was deleted.

1 change: 1 addition & 0 deletions app/prod/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":37,"versionName":"2.9.2","enabled":true,"outputFile":"app-prod-release.apk","fullName":"prodRelease","baseName":"prod-release","dirName":""},"path":"app-prod-release.apk","properties":{}}]
17 changes: 9 additions & 8 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@
-keep class me.zhanghai.android.materialprogressbar.** { *; }
-keep class com.joanzapata.** { *; }




-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
-keep class * extends com.bumptech.glide.module.AppGlideModule {
<init>(...);
}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
*** rewind();
}

-keep class com.crashlytics.** { *; }
-keep class com.crashlytics.android.**
-keepattributes SourceFile,LineNumberTable

-keepattributes Signature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void tearDown() {

@Test
public void languageItemClick_ShowLanguageChooser() {
onView(withId(R.id.action_language_choice)).perform(click());
onView(withId(R.id.container_language)).perform(click());
//Then
onView(withText(R.string.language_selection_heading)).inRoot(isDialog()).check(matches(isDisplayed()));
}
Expand Down
21 changes: 12 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@
<activity
android:name=".presentation.main.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:exported="false">
</activity>
<activity
android:name=".presentation.readbook.BookDetailActivity"
android:label="@string/app_name"
android:screenOrientation="sensorLandscape"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
android:exported="false">
</activity>
<activity
android:name=".presentation.bookinfo.BookInfoActivity"
android:label=""
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:exported="true">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".presentation.main.MainActivity"/>
Expand All @@ -61,7 +64,8 @@
<activity
android:name=".presentation.splash.SplashActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand All @@ -71,23 +75,22 @@
<activity
android:name=".presentation.search.SearchActivity"
android:label="@string/screen_title_search"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:exported="false">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".presentation.main.MainActivity"/>
</activity>
<activity
android:name="za.co.riggaroo.materialhelptutorial.tutorial.MaterialTutorialActivity"
android:label="@string/tutorial_screen"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:exported="false">
</activity>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<meta-data
android:name="io.fabric.ApiKey"
android:value="b2579d751611dc3b58788bad80a51ad37e140ecb"/>
</application>

</manifest>
13 changes: 5 additions & 8 deletions app/src/main/java/org/bookdash/android/BookDashApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.core.CrashlyticsCore;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.google.firebase.installations.FirebaseInstallations;
import com.jakewharton.threetenabp.AndroidThreeTen;

import org.bookdash.android.config.CrashlyticsTree;

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

Expand Down Expand Up @@ -42,13 +40,12 @@ public void onCreate() {
super.onCreate();

AndroidThreeTen.init(this);
Crashlytics crashlyticsKit = new Crashlytics.Builder()
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build();
Fabric.with(this, crashlyticsKit);

FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG);

if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
Timber.d("Firebase Debug Info:" + FirebaseInstanceId.getInstance().getToken());
Timber.d("Firebase Debug Info:%s", FirebaseInstallations.getInstance().getId());
} else {
Timber.plant(new CrashlyticsTree());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.bookdash.android.config;

import android.util.Log;

import com.crashlytics.android.Crashlytics;

import com.google.firebase.crashlytics.FirebaseCrashlytics;
import timber.log.Timber;

/**
Expand All @@ -17,10 +15,10 @@ protected void log(final int priority, final String tag, final String message, f
return;
}

Crashlytics.log(priority, tag, message);
FirebaseCrashlytics.getInstance().log("Priority: " + priority + ", TAG: " + tag + ", Message: " + message);

if (t != null) {
Crashlytics.logException(t);
FirebaseCrashlytics.getInstance().recordException(t);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.BuildConfig;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;

import org.bookdash.android.BuildConfig;
import org.bookdash.android.R;

public class FirebaseConfig implements RemoteConfigSettingsApi {

private static final int CACHE_EXPIRATION_IN_SECONDS = 3600;
private static final long CACHE_EXPIRATION_IN_SECONDS = 3600;
private static final String DEFAULT_LANGUAGE_ID = "default_language_id";
private static final String DEFAULT_LANGUAGE_NAME = "default_language_name";
private static final String DEFAULT_LANGUAGE_ABBREVIATION = "default_language_abbreviation";
Expand All @@ -29,18 +29,18 @@ private FirebaseConfig(FirebaseRemoteConfig firebaseRemoteConfig) {

public static FirebaseConfig newInstance() {
final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG).build();
firebaseRemoteConfig.setConfigSettings(configSettings);
firebaseRemoteConfig.setDefaults(R.xml.firebase_remote_config_defaults);
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder().
setMinimumFetchIntervalInSeconds(BuildConfig.DEBUG ? 0 : CACHE_EXPIRATION_IN_SECONDS).build();
firebaseRemoteConfig.setConfigSettingsAsync(configSettings);
firebaseRemoteConfig.setDefaultsAsync(R.xml.firebase_remote_config_defaults);
return new FirebaseConfig(firebaseRemoteConfig);
}

public FirebaseConfig init() {
firebaseRemoteConfig.fetch(CACHE_EXPIRATION_IN_SECONDS).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
firebaseRemoteConfig.activateFetched();
firebaseRemoteConfig.activate();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import androidx.annotation.WorkerThread;

import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.google.firebase.storage.FileDownloadTask;
import com.google.firebase.storage.FirebaseStorage;
import com.google.gson.Gson;
Expand Down Expand Up @@ -99,8 +100,12 @@ private BookPages getBookPages(String fileName) {
Log.e(TAG, "EX: ", e);
}

FirebaseCrashlytics.getInstance().log("File path: " + fileName); // TODO Remove in next release if book downloading bug is fixed.
FirebaseCrashlytics.getInstance().recordException(e);
Log.e(TAG, "Ex:" + e.getMessage(), e);
} catch (Exception e) {
FirebaseCrashlytics.getInstance().log("File path: " + fileName); // TODO Remove in next release if book downloading bug is fixed.
FirebaseCrashlytics.getInstance().recordException(e);
Log.e(TAG, "error parsing book: " + fileName, e);
}
return bookPages;
Expand Down
Loading

0 comments on commit 743b5a8

Please sign in to comment.