aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java63
-rw-r--r--src/main/res/drawable/actionbar_space_between_icon_and_title.xml8
-rw-r--r--src/main/res/layout/logo_view.xml14
-rw-r--r--src/main/res/values/themes.xml12
4 files changed, 94 insertions, 3 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
index de69c1e6..7138f8e3 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
@@ -22,14 +22,18 @@ 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.view.ViewTreeObserver;
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.Toast;
@@ -45,6 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
+import de.thedevstack.conversationsplus.services.AvatarService;
import de.thedevstack.conversationsplus.ui.dialogs.UserDecisionDialog;
import de.thedevstack.conversationsplus.ui.listeners.ResizePictureUserDecisionListener;
import de.thedevstack.conversationsplus.utils.ConversationUtil;
@@ -112,6 +117,7 @@ public class ConversationActivity extends XmppActivity
protected boolean mUsingEnterKey = false;
private View mContentView;
+ private View avatarLogoView;
private List<Conversation> conversationList = new ArrayList<>();
private Conversation swipedConversation = null;
@@ -351,6 +357,7 @@ public class ConversationActivity extends XmppActivity
final Conversation conversation = getSelectedConversation();
if (ab != null) {
if (titleShouldBeName && conversation != null) {
+ this.updateLogoAvatar(true);
ab.setDisplayHomeAsUpEnabled(true);
ab.setHomeButtonEnabled(true);
if (conversation.getMode() == Conversation.MODE_SINGLE || ConversationsPlusPreferences.useSubject()) {
@@ -362,10 +369,66 @@ public class ConversationActivity extends XmppActivity
ab.setDisplayHomeAsUpEnabled(false);
ab.setHomeButtonEnabled(false);
ab.setTitle(R.string.app_name);
+ this.updateLogoAvatar(false);
}
}
}
+ private void updateLogoAvatar(boolean show) {
+ 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);
+ final View iconPlaceholderView = decorViewGroup.findViewById(R.id.icon_placeholder);
+ if (actionBarView != null) {
+ actionBarView.getViewTreeObserver().addOnGlobalLayoutListener(
+ new ViewTreeObserver.OnGlobalLayoutListener() {
+ public void onGlobalLayout() {
+ // Remove the listener
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ actionBarView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+ } else {
+ actionBarView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
+ }
+
+ // Measure views
+ int[] location = new int[2];
+ actionBarView.getLocationOnScreen(location);
+
+ int[] logoLocation = new int[2];
+ avatarLogoView.getLocationOnScreen(logoLocation);
+
+ int[] iconPlaceHolderLocation = new int[2];
+ if (null != iconPlaceholderView) {
+ iconPlaceholderView.getLocationOnScreen(iconPlaceHolderLocation);
+ }else {
+ iconPlaceHolderLocation[0] = 0;
+ }
+
+ // Add top padding if necessary
+ if (location[1] > logoLocation[1]) {
+ avatarLogoView.setPadding(iconPlaceHolderLocation[0], actionBarView.getMeasuredHeight() / 4 + location[1] - logoLocation[1], 0, 0);
+ }
+ /*if (iconPlaceHolderLocation[0] > logoLocation[0]) {
+ avatarLogoView.setPadding
+ }*/
+ }
+ }
+ );
+ }
+ }
+ if (show) {
+ ImageView avatarView = (ImageView) this.avatarLogoView.findViewById(R.id.logoViewAvatar);
+ avatarView.setImageBitmap(AvatarService.getInstance().get(getSelectedConversation(), getPixel(56)));
+ //avatarView.setAlpha(0.5f);
+ avatarLogoView.setVisibility(View.VISIBLE);
+ } else {
+ avatarLogoView.setVisibility(View.GONE);
+ }
+ }
+
private void openConversation() {
this.updateActionBarTitle();
this.invalidateOptionsMenu();
diff --git a/src/main/res/drawable/actionbar_space_between_icon_and_title.xml b/src/main/res/drawable/actionbar_space_between_icon_and_title.xml
new file mode 100644
index 00000000..53285bc0
--- /dev/null
+++ b/src/main/res/drawable/actionbar_space_between_icon_and_title.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:drawable="@android:color/transparent"
+ android:right="58dp"
+ android:id="@+id/icon_placeholder"/>
+</layer-list> \ No newline at end of file
diff --git a/src/main/res/layout/logo_view.xml b/src/main/res/layout/logo_view.xml
new file mode 100644
index 00000000..e9cc24c7
--- /dev/null
+++ b/src/main/res/layout/logo_view.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <ImageView
+ android:id="@+id/logoViewAvatar"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/ic_profile"
+ android:scaleType="center"
+ android:layout_marginLeft="10dip"
+ />
+</RelativeLayout> \ No newline at end of file
diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml
index 4209a39a..a157084f 100644
--- a/src/main/res/values/themes.xml
+++ b/src/main/res/values/themes.xml
@@ -44,10 +44,16 @@
</style>
<style name="ConversationsActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
- <item name="android:background">@color/primary</item>
- <item name="android:backgroundStacked">@color/primary_dark</item>
+ <item name="android:background">@android:color/transparent</item>
+ <!--item name="android:backgroundStacked">@color/primary_dark</item-->
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
- <item name="android:icon">@android:color/transparent</item>
+ <item name="android:icon">@drawable/actionbar_space_between_icon_and_title</item>
+ <item name="android:windowActionBarOverlay">true</item>
+ <item name="android:titleTextStyle">@style/ConversationsPlusTitleTextStyle</item>
+ </style>
+
+ <style name="ConversationsPlusTitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title.Inverse">
+ <item name="android:textSize">12sp</item>
</style>
<style name="ConversationsActionBarWidget" parent="android:Theme.Holo.Light">