Skip to content
This repository has been archived by the owner on Dec 8, 2019. It is now read-only.

Commit

Permalink
Upgrade to use AndroidX libraries, resolves #88
Browse files Browse the repository at this point in the history
  • Loading branch information
afollestad committed Sep 15, 2018
1 parent 83a5499 commit 62474a6
Show file tree
Hide file tree
Showing 66 changed files with 358 additions and 442 deletions.
15 changes: 3 additions & 12 deletions README.md
Expand Up @@ -390,7 +390,7 @@ when `isDark()` is false. By default, the action text color will match `colorAcc

# Tab Layouts

Tab Layouts from the Design Support library are automatically themed. The main screen in the
Tab Layouts from the Google Material library are automatically themed. The main screen in the
sample project is an example of this, you see the two tabs under the toolbar at the top.

You can customize background theming behavior:
Expand Down Expand Up @@ -456,7 +456,7 @@ In addition, unselected nav drawer items will be shades of white or black based

# Bottom Navigation

Bottom Navigation Views from the Design Support library are automatically themed.
Bottom Navigation Views from the Google Material library are automatically themed.

<img src="https://raw.githubusercontent.com/afollestad/aesthetic/master/images/4.jpg" />

Expand Down Expand Up @@ -521,7 +521,7 @@ also notice that the icons and title color are updated to be most visible over t

# Swipe Refresh Layouts

Swipe Refresh Layouts from the Design Support library are automatically themed.
Swipe Refresh Layouts from the Google Material library are automatically themed.

<img src="https://raw.githubusercontent.com/afollestad/aesthetic/master/images/6.jpg" />

Expand Down Expand Up @@ -589,12 +589,3 @@ adopt the same window theme properties as the main activity.

If you do not use `AestheticActivity`, your custom Activity can implement the `AestheticKeyProvider`
interface.

# Proguard

In case you are using views from the support library (e.g. TextInputLayout & TextInputEditText), you will
need to add the following to your proguard:

```
-keep class android.support.design.widget.** { *; }
```
9 changes: 5 additions & 4 deletions dependencies.gradle
Expand Up @@ -2,16 +2,17 @@ ext.versions = [
minSdk : 16,
compileSdk : 28,
buildTools : '28.0.2',
publishVersion : '0.6.1',
publishVersionCode: 25,
publishVersion : '0.7.0',
publishVersionCode: 26,

gradlePlugin : '3.1.4',
kotlin : '1.2.61',
kotlin : '1.2.70',
spotlessPlugin : '3.14.0',
versionsPlugin : '0.20.0',
bintrayRelease : '0.8.1',

supportLib : '28.0.0-rc02',
androidx : '1.0.0-rc02',

rxJava : '2.2.2',
rxAndroid : '2.1.0',
rxkPrefs : '1.0.1',
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Expand Up @@ -16,3 +16,6 @@ org.gradle.configureondemand=false
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.useAndroidX=true
android.enableJetifier=true
16 changes: 10 additions & 6 deletions library/build.gradle
Expand Up @@ -31,17 +31,21 @@ android {

packagingOptions {
exclude 'META-INF/library_release.kotlin_module'
exclude 'META-INF/proguard/androidx-annotations.pro'
}
}

repositories {
google()
jcenter()
}

dependencies {
implementation 'com.android.support:appcompat-v7:' + versions.supportLib
implementation 'com.android.support:cardview-v7:' + versions.supportLib
implementation 'com.android.support:support-compat:' + versions.supportLib
implementation 'androidx.appcompat:appcompat:' + versions.androidx
implementation 'androidx.cardview:cardview:' + versions.androidx
implementation 'androidx.recyclerview:recyclerview:' + versions.androidx

implementation 'com.android.support:design:' + versions.supportLib
implementation 'com.android.support:recyclerview-v7:' + versions.supportLib
implementation 'com.android.support:support-v13:' + versions.supportLib
implementation 'com.google.android.material:material:' + versions.androidx

implementation 'io.reactivex.rxjava2:rxjava:' + versions.rxJava
implementation 'io.reactivex.rxjava2:rxandroid:' + versions.rxAndroid
Expand Down
25 changes: 0 additions & 25 deletions library/proguard-rules.pro

This file was deleted.

18 changes: 7 additions & 11 deletions library/src/main/java/com/afollestad/aesthetic/Aesthetic.kt
Expand Up @@ -17,11 +17,9 @@ import android.support.annotation.CheckResult
import android.support.annotation.ColorInt
import android.support.annotation.ColorRes
import android.support.annotation.StyleRes
import android.support.v4.content.ContextCompat
import android.support.v4.util.Pair
import android.support.v4.widget.DrawerLayout
import android.support.v7.app.AppCompatActivity
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.drawerlayout.widget.DrawerLayout
import com.afollestad.aesthetic.actions.ViewBackgroundSubscriber
import com.afollestad.aesthetic.internal.PrefNames.KEY_ACCENT_COLOR
import com.afollestad.aesthetic.internal.PrefNames.KEY_ACTIVITY_THEME
Expand Down Expand Up @@ -516,8 +514,7 @@ class Aesthetic private constructor(private var ctxt: Context?) {
rxkPrefs!!
.integer(
KEY_CARD_VIEW_BG_COLOR,
ContextCompat.getColor(
context,
context.color(
if (it)
R.color.ate_cardview_bg_dark
else
Expand Down Expand Up @@ -555,16 +552,15 @@ class Aesthetic private constructor(private var ctxt: Context?) {
rxkPrefs!!
.integer(
KEY_ICON_TITLE_ACTIVE_COLOR,
ContextCompat.getColor(
context, if (isDark) R.color.ate_icon_dark else R.color.ate_icon_light
context.color(
if (isDark) R.color.ate_icon_dark else R.color.ate_icon_light
)
)
.asObservable(),
rxkPrefs!!
.integer(
KEY_ICON_TITLE_INACTIVE_COLOR,
ContextCompat.getColor(
context,
context.color(
if (isDark)
R.color.ate_icon_dark_inactive
else
Expand Down Expand Up @@ -810,7 +806,7 @@ class Aesthetic private constructor(private var ctxt: Context?) {
)
subs += combineLatest<Int, Int, Pair<Int, Int>>(
colorStatusBar(), lightStatusBarMode(),
BiFunction<Int, Int, Pair<Int, Int>> { a, b -> Pair.create(a, b) })
BiFunction<Int, Int, Pair<Int, Int>> { a, b -> Pair(a, b) })
.distinctToMainThread()
.subscribe(
Consumer { invalidateStatusBar() },
Expand Down
Expand Up @@ -9,8 +9,8 @@ import android.annotation.SuppressLint
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
import android.support.v7.view.menu.ActionMenuItemView
import android.util.AttributeSet
import androidx.appcompat.view.menu.ActionMenuItemView
import com.afollestad.aesthetic.utils.TintHelper.createTintedDrawable
import com.afollestad.aesthetic.utils.distinctToMainThread
import com.afollestad.aesthetic.utils.onErrorLogAndRethrow
Expand Down
Expand Up @@ -6,7 +6,7 @@
package com.afollestad.aesthetic

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity

/** @author Aidan Follestad (afollestad) */
open class AestheticActivity : AppCompatActivity(), AestheticKeyProvider {
Expand Down
Expand Up @@ -7,8 +7,8 @@ package com.afollestad.aesthetic

import android.content.Context
import android.content.res.ColorStateList
import android.support.v7.widget.AppCompatButton
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatButton
import com.afollestad.aesthetic.utils.adjustAlpha
import com.afollestad.aesthetic.utils.distinctToMainThread
import com.afollestad.aesthetic.utils.onErrorLogAndRethrow
Expand Down
Expand Up @@ -9,15 +9,15 @@ import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.support.annotation.ColorInt
import android.support.design.widget.BottomNavigationView
import android.support.v4.content.ContextCompat.getColor
import android.util.AttributeSet
import com.afollestad.aesthetic.actions.ViewBackgroundAction
import com.afollestad.aesthetic.utils.adjustAlpha
import com.afollestad.aesthetic.utils.color
import com.afollestad.aesthetic.utils.distinctToMainThread
import com.afollestad.aesthetic.utils.isColorLight
import com.afollestad.aesthetic.utils.onErrorLogAndRethrow
import com.afollestad.aesthetic.utils.plusAssign
import com.google.android.material.bottomnavigation.BottomNavigationView
import io.reactivex.Observable.combineLatest
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
Expand All @@ -32,15 +32,14 @@ class AestheticBottomNavigationView(
) : BottomNavigationView(context, attrs) {

private var modesSubscription: Disposable? = null
private var colorSubscriptions: CompositeDisposable? = null
private var colorSubs: CompositeDisposable? = null
private var lastTextIconColor: Int = 0

private fun invalidateIconTextColor(
backgroundColor: Int,
selectedColor: Int
) {
val baseColor = getColor(
context,
val baseColor = context.color(
if (backgroundColor.isColorLight()) R.color.ate_icon_light else R.color.ate_icon_dark
)
val unselectedIconTextColor = baseColor.adjustAlpha(.87f)
Expand Down Expand Up @@ -69,12 +68,12 @@ class AestheticBottomNavigationView(
}

private fun onState(state: State) {
colorSubscriptions?.clear()
colorSubscriptions = CompositeDisposable()
colorSubs?.clear()
colorSubs = CompositeDisposable()

when (state.iconTextMode) {
BottomNavIconTextMode.SELECTED_PRIMARY ->
colorSubscriptions!! +=
colorSubs +=
Aesthetic.get()
.colorPrimary()
.distinctToMainThread()
Expand All @@ -84,7 +83,7 @@ class AestheticBottomNavigationView(
)

BottomNavIconTextMode.SELECTED_ACCENT ->
colorSubscriptions!! +=
colorSubs +=
Aesthetic.get()
.colorAccent()
.distinctToMainThread()
Expand All @@ -99,23 +98,23 @@ class AestheticBottomNavigationView(

when (state.bgMode) {
BottomNavBgMode.PRIMARY ->
colorSubscriptions!! +=
colorSubs +=
Aesthetic.get()
.colorPrimary()
.distinctToMainThread()
.subscribe(
ViewBackgroundAction(this),
onErrorLogAndRethrow()
)
BottomNavBgMode.PRIMARY_DARK -> colorSubscriptions!! +=
BottomNavBgMode.PRIMARY_DARK -> colorSubs +=
Aesthetic.get()
.colorStatusBar()
.distinctToMainThread()
.subscribe(
ViewBackgroundAction(this),
onErrorLogAndRethrow()
)
BottomNavBgMode.ACCENT -> colorSubscriptions!! +=
BottomNavBgMode.ACCENT -> colorSubs +=
Aesthetic.get()
.colorAccent()
.distinctToMainThread()
Expand All @@ -125,8 +124,7 @@ class AestheticBottomNavigationView(
)
BottomNavBgMode.BLACK_WHITE_AUTO ->
setBackgroundColor(
getColor(
context,
context.color(
if (state.isDark)
R.color.ate_bottom_nav_default_dark_bg
else
Expand Down Expand Up @@ -154,7 +152,7 @@ class AestheticBottomNavigationView(

override fun onDetachedFromWindow() {
modesSubscription?.dispose()
colorSubscriptions?.clear()
colorSubs?.clear()
super.onDetachedFromWindow()
}

Expand Down
Expand Up @@ -8,14 +8,14 @@ package com.afollestad.aesthetic
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.support.v7.widget.AppCompatButton
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatButton
import com.afollestad.aesthetic.utils.TintHelper.setTintAuto
import com.afollestad.aesthetic.utils.ViewUtil.getObservableForResId
import com.afollestad.aesthetic.utils.distinctToMainThread
import com.afollestad.aesthetic.utils.isColorLight
import com.afollestad.aesthetic.utils.onErrorLogAndRethrow
import com.afollestad.aesthetic.utils.resId
import com.afollestad.aesthetic.utils.watchColor
import io.reactivex.Observable.combineLatest
import io.reactivex.disposables.Disposable
import io.reactivex.functions.Consumer
Expand Down Expand Up @@ -56,7 +56,7 @@ class AestheticButton(
override fun onAttachedToWindow() {
super.onAttachedToWindow()
subscription = combineLatest(
getObservableForResId(
watchColor(
context, backgroundResId, Aesthetic.get().colorAccent()
)!!,
Aesthetic.get().isDark,
Expand Down
Expand Up @@ -7,9 +7,9 @@ package com.afollestad.aesthetic

import android.annotation.SuppressLint
import android.content.Context
import android.support.v7.widget.CardView
import android.util.AttributeSet
import com.afollestad.aesthetic.utils.ViewUtil.getObservableForResId
import androidx.cardview.widget.CardView
import com.afollestad.aesthetic.utils.watchColor
import com.afollestad.aesthetic.utils.distinctToMainThread
import com.afollestad.aesthetic.utils.onErrorLogAndRethrow
import com.afollestad.aesthetic.utils.resId
Expand All @@ -34,7 +34,7 @@ class AestheticCardView(

override fun onAttachedToWindow() {
super.onAttachedToWindow()
val obs = getObservableForResId(
val obs = watchColor(
context, backgroundResId, Aesthetic.get().colorCardViewBackground()
)!!
bgSubscription = obs
Expand Down

0 comments on commit 62474a6

Please sign in to comment.