summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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/onboard/OnboardingActivity.java310
-rw-r--r--src/com/android/dialer/onboard/OnboardingController.java85
-rw-r--r--src/com/android/dialer/onboard/OnboardingFragment.java102
-rw-r--r--src/com/android/dialer/onboard/PermissionsChecker.java27
6 files changed, 0 insertions, 536 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 2aff61c4c..2121e988d 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -57,7 +57,6 @@ import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlocke
import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
import com.android.dialer.filterednumber.FilterNumberDialogFragment;
import com.android.dialer.filterednumber.FilteredNumbersUtil;
-import com.android.dialer.onboard.OnboardingActivity;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.IntentUtil.CallIntentBuilder;
import com.android.dialer.util.PhoneNumberUtil;
@@ -217,11 +216,6 @@ public class CallDetailActivity extends AppCompatActivity
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
- if (OnboardingActivity.shouldStartOnboardingActivity(this)) {
- OnboardingActivity.startOnboardingActivity(this);
- finish();
- }
-
mContext = this;
mResources = getResources();
mContactInfoHelper = new ContactInfoHelper(this, GeoUtil.getCurrentCountryIso(this));
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 140437e40..9105e6f5a 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -82,7 +82,6 @@ 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;
@@ -380,11 +379,6 @@ 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/onboard/OnboardingActivity.java b/src/com/android/dialer/onboard/OnboardingActivity.java
deleted file mode 100644
index 9be0fd0a7..000000000
--- a/src/com/android/dialer/onboard/OnboardingActivity.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-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;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.telecom.TelecomManager;
-
-import com.android.contacts.common.util.PermissionsUtil;
-import com.android.dialer.TransactionSafeActivity;
-import com.android.dialer.onboard.OnboardingController.OnboardingScreen;
-import com.android.dialer.onboard.OnboardingController.OnboardingUi;
-import com.android.dialer.util.TelecomUtil;
-import com.android.dialer.R;
-
-/**
- * Activity hosting the onboarding UX flow that appears when you launch Dialer and you don't have
- * the necessary permissions to run the app.
- */
-public class OnboardingActivity extends TransactionSafeActivity implements OnboardingUi,
- 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;
- public static final int SCREEN_COUNT = 2;
-
- private OnboardingController mOnboardingController;
-
- private DefaultDialerOnboardingScreen mDefaultDialerOnboardingScreen;
- private PermissionsOnboardingScreen mPermissionsOnboardingScreen;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.onboarding_activity);
- mOnboardingController = new OnboardingController(this);
- mDefaultDialerOnboardingScreen = new DefaultDialerOnboardingScreen(this);
- mPermissionsOnboardingScreen = new PermissionsOnboardingScreen(this);
- mOnboardingController.addScreen(mDefaultDialerOnboardingScreen);
- mOnboardingController.addScreen(mPermissionsOnboardingScreen);
-
- mOnboardingController.showNextScreen();
- }
-
- @Override
- public void showScreen(int screenId) {
- if (!isSafeToCommitTransactions()) {
- return;
- }
- final Fragment fragment;
- switch (screenId) {
- case SCREEN_DEFAULT_DIALER:
- fragment = mDefaultDialerOnboardingScreen.getFragment();
- break;
- case SCREEN_PERMISSIONS:
- fragment = mPermissionsOnboardingScreen.getFragment();
- break;
- default:
- return;
- }
-
- final FragmentTransaction ft = getFragmentManager().beginTransaction();
- ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
- ft.replace(R.id.onboarding_fragment_container, fragment);
- ft.commit();
- }
-
- @Override
- 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();
- }
-
- @Override
- public boolean hasPhonePermissions() {
- return PermissionsUtil.hasPhonePermissions(this);
- }
-
- @Override
- public boolean hasContactsPermissions() {
- return PermissionsUtil.hasContactsPermissions(this);
- }
-
- @Override
- public boolean isDefaultOrSystemDialer() {
- return TelecomUtil.hasModifyPhoneStatePermission(this);
- }
-
- @Override
- 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
- public void onNextClicked(int screenId) {
- switch (screenId) {
- case SCREEN_DEFAULT_DIALER:
- mDefaultDialerOnboardingScreen.onNextClicked(this);
- break;
- case SCREEN_PERMISSIONS:
- mPermissionsOnboardingScreen.onNextClicked(this);
- break;
- default:
- return;
- }
- }
-
- @Override
- public void onSkipClicked(int screenId) {
- mOnboardingController.onScreenResult(screenId, false);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == SCREEN_DEFAULT_DIALER
- && resultCode == RESULT_OK) {
- mOnboardingController.onScreenResult(SCREEN_DEFAULT_DIALER, true);
- }
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, String[] permissions,
- int[] grantResults) {
- boolean allPermissionsGranted = true;
- if (requestCode == SCREEN_PERMISSIONS) {
- if (permissions.length == 0 && grantResults.length == 0) {
- // Cancellation of permissions dialog
- allPermissionsGranted = false;
- } else {
- for (int result : grantResults) {
- if (result == PackageManager.PERMISSION_DENIED) {
- allPermissionsGranted = false;
- }
- }
- }
-
- if (allPermissionsGranted) {
- mOnboardingController.onScreenResult(SCREEN_PERMISSIONS, true);
- }
- }
- }
-
- public static class DefaultDialerOnboardingScreen extends OnboardingScreen {
- private PermissionsChecker mPermissionsChecker;
-
- public DefaultDialerOnboardingScreen(PermissionsChecker permissionsChecker) {
- mPermissionsChecker = permissionsChecker;
- }
-
- @Override
- public boolean shouldShowScreen() {
- return !mPermissionsChecker.hasAlreadyRequestedDefaultDialer()
- && !mPermissionsChecker.isDefaultOrSystemDialer();
- }
-
- @Override
- public boolean canSkipScreen() {
- return true;
- }
-
- public Fragment getFragment() {
- return new OnboardingFragment(
- SCREEN_DEFAULT_DIALER,
- canSkipScreen(),
- R.color.onboarding_default_dialer_screen_background_color,
- R.drawable.ill_onboard_default,
- R.string.request_default_dialer_screen_title,
- R.string.request_default_dialer_screen_content
- );
- }
-
- @Override
- public void onNextClicked(Activity activity) {
- final Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
- intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME,
- activity.getPackageName());
- activity.startActivityForResult(intent, SCREEN_DEFAULT_DIALER);
- }
- }
-
- public static class PermissionsOnboardingScreen extends OnboardingScreen {
- private PermissionsChecker mPermissionsChecker;
-
- public PermissionsOnboardingScreen(PermissionsChecker permissionsChecker) {
- mPermissionsChecker = permissionsChecker;
- }
-
- @Override
- public boolean shouldShowScreen() {
- return !(mPermissionsChecker.hasPhonePermissions()
- && mPermissionsChecker.hasContactsPermissions());
- }
-
- @Override
- public boolean canSkipScreen() {
- return false;
- }
-
- public Fragment getFragment() {
- return new OnboardingFragment(
- SCREEN_PERMISSIONS,
- canSkipScreen(),
- R.color.onboarding_permissions_screen_background_color,
- R.drawable.ill_onboard_permissions,
- R.string.request_permissions_screen_title,
- R.string.request_permissions_screen_content
- );
- }
-
- @Override
- public void onNextClicked(Activity activity) {
- activity.requestPermissions(new String[] {CALL_PHONE, READ_CONTACTS},
- SCREEN_PERMISSIONS);
- }
- }
-}
diff --git a/src/com/android/dialer/onboard/OnboardingController.java b/src/com/android/dialer/onboard/OnboardingController.java
deleted file mode 100644
index f799479ed..000000000
--- a/src/com/android/dialer/onboard/OnboardingController.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.dialer.onboard;
-
-import android.app.Activity;
-
-import java.util.ArrayList;
-
-/**
- * Class that manages the display of various fragments that show the user prompts asking for
- * certain privileged positions.
- */
-public class OnboardingController {
- public static abstract class OnboardingScreen {
- public abstract boolean shouldShowScreen();
- public abstract boolean canSkipScreen();
- public abstract void onNextClicked(Activity activity);
- }
-
- public interface OnboardingUi {
- public void showScreen(int screenId);
- /**
- * Called when all the necessary permissions have been granted and the main activity
- * can launch.
- */
- public void completeOnboardingFlow();
- }
-
- private int mCurrentScreen = -1;
- private OnboardingUi mOnboardingUi;
- private ArrayList<OnboardingScreen> mScreens = new ArrayList<> ();
-
- public OnboardingController(OnboardingUi onBoardingUi) {
- mOnboardingUi = onBoardingUi;
- }
-
- public void addScreen(OnboardingScreen screen) {
- mScreens.add(screen);
- }
-
- public void showNextScreen() {
- mCurrentScreen++;
-
- if (mCurrentScreen >= mScreens.size()) {
- // Reached the end of onboarding flow
- mOnboardingUi.completeOnboardingFlow();
- return;
- }
-
- if (mScreens.get(mCurrentScreen).shouldShowScreen()) {
- mOnboardingUi.showScreen(mCurrentScreen);
- } else {
- showNextScreen();
- }
- }
-
- public void onScreenResult(int screenId, boolean success) {
- if (screenId >= mScreens.size()) {
- return;
- }
-
- // Show the next screen in the onboarding flow only under the following situations:
- // 1) Success was indicated, and the
- // 2) The user tried to skip the screen, and the screen can be skipped
- if (success && !mScreens.get(mCurrentScreen).shouldShowScreen()) {
- showNextScreen();
- } else if (mScreens.get(mCurrentScreen).canSkipScreen()) {
- showNextScreen();
- }
- }
-}
diff --git a/src/com/android/dialer/onboard/OnboardingFragment.java b/src/com/android/dialer/onboard/OnboardingFragment.java
deleted file mode 100644
index 2836a958c..000000000
--- a/src/com/android/dialer/onboard/OnboardingFragment.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.dialer.onboard;
-
-import android.app.Fragment;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.android.dialer.R;
-
-public class OnboardingFragment extends Fragment implements OnClickListener {
- public static final String ARG_SCREEN_ID = "arg_screen_id";
- public static final String ARG_CAN_SKIP_SCREEN = "arg_can_skip_screen";
- public static final String ARG_BACKGROUND_COLOR_RESOURCE = "arg_background_color_resource";
- public static final String ARG_BACKGROUND_IMAGE_RESOURCE="arg_background_image_resource";
- public static final String ARG_TEXT_TITLE_RESOURCE = "arg_text_title_resource";
- public static final String ARG_TEXT_CONTENT_RESOURCE = "arg_text_content_resource";
-
- private int mScreenId;
-
- public interface HostInterface {
- public void onNextClicked(int screenId);
- public void onSkipClicked(int screenId);
- }
-
- public OnboardingFragment() {}
-
- public OnboardingFragment(int screenId, boolean canSkipScreen, int backgroundColorResourceId,
- int backgroundImageResourceId, int textTitleResourceId, int textContentResourceId) {
- final Bundle args = new Bundle();
- args.putInt(ARG_SCREEN_ID, screenId);
- args.putBoolean(ARG_CAN_SKIP_SCREEN, canSkipScreen);
- args.putInt(ARG_BACKGROUND_COLOR_RESOURCE, backgroundColorResourceId);
- args.putInt(ARG_BACKGROUND_IMAGE_RESOURCE, backgroundImageResourceId);
- args.putInt(ARG_TEXT_TITLE_RESOURCE, textTitleResourceId);
- args.putInt(ARG_TEXT_CONTENT_RESOURCE, textContentResourceId);
- setArguments(args);
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mScreenId = getArguments().getInt(ARG_SCREEN_ID);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- final View view = inflater.inflate(R.layout.onboarding_screen_fragment, container, false);
- final int backgroundColor = getResources().getColor(
- getArguments().getInt(ARG_BACKGROUND_COLOR_RESOURCE), null);
- view.setBackgroundColor(backgroundColor);
- ((ImageView) view.findViewById(R.id.onboarding_screen_background_image)).setImageResource(
- getArguments().getInt(ARG_BACKGROUND_IMAGE_RESOURCE));
- ((TextView) view.findViewById(R.id.onboarding_screen_content)).
- setText(getArguments().getInt(ARG_TEXT_CONTENT_RESOURCE));
- ((TextView) view.findViewById(R.id.onboarding_screen_title)).
- setText(getArguments().getInt(ARG_TEXT_TITLE_RESOURCE));
- ((Button) view.findViewById(R.id.onboard_next_button)).setTextColor(backgroundColor);
-
- if (!getArguments().getBoolean(ARG_CAN_SKIP_SCREEN)) {
- view.findViewById(R.id.onboard_skip_button).setVisibility(View.INVISIBLE);
- }
-
- view.findViewById(R.id.onboard_skip_button).setOnClickListener(this);
- view.findViewById(R.id.onboard_next_button).setOnClickListener(this);
-
- return view;
- }
-
- int getScreenId() {
- return mScreenId;
- }
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.onboard_skip_button) {
- ((HostInterface) getActivity()).onSkipClicked(getScreenId());
- } else if (v.getId() == R.id.onboard_next_button) {
- ((HostInterface) getActivity()).onNextClicked(getScreenId());
- }
- }
-}
diff --git a/src/com/android/dialer/onboard/PermissionsChecker.java b/src/com/android/dialer/onboard/PermissionsChecker.java
deleted file mode 100644
index c6b0bbf30..000000000
--- a/src/com/android/dialer/onboard/PermissionsChecker.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.dialer.onboard;
-
-/**
- * Defines a mockable interface used to verify whether certain permissions/privileged operations
- * are possible.
- */
-public interface PermissionsChecker {
- public boolean hasPhonePermissions();
- public boolean hasContactsPermissions();
- public boolean isDefaultOrSystemDialer();
- public boolean hasAlreadyRequestedDefaultDialer();
-}