Commit 9549d2aa authored by Tiago Cunha's avatar Tiago Cunha Committed by Yusuke Iwaki

Added a burger menu

Uses black color (easy to tint later)
Fixes tinting in the message action selector
parent da2386e7
......@@ -3,7 +3,9 @@ package chat.rocket.android.activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v4.widget.SlidingPaneLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.View;
......@@ -43,6 +45,7 @@ public class MainActivity extends AbstractAuthedActivity {
setContentView(R.layout.activity_main);
statusTicker = new StatusTicker();
setupToolbar();
setupSidebar();
if (roomId == null) {
showFragment(new HomeFragment());
......@@ -91,7 +94,10 @@ public class MainActivity extends AbstractAuthedActivity {
private void setupSidebar() {
SlidingPaneLayout pane = (SlidingPaneLayout) findViewById(R.id.sliding_pane);
if (pane != null) {
if (pane == null) {
return;
}
final SlidingPaneLayout subPane = (SlidingPaneLayout) findViewById(R.id.sub_sliding_pane);
pane.setPanelSlideListener(new SlidingPaneLayout.SimplePanelSlideListener() {
@Override
......@@ -110,6 +116,26 @@ public class MainActivity extends AbstractAuthedActivity {
}
});
}
private void setupToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar == null) {
return;
}
actionBar.setDisplayShowTitleEnabled(false);
if (findViewById(R.id.sliding_pane) == null) {
return;
}
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(
VectorDrawableCompat.create(getResources(), R.drawable.ic_menu_black_24dp, null));
}
private boolean closeSidebarIfNeeded() {
......
package chat.rocket.android.fragment.chatroom;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.support.annotation.StringRes;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import chat.rocket.android.R;
import chat.rocket.android.fragment.AbstractFragment;
abstract class AbstractChatRoomFragment extends AbstractFragment {
protected Toolbar activityToolbar;
private static final String TABLET = "tablet";
private TextView toolbarTitle;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
activityToolbar = (Toolbar) getActivity().findViewById(R.id.activity_main_toolbar);
toolbarTitle = (TextView) getActivity().findViewById(R.id.toolbar_title);
return super.onCreateView(inflater, container, savedInstanceState);
}
protected void setTitleText(@StringRes int stringResId) {
if (toolbarTitle == null) {
return;
}
toolbarTitle.setText(stringResId);
}
protected void setTitleText(CharSequence title) {
if (toolbarTitle == null) {
return;
}
toolbarTitle.setText(title);
}
protected void setTitleDrawableLeft(@DrawableRes int drawableResId) {
if (toolbarTitle == null) {
return;
}
Drawable drawable = drawableResId > 0
? VectorDrawableCompat.create(getResources(), drawableResId, null)
: null;
if (drawable != null && TABLET.equals(toolbarTitle.getTag())) {
DrawableCompat.setTint(drawable, Color.WHITE);
}
toolbarTitle.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
}
}
......@@ -13,13 +13,13 @@ public class HomeFragment extends AbstractChatRoomFragment {
@Override
protected void onSetupView() {
activityToolbar.setTitle(R.string.home_fragment_title);
setTitleText(R.string.home_fragment_title);
}
@Override
public void onResume() {
super.onResume();
activityToolbar.setNavigationIcon(null);
activityToolbar.setTitle(R.string.home_fragment_title);
setTitleDrawableLeft(0);
setTitleText(R.string.home_fragment_title);
}
}
......@@ -266,15 +266,15 @@ public class RoomFragment extends AbstractChatRoomFragment
String type = roomSubscription.getType();
if (RoomSubscription.TYPE_CHANNEL.equals(type)) {
activityToolbar.setNavigationIcon(R.drawable.ic_hashtag_gray_24dp);
setTitleDrawableLeft(R.drawable.ic_hashtag_gray_24dp);
} else if (RoomSubscription.TYPE_PRIVATE.equals(type)) {
activityToolbar.setNavigationIcon(R.drawable.ic_lock_gray_24dp);
setTitleDrawableLeft(R.drawable.ic_lock_gray_24dp);
} else if (RoomSubscription.TYPE_DIRECT_MESSAGE.equals(type)) {
activityToolbar.setNavigationIcon(R.drawable.ic_at_gray_24dp);
setTitleDrawableLeft(R.drawable.ic_at_gray_24dp);
} else {
activityToolbar.setNavigationIcon(null);
setTitleDrawableLeft(0);
}
activityToolbar.setTitle(roomSubscription.getName());
setTitleText(roomSubscription.getName());
}
private void onUpdateLoadMessageProcedure(LoadMessageProcedure procedure) {
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"
android:fillColor="#000000"/>
</vector>
......@@ -15,11 +15,22 @@
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/activity_main_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:title="@string/app_name" />
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:drawablePadding="@dimen/margin_8"
android:tag="tablet"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout
......
......@@ -20,14 +20,25 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:titleTextColor="@color/titleTextColor"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:title="@string/app_name" />
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<View android:layout_width="match_parent"
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="@color/titleTextColor"
android:drawablePadding="@dimen/margin_8"
android:tag="phone"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" />
</android.support.v7.widget.Toolbar>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/button_menu"
android:background="@color/borderColor"/>
android:background="@color/borderColor" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment