mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Added update conversation settings button
This commit is contained in:
parent
94f8ecf746
commit
3f3fa95d72
@ -1,10 +1,6 @@
|
|||||||
package org.communiquons.android.comunic.client.ui.fragments;
|
package org.communiquons.android.comunic.client.ui.fragments;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
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.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@ -12,10 +8,8 @@ import android.os.AsyncTask;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.app.ActionBarDrawerToggle;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
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.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@ -44,6 +38,7 @@ import org.communiquons.android.comunic.client.ui.adapters.ConversationMessageAd
|
|||||||
import org.communiquons.android.comunic.client.ui.listeners.OnScrollChangeDetectListener;
|
import org.communiquons.android.comunic.client.ui.listeners.OnScrollChangeDetectListener;
|
||||||
import org.communiquons.android.comunic.client.ui.utils.BitmapUtils;
|
import org.communiquons.android.comunic.client.ui.utils.BitmapUtils;
|
||||||
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
|
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
|
||||||
|
import org.communiquons.android.comunic.client.ui.views.AppBarLayout;
|
||||||
import org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView;
|
import org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -107,7 +102,7 @@ public class ConversationFragment extends Fragment
|
|||||||
/**
|
/**
|
||||||
* Fragment toolbar
|
* Fragment toolbar
|
||||||
*/
|
*/
|
||||||
private Toolbar mToolbar;
|
private AppBarLayout mAppBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment main progress bar
|
* Fragment main progress bar
|
||||||
@ -239,23 +234,26 @@ public class ConversationFragment extends Fragment
|
|||||||
|
|
||||||
//Get views
|
//Get views
|
||||||
convMessRecyclerView = view.findViewById(R.id.fragment_conversation_messageslist);
|
convMessRecyclerView = view.findViewById(R.id.fragment_conversation_messageslist);
|
||||||
mToolbar = view.findViewById(R.id.toolbar);
|
mAppBar = view.findViewById(R.id.appbar);
|
||||||
|
|
||||||
//Need user ID
|
//Need user ID
|
||||||
int userID = new AccountUtils(getActivity()).get_current_user_id();
|
int userID = new AccountUtils(getActivity()).get_current_user_id();
|
||||||
|
|
||||||
//Initialize toolbar
|
//Initialize toolbar
|
||||||
Drawable backDrawable = UiUtils.getDrawable(getActivity(), R.drawable.ic_back);
|
mAppBar.addBackButton(new View.OnClickListener() {
|
||||||
backDrawable.setColorFilter(UiUtils.getColor(getActivity(), android.R.color.white),
|
|
||||||
PorterDuff.Mode.SRC_IN);
|
|
||||||
mToolbar.setNavigationIcon(backDrawable);
|
|
||||||
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
MainActivity.goBackward(getActivity());
|
MainActivity.goBackward(getActivity());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mAppBar.addButton(R.drawable.ic_settings, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
((MainActivity)getActivity()).updateConversation(conversation_id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//Create the adapter
|
//Create the adapter
|
||||||
convMessAdapter = new ConversationMessageAdapter(getActivity(),
|
convMessAdapter = new ConversationMessageAdapter(getActivity(),
|
||||||
@ -317,6 +315,7 @@ public class ConversationFragment extends Fragment
|
|||||||
|
|
||||||
//Set a listener to detect when the user reaches the top of the conversation
|
//Set a listener to detect when the user reaches the top of the conversation
|
||||||
convMessRecyclerView.setOnScrollChangeDetectListener(this);
|
convMessRecyclerView.setOnScrollChangeDetectListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -645,7 +644,7 @@ public class ConversationFragment extends Fragment
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
getActivity().setTitle(title);
|
getActivity().setTitle(title);
|
||||||
mToolbar.setTitle(title);
|
mAppBar.setTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,89 @@
|
|||||||
|
package org.communiquons.android.comunic.client.ui.views;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v7.widget.AppCompatImageButton;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.communiquons.android.comunic.client.R;
|
||||||
|
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic AppBarLayout base class for the fragments of this application
|
||||||
|
*/
|
||||||
|
public class AppBarLayout extends BaseFrameLayoutView {
|
||||||
|
|
||||||
|
private android.support.design.widget.AppBarLayout mAppBarLayout;
|
||||||
|
private Toolbar mToolbar;
|
||||||
|
|
||||||
|
public AppBarLayout(@NonNull Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppBarLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||||
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppBarLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
|
||||||
|
//Set the view
|
||||||
|
View view = inflate(getContext(), R.layout.view_appbarlayout, this);
|
||||||
|
mAppBarLayout = view.findViewById(R.id.app_bar_layout);
|
||||||
|
mToolbar = view.findViewById(R.id.toolbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Toolbar view
|
||||||
|
*/
|
||||||
|
public Toolbar getToolbar() {
|
||||||
|
return mToolbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the title of the appbar
|
||||||
|
*
|
||||||
|
* @param title The new title
|
||||||
|
*/
|
||||||
|
public void setTitle(String title){
|
||||||
|
mToolbar.setTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add back button to the view
|
||||||
|
*
|
||||||
|
* @param listener The listener to use when the button is clicked
|
||||||
|
*/
|
||||||
|
public void addBackButton(View.OnClickListener listener){
|
||||||
|
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(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a button to the toolbar
|
||||||
|
*
|
||||||
|
* @param icon The icon associated to the button
|
||||||
|
* @param listener OnClickListener for the button
|
||||||
|
*/
|
||||||
|
public void addButton(int icon, @Nullable OnClickListener listener) {
|
||||||
|
|
||||||
|
Drawable drawable = UiUtils.getDrawable(getContext(), icon);
|
||||||
|
drawable.setColorFilter(UiUtils.getColor(getContext(), android.R.color.white),
|
||||||
|
PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
|
AppCompatImageButton btn = new AppCompatImageButton(getActivity(),
|
||||||
|
null, android.support.v7.appcompat.R.attr.toolbarStyle);
|
||||||
|
btn.setPadding(5, 0, 5, 0);
|
||||||
|
btn.setImageDrawable(drawable);
|
||||||
|
btn.setOnClickListener(listener);
|
||||||
|
getToolbar().addView(btn);
|
||||||
|
}
|
||||||
|
}
|
9
app/src/main/res/drawable/ic_settings.xml
Normal file
9
app/src/main/res/drawable/ic_settings.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="@color/default_drawable_color"
|
||||||
|
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
|
||||||
|
</vector>
|
@ -1,8 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
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 -->
|
<!-- Loading wheel -->
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
@ -25,19 +24,11 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
<!-- Application bar -->
|
||||||
|
<org.communiquons.android.comunic.client.ui.views.AppBarLayout
|
||||||
|
android:id="@+id/appbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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 -->
|
<!-- Messages -->
|
||||||
<org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView
|
<org.communiquons.android.comunic.client.ui.views.ScrollRecyclerView
|
||||||
|
16
app/src/main/res/layout/view_appbarlayout.xml
Normal file
16
app/src/main/res/layout/view_appbarlayout.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay"
|
||||||
|
android:id="@+id/app_bar_layout">
|
||||||
|
|
||||||
|
<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>
|
Loading…
Reference in New Issue
Block a user