Commit 2ca8d50e authored by Mygod's avatar Mygod

Refine layout for wide screens

parent 3a66bbba
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
android:paddingEnd="72dip" android:paddingEnd="72dip"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<android.support.v7.widget.GridLayout android:layout_width="match_parent" <com.github.shadowsocks.widget.BoundedGridLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:columnCount="4"> app:bounded_width="288dp"
app:columnCount="4">
<TextView app:layout_column="0" style="@style/TextAppearance.AppCompat.Body2" <TextView app:layout_column="0" style="@style/TextAppearance.AppCompat.Body2"
android:ellipsize="marquee" android:text="@string/sent" android:ellipsize="marquee" android:text="@string/sent"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content"
...@@ -63,7 +64,7 @@ ...@@ -63,7 +64,7 @@
android:textColor="?android:attr/textColorSecondary" android:ellipsize="marquee" android:textColor="?android:attr/textColorSecondary" android:ellipsize="marquee"
android:layout_width="0dp" android:layout_height="wrap_content" app:layout_columnWeight="1" android:layout_width="0dp" android:layout_height="wrap_content" app:layout_columnWeight="1"
app:layout_gravity="fill_horizontal" android:gravity="end"/> app:layout_gravity="fill_horizontal" android:gravity="end"/>
</android.support.v7.widget.GridLayout> </com.github.shadowsocks.widget.BoundedGridLayout>
</LinearLayout> </LinearLayout>
<com.github.jorgecastilloprz.FABProgressCircle android:id="@+id/fabProgressCircle" <com.github.jorgecastilloprz.FABProgressCircle android:id="@+id/fabProgressCircle"
app:reusable="true" app:reusable="true"
......
...@@ -10,5 +10,6 @@ ...@@ -10,5 +10,6 @@
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:paddingBottom="32dp" android:paddingBottom="32dp"
android:clipChildren="false"
android:clipToPadding="false"/> android:clipToPadding="false"/>
</LinearLayout> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Based on: https://github.com/android/platform_frameworks_base/blob/505e3ab/core/res/res/layout/simple_list_item_2.xml --> <!-- Based on: https://github.com/android/platform_frameworks_base/blob/505e3ab/core/res/res/layout/simple_list_item_2.xml -->
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:background="@drawable/background_selectable" <com.github.shadowsocks.widget.BoundedCardView android:layout_width="match_parent"
android:layout_marginTop="8dp" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:background="@drawable/background_selectable"
android:layout_marginEnd="8dp" android:layout_marginTop="8dp"
android:id="@+id/indicator"> android:layout_marginStart="8dp"
<LinearLayout android:layout_width="match_parent" android:layout_marginEnd="8dp"
android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
android:orientation="vertical" app:bounded_width="480dp"
android:padding="8dp" android:id="@+id/indicator">
android:focusable="true"
android:nextFocusRight="@+id/edit"
android:id="@+id/content"
android:background="?android:attr/selectableItemBackground">
<LinearLayout android:layout_width="match_parent" <LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:orientation="vertical"
android:id="@+id/container"> android:padding="8dp"
<TextView android:id="@+id/title" android:focusable="true"
android:layout_width="0dp" android:nextFocusRight="@+id/edit"
android:id="@+id/content"
android:background="?android:attr/selectableItemBackground">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_marginStart="8dp"
android:layout_weight="1" android:id="@+id/container">
android:textAppearance="?android:attr/textAppearanceLarge" <TextView android:id="@+id/title"
android:textColor="?android:attr/textColorPrimary" android:layout_width="0dp"
android:gravity="center_vertical" android:layout_height="wrap_content"
android:maxLines="2" android:layout_gravity="center_vertical"
android:ellipsize="end"/> android:layout_weight="1"
<android.support.v7.widget.AppCompatImageView android:id="@+id/share" android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content" android:textColor="?android:attr/textColorPrimary"
android:layout_height="wrap_content" android:gravity="center_vertical"
android:padding="4dp" android:maxLines="2"
android:layout_gravity="top" android:ellipsize="end"/>
app:srcCompat="@drawable/ic_social_share" <android.support.v7.widget.AppCompatImageView android:id="@+id/share"
android:background="?attr/selectableItemBackgroundBorderless" android:layout_width="wrap_content"
android:contentDescription="Share" android:layout_height="wrap_content"
android:focusable="true" android:padding="4dp"
android:nextFocusLeft="@+id/container"/> android:layout_gravity="top"
<android.support.v7.widget.AppCompatImageView android:id="@+id/edit" app:srcCompat="@drawable/ic_social_share"
android:layout_width="wrap_content" android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Share"
android:focusable="true"
android:nextFocusLeft="@+id/container"/>
<android.support.v7.widget.AppCompatImageView android:id="@+id/edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:layout_gravity="top"
app:srcCompat="@drawable/ic_image_edit"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Edit"
android:focusable="true"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="4dp" android:layout_marginStart="8dp"
android:layout_gravity="top" android:layout_marginTop="4dp"
app:srcCompat="@drawable/ic_image_edit" android:id="@+id/details">
android:background="?attr/selectableItemBackgroundBorderless" <TextView android:id="@+id/address"
android:contentDescription="Edit" android:layout_width="0dp"
android:focusable="true"/> android:layout_height="wrap_content"
android:gravity="top"
android:layout_weight="1"
android:maxLines="2"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
<TextView android:id="@+id/traffic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout android:layout_width="match_parent" </com.github.shadowsocks.widget.BoundedCardView>
android:layout_height="wrap_content" </FrameLayout>
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:id="@+id/details">
<TextView android:id="@+id/address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="top"
android:layout_weight="1"
android:maxLines="2"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
<TextView android:id="@+id/traffic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<declare-styleable name="BoundedView">
<attr name="bounded_width" format="dimension" />
<attr name="bounded_height" format="dimension" />
</declare-styleable>
<declare-styleable name="NumberPickerPreference"> <declare-styleable name="NumberPickerPreference">
<attr name="max" format="integer" /> <attr name="max" format="integer" />
<attr name="min" format="integer" /> <attr name="min" format="integer" />
......
...@@ -25,7 +25,7 @@ import java.util.GregorianCalendar ...@@ -25,7 +25,7 @@ import java.util.GregorianCalendar
import android.content._ import android.content._
import android.os.{Bundle, Handler} import android.os.{Bundle, Handler}
import android.support.v4.content.LocalBroadcastManager import android.support.v4.content.LocalBroadcastManager
import android.support.v7.widget.{DefaultItemAnimator, LinearLayoutManager, RecyclerView, Toolbar} import android.support.v7.widget._
import android.support.v7.widget.RecyclerView.ViewHolder import android.support.v7.widget.RecyclerView.ViewHolder
import android.support.v7.widget.helper.ItemTouchHelper import android.support.v7.widget.helper.ItemTouchHelper
import android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback import android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback
......
package com.github.shadowsocks.widget
import android.content.Context
import android.support.v7.widget.CardView
import android.util.AttributeSet
/**
* @author Mygod
*/
class BoundedCardView(context: Context, attrs: AttributeSet) extends CardView(context, attrs) with BoundedView {
initAttrs(context, attrs)
}
package com.github.shadowsocks.widget
import android.content.Context
import android.support.v7.widget.GridLayout
import android.util.AttributeSet
/**
* @author Mygod
*/
class BoundedGridLayout(context: Context, attrs: AttributeSet) extends GridLayout(context, attrs) with BoundedView {
initAttrs(context, attrs)
}
package com.github.shadowsocks.widget
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.view.View.MeasureSpec
import com.github.shadowsocks.R
/**
* Based on: http://stackoverflow.com/a/6212120/2245107
*
* @author Mygod
*/
trait BoundedView extends View {
private var boundedWidth: Int = _
private var boundedHeight: Int = _
protected def initAttrs(context: Context, attrs: AttributeSet) {
val arr = context.obtainStyledAttributes(attrs, R.styleable.BoundedView)
boundedWidth = arr.getDimensionPixelSize(R.styleable.BoundedView_bounded_width, 0)
boundedHeight = arr.getDimensionPixelSize(R.styleable.BoundedView_bounded_height, 0)
arr.recycle()
}
override def onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit = super.onMeasure(
if (boundedWidth > 0 && boundedWidth < MeasureSpec.getSize(widthMeasureSpec))
MeasureSpec.makeMeasureSpec(boundedWidth, MeasureSpec.getMode(widthMeasureSpec))
else widthMeasureSpec,
if (boundedHeight > 0 && boundedHeight < MeasureSpec.getSize(heightMeasureSpec))
MeasureSpec.makeMeasureSpec(boundedHeight, MeasureSpec.getMode(heightMeasureSpec))
else heightMeasureSpec)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment