summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathanielWaggoner <nwaggoner@cyngn.com>2016-02-10 14:42:16 -0800
committerRichard MacGregor <rmacgregor@cyngn.com>2016-04-08 09:04:33 -0700
commita72e4cb4d44143ceafd04a3b15533d46827865c5 (patch)
treede6285a4015e988670a7d9bf49785e3174c2b3fd
parentea458a116720a79d1b4c2c8f41e0aad82a414f11 (diff)
downloadandroid_packages_apps_InCallUI-a72e4cb4d44143ceafd04a3b15533d46827865c5.tar.gz
android_packages_apps_InCallUI-a72e4cb4d44143ceafd04a3b15533d46827865c5.tar.bz2
android_packages_apps_InCallUI-a72e4cb4d44143ceafd04a3b15533d46827865c5.zip
DeepLink Refactors for CallButtonPresenter and CallButtonFragment
Moves the business logic into CallButtonPresenter, leaves the fragment as a dummy. Fixes some bugs related to when DeepLink buttons are shown. Change-Id: I29840dadde74fa892d77da1322953d696cec469c
-rw-r--r--src/com/android/incallui/CallButtonFragment.java33
-rw-r--r--src/com/android/incallui/CallButtonPresenter.java55
2 files changed, 58 insertions, 30 deletions
diff --git a/src/com/android/incallui/CallButtonFragment.java b/src/com/android/incallui/CallButtonFragment.java
index d8d78b43..c7d0e60c 100644
--- a/src/com/android/incallui/CallButtonFragment.java
+++ b/src/com/android/incallui/CallButtonFragment.java
@@ -55,10 +55,7 @@ import android.widget.TextView;
import com.android.incallui.incallapi.InCallPluginInfo;
-import com.cyanogen.ambient.common.api.ResultCallback;
import com.cyanogen.ambient.deeplink.DeepLink;
-import com.cyanogen.ambient.deeplink.DeepLink.DeepLinkResultList;
-import com.cyanogen.ambient.deeplink.applicationtype.DeepLinkApplicationType;
import java.lang.Override;
import java.util.ArrayList;
@@ -137,26 +134,7 @@ public class CallButtonFragment
private boolean mIsEnabled;
private MaterialPalette mCurrentThemeColors;
- private DeepLink mDeepLink;
- private ResultCallback<DeepLinkResultList> mDeepLinkCallback = new
- ResultCallback<DeepLinkResultList>() {
- @Override
- public void onResult(DeepLinkResultList deepLinkResult) {
- List<DeepLink> links = deepLinkResult.getResults();
- if (links != null) {
- for (DeepLink result : links) {
- if (result.getApplicationType() == DeepLinkApplicationType.NOTE) {
- mDeepLink = result;
- mTakeNoteButton.setImageBitmap(result.getBitmapIcon(getContext()));
- mTakeNoteButton.setOnClickListener(CallButtonFragment.this);
- break;
- }
- }
- } else if (mDeepLink == null) {
- mTakeNoteButton.setVisibility(View.GONE);
- }
- }
- };
+
@Override
public CallButtonPresenter createPresenter() {
// TODO: find a cleaner way to include audio mode provider than having a singleton instance.
@@ -216,7 +194,7 @@ public class CallButtonFragment
R.id.manageVideoCallConferenceButton);
mManageVideoCallConferenceButton.setOnClickListener(this);
mTakeNoteButton = (ImageButton) parent.findViewById(R.id.takeNoteButton);
- getPresenter().getPreferredLinks(mDeepLinkCallback);
+ mTakeNoteButton.setOnClickListener(CallButtonFragment.this);
return parent;
}
@@ -239,6 +217,11 @@ public class CallButtonFragment
}
@Override
+ public void setDeepLink(DeepLink deepLink) {
+ mTakeNoteButton.setImageBitmap(deepLink.getBitmapIcon(getContext()));
+ }
+
+ @Override
public void onClick(View view) {
int id = view.getId();
Log.d(this, "onClick(View " + view + ", id " + id + ")...");
@@ -297,7 +280,7 @@ public class CallButtonFragment
getPresenter().transferCallClicked();
break;
case R.id.takeNoteButton:
- getPresenter().takeNote(mDeepLink);
+ getPresenter().takeNote();
break;
default:
Log.wtf(this, "onClick: unexpected");
diff --git a/src/com/android/incallui/CallButtonPresenter.java b/src/com/android/incallui/CallButtonPresenter.java
index b32a6574..393ed8bc 100644
--- a/src/com/android/incallui/CallButtonPresenter.java
+++ b/src/com/android/incallui/CallButtonPresenter.java
@@ -60,6 +60,7 @@ import com.cyanogen.ambient.common.api.AmbientApiClient;
import com.cyanogen.ambient.common.api.ResultCallback;
import com.cyanogen.ambient.deeplink.DeepLink;
import com.cyanogen.ambient.deeplink.DeepLink.DeepLinkResultList;
+import com.cyanogen.ambient.deeplink.applicationtype.DeepLinkApplicationType;
import com.cyanogen.ambient.deeplink.linkcontent.CallDeepLinkContent;
import com.cyanogen.ambient.deeplink.linkcontent.DeepLinkContentType;
import com.cyanogen.ambient.incall.InCallServices;
@@ -90,6 +91,33 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
private StartInCallCallReceiver mCallback;
+ private DeepLink mDeepLink;
+ /**
+ * Callback for getPreferredLinks(ResultCallback<DeepLinkResultList> deepLinkCallback).
+ *
+ * Updates the UI with the deeplink it should be using as an Icon.
+ */
+ private ResultCallback<DeepLinkResultList> mDeepLinkCallback = new
+ ResultCallback<DeepLinkResultList>() {
+ @Override
+ public void onResult(DeepLinkResultList deepLinkResult) {
+ List<DeepLink> links = deepLinkResult.getResults();
+ mDeepLink = null;
+ if (links != null) {
+ for (DeepLink result : links) {
+ if (result.getApplicationType() == DeepLinkApplicationType.NOTE) {
+ mDeepLink = result;
+ getUi().setDeepLink(mDeepLink);
+ if(mCall != null) {
+ updateButtonsState(mCall);
+ }
+ break;
+ }
+ }
+ }
+ }
+ };
+
@Override
public void onReceiveResult(int resultCode, Bundle resultData) {
if (DEBUG) Log.i(TAG, "Got InCallPlugin result callback code = " + resultCode);
@@ -152,7 +180,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
mCall = callList.getOutgoingCall();
} else if (newState == InCallState.INCALL) {
mCall = callList.getActiveOrBackgroundCall();
-
+ getPreferredLinks(mDeepLinkCallback);
// When connected to voice mail, automatically shows the dialpad.
// (On previous releases we showed it when in-call shows up, before waiting for
// OUTGOING. We may want to do that once we start showing "Voice mail" label on
@@ -171,6 +199,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
mCall = callList.getIncomingCall();
} else {
mCall = null;
+ mDeepLink = null;
}
updateUi(newState, mCall);
}
@@ -616,7 +645,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
(contactInCallPlugins != null && !contactInCallPlugins.isEmpty())) &&
(callState == Call.State.ACTIVE || callState == Call.State.ONHOLD);
- final boolean showNote = callState == Call.State.ACTIVE || callState == Call.State.ONHOLD;
+ final boolean showNote = getVisibilityOfNoteButton();
final boolean showMute = call.can(android.telecom.Call.Details.CAPABILITY_MUTE);
final boolean showAddParticipant = call.can(
android.telecom.Call.Details.CAPABILITY_ADD_PARTICIPANT);
@@ -719,6 +748,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
void modifyChangeToVideoButton();
void displayVideoCallOptions();
void showInviteSnackbar(PendingIntent inviteIntent, String inviteText);
+ void setDeepLink(DeepLink deepLink);
/**
* Once showButton() has been called on each of the individual buttons in the UI, call
@@ -743,9 +773,12 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
onStateChange(null, state, CallList.getInstance());
}
- public void takeNote(DeepLink deepLink) {
- if(mCall != null && deepLink != null) {
- CallDeepLinkContent content = new CallDeepLinkContent(deepLink);
+ /**
+ * Take a note triggered by the CallButtonFragment note button.
+ */
+ public void takeNote() {
+ if(mCall != null && mDeepLink != null) {
+ CallDeepLinkContent content = new CallDeepLinkContent(mDeepLink);
content.setName(
mCall.getCnapName() == null ? CALL_DISPLAY_NAME_UNKNOWN : mCall.getCnapName());
content.setNumber(mCall.getNumber());
@@ -754,6 +787,11 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
getUi().getContext().startActivity(content.build());
}
}
+
+ /**
+ * Get preferred deeplinks for the current call.
+ * @param deepLinkCallback - callback to pass results to.
+ */
public void getPreferredLinks(ResultCallback<DeepLinkResultList> deepLinkCallback) {
Call localCall = mCall;
if(localCall == null) {
@@ -767,4 +805,11 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
}
}
+ /**
+ * Returns the visibility status for the take note icon
+ * @return whether the note button should be shown.
+ */
+ private boolean getVisibilityOfNoteButton() {
+ return mDeepLink != null && mCall != null && mCall.getState() == Call.State.ACTIVE;
+ }
}