mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-12-28 14:39:00 +00:00
Added toolbar in conversation fragment.
This commit is contained in:
parent
f635506985
commit
94f8ecf746
@ -355,6 +355,19 @@ public class MainActivity extends AppCompatActivity implements
|
||||
.create().show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Go backward in the application
|
||||
*
|
||||
* @param activity Activity object
|
||||
*/
|
||||
public static void goBackward(@NonNull Activity activity){
|
||||
if(!(activity instanceof MainActivity))
|
||||
throw new RuntimeException("Called goBackward using an Activity different " +
|
||||
"from MainActivity!");
|
||||
|
||||
((MainActivity)activity).getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the friends list fragment
|
||||
*/
|
||||
|
@ -1,6 +1,9 @@
|
||||
package org.communiquons.android.comunic.client.ui.fragments;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@ -9,8 +12,10 @@ import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@ -99,6 +104,11 @@ public class ConversationFragment extends Fragment
|
||||
*/
|
||||
private ConversationRefreshRunnable refreshRunnable;
|
||||
|
||||
/**
|
||||
* Fragment toolbar
|
||||
*/
|
||||
private Toolbar mToolbar;
|
||||
|
||||
/**
|
||||
* Fragment main progress bar
|
||||
*/
|
||||
@ -227,12 +237,26 @@ public class ConversationFragment extends Fragment
|
||||
no_msg_notice = view.findViewById(R.id.fragment_conversation_noMsgYet);
|
||||
display_not_msg_notice(false);
|
||||
|
||||
//Conversation messages listView
|
||||
//Get views
|
||||
convMessRecyclerView = view.findViewById(R.id.fragment_conversation_messageslist);
|
||||
mToolbar = view.findViewById(R.id.toolbar);
|
||||
|
||||
//Need user ID
|
||||
int userID = new AccountUtils(getActivity()).get_current_user_id();
|
||||
|
||||
//Initialize toolbar
|
||||
Drawable backDrawable = UiUtils.getDrawable(getActivity(), R.drawable.ic_back);
|
||||
backDrawable.setColorFilter(UiUtils.getColor(getActivity(), android.R.color.white),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
mToolbar.setNavigationIcon(backDrawable);
|
||||
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MainActivity.goBackward(getActivity());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Create the adapter
|
||||
convMessAdapter = new ConversationMessageAdapter(getActivity(),
|
||||
messagesList, userID);
|
||||
@ -291,7 +315,6 @@ public class ConversationFragment extends Fragment
|
||||
//Hide new message sending wheel
|
||||
new_message_progress_bar.setVisibility(View.GONE);
|
||||
|
||||
|
||||
//Set a listener to detect when the user reaches the top of the conversation
|
||||
convMessRecyclerView.setOnScrollChangeDetectListener(this);
|
||||
}
|
||||
@ -307,7 +330,7 @@ public class ConversationFragment extends Fragment
|
||||
new Thread(refreshRunnable).start();
|
||||
|
||||
//Update conversation title
|
||||
getActivity().setTitle(R.string.fragment_conversation_title);
|
||||
setTitle(UiUtils.getString(getActivity(), R.string.fragment_conversation_title));
|
||||
MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_conversations);
|
||||
|
||||
|
||||
@ -451,7 +474,7 @@ public class ConversationFragment extends Fragment
|
||||
conversationInfo = info;
|
||||
|
||||
//Update the name of the conversation
|
||||
getActivity().setTitle(info.getDisplayName());
|
||||
setTitle(info.getDisplayName());
|
||||
|
||||
}
|
||||
|
||||
@ -612,6 +635,19 @@ public class ConversationFragment extends Fragment
|
||||
no_msg_notice.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the title of the fragment
|
||||
*
|
||||
* @param title New title
|
||||
*/
|
||||
private void setTitle(String title){
|
||||
if(getActivity() == null)
|
||||
return;
|
||||
|
||||
getActivity().setTitle(title);
|
||||
mToolbar.setTitle(title);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the user reach the top of the conversation
|
||||
*/
|
||||
|
9
app/src/main/res/drawable/ic_back.xml
Normal file
9
app/src/main/res/drawable/ic_back.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="25dp"
|
||||
android:height="25dp"
|
||||
android:viewportWidth="48.0"
|
||||
android:viewportHeight="48.0">
|
||||
<path
|
||||
android:fillColor="@color/default_drawable_color"
|
||||
android:pathData="M40 22H15.66l11.17-11.17L24 8 8 24l16 16 2.83-2.83L15.66 26H40v-4z"/>
|
||||
</vector>
|
@ -1,16 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<!-- Loading wheel -->
|
||||
<ProgressBar
|
||||
android:id="@+id/fragment_conversation_progressbar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
<!-- No message notice -->
|
||||
<TextView
|
||||
@ -26,6 +25,20 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<!-- Messages -->
|
||||
<org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView
|
||||
android:id="@+id/fragment_conversation_messageslist"
|
||||
|
Loading…
Reference in New Issue
Block a user