From bf43c1ffec4087c201b629fdfeafa0a8c32e1570 Mon Sep 17 00:00:00 2001 From: Stephen Bird Date: Tue, 29 Mar 2016 10:21:53 -0700 Subject: Hide coachmark if dialpad opens with text pre-filled Change-Id: Icaed04966b43963b2fb17db47faa87343b63b5e4 --- .../android/dialer/dialpad/DialpadFragment.java | 25 +++++++++++++++++++--- .../dialer/util/CoachMarkDrawableHelper.java | 3 +-- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 31c59ddd8..3d0045910 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -28,6 +28,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; +import android.content.SharedPreferences; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -90,6 +91,7 @@ import com.android.phone.common.CallLogAsync; import com.android.phone.common.animation.AnimUtils; import com.android.phone.common.dialpad.DialpadKeyButton; import com.android.phone.common.dialpad.DialpadView; +import com.android.phone.common.incall.CallMethodUtils; import com.android.phone.common.incall.CallMethodHelper; import com.android.phone.common.incall.CallMethodInfo; import com.android.phone.common.incall.CreditBarHelper; @@ -487,9 +489,26 @@ public class DialpadFragment extends Fragment onCallMethodChanged(callMethodInfos.get(mCurrentCallMethodInfo.mComponent)); } - String unFormattedString = getString(R.string.provider_help); - CoachMarkDrawableHelper.assignViewTreeObserver(mDialpadView, getActivity(), fragmentView, - false, fragmentView.findViewById(R.id.listen_dismiss), unFormattedString); + + Activity act = getActivity(); + if (act != null) { + if (mDigitsFilledByIntent) { + String unFormattedString = getString(R.string.provider_help); + CoachMarkDrawableHelper.assignViewTreeObserver(mDialpadView, act, fragmentView, + false, fragmentView.findViewById(R.id.listen_dismiss), unFormattedString); + } else { + SharedPreferences pref = act.getSharedPreferences( + DialtactsActivity.SHARED_PREFS_NAME, Context.MODE_PRIVATE); + if (CoachMarkDrawableHelper.shouldShowCoachMark(pref) != null) { + // We would have shown the coachmark here, but some text is in our way + // at this point the user will have seen the spinner so we should + // hide the coachmark now and forever. + pref.edit().putBoolean(CallMethodUtils.PREF_SPINNER_COACHMARK_SHOW, false) + .apply(); + } + + } + } } public void updateSpinner(String lastKnownMethod, HashMap diff --git a/src/com/android/dialer/util/CoachMarkDrawableHelper.java b/src/com/android/dialer/util/CoachMarkDrawableHelper.java index bae9767dc..dba3b9016 100644 --- a/src/com/android/dialer/util/CoachMarkDrawableHelper.java +++ b/src/com/android/dialer/util/CoachMarkDrawableHelper.java @@ -89,8 +89,7 @@ public class CoachMarkDrawableHelper { } } - private static CallMethodInfo shouldShowCoachMark(SharedPreferences pref) { - + public static CallMethodInfo shouldShowCoachMark(SharedPreferences pref) { String lastProvider = pref.getString(CallMethodUtils.PREF_LAST_ENABLED_PROVIDER, null); boolean showCoachmark = pref.getBoolean(CallMethodUtils.PREF_SPINNER_COACHMARK_SHOW, false); -- cgit v1.2.3