Skip to content

Commit

Permalink
Merge branch 'hotfix/6.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ccomeaux committed Nov 6, 2021
2 parents 20c9846 + 6ffd8ca commit cc29eb7
Show file tree
Hide file tree
Showing 100 changed files with 230 additions and 921 deletions.
20 changes: 3 additions & 17 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 7 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@ buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'io.fabric.tools:gradle:1.31.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
}
}

def versionMajor = 6
def versionMinor = 8
def versionPatch = 0
def versionBuild = 3
def versionPatch = 1
def versionBuild = 0

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply plugin: 'hugo'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.github.ben-manes.versions'

repositories {
Expand Down Expand Up @@ -60,10 +59,6 @@ android {
checkReleaseBuilds false
}

dexOptions {
jumboMode true
}

defaultConfig {
applicationId "com.boardgamegeek"

Expand Down Expand Up @@ -170,17 +165,14 @@ dependencies {
implementation 'com.squareup.picasso:picasso:2.5.2'

implementation "com.jakewharton:butterknife:$butterknife_version"
implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
implementation 'com.google.firebase:firebase-analytics:17.5.0'
annotationProcessor "com.jakewharton:butterknife-compiler:$butterknife_version"

implementation 'com.jakewharton.timber:timber:4.7.1'

implementation 'com.github.chrisbanes:PhotoView:2.3.0'

implementation 'com.github.rhlff:NestedScrollWebView:v1.0.2'

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

implementation('com.mikepenz:aboutlibraries:7.0.3@aar') {
transitive = true
Expand Down
18 changes: 0 additions & 18 deletions app/src/main/java/com/boardgamegeek/BggApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.os.StrictMode;
import android.os.StrictMode.ThreadPolicy.Builder;
import android.os.StrictMode.VmPolicy;
import android.text.TextUtils;

import com.boardgamegeek.auth.AccountUtils;
import com.boardgamegeek.events.BggEventBusIndex;
Expand All @@ -16,9 +15,6 @@
import com.boardgamegeek.util.NotificationUtils;
import com.boardgamegeek.util.PreferencesUtils;
import com.boardgamegeek.util.RemoteConfig;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.core.CrashlyticsCore;
import com.facebook.stetho.Stetho;
import com.google.firebase.iid.FirebaseInstanceId;
import com.jakewharton.picasso.OkHttp3Downloader;
Expand All @@ -29,8 +25,6 @@
import java.util.Set;

import androidx.multidex.MultiDexApplication;
import hugo.weaving.DebugLog;
import io.fabric.sdk.android.Fabric;
import timber.log.Timber;

import static timber.log.Timber.DebugTree;
Expand All @@ -39,11 +33,9 @@ public class BggApplication extends MultiDexApplication {
private AppExecutors appExecutors;

@Override
@DebugLog
public void onCreate() {
super.onCreate();
appExecutors = new AppExecutors();
initializeFabric();
if (BuildConfig.DEBUG) {
Timber.plant(new DebugTree());
enableStrictMode();
Expand All @@ -54,11 +46,6 @@ public void onCreate() {
.build());
} else {
String username = AccountUtils.getUsername(this);
if (!TextUtils.isEmpty(username)) {
Crashlytics.setUserIdentifier(String.valueOf(username.hashCode()));
}
Crashlytics.setString("BUILD_TIME", BuildConfig.BUILD_TIME);
Crashlytics.setString("GIT_SHA", BuildConfig.GIT_SHA);
Timber.plant(new CrashReportingTree());
}

Expand Down Expand Up @@ -86,11 +73,6 @@ public void onCreate() {
});
}

private void initializeFabric() {
final Crashlytics crashlytics = new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build();
Fabric.with(this, crashlytics, new Answers(), new Crashlytics());
}

private void enableStrictMode() {
final VmPolicy.Builder builder = new VmPolicy.Builder()
.detectActivityLeaks()
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/com/boardgamegeek/auth/AccountUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import android.content.SharedPreferences;
import android.text.TextUtils;

import com.crashlytics.android.Crashlytics;

import androidx.annotation.Nullable;
import androidx.preference.PreferenceManager;

Expand All @@ -26,8 +24,6 @@ public static void clearFields(final Context context) {

public static void setUsername(final Context context, final String username) {
setString(context, username, KEY_USERNAME);
if (!TextUtils.isEmpty(username))
Crashlytics.setUserIdentifier(String.valueOf(username.hashCode()));
}

public static void setFullName(final Context context, String fullName) {
Expand Down
45 changes: 23 additions & 22 deletions app/src/main/java/com/boardgamegeek/auth/NetworkAuthenticator.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package com.boardgamegeek.auth;

import com.boardgamegeek.util.HttpUtils;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.LoginEvent;
import com.google.gson.JsonObject;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import hugo.weaving.DebugLog;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Request.Builder;
import okhttp3.RequestBody;
import okhttp3.Response;
import timber.log.Timber;

public class NetworkAuthenticator {
@SuppressWarnings("FieldCanBeLocal") private static final boolean MOCK_LOGIN = false;
private static final boolean MOCK_LOGIN = false;

private NetworkAuthenticator() {
}
Expand Down Expand Up @@ -47,19 +48,15 @@ private static BggCookieJar tryAuthenticate(@NonNull String username, @NonNull S
}

@Nullable
@DebugLog
private static BggCookieJar performAuthenticate(@NonNull String username, @NonNull String password, @NonNull String method) throws IOException {
final BggCookieJar cookieJar = new BggCookieJar();
final OkHttpClient client = HttpUtils.getHttpClient().newBuilder()
final OkHttpClient client = HttpUtils.getHttpClient(false).newBuilder()
.cookieJar(cookieJar)
.build();
Request post = buildRequest(username, password);
final Response response = client.newCall(post).execute();
if (response.isSuccessful()) {
if (cookieJar.isValid()) {
Answers.getInstance().logLogin(new LoginEvent()
.putMethod(method)
.putSuccess(true));
return cookieJar;
} else {
logAuthFailure(method, "Invalid cookie jar");
Expand All @@ -72,22 +69,26 @@ private static BggCookieJar performAuthenticate(@NonNull String username, @NonNu

private static void logAuthFailure(String method, String reason) {
Timber.w("Failed %1$s login: %2$s", method, reason);
Answers.getInstance().logLogin(new LoginEvent()
.putMethod(method)
.putSuccess(false)
.putCustomAttribute("Reason", reason));
}

@DebugLog
@NonNull
private static Request buildRequest(@NonNull String username, @NonNull String password) {
FormBody formBody = new FormBody.Builder()
.add("username", username)
.add("password", password)
.build();
return new Request.Builder()
.url("https://www.boardgamegeek.com/login")
.post(formBody)
JsonObject credentials = new JsonObject();
credentials.addProperty("username", username);
credentials.addProperty("password", password);
JsonObject body = new JsonObject();
body.add("credentials", credentials);
byte[] bytes;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
bytes = body.toString().getBytes(StandardCharsets.UTF_8);
} else {
//noinspection CharsetObjectCanBeUsed
bytes = body.toString().getBytes(Charset.forName("UTF-8"));
}
return new Builder()
.url("https://boardgamegeek.com/login/api/v1")
.post(RequestBody.create(bytes))
.addHeader("Content-Type", "application/json")
.build();
}
}
10 changes: 0 additions & 10 deletions app/src/main/java/com/boardgamegeek/db/CollectionDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.boardgamegeek.provider.BggContract.*
import com.boardgamegeek.provider.BggContract.Collection
import com.boardgamegeek.util.FileUtils
import com.boardgamegeek.util.SelectionBuilder
import hugo.weaving.DebugLog
import timber.log.Timber

class CollectionDao(private val context: BggApplication) {
Expand Down Expand Up @@ -309,7 +308,6 @@ class CollectionDao(private val context: BggApplication) {
* @param protectedCollectionIds list of collection IDs not to delete.
* @return the number or rows deleted.
*/
@DebugLog
fun delete(gameId: Int, protectedCollectionIds: List<Int>): Int {
// determine the collection IDs that are no longer in the collection
val collectionIdsToDelete = resolver.queryInts(
Expand All @@ -331,7 +329,6 @@ class CollectionDao(private val context: BggApplication) {
return collectionIdsToDelete.size
}

@DebugLog
fun saveItem(item: CollectionItemEntity, game: CollectionItemGameEntity, timestamp: Long, includeStats: Boolean = true, includePrivateInfo: Boolean = true, isBrief: Boolean = false): Int {
val candidate = SyncCandidate.find(resolver, item.collectionId, item.gameId)
if (candidate.dirtyTimestamp != NOT_DIRTY) {
Expand All @@ -344,7 +341,6 @@ class CollectionDao(private val context: BggApplication) {
return item.collectionId
}

@DebugLog
private fun toGameValues(game: CollectionItemGameEntity, includeStats: Boolean, isBrief: Boolean, timestamp: Long): ContentValues {
val values = ContentValues()
values.put(Games.UPDATED_LIST, timestamp)
Expand Down Expand Up @@ -372,7 +368,6 @@ class CollectionDao(private val context: BggApplication) {
return values
}

@DebugLog
private fun upsertGame(gameId: Int, values: ContentValues, isBrief: Boolean) {
val uri = Games.buildGameUri(gameId)
if (resolver.rowExists(uri)) {
Expand All @@ -387,7 +382,6 @@ class CollectionDao(private val context: BggApplication) {
}
}

@DebugLog
private fun toCollectionValues(item: CollectionItemEntity, includeStats: Boolean, includePrivateInfo: Boolean, isBrief: Boolean, timestamp: Long): ContentValues {
val values = ContentValues()
if (!isBrief && includePrivateInfo && includeStats) {
Expand Down Expand Up @@ -437,7 +431,6 @@ class CollectionDao(private val context: BggApplication) {
return values
}

@DebugLog
private fun upsertItem(candidate: SyncCandidate, values: ContentValues, isBrief: Boolean) {
if (candidate.internalId != INVALID_ID.toLong()) {
removeDirtyValues(values, candidate)
Expand All @@ -449,7 +442,6 @@ class CollectionDao(private val context: BggApplication) {
}
}

@DebugLog
private fun removeDirtyValues(values: ContentValues, candidate: SyncCandidate) {
removeValuesIfDirty(values, candidate.statusDirtyTimestamp,
Collection.STATUS_OWN,
Expand Down Expand Up @@ -479,12 +471,10 @@ class CollectionDao(private val context: BggApplication) {
removeValuesIfDirty(values, candidate.hasPartsDirtyTimestamp, Collection.HASPARTS_LIST)
}

@DebugLog
private fun removeValuesIfDirty(values: ContentValues, dirtyFlag: Long, vararg columns: String) {
if (dirtyFlag != NOT_DIRTY) columns.forEach { values.remove(it) }
}

@DebugLog
private fun maybeDeleteThumbnail(values: ContentValues, uri: Uri) {
val newThumbnailUrl: String = values.getAsString(Collection.COLLECTION_THUMBNAIL_URL) ?: ""
val oldThumbnailUrl = resolver.queryString(uri, Collection.COLLECTION_THUMBNAIL_URL) ?: ""
Expand Down
Loading

0 comments on commit cc29eb7

Please sign in to comment.