use of com.android.dialer.DialtactsActivity in project android_packages_apps_Dialer by MoKee.
the class DialpadFragment method callSpeedNumber.
private void callSpeedNumber(int id) {
int number;
switch(id) {
case R.id.two:
number = 2;
break;
case R.id.three:
number = 3;
break;
case R.id.four:
number = 4;
break;
case R.id.five:
number = 5;
break;
case R.id.six:
number = 6;
break;
case R.id.seven:
number = 7;
break;
case R.id.eight:
number = 8;
break;
case R.id.nine:
number = 9;
break;
default:
return;
}
String phoneNumber = SpeedDialUtils.getNumber(getActivity(), number);
if (phoneNumber == null) {
showNoSpeedNumberDialog(number);
} else {
final DialtactsActivity activity = getActivity() instanceof DialtactsActivity ? (DialtactsActivity) getActivity() : null;
final Intent intent = CallUtil.getCallIntent(phoneNumber);
DialerUtils.startActivityWithErrorToast(getActivity(), intent);
hideAndClearDialpad(false);
}
}
use of com.android.dialer.DialtactsActivity in project android_packages_apps_Dialer by MoKee.
the class DialpadFragment method onResume.
@Override
public void onResume() {
Trace.beginSection(TAG + " onResume");
super.onResume();
final DialtactsActivity activity = (DialtactsActivity) getActivity();
mDialpadQueryListener = activity;
final StopWatch stopWatch = StopWatch.start("Dialpad.onResume");
// Query the last dialed number. Do it first because hitting
mHasReadAndWriteCallLogPermission = PermissionsUtil.hasPermission(getActivity(), READ_CALL_LOG) && PermissionsUtil.hasPermission(getActivity(), WRITE_CALL_LOG);
// the DB is 'slow'. This call is asynchronous.
if (mHasReadAndWriteCallLogPermission) {
queryLastOutgoingCall();
} else {
ActivityCompat.requestPermissions(getActivity(), new String[] { READ_CALL_LOG, WRITE_CALL_LOG }, READ_WRITE_CALL_LOG_PERMISSION_REQUEST_CODE);
}
stopWatch.lap("qloc");
final ContentResolver contentResolver = activity.getContentResolver();
// retrieve the DTMF tone play back setting.
mDTMFToneEnabled = Settings.System.getInt(contentResolver, Settings.System.DTMF_TONE_WHEN_DIALING, 1) == 1;
stopWatch.lap("dtwd");
stopWatch.lap("hptc");
mPressedDialpadKeys.clear();
configureScreenFromIntent(getActivity());
stopWatch.lap("fdin");
if (!isPhoneInUse()) {
// A sanity-check: the "dialpad chooser" UI should not be visible if the phone is idle.
showDialpadChooser(false);
}
stopWatch.lap("hnt");
updateDeleteButtonEnabledState();
stopWatch.lap("bes");
stopWatch.stopAndLog(TAG, 50);
// Populate the overflow menu in onResume instead of onCreate, so that if the SMS activity
// is disabled while Dialer is paused, the "Send a text message" option can be correctly
// removed when resumed.
mOverflowMenuButton = mDialpadView.getOverflowMenuButton();
mOverflowPopupMenu = buildOptionsMenu(mOverflowMenuButton);
mOverflowMenuButton.setOnTouchListener(mOverflowPopupMenu.getDragToOpenListener());
mOverflowMenuButton.setOnClickListener(this);
mOverflowMenuButton.setVisibility(isDigitsEmpty() ? View.INVISIBLE : View.VISIBLE);
if (mFirstLaunch) {
// The onHiddenChanged callback does not get called the first time the fragment is
// attached, so call it ourselves here.
onHiddenChanged(false);
}
mFirstLaunch = false;
if (MoreContactUtils.shouldShowOperator(getContext())) {
mOperator.setVisibility(View.VISIBLE);
mOperator.setText(MoreContactUtils.getNetworkSpnName(getContext(), SubscriptionManager.getDefaultVoiceSubscriptionId()));
} else {
mOperator.setVisibility(View.GONE);
}
if (isConfigAvailableNetwork) {
Context context = getActivity();
mWifiCallReadyReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
changeDialpadButton(intent.getBooleanExtra(ACTION_WIFI_CALL_READY_EXTRA, false));
}
};
IntentFilter filter = new IntentFilter(ACTION_WIFI_CALL_READY_STATUS_CHANGE);
context.registerReceiver(mWifiCallReadyReceiver, filter);
changeDialpadButton(WifiCallUtils.isWifiCallReadyEnabled(context));
}
Trace.endSection();
}
use of com.android.dialer.DialtactsActivity in project android_packages_apps_Dialer by MoKee.
the class DialpadFragment method onHiddenChanged.
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
final DialtactsActivity activity = (DialtactsActivity) getActivity();
final DialpadView dialpadView = (DialpadView) getView().findViewById(R.id.dialpad_view);
if (activity == null)
return;
if (!hidden && !isDialpadChooserVisible()) {
if (mAnimate) {
dialpadView.animateShow();
}
mFloatingActionButtonController.setVisible(false);
mFloatingActionButtonController.scaleIn(mAnimate ? mDialpadSlideInDuration : 0);
activity.onDialpadShown();
mDigits.requestFocus();
}
if (hidden) {
if (mAnimate) {
mFloatingActionButtonController.scaleOut();
} else {
mFloatingActionButtonController.setVisible(false);
}
}
}
use of com.android.dialer.DialtactsActivity in project android_packages_apps_Dialer by MoKee.
the class DialpadFragment method configureScreenFromIntent.
/**
* Checks the given Intent and changes dialpad's UI state. For example, if the Intent requires
* the screen to enter "Add Call" mode, this method will show correct UI for the mode.
*/
private void configureScreenFromIntent(Activity parent) {
// If we were not invoked with a DIAL intent,
if (!(parent instanceof DialtactsActivity)) {
setStartedFromNewIntent(false);
return;
}
// See if we were invoked with a DIAL intent. If we were, fill in the appropriate
// digits in the dialer field.
Intent intent = parent.getIntent();
if (!isLayoutReady()) {
// This happens typically when parent's Activity#onNewIntent() is called while
// Fragment#onCreateView() isn't called yet, and thus we cannot configure Views at
// this point. onViewCreate() should call this method after preparing layouts, so
// just ignore this call now.
Log.i(TAG, "Screen configuration is requested before onCreateView() is called. Ignored");
return;
}
boolean needToShowDialpadChooser = false;
// Be sure *not* to show the dialpad chooser if this is an
// explicit "Add call" action, though.
final boolean isAddCallMode = isAddCallMode(intent);
if (!isAddCallMode) {
// Don't show the chooser when called via onNewIntent() and phone number is present.
// i.e. User clicks a telephone link from gmail for example.
// In this case, we want to show the dialpad with the phone number.
final boolean digitsFilled = fillDigitsIfNecessary(intent);
if (!(mStartedFromNewIntent && digitsFilled)) {
final String action = intent.getAction();
if (Intent.ACTION_DIAL.equals(action) || Intent.ACTION_VIEW.equals(action) || Intent.ACTION_MAIN.equals(action)) {
// make the user confirm what they really want to do.
if (isPhoneInUse()) {
needToShowDialpadChooser = true;
}
}
}
} else {
mAddParticipant = intent.getBooleanExtra(ADD_PARTICIPANT_KEY, false);
((HostInterface) getActivity()).setConferenceDialButtonVisibility(true);
}
showDialpadChooser(needToShowDialpadChooser);
setStartedFromNewIntent(false);
}
Aggregations