summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--InCallUI/src/com/android/incallui/AnswerFragment.java27
-rw-r--r--InCallUI/src/com/android/incallui/AnswerPresenter.java5
-rw-r--r--InCallUI/src/com/android/incallui/GlowPadWrapper.java43
3 files changed, 46 insertions, 29 deletions
diff --git a/InCallUI/src/com/android/incallui/AnswerFragment.java b/InCallUI/src/com/android/incallui/AnswerFragment.java
index 1b249f29f..a53d8c9e0 100644
--- a/InCallUI/src/com/android/incallui/AnswerFragment.java
+++ b/InCallUI/src/com/android/incallui/AnswerFragment.java
@@ -79,14 +79,33 @@ public class AnswerFragment extends BaseFragment<AnswerPresenter, AnswerPresente
mGlowpad = (GlowPadWrapper) inflater.inflate(R.layout.answer_fragment,
container, false);
+ Log.d(this, "Creating view for answer fragment ", this);
+ Log.d(this, "Created from activity", getActivity());
mGlowpad.setAnswerListener(this);
return mGlowpad;
}
@Override
+ public void onDestroyView() {
+ Log.d(this, "onDestroyView");
+ if (mGlowpad != null) {
+ mGlowpad.stopPing();
+ mGlowpad = null;
+ }
+ super.onDestroyView();
+ }
+
+ @Override
public void showAnswerUi(boolean show) {
getView().setVisibility(show ? View.VISIBLE : View.GONE);
+
+ Log.d(this, "Show answer UI: " + show);
+ if (show) {
+ mGlowpad.startPing();
+ } else {
+ mGlowpad.stopPing();
+ }
}
@Override
@@ -126,6 +145,14 @@ public class AnswerFragment extends BaseFragment<AnswerPresenter, AnswerPresente
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setCancelable(
true).setView(lv);
+ builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialogInterface) {
+ if (mGlowpad != null) {
+ mGlowpad.startPing();
+ }
+ }
+ });
mCannedResponsePopup = builder.create();
mCannedResponsePopup.show();
}
diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java
index bfe8405a0..dd4deeb6a 100644
--- a/InCallUI/src/com/android/incallui/AnswerPresenter.java
+++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java
@@ -73,6 +73,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
public void onIncomingCall(Call call) {
// TODO: Ui is being destroyed when the fragment detaches. Need clean up step to stop
// getting updates here.
+ Log.d(this, "onIncomingCall: " + this);
if (getUi() != null) {
if (call.getCallId() != mCallId) {
// A new call is coming in.
@@ -88,7 +89,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
// Listen for call updates for the current call.
CallList.getInstance().addCallUpdateListener(mCallId, this);
- Log.d(TAG, "Showing incoming for call id: " + mCallId);
+ Log.d(TAG, "Showing incoming for call id: " + mCallId + " " + this);
final ArrayList<String> textMsgs = CallList.getInstance().getTextResponses(
call.getCallId());
getUi().showAnswerUi(true);
@@ -104,7 +105,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
@Override
public void onCallStateChanged(Call call) {
- Log.d(this, "onCallStateChange() " + call);
+ Log.d(this, "onCallStateChange() " + call + " " + this);
if (call.getState() != Call.State.INCOMING && call.getState() != Call.State.CALL_WAITING) {
// Stop listening for updates.
CallList.getInstance().removeCallUpdateListener(mCallId, this);
diff --git a/InCallUI/src/com/android/incallui/GlowPadWrapper.java b/InCallUI/src/com/android/incallui/GlowPadWrapper.java
index 0e1d47d70..28ccb956c 100644
--- a/InCallUI/src/com/android/incallui/GlowPadWrapper.java
+++ b/InCallUI/src/com/android/incallui/GlowPadWrapper.java
@@ -19,7 +19,6 @@ package com.android.incallui;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
-import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.View;
@@ -48,13 +47,16 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger
private AnswerListener mAnswerListener;
private boolean mPingEnabled = true;
+ private boolean mTargetTriggered = false;
public GlowPadWrapper(Context context) {
super(context);
+ Log.d(this, "class created " + this + " ");
}
public GlowPadWrapper(Context context, AttributeSet attrs) {
super(context, attrs);
+ Log.d(this, "class created " + this);
}
@Override
@@ -62,43 +64,23 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger
Log.d(this, "onFinishInflate()");
super.onFinishInflate();
setOnTriggerListener(this);
- startPing();
- }
-
- @Override
- protected void onWindowVisibilityChanged(int visibility) {
- Log.d(this, "Visibility changed " + visibility);
- super.onWindowVisibilityChanged(visibility);
- switch (visibility) {
- case View.VISIBLE:
- startPing();
- break;
- case View.INVISIBLE:
- case View.GONE:
- stopPing();
- break;
- }
- }
-
- @Override
- protected Parcelable onSaveInstanceState() {
- Log.d(this, "onSaveInstanceState()");
- // TODO: evaluate this versus stopping during fragment onPause/onResume
- stopPing();
- return super.onSaveInstanceState();
}
public void startPing() {
+ Log.d(this, "startPing");
mPingEnabled = true;
triggerPing();
}
public void stopPing() {
+ Log.d(this, "stopPing");
mPingEnabled = false;
+ mPingHandler.removeMessages(PING_MESSAGE_WHAT);
}
private void triggerPing() {
- if (mPingEnabled) {
+ Log.d(this, "triggerPing(): " + mPingEnabled + " " + this);
+ if (mPingEnabled && !mPingHandler.hasMessages(PING_MESSAGE_WHAT)) {
ping();
if (ENABLE_PING_AUTO_REPEAT) {
@@ -116,7 +98,11 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger
@Override
public void onReleased(View v, int handle) {
Log.d(this, "onReleased()");
- startPing();
+ if (mTargetTriggered) {
+ mTargetTriggered = false;
+ } else {
+ startPing();
+ }
}
@Override
@@ -126,12 +112,15 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger
switch (resId) {
case R.drawable.ic_lockscreen_answer:
mAnswerListener.onAnswer();
+ mTargetTriggered = true;
break;
case R.drawable.ic_lockscreen_decline:
mAnswerListener.onDecline();
+ mTargetTriggered = true;
break;
case R.drawable.ic_lockscreen_text:
mAnswerListener.onText();
+ mTargetTriggered = true;
break;
default:
// Code should never reach here.