Tweaked selected color, added circle to offline icon

This commit is contained in:
tzugen 2021-10-25 20:16:19 +02:00
parent cef1153f89
commit eb2e6ada0a
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
5 changed files with 41 additions and 28 deletions

View File

@ -2,6 +2,7 @@ package org.moire.ultrasonic.fragment
import android.content.Context import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.Drawable
import android.os.Build import android.os.Build
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu import android.view.Menu
@ -68,8 +69,10 @@ internal class ServerRowAdapter(
/** /**
* Creates the Row representation of a Server Setting * Creates the Row representation of a Server Setting
*/ */
@Suppress("LongMethod")
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View? { override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View? {
var index = position var index = position
// Skip "Offline" in manage mode // Skip "Offline" in manage mode
if (manageMode) index++ if (manageMode) index++
@ -92,20 +95,29 @@ internal class ServerRowAdapter(
if (setting == null) serverMenu?.visibility = View.INVISIBLE if (setting == null) serverMenu?.visibility = View.INVISIBLE
} }
// Provide icons for the row val icon: Drawable?
val background: Drawable?
// Configure icons for the row
if (index == 0) { if (index == 0) {
serverMenu?.visibility = View.INVISIBLE serverMenu?.visibility = View.INVISIBLE
image?.setImageDrawable(Util.getDrawableFromAttribute(context, R.attr.screen_on_off)) icon = Util.getDrawableFromAttribute(context, R.attr.screen_on_off)
image?.background = ContextCompat.getDrawable(context, R.color.transparent) background = ContextCompat.getDrawable(context, R.drawable.circle)
} else { } else {
val icon = ContextCompat.getDrawable(context, R.drawable.ic_menu_server_dark) icon = ContextCompat.getDrawable(context, R.drawable.ic_menu_server_dark)
icon?.setTint(ServerColor.getForegroundColor(context, setting?.color)) background = ContextCompat.getDrawable(context, R.drawable.circle)
image?.setImageDrawable(icon)
val background = ContextCompat.getDrawable(context, R.drawable.circle)
background?.setTint(ServerColor.getBackgroundColor(context, setting?.color))
image?.background = background
} }
// Set colors
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
icon?.setTint(ServerColor.getForegroundColor(context, setting?.color))
background?.setTint(ServerColor.getBackgroundColor(context, setting?.color))
}
// Set the final drawables
image?.setImageDrawable(icon)
image?.background = background
// Highlight the Active Server's row by changing its background // Highlight the Active Server's row by changing its background
if (index == activeServerProvider.getActiveServer().index) { if (index == activeServerProvider.getActiveServer().index) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

View File

@ -16,7 +16,7 @@
a:scaleType="fitXY" a:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" /> a:importantForAccessibility="no" />
<ImageView <ImageView
a:id="@+id/img_profile" a:id="@+id/img_profile"
@ -29,7 +29,7 @@
tools:tint="@color/selected_menu_dark" tools:tint="@color/selected_menu_dark"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" /> a:importantForAccessibility="no" />
<TextView <TextView
a:id="@+id/name" a:id="@+id/name"

View File

@ -21,7 +21,8 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_menu_server_dark" /> tools:src="@drawable/ic_menu_server_dark"
a:importantForAccessibility="no" />
<TextView <TextView
a:id="@+id/server_name" a:id="@+id/server_name"
@ -55,7 +56,7 @@
a:layout_centerVertical="true" a:layout_centerVertical="true"
a:layout_gravity="end" a:layout_gravity="end"
a:layout_marginEnd="15dp" a:layout_marginEnd="15dp"
a:contentDescription="@string/server_editor.advanced"
a:focusable="false" a:focusable="false"
a:src="?attr/more_vert" a:src="?attr/more_vert"
tools:src="@drawable/ic_more_vert_dark" tools:src="@drawable/ic_more_vert_dark"

View File

@ -7,18 +7,18 @@
<ListView <ListView
a:id="@+id/server_list" a:id="@+id/server_list"
a:layout_width="fill_parent" a:layout_width="fill_parent"
a:layout_height="fill_parent" /> a:layout_height="fill_parent"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
a:id="@+id/server_add_fab" a:id="@+id/server_add_fab"
a:layout_width="wrap_content" a:layout_width="wrap_content"
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_alignRight="@id/server_list"
a:layout_alignEnd="@id/server_list" a:layout_alignEnd="@id/server_list"
a:layout_alignBottom="@id/server_list" a:layout_alignBottom="@id/server_list"
a:layout_margin="16dp" a:layout_margin="16dp"
a:clickable="true" a:clickable="true"
a:focusable="true" a:focusable="true"
a:src="@drawable/ic_add_white" /> a:src="@drawable/ic_add_white"
a:contentDescription="@string/server_editor.new_label" />
</RelativeLayout> </RelativeLayout>

View File

@ -3,20 +3,20 @@
<color name="dividerColor">#555555</color> <color name="dividerColor">#555555</color>
<color name="appwidget_text">#FFFFFF</color> <color name="appwidget_text">#FFFFFF</color>
<color name="transparent">#00000000</color> <color name="transparent">#00000000</color>
<color name="cyan">#ff0099cc</color> <color name="cyan">#0099cc</color>
<color name="navigation_header_light">#ff6200EE</color> <color name="navigation_header_light">#6200EE</color>
<color name="navigation_header_dark">#ffBB86FC</color> <color name="navigation_header_dark">#BB86FC</color>
<color name="ics_opaque">#8033b5e5</color> <color name="ics_opaque">#8033b5e5</color>
<color name="md__transparent">#00000000</color> <color name="md__transparent">#00000000</color>
<color name="translucent">#80000000</color> <color name="translucent">#80000000</color>
<color name="background_color_dark">#ff000000</color> <color name="background_color_dark">#000000</color>
<color name="background_color_grey">#ff333333</color> <color name="background_color_grey">#333333</color>
<color name="background_color_light">#ffffffff</color> <color name="background_color_light">#ffffff</color>
<color name="selected_color_dark">#424242</color> <color name="selected_color_dark">#424242</color>
<color name="selected_color_light">#B1B1B1</color> <color name="selected_color_light">#B6B6B6</color>
<color name="selected_menu_dark">#fff3f3f3</color> <color name="selected_menu_dark">#F3F3F3</color>
<color name="selected_menu_light">#ff000000</color> <color name="selected_menu_light">#000000</color>
<color name="selected_menu_background_dark">#ff333333</color> <color name="selected_menu_background_dark">#333333</color>
<color name="selected_menu_background_black">#ff111111</color> <color name="selected_menu_background_black">#111111</color>
<color name="selected_menu_background_light">#fff3f3f3</color> <color name="selected_menu_background_light">#f3f3f3</color>
</resources> </resources>