mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 05:05:06 +01:00
Adding custom local source icon
Maybe we'll ask as to make one someday...
This commit is contained in:
parent
90a3145345
commit
40ae78c0a3
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.migration
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.kanade.tachiyomi.source.icon
|
import eu.kanade.tachiyomi.source.icon
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.view.roundTextIcon
|
|
||||||
import kotlinx.android.synthetic.main.migration_card_item.*
|
import kotlinx.android.synthetic.main.migration_card_item.*
|
||||||
import kotlinx.android.synthetic.main.source_item.edit_button
|
import kotlinx.android.synthetic.main.source_item.edit_button
|
||||||
import kotlinx.android.synthetic.main.source_item.title
|
import kotlinx.android.synthetic.main.source_item.title
|
||||||
@ -30,7 +29,6 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
|
|||||||
itemView.post {
|
itemView.post {
|
||||||
val icon = source.icon()
|
val icon = source.icon()
|
||||||
if (icon != null) edit_button.setImageDrawable(source.icon())
|
if (icon != null) edit_button.setImageDrawable(source.icon())
|
||||||
else edit_button.roundTextIcon(source.name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|||||||
import eu.kanade.tachiyomi.source.icon
|
import eu.kanade.tachiyomi.source.icon
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.view.roundTextIcon
|
|
||||||
import kotlinx.android.synthetic.main.migration_source_item.*
|
import kotlinx.android.synthetic.main.migration_source_item.*
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) :
|
|||||||
itemView.post {
|
itemView.post {
|
||||||
val icon = source.icon()
|
val icon = source.icon()
|
||||||
if (icon != null) edit_button.setImageDrawable(source.icon())
|
if (icon != null) edit_button.setImageDrawable(source.icon())
|
||||||
else edit_button.roundTextIcon(source.name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceEnabled) {
|
if (sourceEnabled) {
|
||||||
|
@ -3,11 +3,11 @@ package eu.kanade.tachiyomi.ui.source
|
|||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.source.icon
|
import eu.kanade.tachiyomi.source.icon
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.roundTextIcon
|
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
import kotlinx.android.synthetic.main.source_item.*
|
import kotlinx.android.synthetic.main.source_item.*
|
||||||
|
|
||||||
@ -55,7 +55,8 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
|
|||||||
itemView.post {
|
itemView.post {
|
||||||
val icon = source.icon()
|
val icon = source.icon()
|
||||||
if (icon != null) edit_button.setImageDrawable(source.icon())
|
if (icon != null) edit_button.setImageDrawable(source.icon())
|
||||||
else edit_button.roundTextIcon(source.name)
|
else if (item.source.id == LocalSource.ID)
|
||||||
|
edit_button.setImageResource(R.drawable.ic_local_source_32dp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source.supportsLatest) {
|
if (source.supportsLatest) {
|
||||||
|
@ -8,7 +8,6 @@ import android.content.res.ColorStateList
|
|||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Point
|
import android.graphics.Point
|
||||||
import android.graphics.Typeface
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -16,7 +15,6 @@ import android.view.ViewTreeObserver
|
|||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
import androidx.annotation.IdRes
|
import androidx.annotation.IdRes
|
||||||
@ -24,8 +22,6 @@ import androidx.annotation.Px
|
|||||||
import androidx.appcompat.view.menu.MenuBuilder
|
import androidx.appcompat.view.menu.MenuBuilder
|
||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.amulyakhare.textdrawable.TextDrawable
|
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationItemView
|
import com.google.android.material.bottomnavigation.BottomNavigationItemView
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationMenuView
|
import com.google.android.material.bottomnavigation.BottomNavigationMenuView
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
@ -39,7 +35,6 @@ import eu.kanade.tachiyomi.util.system.contextCompatColor
|
|||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import kotlin.math.min
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns coordinates of view.
|
* Returns coordinates of view.
|
||||||
@ -117,23 +112,6 @@ inline fun View.visInvisIf(show: Boolean) {
|
|||||||
visibility = if (show) View.VISIBLE else View.INVISIBLE
|
visibility = if (show) View.VISIBLE else View.INVISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a TextDrawable determined by input
|
|
||||||
*
|
|
||||||
* @param text text of [TextDrawable]
|
|
||||||
* @param random random color
|
|
||||||
*/
|
|
||||||
fun ImageView.roundTextIcon(text: String) {
|
|
||||||
val size = min(this.width, this.height)
|
|
||||||
val letter = text.take(1).toUpperCase()
|
|
||||||
setImageDrawable(
|
|
||||||
TextDrawable.builder().beginConfig().width(size).height(size).textColor(Color.WHITE)
|
|
||||||
.useFont(Typeface.DEFAULT).endConfig().buildRound(
|
|
||||||
letter, ColorGenerator.MATERIAL.getColor(letter)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline val View.marginTop: Int
|
inline val View.marginTop: Int
|
||||||
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin ?: 0
|
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin ?: 0
|
||||||
|
|
||||||
|
28
app/src/main/res/drawable/ic_local_source_32dp.xml
Normal file
28
app/src/main/res/drawable/ic_local_source_32dp.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="32dp"
|
||||||
|
android:height="32dp"
|
||||||
|
android:viewportWidth="40"
|
||||||
|
android:viewportHeight="40">
|
||||||
|
<group
|
||||||
|
android:translateX="4.5"
|
||||||
|
android:translateY="4.5">
|
||||||
|
<path
|
||||||
|
android:fillAlpha=".23"
|
||||||
|
android:fillColor="@android:color/black"
|
||||||
|
android:pathData="M2.5,0L29.5,0A2.5,2.5 0,0 1,32 2.5L32,29.5A2.5,2.5 0,0 1,29.5 32L2.5,32A2.5,2.5 0,0 1,0 29.5L0,2.5A2.5,2.5 0,0 1,2.5 0z" />
|
||||||
|
</group>
|
||||||
|
<group
|
||||||
|
android:translateX="4"
|
||||||
|
android:translateY="4">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M2.5,0L29.5,0A2.5,2.5 0,0 1,32 2.5L32,29.5A2.5,2.5 0,0 1,29.5 32L2.5,32A2.5,2.5 0,0 1,0 29.5L0,2.5A2.5,2.5 0,0 1,2.5 0z" />
|
||||||
|
</group>
|
||||||
|
<group
|
||||||
|
android:translateX="8"
|
||||||
|
android:translateY="8">
|
||||||
|
<path
|
||||||
|
android:fillColor="@color/app_color_primary"
|
||||||
|
android:pathData="M12,11.55C9.64,9.35 6.48,8 3,8v11c3.48,0 6.64,1.35 9,3.55 2.36,-2.19 5.52,-3.55 9,-3.55V8c-3.48,0 -6.64,1.35 -9,3.55zM12,8c1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3 1.34,3 3,3z" />
|
||||||
|
</group>
|
||||||
|
</vector>
|
Loading…
Reference in New Issue
Block a user