-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: custom theme color in various AndroidView (#656)
* Fix: background color of download list when using custom theme * Fix background color in Migration's source list * Fix custom theme color in manga's Edit Info * Fix custom theme color in manga's Migration Config * Fix custom theme color in manga's Migration Config * Fix custom theme color & relayout merge setting's dialog * using CustomColorScheme for DownloadQueue * using CustomColorScheme for metadata source
- Loading branch information
1 parent
c7c76d2
commit 5b77536
Showing
24 changed files
with
512 additions
and
280 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
app/src/main/java/eu/kanade/presentation/components/SpinnerAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package eu.kanade.presentation.components | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ArrayAdapter | ||
import android.widget.TextView | ||
import androidx.annotation.LayoutRes | ||
import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme | ||
|
||
// KMK --> | ||
internal class SpinnerAdapter( | ||
context: Context, | ||
@LayoutRes val resource: Int, | ||
objects: List<String>, | ||
val colorScheme: AndroidViewColorScheme, | ||
) : ArrayAdapter<String>(context, resource, objects) { | ||
private val mInflater = LayoutInflater.from(context) | ||
|
||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { | ||
return createViewFromResource(mInflater, position, convertView, parent, resource) | ||
} | ||
|
||
override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View { | ||
return createViewFromResource(mInflater, position, convertView, parent, resource) | ||
} | ||
|
||
private fun createViewFromResource( | ||
inflater: LayoutInflater, | ||
position: Int, | ||
convertView: View?, | ||
parent: ViewGroup, | ||
resource: Int, | ||
): View { | ||
val text: TextView | ||
|
||
val view = convertView ?: inflater.inflate(resource, parent, false) | ||
|
||
try { | ||
// If no custom field is assigned, assume the whole resource is a TextView | ||
text = view as TextView | ||
} catch (e: ClassCastException) { | ||
throw IllegalStateException("ArrayAdapter requires the resource ID to be a TextView", e) | ||
} | ||
|
||
val item: String? = getItem(position) | ||
if (item != null) text.text = item | ||
|
||
text.setTextColor(colorScheme.textColor) | ||
text.setBackgroundColor(colorScheme.dropdownBgColor) | ||
|
||
return view | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.