diff options
author | Stephen Bird <sbird@cyngn.com> | 2016-01-15 10:44:39 -0800 |
---|---|---|
committer | Richard MacGregor <rmacgregor@cyngn.com> | 2016-04-08 10:42:49 -0700 |
commit | 77d309114c14749e5905387cdb03a520b5a16bff (patch) | |
tree | 2134c36859f39f475ff83b342e74206c02f19106 | |
parent | bdac5aa5af2de5aca946f9bc0caf58b5b38935a6 (diff) | |
download | android_packages_apps_PhoneCommon-77d309114c14749e5905387cdb03a520b5a16bff.tar.gz android_packages_apps_PhoneCommon-77d309114c14749e5905387cdb03a520b5a16bff.tar.bz2 android_packages_apps_PhoneCommon-77d309114c14749e5905387cdb03a520b5a16bff.zip |
Call Method Spinner Bringup
Call Method Spinner is part of the t9 layout
so we need to keep it in PhoneCommon.
Change-Id: Ia1bab96001b24018b3e21e3cb428514357adf06f
-rw-r--r-- | res/drawable/ic_arrow_drop_down.xml | 33 | ||||
-rw-r--r-- | res/drawable/ic_sim_1.xml | 41 | ||||
-rw-r--r-- | res/drawable/ic_sim_2.xml | 47 | ||||
-rw-r--r-- | res/drawable/ic_sim_3.xml | 38 | ||||
-rw-r--r-- | res/drawable/ic_sim_4.xml | 29 | ||||
-rw-r--r-- | res/drawable/ic_sim_backing.xml | 38 | ||||
-rw-r--r-- | res/layout/call_method_spinner_dropdown_item.xml | 41 | ||||
-rw-r--r-- | res/layout/call_method_spinner_item.xml | 39 | ||||
-rw-r--r-- | res/layout/dialpad_view_unthemed.xml | 10 | ||||
-rw-r--r-- | res/values/cm_colors.xml | 12 | ||||
-rw-r--r-- | res/values/cm_dimens.xml | 8 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 6 | ||||
-rw-r--r-- | src/com/android/phone/common/dialpad/DialpadView.java | 5 | ||||
-rw-r--r-- | src/com/android/phone/common/incall/CallMethodSpinnerAdapter.java | 231 | ||||
-rw-r--r-- | src/com/android/phone/common/util/StartInCallCallReceiver.java | 42 |
15 files changed, 619 insertions, 1 deletions
diff --git a/res/drawable/ic_arrow_drop_down.xml b/res/drawable/ic_arrow_drop_down.xml new file mode 100644 index 0000000..619bd6e --- /dev/null +++ b/res/drawable/ic_arrow_drop_down.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The CyanogenMod 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. + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="10dp" + android:height="5dp" + android:viewportWidth="10" + android:viewportHeight="5"> + + <group + android:translateX="-370.000000" + android:translateY="-767.000000"> + <group + android:translateX="370.000000" + android:translateY="767.000000"> + <path + android:fillColor="#000000" + android:pathData="M0,0 L5,5 L10,0 L0,0 Z" /> + </group> + </group> +</vector>
\ No newline at end of file diff --git a/res/drawable/ic_sim_1.xml b/res/drawable/ic_sim_1.xml new file mode 100644 index 0000000..c3ca6da --- /dev/null +++ b/res/drawable/ic_sim_1.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The CyanogenMod 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. + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="23dp" + android:height="18dp" + android:viewportWidth="23" + android:viewportHeight="18"> + + <group + android:translateX="-49.000000" + android:translateY="-572.000000"> + <group + android:translateX="49.000000" + android:translateY="572.000000"> + <path + android:fillColor="#000000" + android:pathData="M20.1327172,17.724375 C21.3427172,17.724375 22.3327172,16.7525735 +22.3327172,15.5514706 L22.3327172,6.81617647 L15.7327172,0.264705882 +L2.53271719,0.264705882 C1.32271719,0.264705882 0.33271719,1.24742647 +0.33271719,2.44852941 L0.33271719,15.5623897 C0.33271719,16.7634926 +1.32271719,17.7352941 2.53271719,17.7352941 L20.1327172,17.724375 +L20.1327172,17.724375 Z M9.14701719,6.26148529 L7.43321719,6.6796875 +L6.98441719,4.92280147 L9.80591719,4.08639706 L11.2810172,4.08639706 +L11.2810172,13.9136029 L9.14701719,13.9136029 L9.14701719,6.26148529 +L9.14701719,6.26148529 Z" /> + </group> + </group> +</vector>
\ No newline at end of file diff --git a/res/drawable/ic_sim_2.xml b/res/drawable/ic_sim_2.xml new file mode 100644 index 0000000..a021c50 --- /dev/null +++ b/res/drawable/ic_sim_2.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The CyanogenMod 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. + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="23dp" + android:height="18dp" + android:viewportWidth="23" + android:viewportHeight="18"> + + <group + android:translateX="-49.000000" + android:translateY="-666.000000"> + <group + android:translateX="49.000000" + android:translateY="666.000000"> + <path + android:fillColor="#000000" + android:pathData="M20.1327172,17.724375 C21.3427172,17.724375 22.3327172,16.7525735 +22.3327172,15.5514706 L22.3327172,6.81617647 L15.7327172,0.264705882 +L2.53271719,0.264705882 C1.32271719,0.264705882 0.33271719,1.24742647 +0.33271719,2.44852941 L0.33271719,15.5623897 C0.33271719,16.7634926 +1.32271719,17.7352941 2.53271719,17.7352941 L20.1327172,17.724375 +L20.1327172,17.724375 Z M6.62141719,12.2255074 L9.86971719,9.58198897 +C11.0841172,8.58616544 11.5571172,8.05877206 11.5571172,7.25730882 +C11.5571172,6.43946691 11.0137172,5.99724265 10.2470172,5.99724265 +C9.49461719,5.99724265 8.97761719,6.41326103 8.25271719,7.29880147 +L6.74681719,6.09333088 C7.70931719,4.79286397 8.64431719,4.08639706 +10.3867172,4.08639706 C12.4074172,4.08639706 13.7472172,5.26347794 +13.7472172,7.07605147 L13.7472172,7.10444118 C13.7472172,8.72483824 +12.9101172,9.52630147 11.1809172,10.8551581 L9.59141719,12.0737316 +L13.8440172,12.0737316 L13.8440172,13.9136029 L6.62141719,13.9136029 +L6.62141719,12.2255074 L6.62141719,12.2255074 Z" /> + </group> + </group> +</vector>
\ No newline at end of file diff --git a/res/drawable/ic_sim_3.xml b/res/drawable/ic_sim_3.xml new file mode 100644 index 0000000..186ffbe --- /dev/null +++ b/res/drawable/ic_sim_3.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The CyanogenMod 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. + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="68dp" + android:height="54dp" + android:viewportWidth="68" + android:viewportHeight="54"> + + <path + android:fillColor="#000000" + android:pathData="M61.2,53.966c3.74,0,6.8-3.004,6.8-6.716v-27L47.6,0H6.8 +C3.06,0,0,3.037,0,6.75v40.534C0,50.996,3.06,54,6.8,54L61.2,53.966z +M27.142,24.179h3.363c1.285,0,2.235-0.338,2.851-1.015 +s0.923-1.603,0.923-2.779c0-0.451-0.072-0.878-0.215-1.282s-0.359-0.759-0.646-1.066s-0.653-0.55-1.097-0.728 +c-0.444-0.178-0.967-0.267-1.569-0.267c-0.424,0-0.837,0.065-1.241,0.195s-0.766,0.314-1.087,0.554s-0.581,0.53-0.779,0.872 +c-0.198,0.342-0.297,0.731-0.297,1.169h-6.911c0-1.271,0.273-2.41,0.82-3.415s1.285-1.856,2.215-2.553s2-1.23,3.209-1.6 +s2.485-0.554,3.825-0.554c1.586,0,3.035,0.185,4.348,0.554s2.437,0.913,3.374,1.63s1.665,1.606,2.184,2.666 +s0.779,2.287,0.779,3.681c0,0.684-0.109,1.34-0.328,1.969s-0.526,1.22-0.923,1.774s-0.882,1.056-1.456,1.507 +s-1.21,0.841-1.907,1.169c1.586,0.574,2.83,1.446,3.732,2.615s1.354,2.615,1.354,4.337c0,1.395-0.284,2.639-0.851,3.732 +s-1.35,2.017-2.348,2.769s-2.177,1.323-3.538,1.712s-2.833,0.584-4.419,0.584c-0.834,0-1.671-0.075-2.512-0.226 +s-1.651-0.376-2.43-0.677s-1.511-0.687-2.194-1.159s-1.275-1.032-1.774-1.682s-0.896-1.384-1.189-2.205s-0.441-1.743-0.441-2.769 +h6.952c0,0.479,0.103,0.923,0.308,1.333s0.482,0.769,0.831,1.077s0.755,0.547,1.22,0.718s0.957,0.256,1.477,0.256 +c0.629,0,1.193-0.092,1.692-0.277c0.499-0.185,0.919-0.441,1.261-0.769s0.602-0.711,0.779-1.148s0.267-0.909,0.267-1.415 +c0-1.504-0.376-2.57-1.128-3.199s-1.791-0.943-3.117-0.943h-3.363V24.179z" /> +</vector>
\ No newline at end of file diff --git a/res/drawable/ic_sim_4.xml b/res/drawable/ic_sim_4.xml new file mode 100644 index 0000000..e97aad7 --- /dev/null +++ b/res/drawable/ic_sim_4.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The CyanogenMod 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. + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="68dp" + android:height="54dp" + android:viewportWidth="68" + android:viewportHeight="54"> + + <path + android:fillColor="#000000" + android:pathData="M61.2,53.966c3.74,0,6.8-3.004,6.8-6.716v-27L47.6,0H6.8 +C3.06,0,0,3.037,0,6.75v40.534C0,50.996,3.06,54,6.8,54L61.2,53.966z +M39.077,30.331h3.035v5.332h-3.035V42h-6.911v-6.337H20.62 +l-0.41-4.225l11.956-19.236V12.14h6.911V30.331z +M26.793,30.331h5.373v-9.188l-0.431,0.697L26.793,30.331z" /> +</vector>
\ No newline at end of file diff --git a/res/drawable/ic_sim_backing.xml b/res/drawable/ic_sim_backing.xml new file mode 100644 index 0000000..cec1fde --- /dev/null +++ b/res/drawable/ic_sim_backing.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The CyanogenMod 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. + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="23dp" + android:height="18dp" + android:viewportWidth="23" + android:viewportHeight="18"> + + <group + android:translateX="-49.000000" + android:translateY="-590.000000"> + <group + android:translateX="49.000000" + android:translateY="590.000000"> + <path + android:fillColor="#FFFFFF" + android:pathData="M20.1327172,17.724375 C21.3427172,17.724375 22.3327172,16.7525735 +22.3327172,15.5514706 L22.3327172,6.81617647 L15.7327172,0.264705882 +L2.53271719,0.264705882 C1.32271719,0.264705882 0.33271719,1.24742647 +0.33271719,2.44852941 L0.33271719,15.5623897 C0.33271719,16.7634926 +1.32271719,17.7352941 2.53271719,17.7352941 L20.1327172,17.724375 +L20.1327172,17.724375 Z" /> + </group> + </group> +</vector> diff --git a/res/layout/call_method_spinner_dropdown_item.xml b/res/layout/call_method_spinner_dropdown_item.xml new file mode 100644 index 0000000..8506c3b --- /dev/null +++ b/res/layout/call_method_spinner_dropdown_item.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The CyanogenMod 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. + --> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:layout_width="@dimen/call_method_spinner_dropdown_item_width" + android:layout_height="@dimen/dialpad_digits_height" + android:paddingStart="@dimen/call_method_spinner_item_default_padding" + android:paddingEnd="@dimen/call_method_spinner_item_default_padding"> + + <ImageView + android:id="@+id/call_method_spinner_item_image" + android:layout_width="@dimen/call_method_spinner_icon_size" + android:layout_height="@dimen/call_method_spinner_icon_size" + android:layout_gravity="center_vertical" /> + + <TextView + android:id="@+id/call_method_spinner_item_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_marginStart="@dimen/call_method_spinner_item_text_left_margin" + android:singleLine="true" + android:ellipsize="end" + android:textSize="15sp" + android:textColor="@color/call_method_spinner_item_text_color"/> + +</LinearLayout>
\ No newline at end of file diff --git a/res/layout/call_method_spinner_item.xml b/res/layout/call_method_spinner_item.xml new file mode 100644 index 0000000..a361306 --- /dev/null +++ b/res/layout/call_method_spinner_item.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The CyanogenMod 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. + --> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingStart="@dimen/call_method_spinner_item_default_padding" > + + <ImageView + android:id="@+id/call_method_spinner_item_image" + android:layout_width="@dimen/call_method_spinner_icon_size" + android:layout_height="@dimen/call_method_spinner_icon_size" + android:layout_gravity="center_vertical" /> + + <ImageView + android:id="@+id/call_method_spinner_drop_down_arrow" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingStart="@dimen/call_method_spinner_item_secondary_padding" + android:paddingEnd="@dimen/call_method_spinner_item_secondary_padding" + android:layout_gravity="center_vertical" + android:src="@drawable/ic_arrow_drop_down" + android:tint="@color/call_method_spinner_drop_down_arrow" /> + +</LinearLayout>
\ No newline at end of file diff --git a/res/layout/dialpad_view_unthemed.xml b/res/layout/dialpad_view_unthemed.xml index fdbc397..18ab647 100644 --- a/res/layout/dialpad_view_unthemed.xml +++ b/res/layout/dialpad_view_unthemed.xml @@ -81,6 +81,16 @@ android:gravity="center" android:visibility="invisible" /> + <Spinner + android:id="@+id/call_method_spinner" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:dropDownWidth="@dimen/call_method_spinner_dropdown_item_width" + android:background="@drawable/btn_dialpad_key" + android:gravity="center_vertical" + android:paddingStart="@dimen/call_method_spinner_padding_start" + android:paddingEnd="@dimen/dialpad_digits_padding" /> + <view class="com.android.phone.common.dialpad.DigitsEditText" xmlns:ex="http://schemas.android.com/apk/res-auto" android:id="@+id/digits" diff --git a/res/values/cm_colors.xml b/res/values/cm_colors.xml new file mode 100644 index 0000000..19f61d7 --- /dev/null +++ b/res/values/cm_colors.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <!-- Color of call method spinner item text --> + <color name="call_method_spinner_item_text_color">#de000000</color> + + <!-- Color of call method spinner drop down arrow --> + <color name="call_method_spinner_drop_down_arrow">#000000</color> + + <!-- Color of sim icons --> + <color name="sim_icon_color">#f5a623</color> + +</resources>
\ No newline at end of file diff --git a/res/values/cm_dimens.xml b/res/values/cm_dimens.xml index eec63b9..3880dd6 100644 --- a/res/values/cm_dimens.xml +++ b/res/values/cm_dimens.xml @@ -18,4 +18,12 @@ <dimen name="dialpad_key_letters_small_size">10sp</dimen> <dimen name="dialpad_key_margin_right">9dp</dimen> <dimen name="dialpad_key_number_left_margin">26dp</dimen> + + <!-- Dimensions for call method spinner and items --> + <dimen name="call_method_spinner_padding_start">4dp</dimen> + <dimen name="call_method_spinner_item_default_padding">12dp</dimen> + <dimen name="call_method_spinner_item_secondary_padding">7dp</dimen> + <dimen name="call_method_spinner_item_text_left_margin">16dp</dimen> + <dimen name="call_method_spinner_dropdown_item_width">134dp</dimen> + <dimen name="call_method_spinner_icon_size">24dp</dimen> </resources>
\ No newline at end of file diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index bba0354..c246c8b 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -15,9 +15,13 @@ See the License for the specific language governing permissions and limitations under the License. --> -<resources> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <!-- In-call screen: call failure reason (call ended due to low battery) --> <string name="callFailed_low_battery">Low battery</string> <string name="to_hint" translatable="false">1111:to;sip:abby@example.com:bcc;sip:bill@example.com:cc;</string> + + <!-- Call method spinner - Default No SIM --> + <string name="call_method_spinner_item_no_sim">No SIM card</string> + <string name="call_method_spinner_item_unknown_sim">SIM <xliff:g id="slot_number">%d</xliff:g></string> </resources> diff --git a/src/com/android/phone/common/dialpad/DialpadView.java b/src/com/android/phone/common/dialpad/DialpadView.java index edef84e..53a9dbe 100644 --- a/src/com/android/phone/common/dialpad/DialpadView.java +++ b/src/com/android/phone/common/dialpad/DialpadView.java @@ -35,6 +35,7 @@ import android.view.accessibility.AccessibilityManager; import android.widget.EditText; import android.widget.ImageButton; import android.widget.LinearLayout; +import android.widget.Spinner; import android.widget.TextView; import com.android.phone.common.R; @@ -68,6 +69,7 @@ public class DialpadView extends LinearLayout { private ImageButton mDelete; private View mOverflowMenuButton; private ColorStateList mRippleColor; + private Spinner mCallMethodSpinner; private ViewGroup mRateContainer; private TextView mIldCountry; @@ -117,6 +119,7 @@ public class DialpadView extends LinearLayout { mRateContainer = (ViewGroup) findViewById(R.id.rate_container); mIldCountry = (TextView) mRateContainer.findViewById(R.id.ild_country); mIldRate = (TextView) mRateContainer.findViewById(R.id.ild_rate); + mCallMethodSpinner = (Spinner) findViewById(R.id.call_method_spinner); AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); @@ -338,6 +341,8 @@ public class DialpadView extends LinearLayout { return mDelete; } + public Spinner getCallMethodSpinner() { return mCallMethodSpinner; } + public View getOverflowMenuButton() { return mOverflowMenuButton; } diff --git a/src/com/android/phone/common/incall/CallMethodSpinnerAdapter.java b/src/com/android/phone/common/incall/CallMethodSpinnerAdapter.java new file mode 100644 index 0000000..434e13d --- /dev/null +++ b/src/com/android/phone/common/incall/CallMethodSpinnerAdapter.java @@ -0,0 +1,231 @@ +/* + * Copyright (C) 2015 The CyanogenMod 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.phone.common.incall; + +import android.content.ComponentName; +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ImageView; +import android.widget.SpinnerAdapter; +import android.widget.TextView; +import com.android.dialer.incall.CallMethodInfo; + +import com.android.phone.common.R; + +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.cyanogen.ambient.incall.util.InCallHelper.NO_COLOR; + +public class CallMethodSpinnerAdapter extends ArrayAdapter<CallMethodInfo> + implements SpinnerAdapter { + private static final String TAG = CallMethodSpinnerAdapter.class.getSimpleName(); + + private final Context mContext; + private Map<String, Integer> mComponentMap; + + public CallMethodSpinnerAdapter(Context context, List<CallMethodInfo> objects) { + super(context, 0, objects); + mContext = context.getApplicationContext(); + processCallMethods(objects); + } + + /** + * Remove all elements from the list. + */ + @Override + public void clear() { + super.clear(); + mComponentMap.clear(); + } + + /** + * Adds the specified list of call method infos at the end of the array. + * + * @param objects The list of call method info entries to add at the end of the array. + */ + public void addAll(List<CallMethodInfo> objects) { + super.addAll(objects); + processCallMethods(objects); + } + + /** + * Adds the specified list of call method infos at the end of the array. + * + * @param objects The list of call method info entries to add at the end of the array. + */ + public void addAll(HashMap<ComponentName, CallMethodInfo> objects) { + super.addAll(objects.values()); + processCallMethods(objects.values()); + } + + /** + * Get a View that displays the data at the specified position in the data set. You can either + * create a View manually or inflate it from an XML layout file. When the View is inflated, the + * parent View (GridView, ListView...) will apply default layout parameters unless you use + * {@link LayoutInflater#inflate(int, ViewGroup, boolean)} + * to specify a root view and to prevent attachment to the root. + * + * @param position The position of the item within the adapter's data set of the item whose + * view we want. + * @param convertView The old view to reuse, if possible. Note: You should check that this view + * is non-null and of an appropriate type before using. If it is not possible + * to convert this view to display the correct data, this method can create a + * new view. Heterogeneous lists can specify their number of view types, so + * that this View is always of the right type + * (see {@link #getViewTypeCount()} and {@link #getItemViewType(int)}). + * @param parent The parent that this view will eventually be attached to + * @return A View corresponding to the data at the specified position. + */ + @Override + public View getView(int position, View convertView, ViewGroup parent) { + CallMethodInfo callMethodInfo = getItem(position); + if (convertView == null) { + convertView = LayoutInflater.from(mContext) + .inflate(R.layout.call_method_spinner_item, parent, false); + } + + setIcon(convertView, callMethodInfo); + + return convertView; + } + + /** + * <p>Get a {@link View} that displays in the drop down popup + * the data at the specified position in the data set.</p> + * + * @param position index of the item whose view we want. + * @param convertView the old view to reuse, if possible. Note: You should + * check that this view is non-null and of an appropriate type before + * using. If it is not possible to convert this view to display the + * correct data, this method can create a new view. + * @param parent the parent that this view will eventually be attached to + * @return a {@link View} corresponding to the data at the + * specified position. + */ + @Override + public View getDropDownView(int position, View convertView, ViewGroup parent) { + CallMethodInfo callMethodInfo = getItem(position); + if (convertView == null) { + convertView = LayoutInflater.from(mContext) + .inflate(R.layout.call_method_spinner_dropdown_item, parent, false); + } + + setIcon(convertView, callMethodInfo); + + TextView text=(TextView) convertView.findViewById(R.id.call_method_spinner_item_text); + text.setText(callMethodInfo.mName); + + return convertView; + } + + private void setIcon(View convertView, CallMethodInfo callMethodInfo) { + ImageView icon = (ImageView) convertView.findViewById(R.id.call_method_spinner_item_image); + if (callMethodInfo.mBadgeIcon != null) { + icon.setImageDrawable(callMethodInfo.mBadgeIcon); + icon.getDrawable().setTintList(null); + icon.setBackground(null); + } else { + int drawableId = getIconForSlot(callMethodInfo.mSlotId); + + // if not all calls + if (callMethodInfo.mSlotId != -1) { + Drawable forground = mContext.getDrawable(drawableId); + Drawable background = mContext.getDrawable(R.drawable.ic_sim_backing); + + if (callMethodInfo.mColor != NO_COLOR) { + forground.setTint(callMethodInfo.mColor); + } else { + forground.setTint(mContext.getResources().getColor(R.color.sim_icon_color)); + } + + Drawable[] layers = {background, forground}; + LayerDrawable layerDrawable = new LayerDrawable(layers); + icon.setImageDrawable(layerDrawable); + } else { + icon.setImageResource(drawableId); + icon.getDrawable().setTint(mContext.getResources().getColor(R.color.sim_icon_color)); + icon.setBackground(null); + } + } + } + + public static int getIconForSlot(int slotId) { + switch (slotId) { + case -1: + return R.drawable.fab_ic_call; + case 1: + return R.drawable.ic_sim_2; + case 2: + return R.drawable.ic_sim_3; + case 3: + return R.drawable.ic_sim_4; + default: + return R.drawable.ic_sim_1; + } + } + + /** + * Map call method component names to spinner positions. + * @param callMethodInfoList list of current call methods + */ + private void processCallMethods(Collection<CallMethodInfo> callMethodInfoList) { + if (mComponentMap == null) { + mComponentMap = new HashMap<String, Integer>(); + } + if (callMethodInfoList != null) { + for (CallMethodInfo info : callMethodInfoList) { + String key = getCallMethodKey(info); + mComponentMap.put(key, mComponentMap.size()); + } + } + } + + /** + * Returns the position of the specified component within the spinner + * @param key String key for call method lookup + * @return Position of specified component, 0 if not found. + */ + public int getPosition(String key) { + int position = 0; + if (!TextUtils.isEmpty(key)) { + position = mComponentMap.containsKey(key) ? + mComponentMap.get(key) : 0; + } + return position; + } + + /** + * Returns an ID for the specified CallMethodInfo + * @param info CallMethodInfo to create id for + * @return String key for specified CallMethodInfo. + */ + public static String getCallMethodKey(CallMethodInfo info) { + if (info == null || info.mComponent == null) { + return null; + } + return info.mComponent.flattenToString() + String.valueOf(info.mSubId); + } +} diff --git a/src/com/android/phone/common/util/StartInCallCallReceiver.java b/src/com/android/phone/common/util/StartInCallCallReceiver.java new file mode 100644 index 0000000..c2dd3c0 --- /dev/null +++ b/src/com/android/phone/common/util/StartInCallCallReceiver.java @@ -0,0 +1,42 @@ +package com.android.phone.common.util; + +import android.os.Bundle; +import android.os.Handler; +import android.os.ResultReceiver; +import android.util.Log; + +import java.lang.ref.WeakReference; + +public class StartInCallCallReceiver extends ResultReceiver { + private static final String TAG = StartInCallCallReceiver.class.getSimpleName(); + private static final boolean DEBUG = false; + + private WeakReference<Receiver> mReceiver; + + public StartInCallCallReceiver(Handler handler) { + super(handler); + } + + @Override + protected void onReceiveResult(int resultCode, Bundle resultData) { + if (DEBUG) { + Log.d(TAG, "Result received resultCode: " + resultCode + " resultData: " + resultData); + } + + if (mReceiver != null) { + Receiver receiver = mReceiver.get(); + if (receiver != null) { + receiver.onReceiveResult(resultCode, resultData); + } + } + } + + public interface Receiver { + public void onReceiveResult(int resultCode, Bundle resultData); + } + + public void setReceiver(Receiver receiver) { + mReceiver = new WeakReference<Receiver>(receiver); + } + +}
\ No newline at end of file |