Commit f138d486 authored by Tiago Cunha's avatar Tiago Cunha

PR based feedback

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