Move settings to the nav drawer

filtering
Floens 10 years ago
parent be981a359c
commit 40f9d3acec
  1. 48
      Clover/app/src/main/java/org/floens/chan/ui/adapter/PinAdapter.java
  2. 6
      Clover/app/src/main/java/org/floens/chan/ui/controller/BrowseController.java
  3. 5
      Clover/app/src/main/java/org/floens/chan/ui/controller/RootNavigationController.java
  4. 32
      Clover/app/src/main/res/layout/cell_divider.xml
  5. 2
      Clover/app/src/main/res/layout/cell_post.xml
  6. 3
      Clover/app/src/main/res/values/attrs.xml
  7. 5
      Clover/app/src/main/res/values/styles.xml

@ -37,14 +37,16 @@ import java.util.List;
import static org.floens.chan.utils.AndroidUtils.ROBOTO_MEDIUM;
import static org.floens.chan.utils.AndroidUtils.dp;
import static org.floens.chan.utils.AndroidUtils.getAttrColor;
import static org.floens.chan.utils.AndroidUtils.setRoundItemBackground;
public class PinAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements SwipeListener.Callback {
private static final int PIN_OFFSET = 1;
private static final int PIN_OFFSET = 4;
private static final int TYPE_HEADER = 0;
private static final int TYPE_PIN = 1;
private static final int TYPE_LINK = 2;
private static final int TYPE_DIVIDER = 3;
private final Callback callback;
private List<Pin> pins = new ArrayList<>();
@ -63,6 +65,8 @@ public class PinAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> im
return new PinViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_pin, parent, false));
case TYPE_LINK:
return new LinkHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_link, parent, false));
case TYPE_DIVIDER:
return new DividerHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_divider, parent, false));
}
return null;
}
@ -85,16 +89,15 @@ public class PinAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> im
case TYPE_LINK:
LinkHolder linkHolder = (LinkHolder) holder;
switch (position) {
case 0:
linkHolder.text.setText(R.string.drawer_board);
linkHolder.image.setImageResource(R.drawable.ic_view_list_24dp);
break;
case 1:
linkHolder.text.setText(R.string.drawer_catalog);
linkHolder.image.setImageResource(R.drawable.ic_view_module_24dp);
linkHolder.text.setText(R.string.settings_screen);
linkHolder.image.setImageResource(R.drawable.ic_settings_grey600_24dp);
break;
}
break;
case TYPE_DIVIDER:
((DividerHolder) holder).withBackground(position != 0);
break;
}
}
@ -116,10 +119,12 @@ public class PinAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> im
@Override
public int getItemViewType(int position) {
switch (position) {
/*case 0:
case 1:
return TYPE_LINK;*/
return TYPE_LINK;
case 0:
case 2:
return TYPE_DIVIDER;
case 3:
return TYPE_HEADER;
default:
return TYPE_PIN;
@ -303,12 +308,33 @@ public class PinAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> im
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
callback.openSettings();
}
});
}
}
public class DividerHolder extends RecyclerView.ViewHolder {
private boolean withBackground = false;
private View divider;
public DividerHolder(View itemView) {
super(itemView);
divider = itemView.findViewById(R.id.divider);
}
public void withBackground(boolean withBackground) {
if (withBackground != this.withBackground) {
this.withBackground = withBackground;
if (withBackground) {
divider.setBackgroundColor(getAttrColor(itemView.getContext(), R.attr.divider_color));
} else {
divider.setBackgroundColor(0);
}
}
}
}
public interface Callback {
void onPinClicked(Pin pin);
@ -317,5 +343,7 @@ public class PinAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> im
void onHeaderClicked(HeaderHolder holder);
boolean isHighlighted(Pin pin);
void openSettings();
}
}

@ -47,7 +47,6 @@ public class BrowseController extends ThreadController implements ToolbarMenuIte
private static final int POST_ID = 2;
private static final int SEARCH_ID = 101;
private static final int SHARE_ID = 102;
private static final int SETTINGS_ID = 103;
private List<FloatingMenuItem> boardItems;
@ -76,7 +75,6 @@ public class BrowseController extends ThreadController implements ToolbarMenuIte
List<FloatingMenuItem> items = new ArrayList<>();
items.add(new FloatingMenuItem(SEARCH_ID, context.getString(R.string.action_search)));
items.add(new FloatingMenuItem(SHARE_ID, context.getString(R.string.action_share)));
items.add(new FloatingMenuItem(SETTINGS_ID, context.getString(R.string.settings_screen)));
overflow.setSubMenu(new FloatingMenu(context, overflow.getView(), items));
}
@ -103,10 +101,6 @@ public class BrowseController extends ThreadController implements ToolbarMenuIte
String link = ChanUrls.getCatalogUrlDesktop(threadLayout.getPresenter().getLoadable().board);
AndroidUtils.shareLink(link);
break;
case SETTINGS_ID:
MainSettingsController mainSettingsController = new MainSettingsController(context);
navigationController.pushController(mainSettingsController);
break;
}
}

@ -170,6 +170,11 @@ public class RootNavigationController extends NavigationController implements Pi
pushController(new WatchSettingsController(context));
}
@Override
public void openSettings() {
pushController(new MainSettingsController(context));
}
public void onEvent(WatchManager.PinAddedMessage message) {
pinAdapter.onPinAdded(message.pin);
drawerLayout.openDrawer(drawer);

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?><!--
Clover - 4chan browser https://github.com/Floens/Clover/
Copyright (C) 2014 Floens
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="7dp" />
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp" />
</LinearLayout>

@ -72,7 +72,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="?attr/post_divider_color" />
android:background="?attr/divider_color" />
<ImageView
android:id="@+id/options"

@ -36,9 +36,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<attr name="post_id_background_light" format="color" />
<attr name="post_id_background_dark" format="color" />
<attr name="post_inline_quote_color" format="color" />
<attr name="post_divider_color" format="color" />
<attr name="post_options_drawable" format="integer" />
<attr name="divider_color" format="color" />
<attr name="dropdown_light_color" format="color" />
<attr name="dropdown_light_pressed_color" format="color" />
<attr name="dropdown_dark_color" format="color" />

@ -51,9 +51,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<item name="post_id_background_light">#ff636363</item>
<item name="post_id_background_dark">#00000000</item>
<item name="post_inline_quote_color">#ff789922</item>
<item name="post_divider_color">#1E000000</item>
<item name="post_options_drawable">@drawable/ic_overflow</item>
<item name="divider_color">#1e000000</item>
<item name="dropdown_light_color">#ffffffff</item>
<item name="dropdown_light_pressed_color">#88ffffff</item>
<item name="dropdown_dark_color">#ff757575</item>
@ -63,6 +64,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<style name="Chan.Theme.Dark">
<item name="backcolor">#ff232323</item>
<item name="divider_color">#1effffff</item>
<item name="post_saved_reply_color">#ff5C5C5C</item>
<item name="post_highlighted_color">#ff444444</item>
<item name="post_subject_color">#ff625cff</item>

Loading…
Cancel
Save