Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  attempt to fix travis ci unshallow
  fix not adding a sync account
  fix applying the google services plugin
  move back to 1.8 for moshi
  update retrofit version
  update some proguard files
  remove annotation from tags
  • Loading branch information
shalzz committed Nov 1, 2019
2 parents 99d8a5e + f877ddd commit 4458cc4
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 52 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ language: android
jdk:
- oraclejdk8

git:
depth: false

env:
matrix:
- ANDROID_API=28 EMULATOR_API=24
Expand Down Expand Up @@ -54,8 +57,6 @@ cache:
- $HOME/.android/build-cache

before_install:
# Deep clone so we can get an accurate commit count for version code
- git fetch --unshallow
# Unencrypt server account key for play publisher
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_3476a8f5fa31_key
-iv $encrypted_3476a8f5fa31_iv -in play-service-account-key.json.enc -out play-service-account-key.json
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ deploy: check-env
git checkout dev
git checkout master
git merge dev --no-edit
git tag -a $(TAG)
git tag $(TAG)
git push && git push --tags
git checkout dev

Expand All @@ -12,7 +12,7 @@ redeploy: check-env
git merge dev --no-edit
git tag -d $(TAG)
git push origin :refs/tags/$(TAG)
git tag -a $(TAG)
git tag $(TAG)
git push && git push --tags
git checkout dev

Expand Down
48 changes: 29 additions & 19 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ bugsnag {
}

play {
serviceAccountCredentials = file("../play-service-account-key.json")
defaultToAppBundles = true
track = "beta"
serviceAccountCredentials = file("../play-service-account-key.json")
}

// query git for the SHA, Tag and commit count. Use these to automate versioning.
Expand All @@ -55,25 +55,19 @@ val gitCommitCount = 2007050 + Integer.parseInt(
android {
compileSdkVersion(28)

defaultConfig.apply {
defaultConfig {
applicationId = "com.shalzz.attendance"
minSdkVersion(16)
targetSdkVersion(28)
multiDexEnabled = true
versionCode = gitCommitCount
versionName = gitTag

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled = true
// viewBinding.isEnabled = true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

resConfig("en")
resValue("string", "app_version", versionName!!)

// Needed because of this https://github.com/robolectric/robolectric/issues/{1399, 3826}
testOptions.unitTests.isIncludeAndroidResources = true
testOptions.unitTests.isReturnDefaultValues = true

javaCompileOptions {
annotationProcessorOptions {
arguments = mapOf(
Expand Down Expand Up @@ -157,9 +151,17 @@ android {
}
}

//Needed because of this https://github.com/square/okio/issues/58
// Needed because of this https://github.com/robolectric/robolectric/issues/{1399, 3826}
testOptions {
unitTests.isReturnDefaultValues = true
unitTests.isIncludeAndroidResources = true
}

lintOptions {
disable("InvalidPackage")
textReport = true
textOutput("stdout")
//Needed because of this https://github.com/square/okio/issues/58
// disable("InvalidPackage")
}

//Needed because of this https://github.com/ReactiveX/RxJava/issues/4445
Expand All @@ -168,23 +170,27 @@ android {
}
}

kapt {
useBuildCache = true
}

dependencies {
val DAGGER_VERSION = "2.24"
val ESPRESSO_VERSION = "3.1.0"
val RETROFIT_VERSION = "2.5.0"
val MOSHI_VERSION = "1.9.0"
val RETROFIT_VERSION = "2.6.2"
val MOSHI_VERSION = "1.8.0"
val ROOM_VERSION = "2.2.1"
val NAV_VERSION = "1.0.0"

// TODO: re-evaluate when RxJava is completely replaced with kotlin co-routines
implementation("com.android.support:multidex:1.0.3")
implementation("androidx.multidex:multidex:2.0.1")

implementation(kotlin("stdlib-jdk7", KotlinCompilerVersion.VERSION))

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0")

implementation("androidx.core:core-ktx:1.0.2")
implementation("androidx.core:core-ktx:1.1.0")
implementation("android.arch.navigation:navigation-fragment-ktx:$NAV_VERSION")
implementation("android.arch.navigation:navigation-ui-ktx:$NAV_VERSION")

Expand Down Expand Up @@ -225,6 +231,7 @@ dependencies {
implementation("com.squareup.moshi:moshi:$MOSHI_VERSION")
implementation("com.squareup.moshi:moshi-adapters:$MOSHI_VERSION")
kapt("com.squareup.moshi:moshi-kotlin-codegen:$MOSHI_VERSION")
// implementation("com.squareup.moshi:moshi-kotlin:1.9.1")

implementation("com.malinskiy:materialicons:1.0.2")
implementation("com.github.amlcurran.showcaseview:library:5.4.0")
Expand Down Expand Up @@ -279,3 +286,6 @@ dependencies {
resolutionStrategy.force("org.checkerframework:checker-compat-qual:2.5.3")
}
}

// Add this at the bottom of your file to actually apply the plugin
apply(mapOf("plugin" to "com.google.gms.google-services"))
13 changes: 0 additions & 13 deletions app/proguard/proguard-butterknife-7.pro

This file was deleted.

42 changes: 42 additions & 0 deletions app/proguard/proguard-moshi.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,48 @@
<fields>;
}

# Retain generated target class's synthetic defaults constructor and keep DefaultConstructorMarker's
# name. We will look this up reflectively to invoke the type's constructor.
#
# We can't _just_ keep the defaults constructor because Proguard/R8's spec doesn't allow wildcard
# matching preceding parameters.
-keepnames class kotlin.jvm.internal.DefaultConstructorMarker
-keepclassmembers @com.squareup.moshi.JsonClass @kotlin.Metadata class * {
synthetic <init>(...);
}

# Retain generated JsonAdapters if annotated type is retained.
-if @com.squareup.moshi.JsonClass class *
-keep class <1>JsonAdapter {
<init>(...);
<fields>;
}
-if @com.squareup.moshi.JsonClass class **$*
-keep class <1>_<2>JsonAdapter {
<init>(...);
<fields>;
}
-if @com.squareup.moshi.JsonClass class **$*$*
-keep class <1>_<2>_<3>JsonAdapter {
<init>(...);
<fields>;
}
-if @com.squareup.moshi.JsonClass class **$*$*$*
-keep class <1>_<2>_<3>_<4>JsonAdapter {
<init>(...);
<fields>;
}
-if @com.squareup.moshi.JsonClass class **$*$*$*$*
-keep class <1>_<2>_<3>_<4>_<5>JsonAdapter {
<init>(...);
<fields>;
}
-if @com.squareup.moshi.JsonClass class **$*$*$*$*$*
-keep class <1>_<2>_<3>_<4>_<5>_<6>JsonAdapter {
<init>(...);
<fields>;
}

# The name of @JsonClass types is used to look up the generated adapter.
-keepnames @com.squareup.moshi.JsonClass class *

Expand Down
3 changes: 2 additions & 1 deletion app/proguard/proguard-retrofit2.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*

# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
-keep,allowobfuscation interface <1>
1 change: 1 addition & 0 deletions app/proguard/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# Application classes that will be serialized/deserialized over Gson
-keep class com.shalzz.attendance.data.model.** { *; }
-keep class com.shalzz.attendance.data.model.entity.** { *; }

-verbose

Expand Down
11 changes: 0 additions & 11 deletions app/src/main/java/com/shalzz/attendance/sync/Authenticator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Authenticator(private val mDataManager: DataManager,
val intent = Intent(mContext, AuthenticatorActivity::class.java)
intent.putExtra(AuthenticatorActivity.ARG_ACCOUNT_TYPE, accountType)
intent.putExtra(AuthenticatorActivity.ARG_AUTH_TYPE, authTokenType)
intent.putExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, true)
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response)

val bundle = Bundle()
Expand Down Expand Up @@ -140,14 +139,4 @@ class Authenticator(private val mDataManager: DataManager,
result.putBoolean(KEY_BOOLEAN_RESULT, false)
return result
}

private fun isAccountAvailable(account: Account, accountManager: AccountManager): Boolean {
val availableAccounts = accountManager.getAccountsByType(account.type)
for (availableAccount in availableAccounts) {
if (account.name == availableAccount.name && account.type == availableAccount.type) {
return true
}
}
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ internal constructor(private val mDataManager: DataManager, @param:ApplicationCo
override fun onNext(subject: Subject) {}

override fun onError(error: Throwable) {
Timber.e(error)
if (error !is RetrofitException) {
Timber.e(error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,20 @@ class AuthenticatorActivity: AccountAuthenticatorActivity(),
Timber.d( "> finishLogin")

val accountName = intent.getStringExtra(AccountManager.KEY_ACCOUNT_NAME)
Timber.d("accountName: %s", accountName)
val account = Account(accountName, intent.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE))

if (getIntent().getBooleanExtra(ARG_IS_ADDING_NEW_ACCOUNT, false)) {
// In case the user tries to add the same account again.
if (!isAccountAvailable(account, mAccountManager)) {
Timber.d("> finishLogin > addAccountExplicitly")
val authtoken = intent.getStringExtra(AccountManager.KEY_AUTHTOKEN)
val authtokenType = mAuthTokenType

// Creating the account on the device and setting the auth regId we got
// (Not setting the auth regId will cause another call to the server to authenticate the user)
mAccountManager.addAccountExplicitly(account, null, null)
mAccountManager.addAccountExplicitly(account,
intent.getStringExtra(ARG_ACCOUNT_PASSWORD),
null)
mAccountManager.setAuthToken(account, authtokenType, authtoken)

// Set up sync
Expand All @@ -96,10 +100,19 @@ class AuthenticatorActivity: AccountAuthenticatorActivity(),
finish()
}

private fun isAccountAvailable(account: Account, accountManager: AccountManager): Boolean {
val availableAccounts = accountManager.getAccountsByType(account.type)
for (availableAccount in availableAccounts) {
if (account.name == availableAccount.name && account.type == availableAccount.type) {
return true
}
}
return false
}

companion object {
var ARG_ACCOUNT_TYPE: String = "ACCOUNT_TYPE"
var ARG_ACCOUNT_PASSWORD: String = "ACCOUNT_PASSWORD"
var ARG_AUTH_TYPE: String = "AUTH_TYPE"
var ARG_IS_ADDING_NEW_ACCOUNT: String = "IS_ADDING_ACCOUNT"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class MainActivity : BaseActivity(), MainMvpView, BillingProvider {

if (!mPreferencesHelper.loginStatus) {
val ourIntent = Intent(this, AuthenticatorActivity::class.java)
ourIntent.putExtra(AuthenticatorActivity.ARG_AUTH_TYPE, MyAccountManager.AUTHTOKEN_TYPE_READ_ONLY)
startActivityForResult(ourIntent, ACTIVITY_RESULT_CODE_AUTHENTICATION)
}
}
Expand Down

0 comments on commit 4458cc4

Please sign in to comment.