Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63605bb0 authored by mengsun's avatar mengsun Committed by Linux Build Service Account
Browse files

Subscription selection when dialing USSD

When USSD is dialed allow user to selct subscription on which
the call has to be made

Change-Id: Iaf893302fd33579f74b747a117a08193a89da6c0
CRs-Fixed: 732935
parent 789d1c80
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -234,6 +234,9 @@
                <action android:name="android.bluetooth.IBluetoothHeadsetPhone" />
            </intent-filter>
        </service>
        <activity android:name="AccountSelection"
            android:theme="@style/Theme.Telecomm.Transparent"
            android:excludeFromRecents="true"/>

    </application>
</manifest>
+54 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
 * Copyright (c) 2014, 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.
 *
 */
-->

<LinearLayout
    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" />
</LinearLayout>
+1 −0
Original line number Diff line number Diff line
@@ -16,4 +16,5 @@

<resources>
    <color name="theme_color">#0288d1</color>
    <color name="dialtacts_secondary_text_color">#737373</color>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -114,4 +114,5 @@

    <string name="headset_plugin_view_text">Headset is plugged in.</string>
    <string name="headset_plugin_view_title">Headset</string>
    <string name="select_account_dialog_title">Select Account</string>
</resources>
+147 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014, 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.
 *
 */
package com.android.server.telecom;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.net.Uri;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ImageView;
import android.widget.TextView;


import java.util.List;
import android.os.Bundle;
import android.telecom.TelecomManager;
import android.view.LayoutInflater;

public class AccountSelection extends Activity {

    TelecomManager mTelecomManager;
    List<PhoneAccountHandle> mAccountHandles;
    Uri mHandle;
    boolean mIsSelected = false;

    @Override
    protected void onCreate(Bundle icicle) {
        Log.d(this, "onCreate()...  this = " + this);

        super.onCreate(icicle);
        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        mHandle = Uri.parse(extras.getString("Handle"));
        mAccountHandles = extras.getParcelableArrayList(android.telecom.
                Call.AVAILABLE_PHONE_ACCOUNTS);
        if (mAccountHandles == null ) {
            finish();
            return;
        }
        mTelecomManager = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
        final DialogInterface.OnClickListener selectionListener =
                new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                mIsSelected = true;
                CallsManager.getInstance().phoneAccountSelectedForMMI(mHandle,
                        mAccountHandles.get(which));
                finish();
            }
        };
        AlertDialog.Builder builder = new AlertDialog.Builder(AccountSelection.this);

        ListAdapter AccountListAdapter = new AccountListAdapter(
                builder.getContext(),
                R.layout.account_list_item,
                mAccountHandles);

        builder.setTitle(R.string.select_account_dialog_title)
                .setAdapter(AccountListAdapter, selectionListener)
                .setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {
                            mIsSelected = false;
                            finish();
                        }
                 }).create().show();
    }

    private class AccountListAdapter extends ArrayAdapter<PhoneAccountHandle> {
        private Context mContext;
        private int mResId;

        public AccountListAdapter(
                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 = inflater.inflate(mResId, null);
            TextView textView = (TextView) rowView.findViewById(R.id.text);
            ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);

            PhoneAccountHandle accountHandle = getItem(position);
            PhoneAccount account = mTelecomManager.getPhoneAccount(accountHandle);
            textView.setText(account.getLabel());
            imageView.setImageDrawable(account.getIcon(mContext));
            return rowView;
        }

    }


    @Override
    protected void onDestroy() {
        Log.d(this, "onDestroy()...  this = " + mIsSelected);
        if(!mIsSelected) {
            CallsManager.getInstance().phoneAccountSelectedForMMI(mHandle, null);
        }
        super.onDestroy();
    }
}
Loading