Skip to content

Commit

Permalink
Adds ability to answer call with hardware HOME button (2/2)
Browse files Browse the repository at this point in the history
(preparation to winter time)

Change-Id: I25d69913847b1756f89a04e14e1dee4a939afcb3
  • Loading branch information
sanja-byelkin authored and Gerrit Code Review committed Sep 4, 2012
1 parent ebffa88 commit c19ad69
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,7 @@
<string name="accessibility_system_title" msgid="7187919089874130484">"Система"</string>
<string name="accessibility_toggle_large_text_title" msgid="6618674985313017711">"Большой текст"</string>
<string name="accessibility_power_button_ends_call_title" msgid="5468375366375940894">"Кнопка питания завершает вызов"</string>
<string name="accessibility_home_button_answers_call_title">"Кнопка Домой отвечает на вызов"</string>
<string name="accessibility_speak_password_title" msgid="3344423945644925355">"Озвучивать пароли"</string>
<string name="accessibility_long_press_timeout_title" msgid="2373216941395035306">"Задержка при нажатии и удержании"</string>
<string name="accessibility_script_injection_title" msgid="7921388904564822855">"Расширение доступности"</string>
Expand Down
2 changes: 2 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2980,6 +2980,8 @@
<string name="accessibility_system_title">System</string>
<!-- Title for the accessibility preference to enable large text. [CHAR LIMIT=35] -->
<string name="accessibility_toggle_large_text_title">Large text</string>
<!-- Title for the accessibility preference to home button to answers a call. [CHAR LIMIT=35] -->
<string name="accessibility_home_button_answers_call_title">Home button answers call.</string>
<!-- Title for the accessibility preference to power button to end a call. [CHAR LIMIT=35] -->
<string name="accessibility_power_button_ends_call_title">Power button ends call</string>
<!-- Title for the accessibility preference to speak passwords. [CHAR LIMIT=35] -->
Expand Down
5 changes: 5 additions & 0 deletions res/xml/accessibility_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
android:title="@string/accessibility_power_button_ends_call_title"
android:persistent="false"/>

<CheckBoxPreference
android:key="toggle_home_button_answers_call_preference"
android:title="@string/accessibility_home_button_answers_call_title"
android:persistent="false"/>

<CheckBoxPreference
android:key="toggle_lock_screen_rotation_preference"
android:title="@string/accelerometer_title"
Expand Down
31 changes: 31 additions & 0 deletions src/com/android/settings/AccessibilitySettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
private static final String TOGGLE_LARGE_TEXT_PREFERENCE = "toggle_large_text_preference";
private static final String TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE =
"toggle_power_button_ends_call_preference";
private static final String TOGGLE_HOME_BUTTON_ANSWERS_CALL_PREFERENCE =
"toggle_home_button_answers_call_preference";
private static final String TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE =
"toggle_lock_screen_rotation_preference";
private static final String TOGGLE_SPEAK_PASSWORD_PREFERENCE =
Expand Down Expand Up @@ -159,6 +161,7 @@ public void onChange() {

private CheckBoxPreference mToggleLargeTextPreference;
private CheckBoxPreference mTogglePowerButtonEndsCallPreference;
private CheckBoxPreference mToggleHomeButtonAnswersCallPreference;
private CheckBoxPreference mToggleLockScreenRotationPreference;
private CheckBoxPreference mToggleSpeakPasswordPreference;
private ListPreference mSelectLongPressTimeoutPreference;
Expand Down Expand Up @@ -215,6 +218,9 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen
} else if (mTogglePowerButtonEndsCallPreference == preference) {
handleTogglePowerButtonEndsCallPreferenceClick();
return true;
} else if (mToggleHomeButtonAnswersCallPreference == preference) {
handleToggleHomeButtonAnswersCallPreferenceClick();
return true;
} else if (mToggleLockScreenRotationPreference == preference) {
handleLockScreenRotationPreferenceClick();
return true;
Expand All @@ -241,6 +247,13 @@ private void handleTogglePowerButtonEndsCallPreferenceClick() {
: Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF));
}

private void handleToggleHomeButtonAnswersCallPreferenceClick() {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.RING_HOME_BUTTON_BEHAVIOR,
(mToggleHomeButtonAnswersCallPreference.isChecked()
? Settings.Secure.RING_HOME_BUTTON_BEHAVIOR_ANSWER
: Settings.Secure.RING_HOME_BUTTON_BEHAVIOR_DO_NOTHING));
}
private void handleLockScreenRotationPreferenceClick() {
RotationPolicy.setRotationLockForAccessibility(getActivity(),
!mToggleLockScreenRotationPreference.isChecked());
Expand All @@ -267,6 +280,13 @@ private void initializeAllPreferences() {
|| !Utils.isVoiceCapable(getActivity())) {
mSystemsCategory.removePreference(mTogglePowerButtonEndsCallPreference);
}
// Home button answers calls.
mToggleHomeButtonAnswersCallPreference =
(CheckBoxPreference) findPreference(TOGGLE_HOME_BUTTON_ANSWERS_CALL_PREFERENCE);
if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME)
|| !Utils.isVoiceCapable(getActivity())) {
mSystemsCategory.removePreference(mToggleHomeButtonAnswersCallPreference);
}

// Lock screen rotation.
mToggleLockScreenRotationPreference =
Expand Down Expand Up @@ -427,6 +447,17 @@ private void updateSystemPreferences() {
mTogglePowerButtonEndsCallPreference.setChecked(powerButtonEndsCall);
}

// Home button answers calls.
if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME)
&& Utils.isVoiceCapable(getActivity())) {
final int incallHomeBehavior = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.RING_HOME_BUTTON_BEHAVIOR,
Settings.Secure.RING_HOME_BUTTON_BEHAVIOR_DEFAULT);
final boolean homeButtonAnswersCall =
(incallHomeBehavior == Settings.Secure.RING_HOME_BUTTON_BEHAVIOR_ANSWER);
mToggleHomeButtonAnswersCallPreference.setChecked(homeButtonAnswersCall);
}

// Auto-rotate screen
updateLockScreenRotationCheckbox();

Expand Down

0 comments on commit c19ad69

Please sign in to comment.