summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/select_account_list_item.xml38
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/com/android/incallui/InCallActivity.java16
-rw-r--r--src/com/android/incallui/SelectPhoneAccountDialogFragment.java149
4 files changed, 14 insertions, 192 deletions
diff --git a/res/layout/select_account_list_item.xml b/res/layout/select_account_list_item.xml
deleted file mode 100644
index 1999fced..00000000
--- a/res/layout/select_account_list_item.xml
+++ /dev/null
@@ -1,38 +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.
--->
-
-<!-- Layout of a single item in the InCallUI Account Chooser Dialog. -->
-<view class="com.android.contacts.common.widget.ActivityTouchLinearLayout"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="4dp" >
-
- <ImageView android:id="@+id/icon"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:tint="@color/dialtacts_secondary_text_color"
- android:scaleType="center" />
-
- <TextView android:id="@+id/text"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="start|center_vertical"
- android:layout_marginLeft="8dp"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="match_parent" />
-</view>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d174511c..38ae07bb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -546,7 +546,4 @@
<!-- This can be used in any application wanting to disable the text "Emergency number" -->
<string name="emergency_call_dialog_number_for_display">Emergency number</string>
-
- <!-- Title for Select Account Dialog [CHAR LIMIT=30] -->
- <string name="select_account_dialog_title">Select Account</string>
</resources>
diff --git a/src/com/android/incallui/InCallActivity.java b/src/com/android/incallui/InCallActivity.java
index 2fcfda54..a6917c86 100644
--- a/src/com/android/incallui/InCallActivity.java
+++ b/src/com/android/incallui/InCallActivity.java
@@ -46,6 +46,8 @@ import android.view.accessibility.AccessibilityEvent;
import com.android.phone.common.animation.AnimUtils;
import com.android.phone.common.animation.AnimationListenerAdapter;
import com.android.contacts.common.interactions.TouchPointManager;
+import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment;
+import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener;
import com.android.incallui.Call.State;
import java.util.ArrayList;
@@ -488,7 +490,6 @@ public class InCallActivity extends Activity {
extras = new Bundle();
}
-
Point touchPoint = null;
if (TouchPointManager.getInstance().hasValidPoint()) {
// Use the most immediate touch point in the InCallUi if available
@@ -532,8 +533,19 @@ public class InCallActivity extends Activity {
phoneAccountHandles = new ArrayList<>();
}
+ SelectPhoneAccountListener listener = new SelectPhoneAccountListener() {
+ @Override
+ public void onPhoneAccountSelected(PhoneAccountHandle selectedAccountHandle) {
+ InCallPresenter.getInstance().handleAccountSelection(selectedAccountHandle);
+ }
+ @Override
+ public void onDialogDismissed() {
+ InCallPresenter.getInstance().cancelAccountSelection();
+ }
+ };
+
SelectPhoneAccountDialogFragment.showAccountDialog(getFragmentManager(),
- phoneAccountHandles);
+ phoneAccountHandles, listener);
} else {
mCallCardFragment.setVisible(true);
}
diff --git a/src/com/android/incallui/SelectPhoneAccountDialogFragment.java b/src/com/android/incallui/SelectPhoneAccountDialogFragment.java
deleted file mode 100644
index 49f23b72..00000000
--- a/src/com/android/incallui/SelectPhoneAccountDialogFragment.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * 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
- */
-
-package com.android.incallui;
-
-import android.telecom.PhoneAccount;
-import android.telecom.PhoneAccountHandle;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.FragmentManager;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.telecom.TelecomManager;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.ListAdapter;
-import android.widget.TextView;
-
-import com.android.contacts.common.R;
-
-import java.util.List;
-
-/**
- * Dialog that allows the user to switch between default SIM cards
- */
-public class SelectPhoneAccountDialogFragment extends DialogFragment {
- private List<PhoneAccountHandle> mAccountHandles;
- private boolean mIsSelected;
- private TelecomManager mTelecomManager;
-
- /**
- * Shows the account selection dialog.
- * This is the preferred way to show this dialog.
- *
- * @param fragmentManager The fragment manager.
- * @param accountHandles The {@code PhoneAccountHandle}s available to select from.
- */
- public static void showAccountDialog(FragmentManager fragmentManager,
- List<PhoneAccountHandle> accountHandles) {
- SelectPhoneAccountDialogFragment fragment =
- new SelectPhoneAccountDialogFragment(accountHandles);
- fragment.show(fragmentManager, "selectAccount");
- }
-
- public SelectPhoneAccountDialogFragment(List<PhoneAccountHandle> accountHandles) {
- super();
- mAccountHandles = accountHandles;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- mIsSelected = false;
- mTelecomManager =
- (TelecomManager) getActivity().getSystemService(Context.TELECOM_SERVICE);
-
- final DialogInterface.OnClickListener selectionListener =
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- mIsSelected = true;
- PhoneAccountHandle selectedAccountHandle = mAccountHandles.get(which);
- InCallPresenter.getInstance().handleAccountSelection(selectedAccountHandle);
- }
- };
-
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-
- ListAdapter selectAccountListAdapter = new SelectAccountListAdapter(
- builder.getContext(),
- R.layout.select_account_list_item,
- mAccountHandles);
-
- return builder.setTitle(R.string.select_account_dialog_title)
- .setAdapter(selectAccountListAdapter, selectionListener)
- .create();
- }
-
- private class SelectAccountListAdapter extends ArrayAdapter<PhoneAccountHandle> {
- private Context mContext;
- private int mResId;
-
- public SelectAccountListAdapter(
- Context context, int resource, List<PhoneAccountHandle> accountHandles) {
- super(context, resource, accountHandles);
- mContext = context;
- mResId = resource;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- LayoutInflater inflater = (LayoutInflater)
- mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
- View rowView;
- final ViewHolder holder;
-
- if (convertView == null) {
- // Cache views for faster scrolling
- rowView = inflater.inflate(mResId, null);
- holder = new ViewHolder();
- holder.textView = (TextView) rowView.findViewById(R.id.text);
- holder.imageView = (ImageView) rowView.findViewById(R.id.icon);
- rowView.setTag(holder);
- }
- else {
- rowView = convertView;
- holder = (ViewHolder) rowView.getTag();
- }
-
- PhoneAccountHandle accountHandle = getItem(position);
- PhoneAccount account = mTelecomManager.getPhoneAccount(accountHandle);
- holder.textView.setText(account.getLabel());
- holder.imageView.setImageDrawable(account.getIcon(mContext));
- return rowView;
- }
-
- private class ViewHolder {
- TextView textView;
- ImageView imageView;
- }
- }
-
- @Override
- public void onPause() {
- if (!mIsSelected) {
- InCallPresenter.getInstance().cancelAccountSelection();
- }
- super.onPause();
- }
-} \ No newline at end of file