From 8d6d18e8758586028dc717a5a6d23a1d45d02b83 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Sun, 17 Jun 2018 23:29:28 +0200 Subject: [PATCH] UI redisign --- .../newpipe/settings/ContentSettingsMain.java | 4 ++ .../settings/ContentSettingsMainDialog.java | 38 ++----------------- .../res/layout/dialog_contentsettings.xml | 5 ++- .../res/layout/dialog_contentsettingsadd.xml | 12 +++--- .../res/layout/dialog_contentsettingtab.xml | 10 +++-- 5 files changed, 23 insertions(+), 46 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMain.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMain.java index cd18e8c42..cccfffc81 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMain.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMain.java @@ -11,6 +11,7 @@ import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v7.app.AppCompatActivity; import android.support.v7.preference.PreferenceManager; +import android.support.v7.widget.CardView; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; @@ -18,6 +19,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.FrameLayout; import android.widget.TextView; import org.schabi.newpipe.R; @@ -176,11 +178,13 @@ public class ContentSettingsMain extends Fragment { TextView text; View view; + CardView cardView; public TabViewHolder(View itemView) { super(itemView); text = itemView.findViewById(R.id.tabName); + cardView = itemView.findViewById(R.id.layoutCard); view = itemView; } diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMainDialog.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMainDialog.java index aae4b4898..4da1c1c33 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMainDialog.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMainDialog.java @@ -11,6 +11,7 @@ import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; +import android.support.v7.widget.CardView; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -50,7 +51,6 @@ public class ContentSettingsMainDialog extends DialogFragment { allTabs.setLayoutManager(new LinearLayoutManager(getContext())); allAdapter = new AllAdapter(); allTabs.setAdapter(allAdapter); - allTabs.addItemDecoration(new DividerItemDecoration(getActivity())); } private void tabNames() { @@ -107,11 +107,12 @@ public class ContentSettingsMainDialog extends DialogFragment { super(itemView); text = itemView.findViewById(R.id.tabName); - view = itemView.findViewById(R.id.layout); + view = itemView.findViewById(R.id.layoutCard); } void bind(int position) { text.setText(allTabs[position]); + ((CardView) view).setCardElevation(0); view.setOnClickListener(v -> { addTab(position); }); @@ -119,37 +120,4 @@ public class ContentSettingsMainDialog extends DialogFragment { } } } - - public class DividerItemDecoration extends RecyclerView.ItemDecoration { - - private final int[] ATTRS = new int[]{android.R.attr.listDivider}; - - private Drawable divider; - - public DividerItemDecoration(Context context) { - final TypedArray styledAttributes = context.obtainStyledAttributes(ATTRS); - divider = styledAttributes.getDrawable(0); - styledAttributes.recycle(); - } - - - @Override - public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { - int left = parent.getPaddingLeft(); - int right = parent.getWidth() - parent.getPaddingRight(); - - int childCount = parent.getChildCount(); - for (int i = 0; i < childCount; i++) { - View child = parent.getChildAt(i); - - RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); - - int top = child.getBottom() + params.bottomMargin; - int bottom = top + divider.getIntrinsicHeight(); - - divider.setBounds(left, top, right, bottom); - divider.draw(c); - } - } - } } diff --git a/app/src/main/res/layout/dialog_contentsettings.xml b/app/src/main/res/layout/dialog_contentsettings.xml index 6b6bfc023..37e035e79 100644 --- a/app/src/main/res/layout/dialog_contentsettings.xml +++ b/app/src/main/res/layout/dialog_contentsettings.xml @@ -1,5 +1,6 @@ @@ -8,6 +9,8 @@ android:id="@+id/usedTabs" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_margin="0dp" /> + android:layout_margin="0dp" + android:paddingBottom="0dp" + android:paddingTop="0dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_contentsettingsadd.xml b/app/src/main/res/layout/dialog_contentsettingsadd.xml index fd5365522..e9ad235fa 100644 --- a/app/src/main/res/layout/dialog_contentsettingsadd.xml +++ b/app/src/main/res/layout/dialog_contentsettingsadd.xml @@ -9,14 +9,14 @@ android:id="@+id/titleTextView" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/tab_chose" - android:textAppearance="?android:attr/textAppearanceLarge" - android:layout_marginLeft="10dp" + android:layout_marginBottom="10dp" + android:layout_marginEnd="5dp" + android:layout_marginLeft="19dp" + android:layout_marginRight="19dp" android:layout_marginStart="10dp" android:layout_marginTop="5dp" - android:layout_marginRight="5dp" - android:layout_marginEnd="5dp" - android:layout_marginBottom="10dp"/> + android:text="@string/tab_chose" + android:textAppearance="?android:attr/textAppearanceLarge" /> @@ -15,10 +16,11 @@ android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_centerVertical="true" - android:paddingBottom="6dp" - android:paddingLeft="3dp" + android:paddingBottom="9dp" + android:paddingLeft="19dp" + android:paddingRight="19dp" android:paddingStart="3dp" - android:paddingTop="6dp" + android:paddingTop="9dp" android:textAppearance="?android:attr/textAppearanceListItem" android:textSize="16sp" />