Created custom view to handle preferences better with MVI

This commit is contained in:
Moez Bhatti
2017-12-03 23:56:56 -05:00
parent e5c897b50c
commit 22cb4e151f
9 changed files with 151 additions and 90 deletions
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<merge 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:gravity="center_vertical"
tools:parentTag="com.moez.QKSMS.presentation.view.PreferenceView">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/titleView"
style="@style/TextPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Default SMS App" />
<TextView
android:id="@+id/summaryView"
style="@style/TextSecondary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="QKSMS is your default SMS app" />
</LinearLayout>
<FrameLayout
android:id="@+id/widgetFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</merge>
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -7,9 +8,42 @@
<include layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/fragmentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="0dp"
android:layout_weight="1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/preferences"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.moez.QKSMS.presentation.view.PreferenceView
android:id="@+id/defaultSms"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/settings_default_sms_title" />
<com.moez.QKSMS.presentation.view.PreferenceView
android:id="@+id/theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/settings_theme_title" />
<com.moez.QKSMS.presentation.view.PreferenceView
android:id="@+id/sync"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:summary="@string/settings_sync_summary"
app:title="@string/settings_sync_title" />
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="PreferenceView">
<attr name="title" format="string" />
<attr name="summary" format="string" />
<attr name="key" format="string" />
<attr name="widget" format="reference" />
</declare-styleable>
</resources>
-17
View File
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference
android:key="defaultSms"
android:title="@string/settings_default_sms_title" />
<Preference
android:key="theme"
android:title="@string/settings_theme_title" />
<Preference
android:key="sync"
android:summary="@string/settings_sync_summary"
android:title="@string/settings_sync_title" />
</PreferenceScreen>