diff options
author | Zhu Youhua <youhua@codeaurora.org> | 2016-07-13 10:52:09 +0800 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2016-08-24 08:18:49 -0600 |
commit | 93136e62f29192f43badde3fe0d36a6af235defc (patch) | |
tree | e4386e5df8dd5aa289d70d7ef403f820d86bc854 | |
parent | 8209338d3554d4263b6ce150ecb2faa6592dc83e (diff) | |
download | android_packages_apps_ContactsCommon-93136e62f29192f43badde3fe0d36a6af235defc.tar.gz android_packages_apps_ContactsCommon-93136e62f29192f43badde3fe0d36a6af235defc.tar.bz2 android_packages_apps_ContactsCommon-93136e62f29192f43badde3fe0d36a6af235defc.zip |
ContactsCommom : Create dialog for open/close video calling menu
When open/close video calling menu will create the Dialog.
Change-Id: I9105e87234a5afb7e751783394f7a431840219f5
CRs-Fixed: 1039337
-rw-r--r-- | res/layout/hint_dialog_layout.xml | 69 | ||||
-rw-r--r-- | res/values/dimens.xml | 5 | ||||
-rw-r--r-- | res/values/qtistrings.xml | 40 | ||||
-rw-r--r-- | src/com/android/contacts/common/CallUtil.java | 102 |
4 files changed, 215 insertions, 1 deletions
diff --git a/res/layout/hint_dialog_layout.xml b/res/layout/hint_dialog_layout.xml new file mode 100644 index 00000000..6b2ef8e4 --- /dev/null +++ b/res/layout/hint_dialog_layout.xml @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (c) 2016, The Linux Foundation. All rights reserved. + ~ + ~ Redistribution and use in source and binary forms, with or without + ~ modification, are permitted provided that the following conditions are + ~ met: + ~ * Redistributions of source code must retain the above copyright + ~ notice, this list of conditions and the following disclaimer. + ~ * Redistributions in binary form must reproduce the above + ~ copyright notice, this list of conditions and the following + ~ disclaimer in the documentation and/or other materials provided + ~ with the distribution. + ~ * Neither the name of The Linux Foundation nor the names of its + ~ contributors may be used to endorse or promote products derived + ~ from this software without specific prior written permission. + ~ + ~ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + ~ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + ~ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + ~ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + ~ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + ~ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + ~ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + ~ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + ~ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + ~ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + ~ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" > + <TextView + android:id="@+id/txt_message" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:layout_above="@+id/txt_checkbox" + android:layout_marginLeft="@dimen/video_calling_dialoglayout_margin" + android:layout_marginRight="@dimen/video_calling_dialoglayout_margin" + android:textSize="@dimen/video_calling_dialoglayout_text_size" /> + + <TextView + android:id="@+id/txt_checkbox" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_above="@+id/btn_ok" + android:layout_marginBottom="@dimen/video_calling_dialoglayout_margin" + android:layout_marginLeft="@dimen/video_calling_dialoglayout_margin" + android:textSize="@dimen/video_calling_dialoglayout_text_size" + android:text="@string/video_call_dialog_checkbox" /> + + <CheckBox + android:id="@+id/videocall" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_above="@+id/btn_ok" + android:layout_toRightOf="@+id/txt_checkbox" + android:layout_marginBottom="@dimen/video_calling_dialoglayout_checkbox_marginbottom" + android:layout_marginLeft="@dimen/video_calling_dialoglayout_checkbox_marginleft" /> + + <Button + android:id="@+id/btn_ok" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:textSize="@dimen/video_calling_dialoglayout_text_size" + android:text="@string/video_call_dialog_ok" /> +</RelativeLayout> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 836bd071..8fc51b1a 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -167,4 +167,9 @@ <dimen name="call_subject_dialog_secondary_text_size">14sp</dimen> <!-- Row padding for call subject history items. --> <dimen name="call_subject_history_item_padding">15dp</dimen> + + <dimen name="video_calling_dialoglayout_margin">30dp</dimen> + <dimen name="video_calling_dialoglayout_checkbox_marginleft">10dp</dimen> + <dimen name="video_calling_dialoglayout_checkbox_marginbottom">24dp</dimen> + <dimen name="video_calling_dialoglayout_text_size">18sp</dimen> </resources> diff --git a/res/values/qtistrings.xml b/res/values/qtistrings.xml new file mode 100644 index 00000000..4c35c032 --- /dev/null +++ b/res/values/qtistrings.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (c) 2016, The Linux Foundation. All rights reserved. + ~ + ~ Redistribution and use in source and binary forms, with or without + ~ modification, are permitted provided that the following conditions are + ~ met: + ~ Redistributions of source code must retain the above copyright + ~ notice, this list of conditions and the following disclaimer. + ~ Redistributions in binary form must reproduce the above + ~ copyright notice, this list of conditions and the following + ~ disclaimer in the documentation and/or other materials provided + ~ with the distribution. + ~ Neither the name of The Linux Foundation nor the names of its + ~ contributors may be used to endorse or promote products derived + ~ from this software without specific prior written permission. + ~ + ~ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + ~ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + ~ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + ~ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + ~ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + ~ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + ~ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + ~ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + ~ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + ~ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + ~ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ~ + --> + +<!-- The xml contains Qti specific resource strings neede for any value added features. --> +<resources> + <!-- video call --> + <string name="video_call">Video Calling</string> + <string name="video_call_dialog_ok">OK</string> + <string name="video_call_dialog_checkbox">"Don't remind me again"</string> + <string name="video_call_message_on"> When using the Verizon Wireless 4G LTE network,the voice portion of a video call will appear on your bill as mobile-to-mobile voice usage, and the video portion will be billed as data. When video calling is turned on, other can see that your phone has video calling. </string> + <string name="video_call_message_off"> Your phone will not be able to make or receive video calls when you turn this setting off. </string> +</resources> diff --git a/src/com/android/contacts/common/CallUtil.java b/src/com/android/contacts/common/CallUtil.java index 88fca92c..8e106dc3 100644 --- a/src/com/android/contacts/common/CallUtil.java +++ b/src/com/android/contacts/common/CallUtil.java @@ -22,15 +22,30 @@ import com.android.contacts.common.util.PermissionsUtil; import com.android.contacts.common.util.PhoneNumberHelper; import com.android.phone.common.PhoneConstants; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; +import android.provider.Settings; +import android.view.LayoutInflater; +import android.view.View; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.text.TextUtils; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; +import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; +import android.widget.Button; +import android.widget.TextView; + +import com.android.contacts.common.R; + import java.util.List; /** @@ -57,6 +72,15 @@ public class CallUtil { */ public static final int VIDEO_CALLING_PRESENCE = 2; + /*Enable Video calling irrespective of video capabilities*/ + public static final int ENABLE_VIDEO_CALLING = 1; + /*Disable Video calling irrespective of video capabilities*/ + public static final int DISABLE_VIDEO_CALLING = 2; + public static final String CONFIG_VIDEO_CALLING = "config_video_calling"; + public static final String DIALOG_VIDEO_CALLING = "display_video_call_dialog"; + private static AlertDialog mAlertDialog = null; + private static final int MAX_PHONE_NUM = 7; + /** * Return an Intent for making a phone call. Scheme (e.g. tel, sip) will be determined * automatically. @@ -170,7 +194,11 @@ public class CallUtil { * {@code false} otherwise. */ public static boolean isVideoEnabled(Context context) { - return (getVideoCallingAvailability(context) & VIDEO_CALLING_ENABLED) != 0; + boolean hasVideoCap = ((getVideoCallingAvailability(context) & + VIDEO_CALLING_ENABLED) != 0); + Settings.System.putInt(context.getContentResolver(), + CONFIG_VIDEO_CALLING,hasVideoCap?ENABLE_VIDEO_CALLING:DISABLE_VIDEO_CALLING); + return hasVideoCap; } /** @@ -201,4 +229,76 @@ public class CallUtil { } return false; } + + /** + * Checks if the number is valid for videoCall + * + * @param number the number to call. + * @return true if the number is valid + * + * @hide + */ + public static boolean isVideoCallNumValid(String number){ + if (null == number) { + return false; + } + if (number.contains("#") || (number.contains("+") && (number.indexOf("+") != 0)) || + number.contains(",") || number.contains(";") || number.contains("*")) { + return false; + } + String norNumber = PhoneNumberHelper.normalizeNumber(number); + if (norNumber.length() < MAX_PHONE_NUM) { + return false; + } + return true; + } + + + /** + * Show dialog when open/close video calling menu + * + * @param isChecked the menu if it is checked. + * @param context + * + * @hide + */ + public static void createVideoCallingDialog(boolean isChecked ,final Context context) { + int value = Settings.System.getInt(context.getContentResolver(), + DIALOG_VIDEO_CALLING,DISABLE_VIDEO_CALLING); + if(mAlertDialog == null && value == DISABLE_VIDEO_CALLING){ + View linearLayout = LayoutInflater.from(context).inflate( + R.layout.hint_dialog_layout, null); + final CheckBox chkBox = (CheckBox) linearLayout + .findViewById(R.id.videocall); + final Button btn = (Button) linearLayout + .findViewById(R.id.btn_ok); + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(mAlertDialog != null){ + mAlertDialog.dismiss(); + mAlertDialog = null; + } + } + }); + + final TextView txtMessage = (TextView) linearLayout + .findViewById(R.id.txt_message); + txtMessage.setText( + isChecked?R.string.video_call_message_on : R.string.video_call_message_off); + + chkBox.setOnCheckedChangeListener(new OnCheckedChangeListener(){ + @Override + public void onCheckedChanged(CompoundButton buttonView, + boolean isChecked) { + Settings.System.putInt(context.getContentResolver(), + DIALOG_VIDEO_CALLING,isChecked?ENABLE_VIDEO_CALLING:DISABLE_VIDEO_CALLING); + } + }); + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setView(linearLayout); + builder.create().setCancelable(false); + mAlertDialog = builder.show(); + } + } } |