Commit c1be4079 authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

Merge branch 'fix/pre_lolipop_vector_icons' into 'feature/prepare_to_release'

Fix bugs on KitKat compatibility.

See merge request terrakok/gitlab-client!82
parents 26186f8c dea3032d
......@@ -25,8 +25,6 @@ android {
buildConfigField "String", "WEB_AUTH_USER_AGENT", '"gitfox_user_agent"'
buildConfigField "String", "ORIGIN_GITLAB_ENDPOINT", '"https://gitlab.com/"'
vectorDrawables.useSupportLibrary true
javaCompileOptions {
annotationProcessorOptions {
arguments = [toothpick_registry_package_name: 'ru.terrakok.gitlabclient']
......
......@@ -3,11 +3,13 @@ package ru.terrakok.gitlabclient.extension
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.net.Uri
import android.support.annotation.LayoutRes
import android.support.design.widget.Snackbar
import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat
import android.support.v4.graphics.drawable.DrawableCompat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -40,6 +42,21 @@ fun Navigator.setLaunchScreen(screenKey: String, data: Any? = null) {
fun Context.color(colorRes: Int) = ContextCompat.getColor(this, colorRes)
fun Context.getTintDrawable(drawableRes: Int, colorRes: Int): Drawable {
val wrapDrawable = DrawableCompat.wrap(ContextCompat.getDrawable(this, drawableRes)!!).mutate()
DrawableCompat.setTint(wrapDrawable, color(colorRes))
return wrapDrawable
}
fun TextView.setStartDrawable(drawable: Drawable) {
setCompoundDrawablesRelativeWithIntrinsicBounds(
drawable,
null,
null,
null
)
}
fun ImageView.tint(colorRes: Int) = this.setColorFilter(this.context.color(colorRes))
fun ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View {
......
......@@ -8,8 +8,10 @@ import kotlinx.android.synthetic.main.item_project.view.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.Visibility
import ru.terrakok.gitlabclient.extension.getTintDrawable
import ru.terrakok.gitlabclient.extension.inflate
import ru.terrakok.gitlabclient.extension.loadRoundedImage
import ru.terrakok.gitlabclient.extension.setStartDrawable
/**
* @author Konstantin Tskhovrebov (aka terrakok) on 18.06.17.
......@@ -19,8 +21,14 @@ class ProjectAdapterDelegate(private val clickListener: (Project) -> Unit) : Ada
override fun isForViewType(items: MutableList<Any>, position: Int) =
items[position] is Project
override fun onCreateViewHolder(parent: ViewGroup): RecyclerView.ViewHolder =
ViewHolder(parent.inflate(R.layout.item_project))
override fun onCreateViewHolder(parent: ViewGroup): RecyclerView.ViewHolder {
val root = parent.inflate(R.layout.item_project)
with(root) {
starsTextView.setStartDrawable(context.getTintDrawable(R.drawable.ic_star_black_24dp, R.color.colorPrimary))
forksTextView.setStartDrawable(context.getTintDrawable(R.drawable.ic_fork, R.color.colorPrimary))
}
return ViewHolder(root)
}
override fun onBindViewHolder(
items: MutableList<Any>,
......
......@@ -26,8 +26,21 @@ class TargetHeaderAdapterDelegate(
override fun isForViewType(items: MutableList<Any>, position: Int) =
items[position] is TargetHeader
override fun onCreateViewHolder(parent: ViewGroup): RecyclerView.ViewHolder =
ViewHolder(parent.inflate(R.layout.item_target_header))
override fun onCreateViewHolder(parent: ViewGroup): RecyclerView.ViewHolder {
val root = parent.inflate(R.layout.item_target_header)
with(root) {
commentsTextView.setStartDrawable(
context.getTintDrawable(
R.drawable.ic_event_commented_24dp,
R.color.colorPrimary
)
)
commitsTextView.setStartDrawable(context.getTintDrawable(R.drawable.ic_commit, R.color.colorPrimary))
upVotesTextView.setStartDrawable(context.getTintDrawable(R.drawable.ic_thumb_up, R.color.colorPrimary))
downVotesTextView.setStartDrawable(context.getTintDrawable(R.drawable.ic_thumb_down, R.color.colorPrimary))
}
return ViewHolder(root)
}
override fun onBindViewHolder(
items: MutableList<Any>,
......
package ru.terrakok.gitlabclient.ui.project
import android.os.Bundle
import android.support.v4.view.ViewCompat
import android.util.TypedValue
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationAdapter
import kotlinx.android.synthetic.main.fragment_project.*
......@@ -91,13 +92,12 @@ class ProjectFragment : BaseFragment(), ProjectInfoFragment.ProjectInfoToolbar {
private fun setToolbarElevation(tab: String) {
if (tab == Screens.PROJECT_INFO_SCREEN) {
toolbar.elevation = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
8f,
resources.displayMetrics
ViewCompat.setElevation(
toolbar,
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8f, resources.displayMetrics)
)
} else {
toolbar.elevation = 0f
ViewCompat.setElevation(toolbar, 0f)
}
}
......
package ru.terrakok.gitlabclient.ui.project
import android.os.Bundle
import android.view.View
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_project_info.*
......@@ -7,9 +9,7 @@ import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.Visibility
import ru.terrakok.gitlabclient.extension.loadRoundedImage
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.extension.*
import ru.terrakok.gitlabclient.presentation.project.info.ProjectInfoPresenter
import ru.terrakok.gitlabclient.presentation.project.info.ProjectInfoView
import ru.terrakok.gitlabclient.toothpick.DI
......@@ -32,6 +32,15 @@ class ProjectInfoFragment : BaseFragment(), ProjectInfoView {
.openScopes(DI.PROJECT_FLOW_SCOPE)
.getInstance(ProjectInfoPresenter::class.java)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
with(view) {
starsTextView.setStartDrawable(context.getTintDrawable(R.drawable.ic_star_black_24dp, R.color.colorPrimary))
forksTextView.setStartDrawable(context.getTintDrawable(R.drawable.ic_fork, R.color.colorPrimary))
}
}
override fun showProject(project: Project, mdReadme: CharSequence) {
(parentFragment as? ProjectInfoToolbar)?.apply {
setTitle(project.name)
......
......@@ -39,15 +39,15 @@
<TextView
android:id="@+id/titleTextView"
app:fontFamily="@font/roboto_medium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/primary_text"
android:textSize="16sp"
app:fontFamily="@font/roboto_medium"
app:layout_constraintLeft_toRightOf="@+id/avatarImageView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/avatarImageView"
......@@ -59,13 +59,13 @@
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:drawablePadding="4dp"
android:drawableStart="@drawable/ic_fork"
android:drawableTint="@color/colorPrimary"
android:gravity="center_vertical|end"
android:textColor="@color/colorPrimary"
android:textSize="16sp"
app:layout_constraintLeft_toLeftOf="@id/titleTextView"
app:layout_constraintTop_toBottomOf="@id/titleTextView"
tools:drawableStart="@drawable/ic_fork"
tools:drawableTint="@color/colorPrimary"
tools:text="34" />
<TextView
......@@ -75,22 +75,22 @@
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:drawablePadding="4dp"
android:drawableStart="@drawable/ic_star_black_24dp"
android:drawableTint="@color/colorPrimary"
android:gravity="center_vertical|end"
android:textColor="@color/colorPrimary"
android:textSize="16sp"
app:layout_constraintLeft_toRightOf="@id/forksTextView"
app:layout_constraintTop_toBottomOf="@id/titleTextView"
tools:drawableStart="@drawable/ic_star_black_24dp"
tools:drawableTint="@color/colorPrimary"
tools:text="68" />
<TextView
android:id="@+id/descriptionTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:textColor="@color/secondary_text"
android:textSize="14sp"
app:layout_constraintLeft_toLeftOf="parent"
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
......@@ -15,7 +14,7 @@
android:layout_marginTop="16dp"
android:src="@drawable/default_img"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iconImageView"
......@@ -28,19 +27,19 @@
app:layout_constraintLeft_toLeftOf="@id/avatarImageView"
app:layout_constraintTop_toTopOf="@id/avatarImageView"
app:tint="@color/white"
tools:src="@drawable/ic_security_white_24dp"/>
tools:src="@drawable/ic_security_white_24dp" />
<TextView
android:id="@+id/titleTextView"
style="@style/TextTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintLeft_toRightOf="@id/avatarImageView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/avatarImageView"
tools:text="GitLab Community Edition by Annabel Dunstone Gray"/>
tools:text="GitLab Community Edition by Annabel Dunstone Gray" />
<TextView
android:id="@+id/descriptionTextView"
......@@ -52,39 +51,39 @@
app:layout_constraintLeft_toLeftOf="@id/titleTextView"
app:layout_constraintRight_toRightOf="@id/titleTextView"
app:layout_constraintTop_toBottomOf="@id/titleTextView"
tools:text="I am having the exact same issue when installing 9.4 from source. I can login via LDAP but I cannot login as the default …"/>
tools:text="I am having the exact same issue when installing 9.4 from source. I can login via LDAP but I cannot login as the default …" />
<TextView
android:id="@+id/starsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:drawablePadding="4dp"
android:drawableStart="@drawable/ic_star_black_24dp"
android:drawableTint="@color/colorPrimary"
android:gravity="center_vertical|end"
android:textColor="@color/colorPrimary"
android:textSize="14sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/descriptionTextView"
tools:text="2911"/>
tools:drawableStart="@drawable/ic_star_black_24dp"
tools:drawableTint="@color/colorPrimary"
tools:text="2911" />
<TextView
android:id="@+id/forksTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:drawablePadding="4dp"
android:drawableStart="@drawable/ic_fork"
android:drawableTint="@color/colorPrimary"
android:gravity="center_vertical|end"
android:textColor="@color/colorPrimary"
android:textSize="14sp"
app:layout_constraintRight_toLeftOf="@+id/starsTextView"
app:layout_constraintTop_toBottomOf="@+id/descriptionTextView"
tools:text="2900"/>
tools:drawableStart="@drawable/ic_fork"
tools:drawableTint="@color/colorPrimary"
tools:text="2900" />
<View
android:layout_width="0dp"
......@@ -93,6 +92,6 @@
android:background="@color/divider"
app:layout_constraintLeft_toLeftOf="@id/titleTextView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/starsTextView"/>
app:layout_constraintTop_toBottomOf="@id/starsTextView" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
......@@ -15,7 +14,7 @@
android:layout_marginTop="16dp"
android:src="@drawable/default_img"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iconImageView"
......@@ -27,19 +26,19 @@
app:layout_constraintLeft_toLeftOf="@id/avatarImageView"
app:layout_constraintTop_toTopOf="@id/avatarImageView"
app:tint="@color/white"
tools:src="@drawable/ic_event_commented_24dp"/>
tools:src="@drawable/ic_event_commented_24dp" />
<TextView
android:id="@+id/titleTextView"
style="@style/TextTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintLeft_toRightOf="@id/avatarImageView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/avatarImageView"
tools:text="GitLab Community Edition by Annabel Dunstone Gray"/>
tools:text="GitLab Community Edition by Annabel Dunstone Gray" />
<TextView
android:id="@+id/descriptionTextView"
......@@ -51,7 +50,7 @@
app:layout_constraintLeft_toLeftOf="@id/titleTextView"
app:layout_constraintRight_toRightOf="@id/titleTextView"
app:layout_constraintTop_toBottomOf="@id/titleTextView"
tools:text="I am having the exact same issue when installing 9.4 from source. I can login via LDAP but I cannot login as the default …"/>
tools:text="I am having the exact same issue when installing 9.4 from source. I can login via LDAP but I cannot login as the default …" />
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/badgesContainer"
......@@ -61,7 +60,7 @@
app:flexWrap="wrap"
app:layout_constraintLeft_toLeftOf="@id/titleTextView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/descriptionTextView"/>
app:layout_constraintTop_toBottomOf="@+id/descriptionTextView" />
<TextView
android:id="@+id/dateTextView"
......@@ -72,7 +71,7 @@
android:textSize="14sp"
app:layout_constraintLeft_toLeftOf="@id/titleTextView"
app:layout_constraintTop_toBottomOf="@+id/badgesContainer"
tools:text="29 min ago"/>
tools:text="29 min ago" />
<TextView
android:id="@+id/commentsTextView"
......@@ -80,14 +79,14 @@
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:drawablePadding="4dp"
android:drawableStart="@drawable/ic_event_commented_24dp"
android:drawableTint="@color/colorPrimary"
android:gravity="center_vertical"
android:textColor="@color/colorPrimary"
android:textSize="14sp"
app:layout_constraintBaseline_toBaselineOf="@id/dateTextView"
app:layout_constraintRight_toRightOf="parent"
tools:text="29"/>
tools:drawableStart="@drawable/ic_event_commented_24dp"
tools:drawableTint="@color/colorPrimary"
tools:text="29" />
<TextView
android:id="@+id/commitsTextView"
......@@ -95,14 +94,14 @@
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:drawablePadding="4dp"
android:drawableStart="@drawable/ic_commit"
android:drawableTint="@color/colorPrimary"
android:gravity="center_vertical"
android:textColor="@color/colorPrimary"
android:textSize="14sp"
app:layout_constraintBaseline_toBaselineOf="@id/dateTextView"
app:layout_constraintRight_toLeftOf="@id/commentsTextView"
tools:text="29"/>
tools:drawableStart="@drawable/ic_commit"
tools:drawableTint="@color/colorPrimary"
tools:text="29" />
<TextView
android:id="@+id/upVotesTextView"
......@@ -110,14 +109,14 @@
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:drawablePadding="4dp"
android:drawableStart="@drawable/ic_thumb_up"
android:drawableTint="@color/colorPrimary"
android:gravity="center_vertical"
android:textColor="@color/colorPrimary"
android:textSize="14sp"
app:layout_constraintBaseline_toBaselineOf="@id/dateTextView"
app:layout_constraintRight_toLeftOf="@id/commitsTextView"
tools:text="29"/>
tools:drawableStart="@drawable/ic_thumb_up"
tools:drawableTint="@color/colorPrimary"
tools:text="29" />
<TextView
android:id="@+id/downVotesTextView"
......@@ -125,14 +124,14 @@
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:drawablePadding="4dp"
android:drawableStart="@drawable/ic_thumb_down"
android:drawableTint="@color/colorPrimary"
android:gravity="center_vertical"
android:textColor="@color/colorPrimary"
android:textSize="14sp"
app:layout_constraintBaseline_toBaselineOf="@id/dateTextView"
app:layout_constraintRight_toLeftOf="@id/upVotesTextView"
tools:text="29"/>
tools:drawableStart="@drawable/ic_thumb_down"
tools:drawableTint="@color/colorPrimary"
tools:text="29" />
<View
android:layout_width="0dp"
......@@ -141,6 +140,6 @@
android:background="@color/divider"
app:layout_constraintLeft_toLeftOf="@id/dateTextView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/dateTextView"/>
app:layout_constraintTop_toBottomOf="@id/dateTextView" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment