summaryrefslogtreecommitdiff
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/dialer/CallDetailActivity.java6
-rw-r--r--src/com/android/dialer/DialtactsActivity.java6
-rw-r--r--src/com/android/dialer/calllog/CallTypeIconsView.java52
-rw-r--r--src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java2
-rw-r--r--src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java8
-rw-r--r--src/com/android/dialer/list/BlockedListSearchAdapter.java2
-rw-r--r--src/com/android/dialer/onboard/OnboardingActivity.java69
-rw-r--r--src/com/android/dialer/onboard/PermissionsChecker.java2
8 files changed, 114 insertions, 33 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index a43ec3edc..12849f416 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -47,6 +47,7 @@ import com.android.contacts.common.testing.NeededForTesting;
import com.android.contacts.common.util.UriUtils;
import com.android.dialer.calllog.CallDetailHistoryAdapter;
import com.android.dialer.calllog.CallLogAsyncTaskUtil.CallLogAsyncTaskListener;
+import com.android.dialer.onboard.OnboardingActivity;
import com.android.dialer.calllog.CallLogAsyncTaskUtil;
import com.android.dialer.calllog.CallTypeHelper;
import com.android.dialer.calllog.ContactInfoHelper;
@@ -220,6 +221,11 @@ public class CallDetailActivity extends AppCompatActivity
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ if (OnboardingActivity.shouldStartOnboardingActivity(this)) {
+ OnboardingActivity.startOnboardingActivity(this);
+ finish();
+ }
+
mContext = this;
setContentView(R.layout.call_detail);
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 9978bbedc..455b09758 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -80,6 +80,7 @@ import com.android.dialer.list.RegularSearchFragment;
import com.android.dialer.list.SearchFragment;
import com.android.dialer.list.SmartDialSearchFragment;
import com.android.dialer.list.SpeedDialFragment;
+import com.android.dialer.onboard.OnboardingActivity;
import com.android.dialer.settings.DialerSettingsActivity;
import com.android.dialer.util.IntentUtil;
import com.android.dialer.util.TelecomUtil;
@@ -374,6 +375,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
Trace.beginSection(TAG + " onCreate");
super.onCreate(savedInstanceState);
+ if (OnboardingActivity.shouldStartOnboardingActivity(this)) {
+ OnboardingActivity.startOnboardingActivity(this);
+ finish();
+ }
+
mFirstLaunch = true;
final Resources resources = getResources();
diff --git a/src/com/android/dialer/calllog/CallTypeIconsView.java b/src/com/android/dialer/calllog/CallTypeIconsView.java
index d680cfe42..cfd8f9748 100644
--- a/src/com/android/dialer/calllog/CallTypeIconsView.java
+++ b/src/com/android/dialer/calllog/CallTypeIconsView.java
@@ -114,6 +114,8 @@ public class CallTypeIconsView extends View {
return mResources.missed;
case AppCompatConstants.CALLS_VOICEMAIL_TYPE:
return mResources.voicemail;
+ case AppCompatConstants.CALLS_BLOCKED_TYPE:
+ return mResources.blocked;
default:
// It is possible for users to end up with calls with unknown call types in their
// call history, possibly due to 3rd party call log implementations (e.g. to
@@ -150,29 +152,22 @@ public class CallTypeIconsView extends View {
private static class Resources {
- /**
- * Drawable representing an incoming answered call.
- */
+ // Drawable representing an incoming answered call.
public final Drawable incoming;
- /**
- * Drawable respresenting an outgoing call.
- */
+ // Drawable respresenting an outgoing call.
public final Drawable outgoing;
- /**
- * Drawable representing an incoming missed call.
- */
+ // Drawable representing an incoming missed call.
public final Drawable missed;
- /**
- * Drawable representing a voicemail.
- */
+ // Drawable representing a voicemail.
public final Drawable voicemail;
- /**
- * Drawable repesenting a video call.
- */
+ // Drawable representing a blocked call.
+ public final Drawable blocked;
+
+ // Drawable repesenting a video call.
public final Drawable videoCall;
/**
@@ -204,21 +199,26 @@ public class CallTypeIconsView extends View {
voicemail = r.getDrawable(R.drawable.ic_call_voicemail_holo_dark);
- // Get the video call icon, scaled to match the height of the call arrows.
- // We want the video call icon to be the same height as the call arrows, while keeping
- // the same width aspect ratio.
- Bitmap videoIcon = BitmapFactory.decodeResource(context.getResources(),
- R.drawable.ic_videocam_24dp);
- int scaledHeight = missed.getIntrinsicHeight();
- int scaledWidth = (int) ((float) videoIcon.getWidth() *
- ((float) missed.getIntrinsicHeight() /
- (float) videoIcon.getHeight()));
- Bitmap scaled = Bitmap.createScaledBitmap(videoIcon, scaledWidth, scaledHeight, false);
- videoCall = new BitmapDrawable(context.getResources(), scaled);
+ blocked = getScaledBitmap(context, R.drawable.ic_block_24dp);
+ blocked.setColorFilter(r.getColor(R.color.blocked_call), PorterDuff.Mode.MULTIPLY);
+
+ videoCall = getScaledBitmap(context, R.drawable.ic_videocam_24dp);
videoCall.setColorFilter(r.getColor(R.color.dialtacts_secondary_text_color),
PorterDuff.Mode.MULTIPLY);
iconMargin = r.getDimensionPixelSize(R.dimen.call_log_icon_margin);
}
+
+ // Gets the icon, scaled to the height of the call type icons. This helps display all the
+ // icons to be the same height, while preserving their width aspect ratio.
+ private Drawable getScaledBitmap(Context context, int resourceId) {
+ Bitmap icon = BitmapFactory.decodeResource(context.getResources(), resourceId);
+ int scaledHeight =
+ context.getResources().getDimensionPixelSize(R.dimen.call_type_icon_size);
+ int scaledWidth = (int) ((float) icon.getWidth()
+ * ((float) scaledHeight / (float) icon.getHeight()));
+ Bitmap scaledIcon = Bitmap.createScaledBitmap(icon, scaledWidth, scaledHeight, false);
+ return new BitmapDrawable(context.getResources(), scaledIcon);
+ }
}
}
diff --git a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java
index 9da9cc15b..c5d2f6f70 100644
--- a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java
+++ b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java
@@ -247,4 +247,4 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler {
}
}, uri, null, null, null, null);
}
-} \ No newline at end of file
+}
diff --git a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
index 1b953875c..476fee49b 100644
--- a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
+++ b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
@@ -123,6 +123,12 @@ public class FilterNumberDialogFragment extends DialogFragment {
return builder.create();
}
+ @Override
+ public void onDestroy() {
+ this.dismissAllowingStateLoss();
+ super.onDestroy();
+ }
+
private String getBlockedMessage(String displayNumber) {
return getString(R.string.snackbar_number_blocked, displayNumber);
}
@@ -194,4 +200,4 @@ public class FilterNumberDialogFragment extends DialogFragment {
}
}, getArguments().getInt(ARG_BLOCK_ID));
}
-} \ No newline at end of file
+}
diff --git a/src/com/android/dialer/list/BlockedListSearchAdapter.java b/src/com/android/dialer/list/BlockedListSearchAdapter.java
index 7ae24e468..dbfbc8b40 100644
--- a/src/com/android/dialer/list/BlockedListSearchAdapter.java
+++ b/src/com/android/dialer/list/BlockedListSearchAdapter.java
@@ -86,4 +86,4 @@ public class BlockedListSearchAdapter extends RegularSearchListAdapter {
mFilteredNumberAsyncQueryHandler.startBlockedQuery(
onCheckListener, normalizedNumber, number, countryIso);
}
-} \ No newline at end of file
+}
diff --git a/src/com/android/dialer/onboard/OnboardingActivity.java b/src/com/android/dialer/onboard/OnboardingActivity.java
index 75378e99d..144e6d441 100644
--- a/src/com/android/dialer/onboard/OnboardingActivity.java
+++ b/src/com/android/dialer/onboard/OnboardingActivity.java
@@ -19,9 +19,11 @@ package com.android.dialer.onboard;
import static android.Manifest.permission.CALL_PHONE;
import static android.Manifest.permission.READ_CONTACTS;
+import android.Manifest;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
@@ -45,6 +47,8 @@ public class OnboardingActivity extends TransactionSafeActivity implements Onboa
PermissionsChecker, OnboardingFragment.HostInterface {
public static final String KEY_ALREADY_REQUESTED_DEFAULT_DIALER =
"key_already_requested_default_dialer";
+ public static final String KEY_CALLING_ACTIVITY_INTENT =
+ "key_calling_activity_intent";
public static final int SCREEN_DEFAULT_DIALER = 0;
public static final int SCREEN_PERMISSIONS = 1;
@@ -95,6 +99,16 @@ public class OnboardingActivity extends TransactionSafeActivity implements Onboa
public void completeOnboardingFlow() {
final Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
editor.putBoolean(KEY_ALREADY_REQUESTED_DEFAULT_DIALER, true).apply();
+
+ // Once we have completed the onboarding flow, relaunch the activity that called us, so
+ // that we return the user to the intended activity.
+ if (getIntent() != null && getIntent().getExtras() != null) {
+ final Intent previousActivityIntent =
+ getIntent().getExtras().getParcelable(KEY_CALLING_ACTIVITY_INTENT);
+ if (previousActivityIntent != null) {
+ startActivity(previousActivityIntent);
+ }
+ }
finish();
}
@@ -114,12 +128,61 @@ public class OnboardingActivity extends TransactionSafeActivity implements Onboa
}
@Override
- public boolean previouslyRequestedDefaultDialer() {
- final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
+ public boolean hasAlreadyRequestedDefaultDialer() {
+ return getAlreadyRequestedDefaultDialerFromPreferences(this);
+ }
+
+ private static boolean getAlreadyRequestedDefaultDialerFromPreferences(Context context) {
+ final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
return preferences.getBoolean(KEY_ALREADY_REQUESTED_DEFAULT_DIALER, false);
}
/**
+ * Checks the current permissions/application state to determine if the
+ * {@link OnboardingActivity} should be displayed. The onboarding flow should be launched if
+ * the current application is NOT the system dialer AND any of these criteria are true.
+ *
+ * 1) The phone application is not currently the default dialer AND we have not
+ * previously displayed a prompt to ask the user to set our app as the default dialer.
+ * 2) The phone application does not have the Phone permission.
+ * 3) The phone application does not have the Contacts permission.
+ *
+ * The exception if the current application is the system dialer applies because:
+ *
+ * 1) The system dialer must always provide immediate access to the dialpad to allow
+ * emergency calls to be made.
+ * 2) In order for the system dialer to require the onboarding flow, the user must have
+ * intentionally removed certain permissions/selected a different dialer. This assumes the
+ * that the user understands the implications of the actions previously taken. For example,
+ * removing the Phone permission from the system dialer displays a dialog that warns the
+ * user that this might break certain core phone functionality. Furthermore, various elements in
+ * the Dialer will prompt the user to grant permissions as needed.
+ *
+ * @param context A valid context object.
+ * @return {@code true} if the onboarding flow should be launched to request for the
+ * necessary permissions or prompt the user to make us the default dialer, {@code false}
+ * otherwise.
+ */
+ public static boolean shouldStartOnboardingActivity(Context context) {
+ // Since there is no official TelecomManager API to check for the system dialer,
+ // check to see if we have the system-only MODIFY_PHONE_STATE permission.
+ if (PermissionsUtil.hasPermission(context, Manifest.permission.MODIFY_PHONE_STATE)) {
+ return false;
+ }
+
+ return (!getAlreadyRequestedDefaultDialerFromPreferences(context)
+ && !TelecomUtil.isDefaultDialer(context))
+ || !PermissionsUtil.hasPhonePermissions(context)
+ || !PermissionsUtil.hasContactsPermissions(context);
+ }
+
+ public static void startOnboardingActivity(Activity callingActivity) {
+ final Intent intent = new Intent(callingActivity, OnboardingActivity.class);
+ intent.putExtra(KEY_CALLING_ACTIVITY_INTENT, callingActivity.getIntent());
+ callingActivity.startActivity(intent);
+ }
+
+ /**
* Triggers the screen-specific logic that should occur when the next button is clicked.
*/
@Override
@@ -180,7 +243,7 @@ public class OnboardingActivity extends TransactionSafeActivity implements Onboa
@Override
public boolean shouldShowScreen() {
- return !mPermissionsChecker.previouslyRequestedDefaultDialer()
+ return !mPermissionsChecker.hasAlreadyRequestedDefaultDialer()
&& !mPermissionsChecker.isDefaultOrSystemDialer();
}
diff --git a/src/com/android/dialer/onboard/PermissionsChecker.java b/src/com/android/dialer/onboard/PermissionsChecker.java
index 78d175e6f..c6b0bbf30 100644
--- a/src/com/android/dialer/onboard/PermissionsChecker.java
+++ b/src/com/android/dialer/onboard/PermissionsChecker.java
@@ -23,5 +23,5 @@ public interface PermissionsChecker {
public boolean hasPhonePermissions();
public boolean hasContactsPermissions();
public boolean isDefaultOrSystemDialer();
- public boolean previouslyRequestedDefaultDialer();
+ public boolean hasAlreadyRequestedDefaultDialer();
}