UI redisign
This commit is contained in:
parent
072e27ed27
commit
8d6d18e875
|
@ -11,6 +11,7 @@ import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.preference.PreferenceManager;
|
import android.support.v7.preference.PreferenceManager;
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
|
@ -18,6 +19,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
@ -176,11 +178,13 @@ public class ContentSettingsMain extends Fragment {
|
||||||
|
|
||||||
TextView text;
|
TextView text;
|
||||||
View view;
|
View view;
|
||||||
|
CardView cardView;
|
||||||
|
|
||||||
public TabViewHolder(View itemView) {
|
public TabViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
text = itemView.findViewById(R.id.tabName);
|
text = itemView.findViewById(R.id.tabName);
|
||||||
|
cardView = itemView.findViewById(R.id.layoutCard);
|
||||||
view = itemView;
|
view = itemView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -50,7 +51,6 @@ public class ContentSettingsMainDialog extends DialogFragment {
|
||||||
allTabs.setLayoutManager(new LinearLayoutManager(getContext()));
|
allTabs.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
allAdapter = new AllAdapter();
|
allAdapter = new AllAdapter();
|
||||||
allTabs.setAdapter(allAdapter);
|
allTabs.setAdapter(allAdapter);
|
||||||
allTabs.addItemDecoration(new DividerItemDecoration(getActivity()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tabNames() {
|
private void tabNames() {
|
||||||
|
@ -107,11 +107,12 @@ public class ContentSettingsMainDialog extends DialogFragment {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
text = itemView.findViewById(R.id.tabName);
|
text = itemView.findViewById(R.id.tabName);
|
||||||
view = itemView.findViewById(R.id.layout);
|
view = itemView.findViewById(R.id.layoutCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bind(int position) {
|
void bind(int position) {
|
||||||
text.setText(allTabs[position]);
|
text.setText(allTabs[position]);
|
||||||
|
((CardView) view).setCardElevation(0);
|
||||||
view.setOnClickListener(v -> {
|
view.setOnClickListener(v -> {
|
||||||
addTab(position);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/relLay"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
@ -8,6 +9,8 @@
|
||||||
android:id="@+id/usedTabs"
|
android:id="@+id/usedTabs"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_margin="0dp" />
|
android:layout_margin="0dp"
|
||||||
|
android:paddingBottom="0dp"
|
||||||
|
android:paddingTop="0dp" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -9,14 +9,14 @@
|
||||||
android:id="@+id/titleTextView"
|
android:id="@+id/titleTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/tab_chose"
|
android:layout_marginBottom="10dp"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:layout_marginEnd="5dp"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="19dp"
|
||||||
|
android:layout_marginRight="19dp"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginRight="5dp"
|
android:text="@string/tab_chose"
|
||||||
android:layout_marginEnd="5dp"
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
android:layout_marginBottom="10dp"/>
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/allTabs"
|
android:id="@+id/allTabs"
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v7.widget.CardView 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:id="@+id/layout"
|
android:id="@+id/layoutCard"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="0dp"
|
||||||
android:layout_marginTop="1dp"
|
android:layout_marginTop="1dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
@ -15,10 +16,11 @@
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:paddingBottom="6dp"
|
android:paddingBottom="9dp"
|
||||||
android:paddingLeft="3dp"
|
android:paddingLeft="19dp"
|
||||||
|
android:paddingRight="19dp"
|
||||||
android:paddingStart="3dp"
|
android:paddingStart="3dp"
|
||||||
android:paddingTop="6dp"
|
android:paddingTop="9dp"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue