From 36cba023af746a6c2da16bf687b08769f31c3ef5 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 31 Jul 2018 11:12:09 +0200 Subject: [PATCH] Added backward button on conversation fragment. --- .../android/comunic/client/ui/activities/MainActivity.java | 6 ++++++ .../comunic/client/ui/fragments/ConversationFragment.java | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java index abce3f4..25160f9 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java @@ -188,6 +188,12 @@ public class MainActivity extends AppCompatActivity implements openConversationL //Get action id int id = item.getItemId(); + //To go backward + if(id == android.R.id.home){ + getSupportFragmentManager().popBackStack(); + return true; + } + //To search a user if(id == R.id.action_search_user){ searchUser(); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java index 963ab29..3f142ed 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java @@ -13,6 +13,7 @@ import android.util.ArrayMap; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; @@ -305,6 +306,8 @@ public class ConversationFragment extends Fragment ((MainActivity) getActivity()) .setSelectedNavigationItem(R.id.main_bottom_navigation_conversations); + ((MainActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); + //Check for conversation information if(conversationInfo == null){ @@ -333,6 +336,8 @@ public class ConversationFragment extends Fragment super.onPause(); refreshRunnable.quitSafely(); + + ((MainActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false); } @Override