Added icons to main settings
This commit is contained in:
parent
300076c5dd
commit
23d0ab78cb
12 changed files with 152 additions and 43 deletions
|
@ -3,13 +3,18 @@ package com.fsck.k9.ui.settings
|
|||
import com.fsck.k9.ui.R
|
||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
||||
import com.xwray.groupie.kotlinandroidextensions.ViewHolder
|
||||
import kotlinx.android.synthetic.main.text_list_item.*
|
||||
import kotlinx.android.synthetic.main.text_icon_list_item.*
|
||||
import android.util.TypedValue
|
||||
|
||||
internal class SettingsActionItem(val text: String, val action: SettingsAction) : Item() {
|
||||
internal class SettingsActionItem(val text: String, val action: SettingsAction, val icon: Int) : Item() {
|
||||
|
||||
override fun getLayout(): Int = R.layout.text_list_item
|
||||
override fun getLayout(): Int = R.layout.text_icon_list_item
|
||||
|
||||
override fun bind(viewHolder: ViewHolder, position: Int) {
|
||||
viewHolder.text.text = text
|
||||
|
||||
val outValue = TypedValue()
|
||||
viewHolder.icon.context.theme.resolveAttribute(icon, outValue, true)
|
||||
viewHolder.icon.setImageResource(outValue.resourceId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,8 +58,16 @@ class SettingsActivity : K9Activity() {
|
|||
private fun populateSettingsList(accounts: List<Account>) {
|
||||
settingsAdapter.clear()
|
||||
|
||||
val miscSection = Section().apply {
|
||||
val item = SettingsActionItem(getString(R.string.about_action), SettingsAction.ABOUT_SCREEN, R.attr.iconSettingsAbout)
|
||||
add(item)
|
||||
}
|
||||
settingsAdapter.add(miscSection)
|
||||
|
||||
val generalSection = Section().apply {
|
||||
add(SettingsActionItem(getString(R.string.general_settings_title), SettingsAction.GENERAL_SETTINGS))
|
||||
val item = SettingsActionItem(getString(R.string.general_settings_title),
|
||||
SettingsAction.GENERAL_SETTINGS, R.attr.iconSettingsGeneral)
|
||||
add(item)
|
||||
}
|
||||
settingsAdapter.add(generalSection)
|
||||
|
||||
|
@ -67,15 +75,11 @@ class SettingsActivity : K9Activity() {
|
|||
for (account in accounts) {
|
||||
add(AccountItem(account))
|
||||
}
|
||||
add(SettingsActionItem(getString(R.string.add_account_action), SettingsAction.ADD_ACCOUNT))
|
||||
val item = SettingsActionItem(getString(R.string.add_account_action), SettingsAction.ADD_ACCOUNT, R.attr.iconSettingsAccountAdd)
|
||||
add(item)
|
||||
}
|
||||
accountSection.setHeader(SettingsDividerItem(getString(R.string.accounts_title)))
|
||||
settingsAdapter.add(accountSection)
|
||||
|
||||
//TODO: add header and/or divider
|
||||
val miscSection = Section().apply {
|
||||
add(SettingsActionItem(getString(R.string.about_action), SettingsAction.ABOUT_SCREEN))
|
||||
}
|
||||
settingsAdapter.add(miscSection)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.fsck.k9.ui.settings
|
||||
|
||||
import com.fsck.k9.ui.R
|
||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
||||
import com.xwray.groupie.kotlinandroidextensions.ViewHolder
|
||||
import kotlinx.android.synthetic.main.text_divider_list_item.*
|
||||
|
||||
internal class SettingsDividerItem(val text: String) : Item() {
|
||||
override fun getLayout(): Int = R.layout.text_divider_list_item
|
||||
|
||||
override fun bind(viewHolder: ViewHolder, position: Int) {
|
||||
viewHolder.text.text = text
|
||||
}
|
||||
}
|
7
app/ui/src/main/res/drawable-anydpi/ic_account_dark.xml
Normal file
7
app/ui/src/main/res/drawable-anydpi/ic_account_dark.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="#FFFFFFFF" android:pathData="M20,8L12,13L4,8V6L12,11L20,6M20,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V6C22,4.89 21.1,4 20,4Z" />
|
||||
</vector>
|
8
app/ui/src/main/res/drawable-anydpi/ic_account_light.xml
Normal file
8
app/ui/src/main/res/drawable-anydpi/ic_account_light.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:alpha="0.54"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="#FF000000" android:pathData="M20,8L12,13L4,8V6L12,11L20,6M20,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V6C22,4.89 21.1,4 20,4Z" />
|
||||
</vector>
|
|
@ -0,0 +1,7 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="#FFFFFFFF" android:pathData="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" />
|
||||
</vector>
|
|
@ -0,0 +1,8 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:alpha="0.54"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="#FF000000" android:pathData="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" />
|
||||
</vector>
|
|
@ -7,31 +7,42 @@
|
|||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:orientation="vertical">
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
tools:text="Personal" />
|
||||
<ImageView
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:contentDescription="@string/account_settings_action"
|
||||
android:padding="8dp"
|
||||
android:src="?attr/iconSettingsAccount" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/email"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
tools:text="test@example.org" />
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingTop="8dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
tools:text="Personal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/email"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:paddingBottom="8dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
tools:text="test@example.org" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -4,16 +4,14 @@
|
|||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:ellipsize="end"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingTop="4dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
tools:text="List item with simple text" />
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textStyle="bold"
|
||||
tools:text="Divider" />
|
35
app/ui/src/main/res/layout/text_icon_list_item.xml
Normal file
35
app/ui/src/main/res/layout/text_icon_list_item.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:paddingLeft="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:contentDescription="@string/account_settings_action"
|
||||
android:padding="8dp"
|
||||
android:src="?attr/iconActionSettings" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
tools:text="List item with simple text" />
|
||||
</LinearLayout>
|
|
@ -52,6 +52,10 @@
|
|||
<attr name="iconPreferencesVarious" format="reference" />
|
||||
<attr name="iconPreferencesPrivacy" format="reference" />
|
||||
<attr name="iconPreferencesDebug" format="reference" />
|
||||
<attr name="iconSettingsAbout" format="reference" />
|
||||
<attr name="iconSettingsGeneral" format="reference" />
|
||||
<attr name="iconSettingsAccount" format="reference" />
|
||||
<attr name="iconSettingsAccountAdd" format="reference" />
|
||||
<attr name="textColorPrimaryRecipientDropdown" format="reference" />
|
||||
<attr name="textColorSecondaryRecipientDropdown" format="reference" />
|
||||
<attr name="backgroundColorChooseAccountHeader" format="color" />
|
||||
|
|
|
@ -72,6 +72,10 @@
|
|||
<item name="iconPreferencesVarious">@drawable/ic_widgets_light</item>
|
||||
<item name="iconPreferencesPrivacy">@drawable/ic_shield_light</item>
|
||||
<item name="iconPreferencesDebug">@drawable/ic_bug_light</item>
|
||||
<item name="iconSettingsAbout">@drawable/ic_info_outline_light</item>
|
||||
<item name="iconSettingsGeneral">@drawable/ic_cog_light</item>
|
||||
<item name="iconSettingsAccount">@drawable/ic_account_light</item>
|
||||
<item name="iconSettingsAccountAdd">@drawable/ic_account_plus_light</item>
|
||||
<item name="textColorPrimaryRecipientDropdown">@android:color/primary_text_light</item>
|
||||
<item name="textColorSecondaryRecipientDropdown">@android:color/secondary_text_light</item>
|
||||
<item name="messageListSelectedBackgroundColor">#8038B8E2</item>
|
||||
|
@ -164,6 +168,10 @@
|
|||
<item name="iconPreferencesVarious">@drawable/ic_widgets_dark</item>
|
||||
<item name="iconPreferencesPrivacy">@drawable/ic_shield_dark</item>
|
||||
<item name="iconPreferencesDebug">@drawable/ic_bug_dark</item>
|
||||
<item name="iconSettingsAbout">@drawable/ic_info_outline_dark</item>
|
||||
<item name="iconSettingsGeneral">@drawable/ic_cog_dark</item>
|
||||
<item name="iconSettingsAccount">@drawable/ic_account_dark</item>
|
||||
<item name="iconSettingsAccountAdd">@drawable/ic_account_plus_dark</item>
|
||||
<item name="textColorPrimaryRecipientDropdown">@android:color/primary_text_dark</item>
|
||||
<item name="textColorSecondaryRecipientDropdown">@android:color/secondary_text_dark</item>
|
||||
<item name="messageListSelectedBackgroundColor">#8038B8E2</item>
|
||||
|
|
Loading…
Reference in a new issue