<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
+<!-- Copyright (C) 2009 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.
limitations under the License.
-->
+<!-- Background resource for backspace button for the various 12 key dialers. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="true"
- android:drawable="@drawable/btn_dial_delete_pressed" />
- <item android:state_focused="true"
- android:drawable="@drawable/btn_dial_delete_selected" />
- <item
- android:drawable="@drawable/btn_dial_delete_normal" />
+ <!-- Disabled views -->
+ <item android:state_focused="true" android:state_enabled="false"
+ android:drawable="@drawable/btn_dial_action_right_disable_focused" />
+ <item android:state_enabled="false"
+ android:drawable="@drawable/btn_dial_action_right_disable" />
+
+ <!-- Enabled views -->
+ <item android:state_pressed="true" android:state_enabled="true"
+ android:drawable="@drawable/btn_dial_action_right_pressed" />
+ <item android:state_focused="true" android:state_enabled="true"
+ android:drawable="@drawable/btn_dial_action_right_selected" />
+ <item android:state_enabled="true"
+ android:drawable="@drawable/btn_dial_action_right_normal" />
</selector>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="true"
- android:drawable="@drawable/btn_dial_delete_pressed" />
- <item android:state_focused="true"
- android:drawable="@drawable/btn_dial_delete_selected" />
- <item
- android:drawable="@drawable/btn_dial_delete_activated" />
-</selector>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="true"
- android:drawable="@drawable/ic_delete_phone_number_blk" />
- <item android:state_focused="true"
- android:drawable="@drawable/ic_delete_phone_number_blk" />
- <item
- android:drawable="@drawable/ic_delete_phone_number_wht" />
-</selector>
-
android:layout_height="fill_parent"
android:orientation="vertical"
>
- <LinearLayout android:id="@+id/digitsAndBackspace"
+ <!-- Text field above the keypad where the digits are displayed -->
+ <EditText android:id="@+id/digits"
android:layout_width="fill_parent"
android:layout_height="66dip"
- android:layout_marginTop="3dip"
- android:layout_marginBottom="5dip"
- android:layout_marginLeft="3dip"
- android:layout_marginRight="3dip"
- android:orientation="horizontal"
- >
-
- <EditText android:id="@+id/digits"
- android:layout_width="0dip"
- android:layout_weight="1"
- android:layout_height="66dip"
- android:maxLines="1"
- android:scrollHorizontally="true"
- android:textSize="28sp"
- android:freezesText="true"
- android:background="@drawable/btn_dial_textfield"
- android:textColor="@color/dialer_button_text"
- android:focusableInTouchMode="false"
- android:nextFocusRight="@+id/backspace"
- />
-
- <ImageButton android:id="@+id/backspace"
- style="@android:style/Widget.Button.Inset"
- android:layout_width="wrap_content"
- android:layout_height="66dip"
- android:background="@drawable/btn_dial_delete"
- android:src="@drawable/ic_delete_phone_number"
- android:gravity="center"
- />
-
- </LinearLayout>
+ android:maxLines="1"
+ android:scrollHorizontally="true"
+ android:textSize="28sp"
+ android:freezesText="true"
+ android:background="@drawable/btn_dial_textfield"
+ android:textColor="@color/dialer_button_text"
+ android:focusableInTouchMode="false"
+ />
<!-- Keypad section -->
<include layout="@layout/dialpad" />
- <!-- Horizontal row of buttons (Voicemail + DialButton + Backspace.) -->
- <LinearLayout android:id="@+id/voicemailAndDialAndBackspace"
+ <!-- Horizontal row of buttons (Voicemail + DialButton + Delete.) -->
+ <LinearLayout android:id="@+id/voicemailAndDialAndDelete"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:state_enabled="false"
android:background="@drawable/btn_dial_action"
android:src="@drawable/ic_dial_action_call" />
+
+ <!-- Onscreen "Backspace/Delete" button -->
+ <ImageButton android:id="@+id/deleteButton"
+ android:layout_width="90dip"
+ android:layout_height="52dip"
+ android:layout_gravity="center_vertical"
+ android:state_enabled="false"
+ android:background="@drawable/btn_dial_delete"
+ android:src="@drawable/ic_dial_action_delete" />
</LinearLayout>
<!-- "Dialpad chooser" UI, shown only when the user brings up the
android:layout_height="fill_parent"
android:orientation="vertical"
>
- <LinearLayout android:id="@+id/digitsAndBackspace"
+
+ <!-- Text field above the keypad where the digits are displayed -->
+ <EditText android:id="@+id/digits"
android:layout_width="fill_parent"
android:layout_height="66dip"
- android:addStatesFromChildren="true"
- android:gravity="center_vertical"
- android:baselineAligned="false"
- android:layout_marginTop="3dip"
- android:layout_marginBottom="5dip"
- android:layout_marginLeft="3dip"
- android:layout_marginRight="3dip"
- >
-
- <EditText android:id="@+id/digits"
- android:layout_width="0dip"
- android:layout_weight="1"
- android:layout_height="66dip"
- android:maxLines="1"
- android:scrollHorizontally="true"
- android:textSize="28sp"
- android:freezesText="true"
- android:background="@drawable/btn_dial_textfield"
- android:textColor="@color/dialer_button_text"
- android:hint="@string/dialerKeyboardHintText"
- />
-
- <!--
- The button goes at the right.
- -->
- <ImageButton android:id="@+id/backspace"
- style="@android:style/Widget.Button.Inset"
- android:src="@drawable/ic_delete_phone_number"
- android:layout_width="wrap_content"
- android:layout_height="66dip"
- android:background="@drawable/btn_dial_delete"
- android:gravity="center"
- />
-
- </LinearLayout>
+ android:maxLines="1"
+ android:scrollHorizontally="true"
+ android:textSize="28sp"
+ android:freezesText="true"
+ android:background="@drawable/btn_dial_textfield"
+ android:textColor="@color/dialer_button_text"
+ android:hint="@string/dialerKeyboardHintText"
+ />
- <!-- Horizontal row of buttons (Voicemail + DialButton + Backspace.) -->
- <LinearLayout android:id="@+id/voicemailAndDialAndBackspace"
+ <!-- Horizontal row of buttons (Voicemail + DialButton + Delete.) -->
+ <LinearLayout android:id="@+id/voicemailAndDialAndDelete"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:state_enabled="false"
android:background="@drawable/btn_dial_action"
android:src="@drawable/ic_dial_action_call" />
+
+ <!-- Onscreen "Backspace/Delete" button -->
+ <ImageButton android:id="@+id/deleteButton"
+ android:layout_width="90dip"
+ android:layout_height="52dip"
+ android:layout_gravity="center_vertical"
+ android:state_enabled="false"
+ android:background="@drawable/btn_dial_delete"
+ android:src="@drawable/ic_dial_action_delete" />
</LinearLayout>
<!-- "Dialpad chooser" UI, shown only when the user brings up the
private Object mToneGeneratorLock = new Object();
private Drawable mDigitsBackground;
private Drawable mDigitsEmptyBackground;
- private Drawable mDeleteBackground;
- private Drawable mDeleteEmptyBackground;
- private View mDigitsAndBackspace;
private View mDialpad;
- private View mVoicemailDialAndBackspaceRow;
+ private View mVoicemailDialAndDeleteRow;
private View mVoicemailButton;
private View mDialButton;
private ListView mDialpadChooser;
mDigits.getText().clear();
}
- // Set the proper background for the dial input area
- if (mDigits.length() != 0) {
- mDelete.setBackgroundDrawable(mDeleteBackground);
- mDigits.setBackgroundDrawable(mDigitsBackground);
- mDigits.setCompoundDrawablesWithIntrinsicBounds(
- getResources().getDrawable(R.drawable.ic_dial_number), null, null, null);
- } else {
- mDelete.setBackgroundDrawable(mDeleteEmptyBackground);
- mDigits.setBackgroundDrawable(mDigitsEmptyBackground);
- mDigits.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
- }
-
- updateDialButtonStateEnabledAttr();
+ updateDialAndDeleteButtonStateEnabledAttr();
}
@Override
mDigitsBackground = r.getDrawable(R.drawable.btn_dial_textfield_active);
//mDigitsBackground.setDither(true);
mDigitsEmptyBackground = r.getDrawable(R.drawable.btn_dial_textfield);
- //mDigitsEmptyBackground.setDither(true);
- mDeleteBackground = r.getDrawable(R.drawable.btn_dial_delete_active);
- //mDeleteBackground.setDither(true);
- mDeleteEmptyBackground = r.getDrawable(R.drawable.btn_dial_delete);
- //mDeleteEmptyBackground.setDither(true);
mDigits = (EditText) findViewById(R.id.digits);
mDigits.setKeyListener(DialerKeyListener.getInstance());
setupKeypad();
}
- mVoicemailDialAndBackspaceRow = findViewById(R.id.voicemailAndDialAndBackspace);
+ mVoicemailDialAndDeleteRow = findViewById(R.id.voicemailAndDialAndDelete);
initVoicemailButton();
// Check whether we should show the onscreen "Dial" button.
- mDialButton = mVoicemailDialAndBackspaceRow.findViewById(R.id.dialButton);
+ mDialButton = mVoicemailDialAndDeleteRow.findViewById(R.id.dialButton);
if (r.getBoolean(R.bool.config_show_onscreen_dial_button)) {
mDialButton.setOnClickListener(this);
mDialButton = null;
}
- view = findViewById(R.id.backspace);
+ view = mVoicemailDialAndDeleteRow.findViewById(R.id.deleteButton);
view.setOnClickListener(this);
view.setOnLongClickListener(this);
mDelete = view;
- mDigitsAndBackspace = findViewById(R.id.digitsAndBackspace);
mDialpad = findViewById(R.id.dialpad); // This is null in landscape mode
// Set up the "dialpad chooser" UI; see showDialpadChooser().
showDialpadChooser(false);
}
- updateDialButtonStateEnabledAttr();
+ updateDialAndDeleteButtonStateEnabledAttr();
}
@Override
keyPressed(KeyEvent.KEYCODE_STAR);
return;
}
- case R.id.backspace: {
+ case R.id.deleteButton: {
keyPressed(KeyEvent.KEYCODE_DEL);
return;
}
final Editable digits = mDigits.getText();
int id = view.getId();
switch (id) {
- case R.id.backspace: {
+ case R.id.deleteButton: {
digits.clear();
+ // TODO: The framework forgets to clear the pressed
+ // status of disabled button. Until this is fixed,
+ // clear manually the pressed status. b/2133127
+ mDelete.setPressed(false);
return true;
}
case R.id.one: {
private void showDialpadChooser(boolean enabled) {
if (enabled) {
// Log.i(TAG, "Showing dialpad chooser!");
- mDigitsAndBackspace.setVisibility(View.GONE);
+ mDigits.setVisibility(View.GONE);
if (mDialpad != null) mDialpad.setVisibility(View.GONE);
- mVoicemailDialAndBackspaceRow.setVisibility(View.GONE);
+ mVoicemailDialAndDeleteRow.setVisibility(View.GONE);
mDialpadChooser.setVisibility(View.VISIBLE);
// Instantiate the DialpadChooserAdapter and hook it up to the
}
} else {
// Log.i(TAG, "Displaying normal Dialer UI.");
- mDigitsAndBackspace.setVisibility(View.VISIBLE);
+ mDigits.setVisibility(View.VISIBLE);
if (mDialpad != null) mDialpad.setVisibility(View.VISIBLE);
- mVoicemailDialAndBackspaceRow.setVisibility(View.VISIBLE);
+ mVoicemailDialAndDeleteRow.setVisibility(View.VISIBLE);
mDialpadChooser.setVisibility(View.GONE);
}
}
}
/**
- * Update the enabledness of the "Dial" button if applicable.
+ * Update the enabledness of the "Dial" and "Backspace" buttons if applicable.
*/
- private void updateDialButtonStateEnabledAttr() {
+ private void updateDialAndDeleteButtonStateEnabledAttr() {
+ final boolean notEmpty = mDigits.length() != 0;
+
if (mDialButton != null) {
- mDialButton.setEnabled(mDigits.length() != 0);
+ mDialButton.setEnabled(notEmpty);
}
+ mDelete.setEnabled(notEmpty);
}
+
/**
* Check if voicemail is enabled/accessible.
*/
// Possibly no READ_PHONE_STATE privilege.
}
- mVoicemailButton = mVoicemailDialAndBackspaceRow.findViewById(R.id.voicemailButton);
+ mVoicemailButton = mVoicemailDialAndDeleteRow.findViewById(R.id.voicemailButton);
if (hasVoicemail) {
mVoicemailButton.setOnClickListener(this);
} else {