Merge "Replace 9patch with shadow on searchbox with elevated view"
diff --git a/res/drawable/background_all_contacts.xml b/res/drawable/background_all_contacts.xml
deleted file mode 100644
index c14886a..0000000
--- a/res/drawable/background_all_contacts.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?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
- -->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="false">
- <shape android:shape="rectangle" >
- <solid android:color="@color/all_contacts_button_color" />
- </shape>
- </item>
-
- <item android:state_pressed="true">
- <shape android:shape="rectangle" >
- <solid android:color="@color/all_contacts_button_pressed_color" />
- </shape>
- </item>
-</selector>
\ No newline at end of file
diff --git a/res/drawable/ic_voicemail_delete.xml b/res/drawable/ic_voicemail_delete.xml
new file mode 100644
index 0000000..e81da9a
--- /dev/null
+++ b/res/drawable/ic_voicemail_delete.xml
@@ -0,0 +1,20 @@
+<?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.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/ic_menu_delete_dk"
+ android:gravity="center"
+ android:tint="@color/actionbar_icon_color" />
diff --git a/res/layout/phone_favorites_menu.xml b/res/layout/phone_favorites_menu.xml
deleted file mode 100644
index 0f7aa21..0000000
--- a/res/layout/phone_favorites_menu.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?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
- -->
-
-<!-- The phone favorites menu appears on the main dialer screen above the favorite callers area,
- and provides access to the All Contacts list. This is 1dp tall as a temporary hack to hide
- it because it is no longer being used. It should be removed from its parent adapter entirely
- eventually. -->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/phone_favorites_menu"
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:paddingLeft="@dimen/favorites_menu_padding_horizontal"
- android:paddingRight="@dimen/favorites_menu_padding_horizontal"
- android:paddingTop="@dimen/favorites_menu_padding_top"
- android:paddingBottom="@dimen/favorites_menu_padding_bottom"
- android:background="@color/favorites_menu_background_color"
- >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="@dimen/favorites_menu_speed_dial_height"
- android:fontFamily="@string/favorites_menu_speed_dial_font_family"
- android:text="@string/favorites_menu_speed_dial"
- android:textSize="@dimen/favorites_menu_speed_dial_text_size"
- android:textColor="@color/speed_dial_text_color"
- android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:gravity="center"
- />
- <Button
- android:id="@+id/all_contacts_button"
- android:fontFamily="@string/favorites_menu_all_contacts_font_family"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/favorites_menu_all_contacts_height"
- android:paddingLeft="@dimen/favorites_menu_padding_horizontal"
- android:paddingRight="@dimen/favorites_menu_padding_horizontal"
- android:text="@string/favorites_menu_all_contacts"
- android:textSize="@dimen/favorites_menu_all_contacts_text_size"
- android:background="@drawable/background_all_contacts"
- android:textColor="@color/all_contacts_button_text_color"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:gravity="center"
- />
-</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/search_edittext.xml b/res/layout/search_edittext.xml
index 9eb2ea6..03c5106 100644
--- a/res/layout/search_edittext.xml
+++ b/res/layout/search_edittext.xml
@@ -33,6 +33,7 @@
android:textColor="@color/searchbox_text_color"
android:textColorHint="@color/searchbox_hint_text_color"
android:hint="@string/dialer_hint_find_contact"
+ android:longClickable="false"
android:inputType="textFilter"/>
<ImageView
android:id="@+id/search_close_button"
@@ -61,4 +62,4 @@
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/ic_overflow_menu"
android:tint="@color/searchbox_options_menu_color" />
-</view>
\ No newline at end of file
+</view>
diff --git a/res/menu/call_details_options.xml b/res/menu/call_details_options.xml
index 39c8a67..c1daa6f 100644
--- a/res/menu/call_details_options.xml
+++ b/res/menu/call_details_options.xml
@@ -16,7 +16,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_trash"
- android:icon="@drawable/ic_menu_delete_dk"
+ android:icon="@drawable/ic_voicemail_delete"
android:showAsAction="ifRoom"
android:title="@string/recentCalls_trashVoicemail"
android:onClick="onMenuTrashVoicemail"
diff --git a/res/menu/dialpad_options.xml b/res/menu/dialpad_options.xml
index c6b5dda..6f0b5dd 100644
--- a/res/menu/dialpad_options.xml
+++ b/res/menu/dialpad_options.xml
@@ -17,16 +17,16 @@
<item
android:id="@+id/menu_add_contact"
android:title="@string/add_contact"
- android:showAsAction="withText"
- android:orderInCategory="1" />
+ android:showAsAction="withText" />
<item
android:id="@+id/menu_2s_pause"
android:title="@string/add_2sec_pause"
- android:showAsAction="withText"
- android:orderInCategory="1" />
+ android:showAsAction="withText" />
<item
android:id="@+id/menu_add_wait"
android:title="@string/add_wait"
- android:showAsAction="withText"
- android:orderInCategory="1" />
+ android:showAsAction="withText" />
+ <item android:id="@+id/menu_send_message"
+ android:title="@string/menu_sendTextMessage"
+ android:showAsAction="withText" />
</menu>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 301d416..7d5ef71 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -88,21 +88,6 @@
<!-- Text color for the "Remove" text when a contact is dragged on top of the remove view -->
<color name="remove_highlighted_text_color">#FF3F3B</color>
- <!-- Text color for the "speed dial" label in the favorites menu. -->
- <color name="speed_dial_text_color">#555555</color>
-
- <!-- Background color for the "All Contacts" button in the favorites menu. -->
- <color name="all_contacts_button_color">#999999</color>
-
- <!-- Background color for the "All Contacts" button in the favorites menu when pressed. -->
- <color name="all_contacts_button_pressed_color">#808080</color>
-
- <!-- Background color for the favorites menu. -->
- <color name="favorites_menu_background_color">#eeeeee</color>
-
- <!-- Text color for the "All Contacts" button above the favorite callers -->
- <color name="all_contacts_button_text_color">#ffffff</color>
-
<!-- Color of the bottom border below the contacts grid on the main dialer screen. -->
<color name="contacts_grid_bottom_border_color">#16000000</color>
@@ -121,4 +106,7 @@
<!-- Color for answered or outgoing call icons. -->
<color name="answered_call">#2aad6f</color>
+
+ <!-- Color for icons in the actionbar -->
+ <color name="actionbar_icon_color">#ffffff</color>
</resources>
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 418d54a..1adfeb8 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -21,6 +21,7 @@
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
+import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
@@ -260,6 +261,8 @@
private boolean mFirstLaunch = false;
private boolean mAnimate = false;
+ private ComponentName mSmsPackageComponentName;
+
private static final String PREF_DIGITS_FILLED_BY_INTENT = "pref_digits_filled_by_intent";
/**
@@ -392,8 +395,6 @@
mOverflowMenuButton = mDialpadView.getOverflowMenuButton();
mOverflowMenuButton.setOnClickListener(this);
- final PopupMenu overflowMenu = buildOptionsMenu(mOverflowMenuButton);
- mOverflowMenuButton.setOnTouchListener(overflowMenu.getDragToOpenListener());
return fragmentView;
}
@@ -654,6 +655,11 @@
stopWatch.lap("bes");
stopWatch.stopAndLog(TAG, 50);
+
+ mSmsPackageComponentName = DialerUtils.getSmsComponent(activity);
+
+ final PopupMenu overflowMenu = buildOptionsMenu(mOverflowMenuButton);
+ mOverflowMenuButton.setOnTouchListener(overflowMenu.getDragToOpenListener());
}
@Override
@@ -845,9 +851,12 @@
*
* @param invoker the View that invoked the options menu, to act as an anchor location.
*/
- public PopupMenu buildOptionsMenu(View invoker) {
+ private PopupMenu buildOptionsMenu(View invoker) {
final PopupMenu popupMenu = new PopupMenu(getActivity(), invoker);
popupMenu.inflate(R.menu.dialpad_options);
+ final Menu menu = popupMenu.getMenu();
+ final MenuItem sendMessage = menu.findItem(R.id.menu_send_message);
+ sendMessage.setVisible(mSmsPackageComponentName != null);
popupMenu.setOnMenuItemClickListener(this);
return popupMenu;
}
@@ -1407,17 +1416,25 @@
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
- case R.id.menu_add_contact:
+ case R.id.menu_add_contact: {
final CharSequence digits = mDigits.getText();
DialerUtils.startActivityWithErrorToast(getActivity(),
DialtactsActivity.getAddNumberToContactIntent(digits));
return true;
+ }
case R.id.menu_2s_pause:
updateDialString(PAUSE);
return true;
case R.id.menu_add_wait:
updateDialString(WAIT);
return true;
+ case R.id.menu_send_message: {
+ final CharSequence digits = mDigits.getText();
+ final Intent smsIntent = new Intent(Intent.ACTION_SENDTO,
+ Uri.fromParts(CallUtil.SCHEME_SMSTO, digits.toString(), null));
+ smsIntent.setComponent(mSmsPackageComponentName);
+ DialerUtils.startActivityWithErrorToast(getActivity(), smsIntent);
+ }
default:
return false;
}
diff --git a/src/com/android/dialer/list/SpeedDialFragment.java b/src/com/android/dialer/list/SpeedDialFragment.java
index 0399bf7..478327c 100644
--- a/src/com/android/dialer/list/SpeedDialFragment.java
+++ b/src/com/android/dialer/list/SpeedDialFragment.java
@@ -146,7 +146,6 @@
private PhoneFavoriteListView mListView;
- private View mPhoneFavoritesMenu;
private View mContactTileFrame;
private TileInteractionTeaserView mTileInteractionTeaserView;
@@ -211,8 +210,6 @@
mEmptyView = mParentView.findViewById(R.id.phone_no_favorites_view);
- mPhoneFavoritesMenu = inflater.inflate(R.layout.phone_favorites_menu, mListView, false);
-
mContactTileFrame = mParentView.findViewById(R.id.contact_tile_frame);
mTileInteractionTeaserView = (TileInteractionTeaserView) inflater.inflate(
diff --git a/src/com/android/dialer/util/DialerUtils.java b/src/com/android/dialer/util/DialerUtils.java
index 8b0c4c6..584caa9 100644
--- a/src/com/android/dialer/util/DialerUtils.java
+++ b/src/com/android/dialer/util/DialerUtils.java
@@ -16,12 +16,20 @@
package com.android.dialer.util;
import android.content.ActivityNotFoundException;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.net.Uri;
+import android.provider.Telephony;
import android.widget.Toast;
+import com.android.contacts.common.CallUtil;
import com.android.dialer.R;
+import java.util.List;
+
/**
* General purpose utility methods for the Dialer.
*/
@@ -54,4 +62,24 @@
Toast.makeText(context, msgId, Toast.LENGTH_SHORT).show();
}
}
+
+ /**
+ * Returns the component name to use in order to send an SMS using the default SMS application,
+ * or null if none exists.
+ */
+ public static ComponentName getSmsComponent(Context context) {
+ String smsPackage = Telephony.Sms.getDefaultSmsPackage(context);
+ if (smsPackage != null) {
+ final PackageManager packageManager = context.getPackageManager();
+ final Intent intent = new Intent(Intent.ACTION_SENDTO,
+ Uri.fromParts(CallUtil.SCHEME_SMSTO, "", null));
+ final List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, 0);
+ for (ResolveInfo resolveInfo : resolveInfos) {
+ if (smsPackage.equals(resolveInfo.activityInfo.packageName)) {
+ return new ComponentName(smsPackage, resolveInfo.activityInfo.name);
+ }
+ }
+ }
+ return null;
+ }
}