From be8c904593d72d111058980104ad71667baff68b Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 22 Aug 2018 10:46:13 +0200 Subject: [PATCH] Added bar on update conversation fragment --- .../fragments/UpdateConversationFragment.java | 19 ++++++++++++++++--- .../comunic/client/ui/views/AppBarLayout.java | 11 ++++++++++- .../layout/fragment_update_conversation.xml | 7 ++++++- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UpdateConversationFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UpdateConversationFragment.java index 929e252..24cfc8f 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UpdateConversationFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UpdateConversationFragment.java @@ -33,6 +33,7 @@ import org.communiquons.android.comunic.client.ui.adapters.UsersAsysncInfoAdapte import org.communiquons.android.comunic.client.data.models.ConversationsInfo; import org.communiquons.android.comunic.client.data.helpers.ConversationsListHelper; import org.communiquons.android.comunic.client.ui.listeners.openConversationListener; +import org.communiquons.android.comunic.client.ui.views.AppBarLayout; import java.util.ArrayList; @@ -85,6 +86,11 @@ public class UpdateConversationFragment extends Fragment { */ private boolean conversation_owner = true; + /** + * Application bar + */ + private AppBarLayout mAppBar; + /** * The name of the conversation */ @@ -193,6 +199,7 @@ public class UpdateConversationFragment extends Fragment { super.onViewCreated(view, savedInstanceState); //Get the views + mAppBar = view.findViewById(R.id.appbar); progressBar = view.findViewById(R.id.progress_bar); nameView = view.findViewById(R.id.fragment_update_conversation_name); followCheckbox = view.findViewById(R.id.fragment_update_conversation_follow); @@ -222,7 +229,13 @@ public class UpdateConversationFragment extends Fragment { //Set members list context menu membersList.setOnCreateContextMenuListener(membersListContext); - + //Add back buttn + mAppBar.addBackButton(new View.OnClickListener() { + @Override + public void onClick(View v) { + MainActivity.goBackward(getActivity()); + } + }); } @@ -232,9 +245,9 @@ public class UpdateConversationFragment extends Fragment { //Set the adapted title if(current_action == ACTION_CREATE_CONVERSATION) - getActivity().setTitle(R.string.fragment_update_conversation_title_create); + mAppBar.setTitle(R.string.fragment_update_conversation_title_create); else - getActivity().setTitle(R.string.fragment_update_conversation_title_update); + mAppBar.setTitle(R.string.fragment_update_conversation_title_update); MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_conversations); } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/views/AppBarLayout.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/views/AppBarLayout.java index 40ba407..6064ce8 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/views/AppBarLayout.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/views/AppBarLayout.java @@ -45,6 +45,15 @@ public class AppBarLayout extends BaseFrameLayoutView { return mToolbar; } + /** + * Update (set) the title of the conversatoin + * + * @param resId The ID of the target ressource + */ + public void setTitle(int resId){ + setTitle(UiUtils.getString(getContext(), resId)); + } + /** * Update the title of the appbar * @@ -81,7 +90,7 @@ public class AppBarLayout extends BaseFrameLayoutView { AppCompatImageButton btn = new AppCompatImageButton(getActivity(), null, android.support.v7.appcompat.R.attr.toolbarStyle); - btn.setPadding(5, 0, 5, 0); + btn.setPadding(10, 0, 10, 0); btn.setImageDrawable(drawable); btn.setOnClickListener(listener); getToolbar().addView(btn); diff --git a/app/src/main/res/layout/fragment_update_conversation.xml b/app/src/main/res/layout/fragment_update_conversation.xml index 279b610..287abf8 100644 --- a/app/src/main/res/layout/fragment_update_conversation.xml +++ b/app/src/main/res/layout/fragment_update_conversation.xml @@ -3,7 +3,12 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - + + +