Permalink
Browse files

Added user state icons, based on a patch by xZise

  • Loading branch information...
1 parent eaa835c commit 0dea621b706f13ece5c68987b3162350c148b017 @pcgod committed Nov 24, 2010
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -5,14 +5,11 @@
android:layout_height="wrap_content"
android:layout_width="fill_parent">
- <CheckBox
- android:layout_height="wrap_content"
+ <ImageView
+ android:layout_height="match_parent"
android:layout_width="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_marginTop="5dip"
- android:focusable="false"
- android:clickable="false"
- android:id="@+id/userRowTalkState"></CheckBox>
+ android:id="@+id/userRowState"
+ android:src="@drawable/icon" />
<TextView
android:layout_toLeftOf="@+id/userRowStatus"
android:layout_height="wrap_content"
@@ -24,7 +21,7 @@
android:singleLine="true"
android:textSize="25sp"
android:layout_centerVertical="true"
- android:layout_toRightOf="@+id/userRowTalkState" />
+ android:layout_toRightOf="@+id/userRowState" />
<!--
singleLine is deprecated but it is the only way to get ellipsize work
it seems. 'inputType text, maxLines 1' didn't work. It's a known issue
@@ -33,13 +30,4 @@
happens first, they remove support for singleLine or they manage to
reproduce the error. :p
-->
-
- <TextView
- android:id="@+id/userRowStatus"
- android:gravity="center"
- android:layout_alignParentRight="true"
- android:layout_height="wrap_content"
- android:layout_centerVertical="true"
- android:text="[Status]"
- android:layout_width="100dp" />
</RelativeLayout>
@@ -16,7 +16,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
-import android.widget.CheckBox;
+import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
@@ -241,20 +241,25 @@ private final void refreshElements(final View view, final User user) {
}
final TextView name = (TextView) view.findViewById(R.id.userRowName);
- final TextView status = (TextView) view.findViewById(R.id.userRowStatus);
- final CheckBox state = (CheckBox) view.findViewById(R.id.userRowTalkState);
+ final ImageView state = (ImageView) view.findViewById(R.id.userRowState);
name.setText(user.name);
- if (!user.muted && !user.deafened) {
- status.setText("");
- } else {
- status.setText((user.muted && user.deafened) ? "M+D"
- : user.muted ? "M" : "D");
+ switch (user.userState) {
+ case User.USERSTATE_DEAFENED:
+ state.setImageResource(R.drawable.deafened);
+ break;
+ case User.USERSTATE_MUTED:
+ state.setImageResource(R.drawable.muted);
+ break;
+ default:
+ if (user.talkingState == AudioOutputHost.STATE_TALKING) {
+ state.setImageResource(R.drawable.talking_on);
+ } else {
+ state.setImageResource(R.drawable.talking_off);
+ }
}
- state.setChecked(user.talkingState == AudioOutputHost.STATE_TALKING);
-
view.invalidate();
}
@@ -211,13 +211,32 @@ public void processTcp(final short type, final byte[] buffer)
added = true;
}
+ if (us.hasSelfDeaf() || us.hasSelfMute()) {
+ if (us.getSelfDeaf()) {
+ user.userState = User.USERSTATE_DEAFENED;
+ } else if (us.getSelfMute()) {
+ user.userState = User.USERSTATE_MUTED;
+ } else {
+ user.userState = User.USERSTATE_NONE;
+ }
+ }
+
if (us.hasMute()) {
user.muted = us.getMute();
+ user.userState = user.muted ? User.USERSTATE_MUTED
+ : User.USERSTATE_NONE;
}
if (us.hasDeaf()) {
user.deafened = us.getDeaf();
user.muted |= user.deafened;
+ user.userState = user.deafened ? User.USERSTATE_DEAFENED
+ : (user.muted ? User.USERSTATE_MUTED : User.USERSTATE_NONE);
+ }
+
+ if (us.hasSuppress()) {
+ user.userState = us.getSuppress() ? User.USERSTATE_MUTED
+ : User.USERSTATE_NONE;
}
if (us.hasName()) {
@@ -22,10 +22,15 @@ public User createFromParcel(final Parcel source) {
public static final int TALKINGSTATE_SHOUTING = 2;
public static final int TALKINGSTATE_WHISPERING = 3;
+ public static final int USERSTATE_NONE = 0;
+ public static final int USERSTATE_MUTED = 1;
+ public static final int USERSTATE_DEAFENED = 2;
+
public int session;
public String name;
public float averageAvailable;
public int talkingState;
+ public int userState;
public boolean isCurrent;
public boolean muted;

0 comments on commit 0dea621

Please sign in to comment.