Commit f138d486 authored by Tiago Cunha's avatar Tiago Cunha

PR based feedback

parent 853b8c8f
......@@ -10,41 +10,41 @@ import android.view.ViewGroup;
import chat.rocket.android.R;
import chat.rocket.android.fragment.AbstractFragment;
import chat.rocket.android.widget.CustomToolbar;
import chat.rocket.android.widget.RoomToolbar;
abstract class AbstractChatRoomFragment extends AbstractFragment {
private CustomToolbar customToolbar;
private RoomToolbar roomToolbar;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
customToolbar = (CustomToolbar) getActivity().findViewById(R.id.activity_main_toolbar);
roomToolbar = (RoomToolbar) getActivity().findViewById(R.id.activity_main_toolbar);
return super.onCreateView(inflater, container, savedInstanceState);
}
protected void setTitleText(@StringRes int stringResId) {
if (customToolbar == null) {
if (roomToolbar == null) {
return;
}
customToolbar.setTitle(stringResId);
roomToolbar.setTitle(stringResId);
}
protected void setTitleText(CharSequence title) {
if (customToolbar == null) {
if (roomToolbar == null) {
return;
}
customToolbar.setTitle(title);
roomToolbar.setTitle(title);
}
protected void setTitleDrawableLeft(@DrawableRes int drawableResId) {
if (customToolbar == null) {
if (roomToolbar == null) {
return;
}
customToolbar.setTitleDrawableLeft(drawableResId);
roomToolbar.setRoomIcon(drawableResId);
}
}
......@@ -14,13 +14,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<chat.rocket.android.widget.CustomToolbar
<chat.rocket.android.widget.RoomToolbar
android:id="@+id/activity_main_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleText="@string/app_name"
app:titleTextColor="@color/titleTextColor"
app:titleDrawablePadding="@dimen/margin_8" />
</android.support.design.widget.AppBarLayout>
......
......@@ -15,7 +15,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<chat.rocket.android.widget.CustomToolbar
<chat.rocket.android.widget.RoomToolbar
android:id="@+id/activity_main_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
......@@ -13,27 +13,27 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
public class CustomToolbar extends Toolbar {
public class RoomToolbar extends Toolbar {
private TextView titleTextView;
public CustomToolbar(Context context) {
public RoomToolbar(Context context) {
super(context);
initialize(context, null);
}
public CustomToolbar(Context context, @Nullable AttributeSet attrs) {
public RoomToolbar(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs);
}
public CustomToolbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
public RoomToolbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context, attrs);
}
private void initialize(Context context, @Nullable AttributeSet attrs) {
View.inflate(context, R.layout.custom_toolbar, this);
View.inflate(context, R.layout.room_toolbar, this);
titleTextView = (TextView) findViewById(R.id.toolbar_title);
......@@ -43,15 +43,15 @@ public class CustomToolbar extends Toolbar {
TypedArray typedArray = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.CustomToolbar,
R.styleable.RoomToolbar,
0, 0);
try {
titleTextView.setText(typedArray.getText(R.styleable.CustomToolbar_titleText));
titleTextView.setText(typedArray.getText(R.styleable.RoomToolbar_titleText));
titleTextView
.setTextColor(typedArray.getColor(R.styleable.CustomToolbar_titleTextColor, Color.BLACK));
.setTextColor(typedArray.getColor(R.styleable.RoomToolbar_titleTextColor, Color.BLACK));
titleTextView.setCompoundDrawablePadding(
typedArray.getLayoutDimension(R.styleable.CustomToolbar_titleDrawablePadding, 0));
typedArray.getLayoutDimension(R.styleable.RoomToolbar_titleDrawablePadding, 0));
} finally {
typedArray.recycle();
}
......@@ -75,7 +75,7 @@ public class CustomToolbar extends Toolbar {
super.setTitle(title);
}
public void setTitleDrawableLeft(@DrawableRes int drawableResId) {
public void setRoomIcon(@DrawableRes int drawableResId) {
if (titleTextView == null) {
return;
}
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CustomToolbar">
<declare-styleable name="RoomToolbar">
<attr name="titleText" format="string" />
<attr name="titleTextColor" format="color" />
<attr name="titleDrawablePadding" format="dimension" />
......
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