Added animated missedChat icon
This commit is contained in:
parent
a8928e6858
commit
da4056fb9d
3 changed files with 58 additions and 11 deletions
|
@ -91,14 +91,32 @@
|
|||
android:scaleType="fitXY"
|
||||
android:src="@drawable/settings" />
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_chat"
|
||||
android:id="@+id/chat"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/chat" />
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2">
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_chat"
|
||||
android:id="@+id/chat"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/chat" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/missedChats"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:gravity="center"
|
||||
android:textSize="20dp"
|
||||
android:visibility="gone"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/missed_calls_bg" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
private static final int callActivity = 19;
|
||||
private static LinphoneActivity instance;
|
||||
private StatusFragment statusFragment;
|
||||
private TextView missedCalls;
|
||||
private TextView missedCalls, missedChats;
|
||||
private ImageView history, contacts, dialer, settings, chat;
|
||||
private FragmentsAvailable currentFragment;
|
||||
private Fragment dialerFragment, messageListenerFragment;
|
||||
|
@ -148,6 +148,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
chat = (ImageView) findViewById(R.id.chat);
|
||||
chat.setOnClickListener(this);
|
||||
missedCalls = (TextView) findViewById(R.id.missedCalls);
|
||||
missedChats = (TextView) findViewById(R.id.missedChats);
|
||||
}
|
||||
|
||||
private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras) {
|
||||
|
@ -275,6 +276,9 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
extras.putString("DisplayName", lAddress.getDisplayName());
|
||||
extras.putString("PictureUri", uri.toString());
|
||||
}
|
||||
|
||||
LinphoneService.instance().resetMessageNotifCount();
|
||||
displayMissedChats(0);
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
||||
}
|
||||
|
||||
|
@ -415,6 +419,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
if (LinphoneService.isReady()) {
|
||||
LinphoneUtils.findUriPictureOfContactAndSetDisplayName(from, getContentResolver());
|
||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getDisplayName(), message);
|
||||
displayMissedChats(LinphoneService.instance().getMessageNotifCount());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,7 +446,9 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
if (missedCallsCount > 0) {
|
||||
missedCalls.setText(missedCallsCount + "");
|
||||
missedCalls.setVisibility(View.VISIBLE);
|
||||
missedCalls.startAnimation(AnimationUtils.loadAnimation(LinphoneActivity.this, R.anim.bounce));
|
||||
if (!getResources().getBoolean(R.bool.disable_animations)) {
|
||||
missedCalls.startAnimation(AnimationUtils.loadAnimation(LinphoneActivity.this, R.anim.bounce));
|
||||
}
|
||||
} else {
|
||||
missedCalls.clearAnimation();
|
||||
missedCalls.setVisibility(View.GONE);
|
||||
|
@ -449,6 +456,24 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void displayMissedChats(final int missedChatCount) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (missedChatCount > 0) {
|
||||
missedChats.setText(missedChatCount + "");
|
||||
missedChats.setVisibility(View.VISIBLE);
|
||||
if (!getResources().getBoolean(R.bool.disable_animations)) {
|
||||
missedChats.startAnimation(AnimationUtils.loadAnimation(LinphoneActivity.this, R.anim.bounce));
|
||||
}
|
||||
} else {
|
||||
missedChats.clearAnimation();
|
||||
missedChats.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCallStateChanged(LinphoneCall call, State state,
|
||||
|
|
|
@ -48,7 +48,6 @@ import android.content.pm.PackageInfo;
|
|||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.WifiManager.WifiLock;
|
||||
import android.os.Build;
|
||||
|
@ -115,8 +114,13 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
private static final int IC_LEVEL_OFFLINE=3;
|
||||
|
||||
|
||||
public int getMessageNotifCount() {
|
||||
return mMsgNotifCount;
|
||||
}
|
||||
|
||||
|
||||
public void resetMessageNotifCount() {
|
||||
mMsgNotifCount = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
|
Loading…
Reference in a new issue