+ New Tab is now on the bottom
Made dialog more beautiful
This commit is contained in:
parent
33f5ed5b14
commit
6d64215614
|
@ -57,7 +57,6 @@ public class ContentSettingsMain extends Fragment {
|
||||||
|
|
||||||
tabNames();
|
tabNames();
|
||||||
initUsedTabs();
|
initUsedTabs();
|
||||||
initAddButton(rootView);
|
|
||||||
|
|
||||||
usedTabsView = rootView.findViewById(R.id.usedTabs);
|
usedTabsView = rootView.findViewById(R.id.usedTabs);
|
||||||
usedTabsView.setLayoutManager(new LinearLayoutManager(getContext()));
|
usedTabsView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
@ -80,7 +79,6 @@ public class ContentSettingsMain extends Fragment {
|
||||||
save.append("\n");
|
save.append("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveString = save.toString();
|
saveString = save.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,18 +98,6 @@ public class ContentSettingsMain extends Fragment {
|
||||||
usedTabs.addAll(Arrays.asList(tabs));
|
usedTabs.addAll(Arrays.asList(tabs));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initAddButton(View rootView) {
|
|
||||||
Button addButton = rootView.findViewById(R.id.buttonAdd);
|
|
||||||
addButton.setBackgroundResource(ThemeHelper.getIconByAttr(R.attr.ic_add, getActivity()));
|
|
||||||
addButton.setOnClickListener(v -> {
|
|
||||||
ContentSettingsMainDialog contentSettingsMainDialog = new ContentSettingsMainDialog();
|
|
||||||
contentSettingsMainDialog.setOnAddListener((int position) -> {
|
|
||||||
addTab(position);
|
|
||||||
});
|
|
||||||
contentSettingsMainDialog.show(getFragmentManager(), "select_channel");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tabNames() {
|
private void tabNames() {
|
||||||
allTabs[0] = getString(R.string.blank_page_summary);
|
allTabs[0] = getString(R.string.blank_page_summary);
|
||||||
allTabs[1] = getString(R.string.kiosk_page_summary);
|
allTabs[1] = getString(R.string.kiosk_page_summary);
|
||||||
|
@ -143,6 +129,10 @@ public class ContentSettingsMain extends Fragment {
|
||||||
// ... code from gist
|
// ... code from gist
|
||||||
@Override
|
@Override
|
||||||
public void onItemDismiss(int position) {
|
public void onItemDismiss(int position) {
|
||||||
|
if(position==getItemCount() - 1) {
|
||||||
|
notifyDataSetChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
usedTabs.remove(position);
|
usedTabs.remove(position);
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
saveChanges();
|
saveChanges();
|
||||||
|
@ -150,6 +140,7 @@ public class ContentSettingsMain extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemMove(int fromPosition, int toPosition) {
|
public void onItemMove(int fromPosition, int toPosition) {
|
||||||
|
if(fromPosition==getItemCount() - 1 || toPosition==getItemCount() - 1) return;
|
||||||
if (fromPosition < toPosition) {
|
if (fromPosition < toPosition) {
|
||||||
for (int i = fromPosition; i < toPosition; i++) {
|
for (int i = fromPosition; i < toPosition; i++) {
|
||||||
Collections.swap(usedTabs, i, i + 1);
|
Collections.swap(usedTabs, i, i + 1);
|
||||||
|
@ -178,21 +169,31 @@ public class ContentSettingsMain extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return usedTabs.size();
|
return usedTabs.size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TabViewHolder extends RecyclerView.ViewHolder {
|
class TabViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
TextView text;
|
TextView text;
|
||||||
|
View view;
|
||||||
|
|
||||||
public TabViewHolder(View itemView) {
|
public TabViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
text = itemView.findViewById(R.id.tabName);
|
text = itemView.findViewById(R.id.tabName);
|
||||||
|
view = itemView;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bind(int position) {
|
void bind(int position) {
|
||||||
if(usedTabs.get(position).startsWith("6\t")) {
|
if(position == getItemCount() - 1) {
|
||||||
|
String newTabString = "+ " + getString(R.string.tab_new);
|
||||||
|
text.setText(newTabString);
|
||||||
|
view.setOnClickListener(v -> {
|
||||||
|
ContentSettingsMainDialog contentSettingsMainDialog = new ContentSettingsMainDialog();
|
||||||
|
contentSettingsMainDialog.setOnAddListener(ContentSettingsMain.this::addTab);
|
||||||
|
contentSettingsMainDialog.show(getFragmentManager(), "select_channel");
|
||||||
|
});
|
||||||
|
} else if(usedTabs.get(position).startsWith("6\t")) {
|
||||||
String channelInfo[] = usedTabs.get(position).split("\t");
|
String channelInfo[] = usedTabs.get(position).split("\t");
|
||||||
String channelName = "";
|
String channelName = "";
|
||||||
if(channelInfo.length==4) channelName = channelInfo[2];
|
if(channelInfo.length==4) channelName = channelInfo[2];
|
||||||
|
@ -273,6 +274,7 @@ public class ContentSettingsMain extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
||||||
mAdapter.onItemDismiss(viewHolder.getAdapterPosition());
|
mAdapter.onItemDismiss(viewHolder.getAdapterPosition());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,50 +4,10 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<android.support.v7.widget.RecyclerView
|
||||||
|
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_alignParentTop="true"
|
android:layout_margin="0dp" />
|
||||||
android:layout_margin="2dp"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/topBar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:paddingBottom="3dp"
|
|
||||||
android:paddingTop="3dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/secondText"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingLeft="3dp"
|
|
||||||
android:text="@string/chosenTabs"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/buttonAdd"
|
|
||||||
android:layout_width="25dp"
|
|
||||||
android:layout_height="25dp"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:background="@color/transparent_background_color"
|
|
||||||
android:paddingBottom="5dp"
|
|
||||||
android:paddingLeft="5dp"
|
|
||||||
android:paddingRight="15dp"
|
|
||||||
android:paddingTop="5dp" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
|
||||||
android:id="@+id/usedTabs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_margin="0dp" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -2,12 +2,27 @@
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:padding="13dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
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_marginStart="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:layout_marginBottom="10dp"/>
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/allTabs"
|
android:id="@+id/allTabs"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="0dp" />
|
android:layout_below="@+id/titleTextView"
|
||||||
|
android:layout_centerHorizontal="true" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?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"
|
||||||
android:id="@+id/layout"
|
android:id="@+id/layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
<string name="tab_main">Main</string>
|
<string name="tab_main">Main</string>
|
||||||
<string name="tab_subscriptions">Subscriptions</string>
|
<string name="tab_subscriptions">Subscriptions</string>
|
||||||
<string name="tab_bookmarks">Bookmarks</string>
|
<string name="tab_bookmarks">Bookmarks</string>
|
||||||
|
<string name="tab_new">New Tab</string>
|
||||||
|
<string name="tab_chose">Chose Tab</string>
|
||||||
|
|
||||||
<string name="fragment_whats_new">What\'s New</string>
|
<string name="fragment_whats_new">What\'s New</string>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue