1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 22:31:16 +00:00

Improving content margin on tablets and using support library dimensions for everything possible.

Ref #404.
This commit is contained in:
George Venios 2015-08-23 22:03:15 +01:00
parent 11ab6cee57
commit dda0e48fda
9 changed files with 24 additions and 23 deletions

View file

@ -4,13 +4,6 @@ import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer.DrawableContainerState;
import android.graphics.drawable.StateListDrawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -18,7 +11,6 @@ import android.support.v7.widget.SwitchCompat;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -44,7 +36,6 @@ import com.nutomic.syncthingandroid.syncthing.SyncthingService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static android.os.Build.VERSION_CODES.LOLLIPOP;
import static android.support.v4.view.MarginLayoutParamsCompat.setMarginEnd; import static android.support.v4.view.MarginLayoutParamsCompat.setMarginEnd;
import static android.support.v4.view.MarginLayoutParamsCompat.setMarginStart; import static android.support.v4.view.MarginLayoutParamsCompat.setMarginStart;
import static android.view.Gravity.CENTER_VERTICAL; import static android.view.Gravity.CENTER_VERTICAL;
@ -366,8 +357,11 @@ public class FolderFragment extends Fragment
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(WRAP_CONTENT, dp(48, getActivity())); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(WRAP_CONTENT, dp(48, getActivity()));
// 72dp margin to align with dividers // 72dp margin to align with dividers
// 4dp additional margin to align with the rest of the items // 4dp additional margin to align with the rest of the items
setMarginStart(params, dp(72 + 4, getActivity())); int dividerInset = getResources().getDimensionPixelOffset(R.dimen.material_divider_inset);
setMarginEnd(params, dp(16 + 4, getActivity())); int contentInset = getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material);
int textPadding = dp(4, getActivity());
setMarginStart(params, dividerInset + textPadding);
setMarginEnd(params, contentInset + textPadding);
TextView emptyView = new TextView(mDevicesContainer.getContext()); TextView emptyView = new TextView(mDevicesContainer.getContext());
emptyView.setGravity(CENTER_VERTICAL); emptyView.setGravity(CENTER_VERTICAL);
emptyView.setText(R.string.devices_list_empty); emptyView.setText(R.string.devices_list_empty);

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android" <inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="72dp"> android:insetLeft="@dimen/material_divider_inset">
<shape> <shape>
<solid android:color="@color/divider" /> <solid android:color="@color/divider" />
<size android:height="1px" /> <size android:height="1px" />

View file

@ -80,9 +80,8 @@
android:id="@+id/versioningKeep" android:id="@+id/versioningKeep"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="16dp" android:layout_marginEnd="@dimen/abc_action_bar_content_inset_material"
android:layout_marginRight="16dp" android:layout_marginRight="@dimen/abc_action_bar_content_inset_material"
android:text="0"
android:textAppearance="@style/TextAppearance.AppCompat.Caption" android:textAppearance="@style/TextAppearance.AppCompat.Caption"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
</LinearLayout> </LinearLayout>

View file

@ -4,7 +4,7 @@
style="@style/Widget.Syncthing.TextView.Label.DeviceList" style="@style/Widget.Syncthing.TextView.Label.DeviceList"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_marginLeft="72dp" android:layout_marginLeft="@dimen/material_divider_inset"
android:layout_marginStart="72dp" android:layout_marginStart="@dimen/material_divider_inset"
android:textAppearance="@style/TextAppearance.AppCompat.Caption" android:textAppearance="@style/TextAppearance.AppCompat.Caption"
tools:ignore="RtlHardcoded,RtlSymmetry" /> tools:ignore="RtlHardcoded,RtlSymmetry" />

View file

@ -4,8 +4,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="8dp" android:paddingBottom="8dp"
android:paddingLeft="16dp" android:paddingLeft="@dimen/abc_action_bar_content_inset_material"
android:paddingRight="16dp" android:paddingRight="@dimen/abc_action_bar_content_inset_material"
android:paddingTop="8dp"> android:paddingTop="8dp">
<TextView <TextView

View file

@ -4,8 +4,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="8dp" android:paddingBottom="8dp"
android:paddingLeft="16dp" android:paddingLeft="@dimen/abc_action_bar_content_inset_material"
android:paddingRight="16dp" android:paddingRight="@dimen/abc_action_bar_content_inset_material"
android:paddingTop="8dp"> android:paddingTop="8dp">
<TextView <TextView

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="material_divider_inset">80dp</dimen>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="material_divider_inset">72dp</dimen>
</resources>

View file

@ -22,8 +22,8 @@
<item name="android:gravity">start|center_vertical</item> <item name="android:gravity">start|center_vertical</item>
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Body1</item> <item name="android:textAppearance">@style/TextAppearance.AppCompat.Body1</item>
<item name="android:textColor">?attr/editTextColor</item> <item name="android:textColor">?attr/editTextColor</item>
<item name="android:paddingLeft">16dp</item> <item name="android:paddingLeft">@dimen/abc_action_bar_content_inset_material</item>
<item name="android:paddingRight">16dp</item> <item name="android:paddingRight">@dimen/abc_action_bar_content_inset_material</item>
</style> </style>
<style name="Widget.Syncthing.TextView.Label.DeviceList"> <style name="Widget.Syncthing.TextView.Label.DeviceList">