summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/app
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2018-02-05 15:59:47 -0800
committerCopybara-Service <copybara-piper@google.com>2018-02-05 17:49:19 -0800
commit014ffe1d515841a065ae946596d743558d28d8f0 (patch)
tree86ca9c31e506ff75d60ac3a879d1ce8193c85419 /java/com/android/dialer/app
parent0901d5919adbe7d0f2152583371ac9dba9b00ff2 (diff)
Missed calls now go to MainActivity if you have the component enabled.
This CL has a few changes of varying relevance: Most Relevance: - MissedCallNotifications will open MainActivity if the component is enabled (Meaning the launcher is in their app drawer and the flag is flipped). - Implemented show tab intent (open MainActivity directly to a specific tab) - Tests Some Relevance: - Implemented checking for ACTION_DIAL intents (dialpad will open immediately) - Tests Not Relevant but nice QoL changes: - Added tests for missed calls being marked as read - Makes espresso tests more horizontal to reduce timeouts - Bug: 72525550,72525615 Test: implemented PiperOrigin-RevId: 184600627 Change-Id: If96a44ce252e97c022ebc1b58fa783b3326035e7
Diffstat (limited to 'java/com/android/dialer/app')
-rw-r--r--java/com/android/dialer/app/MainComponent.java26
-rw-r--r--java/com/android/dialer/app/calllog/CallLogAdapter.java6
-rw-r--r--java/com/android/dialer/app/calllog/MissedCallNotifier.java10
3 files changed, 36 insertions, 6 deletions
diff --git a/java/com/android/dialer/app/MainComponent.java b/java/com/android/dialer/app/MainComponent.java
index b19ad908e..9d328491d 100644
--- a/java/com/android/dialer/app/MainComponent.java
+++ b/java/com/android/dialer/app/MainComponent.java
@@ -46,6 +46,16 @@ public class MainComponent {
}
}
+ public static boolean isNuiComponentEnabled(Context context) {
+ if (!isNewUiEnabled(context)) {
+ return false;
+ }
+ return context
+ .getPackageManager()
+ .getComponentEnabledSetting(new ComponentName(context, getComponentName()))
+ == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+ }
+
/**
* Enables the NUI activity component. By default the component is disabled and can't be accessed.
* Once the component has been enabled the user will get an option to use the new UI to handle
@@ -55,7 +65,7 @@ public class MainComponent {
context
.getPackageManager()
.setComponentEnabledSetting(
- new ComponentName(context, "com.android.dialer.main.impl.MainActivity"),
+ new ComponentName(context, getComponentName()),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
}
@@ -87,9 +97,21 @@ public class MainComponent {
*/
public static Intent getIntent(Context context) {
Intent intent = new Intent();
- intent.setComponent(new ComponentName(context, "com.android.dialer.main.impl.MainActivity"));
+ intent.setComponent(new ComponentName(context, getComponentName()));
intent.setAction(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return intent;
}
+
+ public static Intent getShowCallLogIntent(Context context) {
+ Intent intent = new Intent();
+ intent.setComponent(new ComponentName(context, getComponentName()));
+ intent.setAction("ACTION_SHOW_TAB");
+ intent.putExtra("EXTRA_SHOW_TAB", 1);
+ return intent;
+ }
+
+ private static String getComponentName() {
+ return "com.android.dialer.main.impl.MainActivity";
+ }
}
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java
index b8ec168f6..51df70219 100644
--- a/java/com/android/dialer/app/calllog/CallLogAdapter.java
+++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java
@@ -85,6 +85,7 @@ import com.android.dialer.logging.ContactSource;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
import com.android.dialer.logging.UiAction;
+import com.android.dialer.main.MainActivityPeer;
import com.android.dialer.performancereport.PerformanceReport;
import com.android.dialer.phonenumbercache.CallLogQuery;
import com.android.dialer.phonenumbercache.ContactInfo;
@@ -382,10 +383,11 @@ public class CallLogAdapter extends GroupingListAdapter
if (activityType == ACTIVITY_TYPE_DIALTACTS) {
if (v.getContext() instanceof CallLogFragmentListener) {
((CallLogFragmentListener) v.getContext()).updateTabUnreadCounts();
- } else if (v.getContext() instanceof FragmentUtilListener) {
+ } else if (v.getContext() instanceof MainActivityPeer.PeerSupplier) {
// This is really bad, but we must do this to prevent a dependency cycle, enforce
// best practices in new code, and avoid refactoring DialtactsActivity.
- ((FragmentUtilListener) v.getContext())
+ ((FragmentUtilListener)
+ ((MainActivityPeer.PeerSupplier) v.getContext()).getPeer())
.getImpl(CallLogFragmentListener.class)
.updateTabUnreadCounts();
} else {
diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
index dd92bb4e2..417f8f0f9 100644
--- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java
+++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
@@ -43,6 +43,7 @@ import android.util.ArraySet;
import com.android.contacts.common.ContactsUtils;
import com.android.contacts.common.compat.PhoneNumberUtilsCompat;
import com.android.dialer.app.DialtactsActivity;
+import com.android.dialer.app.MainComponent;
import com.android.dialer.app.R;
import com.android.dialer.app.calllog.CallLogNotificationsQueryHelper.NewCall;
import com.android.dialer.app.contactinfo.ContactPhotoLoader;
@@ -470,8 +471,13 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> {
* @param callUri Uri of the call to jump to. May be null
*/
private PendingIntent createCallLogPendingIntent(@Nullable Uri callUri) {
- Intent contentIntent =
- DialtactsActivity.getShowTabIntent(context, DialtactsPagerAdapter.TAB_INDEX_HISTORY);
+ Intent contentIntent;
+ if (MainComponent.isNuiComponentEnabled(context)) {
+ contentIntent = MainComponent.getShowCallLogIntent(context);
+ } else {
+ contentIntent =
+ DialtactsActivity.getShowTabIntent(context, DialtactsPagerAdapter.TAB_INDEX_HISTORY);
+ }
// TODO (a bug): scroll to call
contentIntent.setData(callUri);
return PendingIntent.getActivity(context, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT);