diff options
author | Stephen Bird <sbird@cyngn.com> | 2016-01-19 11:56:21 -0800 |
---|---|---|
committer | Stephen Bird <sbird@cyngn.com> | 2016-04-08 10:15:57 -0700 |
commit | ed6e9210c3e726d1a050a2587f943aaa496649a1 (patch) | |
tree | 1fd0369eb52526b007e982fdeef71f7b9bb23618 | |
parent | 18fa2d2920faf214ec1f7b1afb10344a8e7e422b (diff) | |
download | android_packages_apps_Dialer-ed6e9210c3e726d1a050a2587f943aaa496649a1.tar.gz android_packages_apps_Dialer-ed6e9210c3e726d1a050a2587f943aaa496649a1.tar.bz2 android_packages_apps_Dialer-ed6e9210c3e726d1a050a2587f943aaa496649a1.zip |
Initial import of credits bar
Change-Id: I288e85fe472e32761a215449d9e6566854417526
-rw-r--r-- | res/layout/dialer_preferences.xml | 60 | ||||
-rw-r--r-- | res/layout/empty_content_view.xml | 96 | ||||
-rw-r--r-- | res/layout/preference_header_switch.xml | 76 | ||||
-rw-r--r-- | res/values/cm_colors.xml | 6 | ||||
-rw-r--r-- | res/values/cm_dimens.xml | 1 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 13 | ||||
-rw-r--r-- | res/values/cm_styles.xml | 14 | ||||
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 9 | ||||
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 58 | ||||
-rw-r--r-- | src/com/android/dialer/incall/CallMethodInfo.java | 87 | ||||
-rw-r--r-- | src/com/android/dialer/list/SearchFragment.java | 3 | ||||
-rw-r--r-- | src/com/android/dialer/list/SmartDialSearchFragment.java | 39 | ||||
-rw-r--r-- | src/com/android/dialer/widget/EmptyContentView.java | 11 |
13 files changed, 460 insertions, 13 deletions
diff --git a/res/layout/dialer_preferences.xml b/res/layout/dialer_preferences.xml new file mode 100644 index 000000000..4bcbbe3f4 --- /dev/null +++ b/res/layout/dialer_preferences.xml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2014 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. +--> + +<!-- Layout of a header item in PreferenceActivity. This is modified from the platform + preference_header_item--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="48dp" + android:background="?android:attr/selectableItemBackground" + android:gravity="center_vertical" + android:paddingEnd="?android:attr/scrollbarSize"> + + <RelativeLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/preference_side_margin" + android:layout_marginEnd="@dimen/preference_side_margin" + android:layout_weight="1" + android:paddingTop="@dimen/preference_padding_top" + android:paddingBottom="@dimen/preference_padding_bottom"> + + <TextView android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:singleLine="true" + android:textAppearance="?android:attr/textAppearance" + android:textSize="16sp" + android:textColor="@color/setting_primary_color" + android:ellipsize="marquee" + android:fadingEdge="horizontal" /> + + <TextView android:id="@+id/summary" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/title" + android:layout_alignStart="@id/title" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="@color/setting_secondary_color" + android:lineSpacingExtra="@dimen/preference_summary_line_spacing_extra" + android:ellipsize="end" + android:maxLines="2" /> + + </RelativeLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/res/layout/empty_content_view.xml b/res/layout/empty_content_view.xml index 97ac4c79c..eee5818dc 100644 --- a/res/layout/empty_content_view.xml +++ b/res/layout/empty_content_view.xml @@ -17,7 +17,7 @@ <merge xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:id="@+id/emptyListViewImage" - android:layout_height="wrap_content" + android:layout_height="100dp" android:layout_width="match_parent" android:gravity="center_horizontal" /> @@ -29,9 +29,93 @@ android:textSize="@dimen/empty_list_message_text_size" android:textColor="@color/empty_list_text_color" android:paddingRight="16dp" - android:paddingLeft="16dp" - android:paddingTop="8dp" - android:paddingBottom="8dp" /> + android:paddingLeft="16dp" /> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingRight="16dp" + android:paddingLeft="16dp" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal"> + <LinearLayout + android:orientation="vertical" + android:layout_gravity="center_horizontal" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <TextView + android:layout_gravity="center_horizontal" + android:gravity="center" + android:text="@string/empty_dialpad_example_seven" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/T9SubTextStyleBold" /> + <TextView + android:id="@+id/empty_dialpad_pqrs" + android:textColor="@color/recent_subtitle_color" + android:textSize="10sp" + android:gravity="center" + android:text="@string/empty_dialpad_example_pqrs" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + </LinearLayout> + <TextView + android:layout_gravity="center_horizontal" + android:gravity="center" + android:text="@string/empty_dialpad_example_plus" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/T9SubTextStyleBold" /> + <LinearLayout + android:orientation="vertical" + android:layout_gravity="center_horizontal" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <TextView + android:layout_gravity="center_horizontal" + android:gravity="center" + android:text="@string/empty_dialpad_example_two" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/T9SubTextStyleBold" /> + <TextView + android:id="@+id/empty_dialpad_abc" + android:textSize="10sp" + android:textColor="@color/recent_subtitle_color" + android:gravity="center" + android:text="@string/empty_dialpad_example_abc" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + </LinearLayout> + <TextView + android:layout_gravity="center_horizontal" + android:gravity="center" + android:text="@string/empty_dialpad_example_plus" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/T9SubTextStyleBold" /> + <LinearLayout + android:orientation="vertical" + android:layout_gravity="center_horizontal" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <TextView + android:layout_gravity="center_horizontal" + android:gravity="center" + android:text="@string/empty_dialpad_example_six" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/T9SubTextStyleBold" /> + <TextView + android:id="@+id/empty_dialpad_mno" + android:textColor="@color/recent_subtitle_color" + android:textSize="10sp" + android:gravity="center" + android:text="@string/empty_dialpad_example_mno" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + </LinearLayout> + </LinearLayout> <TextView android:id="@+id/emptyListViewAction" @@ -41,8 +125,8 @@ android:layout_gravity="center_horizontal" android:paddingRight="16dp" android:paddingLeft="16dp" - android:paddingTop="8dp" - android:paddingBottom="8dp" + android:paddingTop="2dp" + android:paddingBottom="2dp" android:background="?android:attr/selectableItemBackground" android:clickable="true" style="@style/TextActionStyle" /> diff --git a/res/layout/preference_header_switch.xml b/res/layout/preference_header_switch.xml new file mode 100644 index 000000000..4e0aaca42 --- /dev/null +++ b/res/layout/preference_header_switch.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2006 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. +--> + +<!-- Layout of a header item in PreferenceActivity. --> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="48dp" + android:gravity="center_vertical" + android:background="?android:attr/selectableItemBackground" + android:paddingEnd="?android:attr/scrollbarSize"> + +<LinearLayout + android:layout_weight="1" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:background="?android:attr/activatedBackgroundIndicator" + android:gravity="center_vertical" + android:paddingEnd="?android:attr/scrollbarSize"> + + <RelativeLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/preference_side_margin" + android:layout_marginEnd="@dimen/preference_side_margin" + android:layout_weight="1" + android:paddingTop="@dimen/preference_padding_top" + android:paddingBottom="@dimen/preference_padding_bottom"> + + <TextView android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:singleLine="true" + android:textAppearance="?android:attr/textAppearance" + android:textSize="16sp" + android:textColor="@color/setting_primary_color" + android:ellipsize="marquee" + android:fadingEdge="horizontal" /> + + <TextView android:id="@+id/summary" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/title" + android:layout_alignStart="@id/title" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="@color/setting_secondary_color" + android:lineSpacingExtra="@dimen/preference_summary_line_spacing_extra" + android:ellipsize="end" + android:maxLines="2" /> + + </RelativeLayout> + +</LinearLayout> + + <Switch android:id="@+id/switchWidget" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:padding="8dip" + android:focusable="false" + android:clickable="true" /> + +</LinearLayout> diff --git a/res/values/cm_colors.xml b/res/values/cm_colors.xml new file mode 100644 index 000000000..072571d58 --- /dev/null +++ b/res/values/cm_colors.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <!-- T9 hint color --> + <color name="recent_subtitle_color">#a79f9c</color> + +</resources>
\ No newline at end of file diff --git a/res/values/cm_dimens.xml b/res/values/cm_dimens.xml index c2390bfdc..b93f721f6 100644 --- a/res/values/cm_dimens.xml +++ b/res/values/cm_dimens.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <dimen name="contact_list_badge_margin">1dp</dimen> + <dimen name="dialpad_credits_padding">14dp</dimen> </resources>
\ No newline at end of file diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 852748593..6d68e774a 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -121,6 +121,19 @@ <string name="invalid_number_text">"%1$s could not make this call. Is the number correct?"</string> + <!-- T9 Search Text --> + <string name="empty_dialpad_t9_example">Search for %1$s by dialing:</string> + <string name="empty_dialpad_example_pqrs" translatable="false"><![CDATA[PQR<b>S</b>]]></string> + <string name="empty_dialpad_example_abc" translatable="false"><![CDATA[<b>A</b>BC]]></string> + <string name="empty_dialpad_example_mno" translatable="false"><![CDATA[<b>M</b>NO]]></string> + <string name="empty_dialpad_example_plus" translatable="false">+</string> + <string name="empty_dialpad_example_seven" translatable="false">7</string> + <string name="empty_dialpad_example_two" translatable="false">2</string> + <string name="empty_dialpad_example_six" translatable="false">6</string> + <string name="empty_dialpad_example_name" translatable="false">\"Sam\"</string> + <!-- InCall Plugin Settings --> <string name="incall_plugin_settings"><xliff:g id="name">%1$s</xliff:g> settings</string> + + </resources> diff --git a/res/values/cm_styles.xml b/res/values/cm_styles.xml new file mode 100644 index 000000000..2e8bec68f --- /dev/null +++ b/res/values/cm_styles.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <style name="T9SubTextStyleBold"> + <item name="android:layout_width">wrap_content</item> + <item name="android:layout_height">wrap_content</item> + <item name="android:gravity">center</item> + <item name="android:textColor">@color/empty_list_text_color</item> + <item name="android:singleLine">true</item> + <item name="android:textAllCaps">true</item> + <item name="android:textStyle">bold</item> + <item name="android:textSize">19sp</item> + </style> +</resources>
\ No newline at end of file diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index e063526c0..443fef4b8 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -79,6 +79,7 @@ import com.android.dialer.database.DialerDatabaseHelper; import com.android.dialer.dialpad.DialpadFragment; import com.android.dialer.dialpad.SmartDialNameMatcher; import com.android.dialer.dialpad.SmartDialPrefix; +import com.android.dialer.incall.CallMethodInfo; import com.android.dialer.interactions.PhoneNumberInteraction; import com.android.dialer.list.DragDropController; import com.android.dialer.list.ListsFragment; @@ -116,6 +117,7 @@ import java.util.Locale; */ public class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener, DialpadFragment.OnDialpadQueryChangedListener, + DialpadFragment.OnCallMethodChangedListener, OnListFragmentScrolledListener, CallLogFragment.HostInterface, DialpadFragment.HostInterface, @@ -261,6 +263,13 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O */ private String mVoiceSearchQuery; + @Override + public void onCallMethodChangedListener(CallMethodInfo cmi) { + if (mSmartDialSearchFragment != null) { + mSmartDialSearchFragment.setCurrentCallMethod(cmi); + } + } + protected class OptionsPopupMenu extends PopupMenu { public OptionsPopupMenu(Context context, View anchor) { super(context, anchor, Gravity.END); diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 367b84129..48830bdaa 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -21,6 +21,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.app.Fragment; +import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; @@ -97,7 +98,9 @@ import com.android.phone.common.util.StartInCallCallReceiver; import com.cyanogen.ambient.incall.extension.OriginCodes; import com.google.common.annotations.VisibleForTesting; +import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Currency; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -148,6 +151,10 @@ public class DialpadFragment extends Fragment void onDialpadQueryChanged(String query); } + public interface OnCallMethodChangedListener { + void onCallMethodChangedListener(CallMethodInfo cmi); + } + public interface HostInterface { /** * Notifies the parent activity that the space above the dialpad has been tapped with @@ -179,6 +186,8 @@ public class DialpadFragment extends Fragment private OnDialpadQueryChangedListener mDialpadQueryListener; + private OnCallMethodChangedListener mCallMethodChangedListener; + private DialpadView mDialpadView; private EditText mDigits; private int mDialpadSlideInDuration; @@ -459,6 +468,7 @@ public class DialpadFragment extends Fragment if (mCurrentCallMethodInfo == null || !callMethodInfo.equals(mCurrentCallMethodInfo)) { onCallMethodChanged(callMethodInfo); + mCallMethodChangedListener.onCallMethodChangedListener(callMethodInfo); } } @@ -470,6 +480,43 @@ public class DialpadFragment extends Fragment }); } + private void callMethodCredits(CallMethodInfo cmi) { + String creditText = cmi.getCreditsDescriptionText(getResources()); + String buttonText = null; + + boolean warnIfLow = false; + if (TextUtils.isEmpty(creditText)) { + clearCallRateInformation(); + return; + } else { + if (cmi.usesSubscriptions()) { + buttonText = cmi.mSubscriptionButtonText; + } else { + if (cmi.getCurrencyAmount() <= cmi.mCreditWarn) { + warnIfLow = true; + } + buttonText = mCurrentCallMethodInfo.mCreditButtonText; + } + } + setCallRateInformation(creditText, buttonText, cmi.mManageCreditIntent); + + /*creditsAvailable.setText(TextUtils.isEmpty(startText) ? "" : startText); + creditsAvailable.setTextColor(warnIfLow ? getResources().getColor(R.color + .credit_banner_alert_color) : getResources().getColor(R.color.dialer_theme_color)); + creditWarningImage.setVisibility(warnIfLow ? View.VISIBLE : View.GONE); + + if (!TextUtils.isEmpty(endText)) { + creditsIntentButton.setText(endText); + loadCreditIntent(mCurrentCallMethodInfo); + } else { + // if we're going to try to get the intent for this button, wait till we + // have that to show the credits banner. If there's no hope, assume that we + // will go on without the creditIntentButton. + //animateCreditBanner(false); + } */ + + } + private void onCallMethodChanged(CallMethodInfo callMethodInfo) { mLastKnownCallMethod = CallMethodSpinnerAdapter.getCallMethodKey(callMethodInfo); mCurrentCallMethodInfo = callMethodInfo; @@ -478,11 +525,13 @@ public class DialpadFragment extends Fragment //onDialpadQueryChanged(query, true); if (callMethodInfo != null && callMethodInfo.mIsInCallProvider) { + callMethodCredits(callMethodInfo); //loadCreditComponentInfo(callMethodInfo); // Hide overflow pause menu if call provider selected //hideShowOverflow(false); } else { + clearCallRateInformation(); // show overflow pause menu if sim card //hideShowOverflow(true); @@ -669,11 +718,11 @@ public class DialpadFragment extends Fragment } public void clearCallRateInformation() { - setCallRateInformation(null, null); + setCallRateInformation(null, null, null); } - public void setCallRateInformation(String countryName, String displayRate) { - mDialpadView.setCallRateInformation(countryName, displayRate); + public void setCallRateInformation(String countryName, String displayRate, PendingIntent p) { + mDialpadView.setCallRateInformation(countryName, displayRate, p); } /** @@ -762,6 +811,7 @@ public class DialpadFragment extends Fragment final DialtactsActivity activity = (DialtactsActivity) getActivity(); mDialpadQueryListener = activity; + mCallMethodChangedListener = activity; mSims = CallMethodUtils.getSimInfoList(getActivity()); if (CallMethodHelper.subscribe(AMBIENT_SUBSCRIPTION_ID, pluginsUpdatedReceiver)) { @@ -1486,7 +1536,7 @@ public class DialpadFragment extends Fragment * for each item in the "dialpad chooser" list. */ private static class DialpadChooserAdapter extends BaseAdapter { - private LayoutInflater mInflater; + public LayoutInflater mInflater; // Simple struct for a single "choice" item. static class ChoiceItem { diff --git a/src/com/android/dialer/incall/CallMethodInfo.java b/src/com/android/dialer/incall/CallMethodInfo.java index 062e876ef..bac68ab07 100644 --- a/src/com/android/dialer/incall/CallMethodInfo.java +++ b/src/com/android/dialer/incall/CallMethodInfo.java @@ -23,15 +23,23 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.UserHandle; import android.telephony.PhoneNumberUtils; +import android.text.TextUtils; +import android.util.Log; import com.android.dialer.DialerApplication; import com.android.dialer.incall.CallMethodHelper; import com.android.phone.common.util.StartInCallCallReceiver; import com.cyanogen.ambient.incall.InCallServices; +import com.cyanogen.ambient.incall.extension.CreditBalance; import com.cyanogen.ambient.incall.extension.CreditInfo; import com.cyanogen.ambient.incall.extension.OriginCodes; import com.cyanogen.ambient.incall.extension.StartCallRequest; +import com.cyanogen.ambient.incall.extension.SubscriptionInfo; import com.google.common.base.Objects; +import java.math.BigDecimal; +import java.util.Currency; +import java.util.List; + public class CallMethodInfo { public String mId; @@ -71,6 +79,8 @@ public class CallMethodInfo { mActionTwoText, mIsInCallProvider); } + public static final String TAG = "CallMethodInfo"; + @Override public boolean equals(Object object) { if (this == object) { @@ -127,4 +137,81 @@ public class CallMethodInfo { } } } + + private boolean isSubscription; + private boolean isCredits; + private int mCurrencyAmmount; + + public String getCreditsDescriptionText(Resources r) { + String ret = null; + CreditInfo ci = this.mProviderCreditInfo; + + List<SubscriptionInfo> subscriptionInfos = ci.subscriptions; + + if (subscriptionInfos != null && !subscriptionInfos.isEmpty()) { + int subscriptionSize = subscriptionInfos.size(); + StringBuilder subscripText = new StringBuilder(); + int extraCount = 0; + for (int i = 0; i < subscriptionSize; i++) { + SubscriptionInfo si = subscriptionInfos.get(i); + if (i >= 3) { + extraCount++; + if (i == subscriptionSize - 1) { + subscripText.append("+" + extraCount); + } + } else { + // Region codes should be no larger than three char long the credits bar + // can only show so much. + if (si.regionCode.length() <= 3) { + subscripText.append(si.regionCode); + if (i < subscriptionSize - 1) { + subscripText.append(", "); + } + } + } + } + return subscripText.toString(); + } else { + CreditBalance balance = ci.balance; + if (balance != null) { + mCurrencyAmmount = (int) balance.balance; + try { + if (balance.currencyCode != null) { + Currency currencyCode = Currency.getInstance(balance.currencyCode); + BigDecimal availableCredit = BigDecimal.valueOf(mCurrencyAmmount, + currencyCode.getDefaultFractionDigits()); + + + return currencyCode.getSymbol(r.getConfiguration().locale) + + availableCredit.toString(); + } else { + throw new IllegalArgumentException(); + } + } catch (IllegalArgumentException e) { + Log.w(TAG, "Unable to retrieve currency code for plugin: " + + this.mComponent); + + return null; + } + } else { + Log.e(TAG, "Plugin has credit component but the balance and subscriptions are" + + " null. This should never happen. Not showing credit banner due to " + + "failures."); + + return null; + } + } + } + + public boolean usesSubscriptions() { + return isSubscription; + } + + public boolean usesCurrency() { + return isCredits; + } + + public int getCurrencyAmount() { + return mCurrencyAmmount; + } } diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java index 530fd8839..9f9ea7bb6 100644 --- a/src/com/android/dialer/list/SearchFragment.java +++ b/src/com/android/dialer/list/SearchFragment.java @@ -376,8 +376,11 @@ public class SearchFragment extends PhoneNumberPickerFragment { mActivityOnTouchListener = onTouchListener; } + LayoutInflater mInflateView; + @Override protected View inflateView(LayoutInflater inflater, ViewGroup container) { + mInflateView = inflater; final LinearLayout parent = (LinearLayout) super.inflateView(inflater, container); final int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_PORTRAIT) { diff --git a/src/com/android/dialer/list/SmartDialSearchFragment.java b/src/com/android/dialer/list/SmartDialSearchFragment.java index 72d3abf68..d516d109d 100644 --- a/src/com/android/dialer/list/SmartDialSearchFragment.java +++ b/src/com/android/dialer/list/SmartDialSearchFragment.java @@ -19,16 +19,20 @@ import static android.Manifest.permission.CALL_PHONE; import android.app.Activity; import android.content.Loader; +import android.content.res.Resources; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.text.Html; import android.util.Log; import android.view.View; +import android.widget.TextView; import com.android.contacts.common.list.ContactEntryListAdapter; import com.android.contacts.common.util.PermissionsUtil; import com.android.dialer.dialpad.SmartDialCursorLoader; import com.android.dialer.R; +import com.android.dialer.incall.CallMethodInfo; import com.android.dialer.widget.EmptyContentView; import java.util.ArrayList; @@ -42,6 +46,8 @@ public class SmartDialSearchFragment extends SearchFragment private static final int CALL_PHONE_PERMISSION_REQUEST_CODE = 1; + private CallMethodInfo mCurrentCallMethod; + /** * Creates a SmartDialListAdapter to display and operate on search results. */ @@ -84,6 +90,8 @@ public class SmartDialSearchFragment extends SearchFragment @Override protected void setupEmptyView() { + final SmartDialNumberListAdapter adapter = (SmartDialNumberListAdapter) getAdapter(); + adapter.getCount(); if (mEmptyView != null && getActivity() != null) { if (!PermissionsUtil.hasPermission(getActivity(), CALL_PHONE)) { mEmptyView.setImage(R.drawable.empty_contacts); @@ -91,13 +99,38 @@ public class SmartDialSearchFragment extends SearchFragment mEmptyView.setDescription(R.string.permission_place_call); mEmptyView.setActionClickedListener(this); } else { - mEmptyView.setImage(EmptyContentView.NO_IMAGE); - mEmptyView.setActionLabel(EmptyContentView.NO_LABEL); - mEmptyView.setDescription(EmptyContentView.NO_LABEL); + if (adapter.getCount() == 0) { + mEmptyView.setActionLabel(mEmptyView.NO_LABEL); + mEmptyView.setImage(R.drawable.empty_contacts); + + if (mCurrentCallMethod == null) { + Resources r = getResources(); + mEmptyView.setImage(R.drawable.empty_contacts); + mEmptyView.setDescription( + String.format(r.getString(R.string.empty_dialpad_t9_example), + r.getString(R.string.empty_dialpad_example_name))); + + int[] idsToFormat = new int[] { + R.id.empty_dialpad_pqrs, + R.id.empty_dialpad_abc, + R.id.empty_dialpad_mno + }; + for (int id : idsToFormat) { + TextView textView = (TextView) mEmptyView.findViewById(id); + textView.setText(Html.fromHtml(textView.getText().toString())); + } + } else { + + } + } } } } + public void setCurrentCallMethod(CallMethodInfo cmi) { + mCurrentCallMethod = cmi; + } + @Override public void onEmptyViewActionButtonClicked() { final Activity activity = getActivity(); diff --git a/src/com/android/dialer/widget/EmptyContentView.java b/src/com/android/dialer/widget/EmptyContentView.java index f248967de..0a4e6fb24 100644 --- a/src/com/android/dialer/widget/EmptyContentView.java +++ b/src/com/android/dialer/widget/EmptyContentView.java @@ -17,6 +17,7 @@ package com.android.dialer.widget; import android.content.Context; +import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; @@ -79,6 +80,16 @@ public class EmptyContentView extends LinearLayout implements View.OnClickListen } } + public void setDescription(String string) { + if (TextUtils.isEmpty(string)) { + mDescriptionView.setText(null); + mDescriptionView.setVisibility(View.GONE); + } else { + mDescriptionView.setText(string); + mDescriptionView.setVisibility(View.VISIBLE); + } + } + public void setImage(int resourceId) { mImageView.setImageResource(resourceId); if (resourceId == NO_LABEL) { |