1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-23 18:36:50 +01:00

Apply some Material design guidelines to the app management

- replace the PagerTabStrip with a TabLayout (moved to top)
- change the row element to adhere to the guidelines wrt spacing
- move the FAB a bit and hide it when scrolling down, scroll up to reveal it again
This commit is contained in:
Daniele Gobbetti 2017-04-01 17:06:38 +02:00
parent db4e37d08b
commit 9a0439c6e0
4 changed files with 46 additions and 24 deletions

View File

@ -24,6 +24,7 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.widget.LinearLayoutManager;
@ -259,9 +260,21 @@ public abstract class AbstractAppManagerFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final FloatingActionButton appListFab = ((FloatingActionButton) getActivity().findViewById(R.id.fab));
View rootView = inflater.inflate(R.layout.activity_appmanager, container, false);
RecyclerView appListView = (RecyclerView) (rootView.findViewById(R.id.appListView));
appListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dy > 0) {
appListFab.hide();
} else if (dy < 0) {
appListFab.show();
}
}
});
appListView.setLayoutManager(new LinearLayoutManager(getActivity()));
mGBDeviceAppAdapter = new GBDeviceAppAdapter(appList, R.layout.item_with_details_and_drag_handle, this);
appListView.setAdapter(mGBDeviceAppAdapter);

View File

@ -5,7 +5,10 @@
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AbstractAppManagerFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/appListView"
android:layout_width="match_parent"
android:layout_height="fill_parent" />
android:id="@+id/appListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:divider="@null" />
</RelativeLayout>

View File

@ -3,10 +3,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="0px"
android:paddingLeft="0px"
android:paddingRight="0px"
android:paddingTop="0px"
tools:context=".activities.appmanager.AppManagerActivity">
<LinearLayout
@ -21,11 +17,11 @@
android:layout_height="match_parent"
tools:context=".activities.appmanager.AppManagerActivity">
<android.support.v4.view.PagerTabStrip
<android.support.design.widget.TabLayout
android:id="@+id/charts_pagerTabStrip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
android:layout_gravity="top" />
</android.support.v4.view.ViewPager>
</LinearLayout>
@ -39,7 +35,7 @@
android:src="@drawable/ic_add_white"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp" />
android:layout_marginBottom="30dp"
android:layout_marginEnd="10dp" />
</android.widget.RelativeLayout>

View File

@ -4,50 +4,60 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:padding="8dp">
android:minHeight="60dp">
<ImageView
android:id="@+id/item_image"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentStart="true"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_centerVertical="true"
android:contentDescription="@string/candidate_item_device_image" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="@+id/item_image"
android:layout_toStartOf="@+id/drag_handle"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingEnd="8dp">
android:paddingBottom="8dp"
android:paddingTop="8dp">
<TextView
android:id="@+id/item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:scrollHorizontally="false"
style="@style/Base.TextAppearance.AppCompat.SearchResult.Title"
android:text="Item Name"
android:maxLines="1" />
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
<TextView
android:id="@+id/item_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Base.TextAppearance.AppCompat.SearchResult"
android:text="Item Description" />
android:text="Item Description"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
</LinearLayout>
<ImageView
android:id="@+id/drag_handle"
android:tint="@color/secondarytext"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:layout_centerVertical="true"
android:contentDescription="drag handle"
android:tint="@color/secondarytext"
app:srcCompat="@drawable/ic_drag_handle_black_24dp" />
</RelativeLayout>