Skip to content

Commit

Permalink
[TASK] Update libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
asousawit committed Oct 22, 2020
1 parent e2265ad commit 904f31f
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 158 deletions.
51 changes: 36 additions & 15 deletions .travis.yml
@@ -1,31 +1,52 @@
language: android
jdk: oraclejdk8

env:
global:
- ANDROID_API_LEVEL=30
- ANDROID_BUILD_TOOLS_VERSION=30.0.2

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

branches:
only:
- master

android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
- platform-tools
- tools
licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+

components:
- tools
- platform-tools
# The BuildTools version used by your project
- build-tools-29.0.2

- build-tools-$ANDROID_BUILD_TOOLS_VERSION
# The SDK version used to compile your project
- android-29
- android-$ANDROID_API_LEVEL
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-$ANDROID_API_LEVEL
# Android emulator
- android-22
- sys-img-armeabi-v7a-android-22

before_install:
- yes | sdkmanager "platforms;android-29"
- yes | sdkmanager "platforms;android-30"
- yes | sdkmanager "build-tools;30.0.2"

before_script:
- chmod +x gradlew
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
- yes | sdkmanager --update
- yes | sdkmanager --licenses
# Launch emulator before the execution
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
- "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | sudo bash"

script: ./gradlew build assembleDebug
20 changes: 3 additions & 17 deletions build.gradle
@@ -1,17 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10"
}
}

Expand All @@ -22,15 +17,6 @@ allprojects {
}
}

repositories {
flatDir {
dirs 'libs'
}

maven { url "https://nexus.wit-software.com/repository/releases/" }
maven { url "https://nexus.wit-software.com/repository/snapshots/" }
}

task clean(type: Delete) {
delete rootProject.buildDir
}
11 changes: 5 additions & 6 deletions demo/build.gradle
Expand Up @@ -3,12 +3,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
compileSdkVersion 30

defaultConfig {
applicationId "com.andrefrsousa.supertoolbar.demo"
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
Expand All @@ -17,8 +17,7 @@ android {
dependencies {
implementation project(path: ':lib')

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
}
4 changes: 2 additions & 2 deletions demo/src/main/res/layout/list_item.xml
Expand Up @@ -5,9 +5,9 @@

<TextView
android:id="@+id/text_view"
android:text="Hello World!"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:padding="8dp" />
android:padding="8dp"
android:text="Hello World!" />

</FrameLayout>
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
#Thu Oct 22 08:45:56 WEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
24 changes: 16 additions & 8 deletions lib/build.gradle
Expand Up @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
compileSdkVersion 30

defaultConfig {
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0.0"
}
Expand All @@ -19,13 +19,21 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

buildFeatures {
viewBinding true
}
}

dependencies {
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

// Support libraries
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
}
36 changes: 0 additions & 36 deletions lib/src/main/java/com/andrefrsousa/supertoolbar/KExtensions.kt

This file was deleted.

76 changes: 35 additions & 41 deletions lib/src/main/java/com/andrefrsousa/supertoolbar/SuperToolbar.kt
Expand Up @@ -28,23 +28,26 @@ import android.graphics.Typeface
import android.os.Build
import android.util.AttributeSet
import android.view.Gravity
import android.view.LayoutInflater
import android.view.animation.DecelerateInterpolator
import androidx.appcompat.widget.AppCompatTextView
import androidx.appcompat.widget.Toolbar
import androidx.core.view.ViewCompat
import com.andrefrsousa.supertoolbar.databinding.SuperToolbarTitleBinding

private const val DURATION = 250

open class SuperToolbar : Toolbar {

private lateinit var titleView: AppCompatTextView
private lateinit var binding: SuperToolbarTitleBinding

private var isElevationShown = false
private var centerTitle = false
private var useLightFont = false
private var animationDuration = 0L
private var toolbarElevation = 0f

// region Constructor

constructor(context: Context) : super(context) {
initView(context, null, 0)
}
Expand All @@ -62,15 +65,11 @@ open class SuperToolbar : Toolbar {
}

private fun initView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) {
if (isInEditMode || attrs == null) {
return
}
if (attrs == null) return

with(context.obtainStyledAttributes(attrs, R.styleable.SuperToolbar, defStyleAttr, 0)) {
animationDuration =
getInt(R.styleable.SuperToolbar_superToolbar_animationDuration, DURATION).toLong()
isElevationShown =
getBoolean(R.styleable.SuperToolbar_superToolbar_showElevationAtStart, false)
animationDuration = getInt(R.styleable.SuperToolbar_superToolbar_animationDuration, DURATION).toLong()
isElevationShown = getBoolean(R.styleable.SuperToolbar_superToolbar_showElevationAtStart, false)
centerTitle = getBoolean(R.styleable.SuperToolbar_superToolbar_centerTitle, false)
useLightFont = getBoolean(R.styleable.SuperToolbar_superToolbar_useLightFont, false)
recycle()
Expand All @@ -80,88 +79,83 @@ open class SuperToolbar : Toolbar {
with(ViewCompat.getElevation(this)) {
toolbarElevation = if (this == 0f) {
resources.getDimension(R.dimen.super_toolbar_default_elevation)
} else {
this
}

} else this
}

// By default we remove the elevation when creating the toolbar
if (!isElevationShown) {
ViewCompat.setElevation(this, 0f)
}
if (!isElevationShown) ViewCompat.setElevation(this, 0f)

// Add a custom title view
if (centerTitle || useLightFont) {
titleView = inflate(R.layout.super_toolbar_title) as AppCompatTextView
binding = SuperToolbarTitleBinding.inflate(LayoutInflater.from(context), this, false)

if (useLightFont) {
titleView.typeface = Typeface.SANS_SERIF
}
if (useLightFont) binding.toolbarTitle.typeface = Typeface.SANS_SERIF

if (centerTitle) {
val layoutParams = titleView.layoutParams as Toolbar.LayoutParams
val layoutParams = binding.toolbarTitle.layoutParams as LayoutParams
layoutParams.gravity = Gravity.CENTER
addView(titleView, layoutParams)
addView(binding.toolbarTitle, layoutParams)

} else {
addView(titleView)
}
} else addView(binding.toolbarTitle)
}
}

// endregion

// region Methods from Toolbar

override fun setTitle(resId: Int) {
if (::titleView.isInitialized) {
titleView.setText(resId)
if (::binding.isInitialized) {
binding.toolbarTitle.setText(resId)
return
}

super.setTitle(resId)
}

override fun setTitle(title: CharSequence?) {
if (::titleView.isInitialized) {
titleView.text = title
if (::binding.isInitialized) {
binding.toolbarTitle.text = title
return
}

super.setTitle(title)
}

@Suppress("DEPRECATION")
override fun setTitleTextAppearance(context: Context?, resId: Int) {
if (::titleView.isInitialized) {
if (hasMinimumSdk(Build.VERSION_CODES.M)) {
titleView.setTextAppearance(resId)

} else {
titleView.setTextAppearance(context, resId)
}
if (::binding.isInitialized) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
binding.toolbarTitle.setTextAppearance(resId)

} else binding.toolbarTitle.setTextAppearance(context, resId)
return
}

super.setTitleTextAppearance(context, resId)
}

override fun setTitleTextColor(color: Int) {
if (::titleView.isInitialized) {
titleView.setTextColor(color)
if (::binding.isInitialized) {
binding.toolbarTitle.setTextColor(color)
return
}

super.setTitleTextColor(color)
}

//region PUBLIC METHODS
// endregion

//region Public methods

/**
* Toggles the toolbar elevation visibility using an animation
*
* @param show true if you want to show the elevation; false otherwise
*/
fun setElevationVisibility(show: Boolean) {
if (isElevationShown == show) {
return
}
if (isElevationShown == show) return

isElevationShown = show

Expand Down

0 comments on commit 904f31f

Please sign in to comment.