aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-06-07 15:22:51 +0200
committersteckbrief <steckbrief@chefmail.de>2016-06-07 15:22:51 +0200
commitf7d2e1560377b36d3730922a2fadaee05a570b49 (patch)
tree1c99bd75d863d82a82495fabe434892ee76b9842 /src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
parentc5c5b417ddd66b4611b0493c0e0a8349adbd34a4 (diff)
Related to FS#140, Logo implementation moved to FloatingActionButton
- Appcompat v7 dependency added - References adjusted to work correctly with appcompat v7
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java89
1 files changed, 21 insertions, 68 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
index af8eeea1..abe82b24 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
@@ -1,7 +1,8 @@
package de.thedevstack.conversationsplus.ui;
import android.annotation.SuppressLint;
-import android.app.ActionBar;
+import android.support.design.widget.FloatingActionButton;
+import android.support.v7.app.ActionBar;
import android.app.AlertDialog;
import android.app.FragmentTransaction;
import android.app.PendingIntent;
@@ -18,21 +19,19 @@ import android.provider.MediaStore;
import android.provider.Settings;
import android.support.v4.widget.SlidingPaneLayout;
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
+import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.util.Pair;
import android.view.Gravity;
import android.view.KeyEvent;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Surface;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
-import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.TextView;
@@ -52,7 +51,6 @@ import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
import de.thedevstack.conversationsplus.services.AvatarService;
import de.thedevstack.conversationsplus.ui.dialogs.UserDecisionDialog;
import de.thedevstack.conversationsplus.ui.listeners.AvatarLogoOnClickListener;
-import de.thedevstack.conversationsplus.ui.listeners.AvatarLogoPositioningListener;
import de.thedevstack.conversationsplus.ui.listeners.ResizePictureUserDecisionListener;
import de.thedevstack.conversationsplus.utils.ConversationUtil;
import de.timroes.android.listview.EnhancedListView;
@@ -119,8 +117,6 @@ public class ConversationActivity extends XmppActivity
protected boolean mUsingEnterKey = false;
private View mContentView;
- private View avatarLogoView;
- private View titleView;
private List<Conversation> conversationList = new ArrayList<>();
private Conversation swipedConversation = null;
@@ -185,6 +181,7 @@ public class ConversationActivity extends XmppActivity
@Override
protected void onCreate(final Bundle savedInstanceState) {
+ this.useDefaultActionBar = false;
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
mOpenConverstaion = savedInstanceState.getString(STATE_OPEN_CONVERSATION, null);
@@ -199,6 +196,10 @@ public class ConversationActivity extends XmppActivity
setContentView(R.layout.fragment_conversations_overview);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ this.disableHomeButtonAsUp();
+
this.mConversationFragment = new ConversationFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.selected_conversation, this.mConversationFragment, "conversation");
@@ -208,11 +209,6 @@ public class ConversationActivity extends XmppActivity
this.listAdapter = new ConversationAdapter(this, conversationList);
listView.setAdapter(this.listAdapter);
- if (getActionBar() != null) {
- getActionBar().setDisplayHomeAsUpEnabled(false);
- getActionBar().setHomeButtonEnabled(false);
- }
-
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
@@ -356,18 +352,18 @@ public class ConversationActivity extends XmppActivity
}
private void updateActionBarTitle(boolean titleShouldBeName) {
- final ActionBar ab = getActionBar();
+ final ActionBar ab = getSupportActionBar();
if (ab != null) {
- if (null == this.titleView || null == this.avatarLogoView) {
- this.initializeCustomActionBarViews(ab);
- }
- TextView title = (TextView) this.titleView.findViewById(R.id.conversationsTitle);
+ TextView title = (TextView) findViewById(R.id.cplusTitle);
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+
final Conversation conversation = getSelectedConversation();
if (titleShouldBeName && conversation != null) {
- this.toggleShowCustomActionBarView(ab, true);
- this.showLogoAvatar();
- ab.setDisplayHomeAsUpEnabled(true);
- ab.setHomeButtonEnabled(true);
+ ab.setDisplayHomeAsUpEnabled(true);
+ ab.setHomeButtonEnabled(true);
+ fab.setImageBitmap(AvatarService.getInstance().getCircled(getSelectedConversation(), getResources().getDimensionPixelSize(R.dimen.design_fab_image_size)));
+ fab.setOnClickListener(new AvatarLogoOnClickListener(getSelectedConversation()));
+ fab.setVisibility(View.VISIBLE);
if (conversation.getMode() == Conversation.MODE_SINGLE || ConversationsPlusPreferences.useSubject()) {
title.setText(conversation.getName());
@@ -375,57 +371,14 @@ public class ConversationActivity extends XmppActivity
title.setText(conversation.getJid().toBareJid().toString());
}
} else {
- this.toggleShowCustomActionBarView(ab, false);
- ab.setDisplayHomeAsUpEnabled(false);
- ab.setHomeButtonEnabled(false);
+ ab.setDisplayHomeAsUpEnabled(false);
+ ab.setHomeButtonEnabled(false);
title.setText(R.string.app_name);
- this.hideLogoAvatar();
+ fab.setVisibility(View.GONE);
}
}
}
- private void toggleShowCustomActionBarView(ActionBar ab, boolean show) {
- if (show) {
- ab.setDisplayShowTitleEnabled(false);
- ab.setDisplayShowCustomEnabled(true);
- } else {
- ab.setDisplayShowTitleEnabled(true);
- ab.setDisplayShowCustomEnabled(false);
- }
- }
-
- private void initializeCustomActionBarViews(ActionBar ab) {
- if (null == this.titleView) {
- this.titleView = LayoutInflater.from(this).inflate(R.layout.title, null);
- ab.setCustomView(this.titleView);
- }
- if (null == this.avatarLogoView) {
- this.avatarLogoView = LayoutInflater.from(this).inflate(R.layout.logo_view, null, false);
- ViewGroup decorViewGroup = (ViewGroup) getWindow().getDecorView();
- decorViewGroup.addView(avatarLogoView);
- int resId = getResources().getIdentifier("action_bar_container", "id", "android");
- final View actionBarView = decorViewGroup.findViewById(resId);
- if (actionBarView != null) {
- actionBarView.getViewTreeObserver().addOnGlobalLayoutListener(new AvatarLogoPositioningListener(actionBarView, avatarLogoView));
- }
- }
- }
-
- private void hideLogoAvatar() {
- if (null != this.avatarLogoView) {
- this.avatarLogoView.setVisibility(View.GONE);
- }
- }
-
- private void showLogoAvatar() {
- if (null != this.avatarLogoView) {
- ImageView avatarView = (ImageView) this.avatarLogoView.findViewById(R.id.logoViewAvatar);
- avatarView.setImageBitmap(AvatarService.getInstance().getCircled(getSelectedConversation(), getPixel(56)));
- avatarLogoView.setVisibility(View.VISIBLE);
- avatarView.setOnClickListener(new AvatarLogoOnClickListener(getSelectedConversation()));
- }
- }
-
private void openConversation() {
this.updateActionBarTitle();
this.invalidateOptionsMenu();
@@ -1144,7 +1097,7 @@ public class ConversationActivity extends XmppActivity
super.onResume();
final int theme = findTheme();
final boolean usingEnterKey = ConversationsPlusPreferences.displayEnterKey();
- if (this.mTheme != theme || usingEnterKey != mUsingEnterKey) {
+ if (this.useDefaultActionBar && (this.mTheme != theme || usingEnterKey != mUsingEnterKey)) {
recreate();
}
this.mActivityPaused = false;