diff options
author | Sandeep Gutta <sangutta@codeaurora.org> | 2013-11-11 19:23:13 +0530 |
---|---|---|
committer | Sandeep Gutta <sangutta@codeaurora.org> | 2013-11-25 14:57:09 +0530 |
commit | d6e8ea435025aceadbf58ba78c4a2dd7fc745027 (patch) | |
tree | f33e72b81e5951dae3aa4a4679705b6892b4bed3 /src/com/android/incallui/msim/MSimInCallActivity.java | |
parent | f053a386531bb464cd95e7069f2bd0c058792941 (diff) | |
download | android_packages_apps_InCallUI-d6e8ea435025aceadbf58ba78c4a2dd7fc745027.tar.gz android_packages_apps_InCallUI-d6e8ea435025aceadbf58ba78c4a2dd7fc745027.tar.bz2 android_packages_apps_InCallUI-d6e8ea435025aceadbf58ba78c4a2dd7fc745027.zip |
DSDA: Add InCallUI DSDA support.
-Add tab view support for DSDA
-Add support to display voice calls based on the
current active subscription.
-Add few utilities in CallList, which required for handling
voice calls across multiple subscription.
Change-Id: Ib683f7c3b41ed3bb04367be1e9c331908bc46004
Diffstat (limited to 'src/com/android/incallui/msim/MSimInCallActivity.java')
-rw-r--r-- | src/com/android/incallui/msim/MSimInCallActivity.java | 232 |
1 files changed, 232 insertions, 0 deletions
diff --git a/src/com/android/incallui/msim/MSimInCallActivity.java b/src/com/android/incallui/msim/MSimInCallActivity.java new file mode 100644 index 00000000..3f61a595 --- /dev/null +++ b/src/com/android/incallui/msim/MSimInCallActivity.java @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2013 The Linux Foundation. All rights reserved. + * Not a Contribution. + * + * Copyright (C) 2006 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.app.ActionBar; +import android.app.FragmentTransaction; +import android.app.ActionBar.Tab; +import android.content.res.TypedArray; +import android.os.Bundle; +import android.telephony.MSimTelephonyManager; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.ImageView; +import android.widget.TextView; + +/** + * Phone app "multisim in call" screen. + */ +public class MSimInCallActivity extends InCallActivity { + + private MSimAnswerFragment mAnswerFragment; + + private final int TAB_COUNT_ONE = 1; + private final int TAB_COUNT_TWO = 2; + private final int TAB_POSITION_FIRST = 0; + + private Tab[] mDsdaTab = new Tab[TAB_COUNT_TWO]; + private boolean[] mDsdaTabAdd = {false, false}; + + @Override + protected void onCreate(Bundle icicle) { + Log.d(this, "onCreate()... this = " + this); + + super.onCreate(icicle); + + // set this flag so this activity will stay in front of the keyguard + // Have the WindowManager filter out touch events that are "too fat". + getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED + | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON + | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD + | WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES); + + requestWindowFeature(Window.FEATURE_ACTION_BAR); + + getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); + getActionBar().setDisplayShowTitleEnabled(false); + getActionBar().setDisplayShowHomeEnabled(false); + + // Inflate everything in incall_screen.xml and add it to the screen. + setContentView(R.layout.incall_screen_msim); + + initializeInCall(); + + initializeDsdaSwitchTab(); + Log.d(this, "onCreate(): exit"); + } + + @Override + protected void onStart() { + Log.d(this, "onStart()..."); + super.onStart(); + + // setting activity should be last thing in setup process + InCallPresenter.getInstance().setActivity(this); + } + + @Override + public void finish() { + Log.i(this, "finish(). Dialog showing: " + (mDialog != null)); + + // skip finish if we are still showing a dialog. + if (!hasPendingErrorDialog() && !mAnswerFragment.hasPendingDialogs()) { + super.finish(); + } + } + + @Override + protected void initializeInCall() { + if (mCallButtonFragment == null) { + mCallButtonFragment = (CallButtonFragment) getFragmentManager() + .findFragmentById(R.id.callButtonFragment); + mCallButtonFragment.getView().setVisibility(View.INVISIBLE); + } + + if (mCallCardFragment == null) { + mCallCardFragment = (CallCardFragment) getFragmentManager() + .findFragmentById(R.id.callCardFragment); + } + + if (mAnswerFragment == null) { + mAnswerFragment = (MSimAnswerFragment) getFragmentManager() + .findFragmentById(R.id.answerFragment); + } + + if (mDialpadFragment == null) { + mDialpadFragment = (DialpadFragment) getFragmentManager() + .findFragmentById(R.id.dialpadFragment); + mDialpadFragment.getView().setVisibility(View.INVISIBLE); + } + + if (mConferenceManagerFragment == null) { + mConferenceManagerFragment = (ConferenceManagerFragment) getFragmentManager() + .findFragmentById(R.id.conferenceManagerFragment); + mConferenceManagerFragment.getView().setVisibility(View.INVISIBLE); + } + } + + @Override + public void dismissPendingDialogs() { + if (mDialog != null) { + mDialog.dismiss(); + mDialog = null; + } + mAnswerFragment.dismissPendingDialogues(); + } + + private void initializeDsdaSwitchTab() { + int phoneCount = MSimTelephonyManager.getDefault().getPhoneCount(); + ActionBar bar = getActionBar(); + View[] mDsdaTabLayout = new View[phoneCount]; + TypedArray icons = getResources().obtainTypedArray(R.array.sim_icons); + int[] subString = {R.string.sub_1, R.string.sub_2}; + + for (int i = 0; i < phoneCount; i++) { + mDsdaTabLayout[i] = getLayoutInflater() + .inflate(R.layout.msim_tab_sub_info, null); + + ((ImageView)mDsdaTabLayout[i].findViewById(R.id.tabSubIcon)) + .setBackground(icons.getDrawable(i)); + + ((TextView)mDsdaTabLayout[i].findViewById(R.id.tabSubText)) + .setText(subString[i]); + + mDsdaTab[i] = bar.newTab().setCustomView(mDsdaTabLayout[i]) + .setTabListener(new TabListener(i)); + } + } + + @Override + public void updateDsdaTab() { + int phoneCount = MSimTelephonyManager.getDefault().getPhoneCount(); + ActionBar bar = getActionBar(); + + for (int i = 0; i < phoneCount; i++) { + if (CallList.getInstance().existsLiveCall(i)) { + if (!mDsdaTabAdd[i]) { + addDsdaTab(i); + } + } else { + removeDsdaTab(i); + } + } + + updateDsdaTabSelection(); + } + + private void addDsdaTab(int subscription) { + ActionBar bar = getActionBar(); + int tabCount = bar.getTabCount(); + + if (tabCount < subscription) { + bar.addTab(mDsdaTab[subscription], false); + } else { + bar.addTab(mDsdaTab[subscription], subscription, false); + } + mDsdaTabAdd[subscription] = true; + } + + private void removeDsdaTab(int subscription) { + ActionBar bar = getActionBar(); + int tabCount = bar.getTabCount(); + + for (int i = 0; i < tabCount; i++) { + if (bar.getTabAt(i).equals(mDsdaTab[subscription])) { + bar.removeTab(mDsdaTab[subscription]); + mDsdaTabAdd[subscription] = false; + return; + } + } + } + + private void updateDsdaTabSelection() { + ActionBar bar = getActionBar(); + int barCount = bar.getTabCount(); + + if (barCount == TAB_COUNT_ONE) { + bar.selectTab(bar.getTabAt(TAB_POSITION_FIRST)); + } else if (barCount == TAB_COUNT_TWO) { + bar.selectTab(bar.getTabAt(CallList.getInstance().getActiveSubscription())); + } + } + + private class TabListener implements ActionBar.TabListener { + int mSubscription; + + public TabListener(int subId) { + mSubscription = subId; + } + + public void onTabSelected(Tab tab, FragmentTransaction ft) { + ActionBar bar = getActionBar(); + + if (CallList.getInstance().existsLiveCall(mSubscription)) { + CallCommandClient.getInstance().setActiveSubscription(mSubscription); + } + } + + public void onTabUnselected(Tab tab, FragmentTransaction ft) { + } + + public void onTabReselected(Tab tab, FragmentTransaction ft) { + } + } +} |