aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-11-22 12:49:56 -0500
committerGitHub <noreply@github.com>2017-11-22 12:49:56 -0500
commitf619522bd805e0e090fe9d47ed7b23c4210c634d (patch)
tree1a1637dc498b7ad16cbabab1716aed343a9db954 /app/src/main
parentf6499a8741b8234770ba61c003f8065da041cdfe (diff)
downloadfrost-f619522bd805e0e090fe9d47ed7b23c4210c634d.tar.gz
frost-f619522bd805e0e090fe9d47ed7b23c4210c634d.tar.bz2
frost-f619522bd805e0e090fe9d47ed7b23c4210c634d.zip
Fix/tab layout (#510)
* Test wrap content width * Compute badge icon dimensions * Reuse views * Remove unnecessary color set * Change image bound * Set min * Change dp * Snapshot * Hardcode dimensions * Add min width
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt5
-rw-r--r--app/src/main/res/layout/activity_main.xml31
-rw-r--r--app/src/main/res/layout/activity_main_bottom_tabs.xml35
-rw-r--r--app/src/main/res/layout/view_badged_icon.xml7
-rw-r--r--app/src/main/res/layout/view_main_fab.xml8
-rw-r--r--app/src/main/res/layout/view_main_tab_layout.xml10
-rw-r--r--app/src/main/res/layout/view_main_toolbar.xml8
-rw-r--r--app/src/main/res/layout/view_main_viewpager.xml7
-rw-r--r--app/src/main/res/values/dimens.xml1
10 files changed, 50 insertions, 66 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
index 5d7e3625..57cda44a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -210,9 +210,7 @@ class MainActivity : BaseActivity(),
}
adapter.pages.forEach {
tabs.addTab(tabs.newTab()
- .setCustomView(BadgedIcon(this).apply {
- iicon = it.icon
- }))
+ .setCustomView(BadgedIcon(this).apply { iicon = it.icon }))
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
index c1015aad..ed7a3c4f 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
@@ -7,6 +7,7 @@ import android.util.AttributeSet
import android.widget.ImageView
import android.widget.TextView
import ca.allanwang.kau.utils.*
+import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.IIcon
import com.pitchedapps.frost.R
import com.pitchedapps.frost.utils.Prefs
@@ -31,12 +32,10 @@ class BadgedIcon @JvmOverloads constructor(
badgeTextView.setTextColor(Prefs.mainActivityLayout.iconColor())
}
-
var iicon: IIcon? = null
- get() = field
set(value) {
field = value
- badgeImage.setImageDrawable(value?.toDrawable(context, color = Prefs.mainActivityLayout.iconColor()))
+ badgeImage.setImageDrawable(value?.toDrawable(context, sizeDp = 20, color = Prefs.mainActivityLayout.iconColor()))
}
fun setAllAlpha(alpha: Float) {
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 440cbba3..883221d9 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
@@ -14,36 +13,14 @@
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
- <android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:background="?attr/colorPrimary"
- app:layout_scrollFlags="scroll|enterAlways"
- app:popupTheme="@style/AppTheme.PopupOverlay">
+ <include layout="@layout/view_main_toolbar" />
- </android.support.v7.widget.Toolbar>
-
- <android.support.design.widget.TabLayout
- android:id="@+id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- app:tabIndicatorHeight="0dp" />
+ <include layout="@layout/view_main_tab_layout" />
</android.support.design.widget.AppBarLayout>
- <com.pitchedapps.frost.views.FrostViewPager
- android:id="@+id/container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+ <include layout="@layout/view_main_viewpager" />
- <android.support.design.widget.FloatingActionButton
- android:id="@+id/fab"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end|bottom"
- android:layout_margin="@dimen/kau_fab_margin"
- android:visibility="gone" />
+ <include layout="@layout/view_main_fab" />
</android.support.design.widget.CoordinatorLayout>
diff --git a/app/src/main/res/layout/activity_main_bottom_tabs.xml b/app/src/main/res/layout/activity_main_bottom_tabs.xml
index 09742387..783aa455 100644
--- a/app/src/main/res/layout/activity_main_bottom_tabs.xml
+++ b/app/src/main/res/layout/activity_main_bottom_tabs.xml
@@ -1,7 +1,5 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -21,40 +19,17 @@
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
- <android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:background="?attr/colorPrimary"
- app:layout_scrollFlags="scroll|enterAlways"
- app:popupTheme="@style/AppTheme.PopupOverlay">
-
- </android.support.v7.widget.Toolbar>
+ <include layout="@layout/view_main_toolbar" />
</android.support.design.widget.AppBarLayout>
- <com.pitchedapps.frost.views.FrostViewPager
- android:id="@+id/container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:layout_behavior="@string/appbar_scrolling_view_behavior" />
-
- <android.support.design.widget.FloatingActionButton
- android:id="@+id/fab"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end|bottom"
- android:layout_margin="@dimen/kau_fab_margin"
- android:visibility="gone" />
+ <include layout="@layout/view_main_viewpager" />
+
+ <include layout="@layout/view_main_fab" />
</android.support.design.widget.CoordinatorLayout>
- <android.support.design.widget.TabLayout
- android:id="@+id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- app:tabIndicatorHeight="0dp" />
+ <include layout="@layout/view_main_tab_layout" />
</LinearLayout>
diff --git a/app/src/main/res/layout/view_badged_icon.xml b/app/src/main/res/layout/view_badged_icon.xml
index cc6b16cc..c64e7809 100644
--- a/app/src/main/res/layout/view_badged_icon.xml
+++ b/app/src/main/res/layout/view_badged_icon.xml
@@ -3,11 +3,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
- android:layout_height="50dp">
+ android:layout_height="@dimen/tab_bar_height"
+ android:minWidth="@dimen/tab_bar_height">
<android.support.constraint.Guideline
android:id="@+id/g_v_c"
- android:layout_width="1dp"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5"
@@ -17,7 +18,7 @@
<android.support.constraint.Guideline
android:id="@+id/g_h_c"
android:layout_width="wrap_content"
- android:layout_height="1dp"
+ android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5"
tools:layout_editor_absoluteX="0dp"
diff --git a/app/src/main/res/layout/view_main_fab.xml b/app/src/main/res/layout/view_main_fab.xml
new file mode 100644
index 00000000..5e1fed77
--- /dev/null
+++ b/app/src/main/res/layout/view_main_fab.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.FloatingActionButton xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/fab"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="end|bottom"
+ android:layout_margin="@dimen/kau_fab_margin"
+ android:visibility="gone" /> \ No newline at end of file
diff --git a/app/src/main/res/layout/view_main_tab_layout.xml b/app/src/main/res/layout/view_main_tab_layout.xml
new file mode 100644
index 00000000..ed4f5d60
--- /dev/null
+++ b/app/src/main/res/layout/view_main_tab_layout.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/tabs"
+ style="@style/Widget.Design.TabLayout"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/tab_bar_height"
+ app:tabGravity="fill"
+ app:tabIndicatorHeight="0dp"
+ app:tabMode="fixed" />
diff --git a/app/src/main/res/layout/view_main_toolbar.xml b/app/src/main/res/layout/view_main_toolbar.xml
new file mode 100644
index 00000000..b0a4de7c
--- /dev/null
+++ b/app/src/main/res/layout/view_main_toolbar.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ app:layout_scrollFlags="scroll|enterAlways"
+ app:popupTheme="@style/AppTheme.PopupOverlay" /> \ No newline at end of file
diff --git a/app/src/main/res/layout/view_main_viewpager.xml b/app/src/main/res/layout/view_main_viewpager.xml
new file mode 100644
index 00000000..0c3f314c
--- /dev/null
+++ b/app/src/main/res/layout/view_main_viewpager.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.pitchedapps.frost.views.FrostViewPager xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" /> \ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index f7855b5b..888340e9 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -5,5 +5,6 @@
<dimen name="context_menu_height">60dp</dimen>
+ <dimen name="tab_bar_height">50dp</dimen>
<dimen name="intro_bar_height">64dp</dimen>
</resources>