forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added side slide gestures to touch exploration controller.
The user can control settings that might be normally changed using sliders by sliding along the edge of the screen when ChromeVox is on. For example, the user can slide along the right edge of the screen and adjust the volume. If the user enters this mode and leaves the boundaries without releasing their touch, they will stop adjusting the setting, however, they will not enter touch exploration. If they return to the given boundaries, they will be able to modify the setting again. If the user does not touch a "hot edge" of the screen, they will not enter this state if they move to the an of the screen. BUG=393326 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=284819 Review URL: https://codereview.chromium.org/385073009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285149 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
lisayin@chromium.org
committed
Jul 24, 2014
1 parent
518c63a
commit 7d48759
Showing
12 changed files
with
703 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ash/ash_touch_exploration_manager_chromeos.h" | ||
|
||
#include "ash/accessibility_delegate.h" | ||
#include "ash/audio/sounds.h" | ||
#include "ash/root_window_controller.h" | ||
#include "ash/shell.h" | ||
#include "ash/system/tray/system_tray_notifier.h" | ||
#include "base/command_line.h" | ||
#include "chromeos/audio/chromeos_sounds.h" | ||
#include "chromeos/audio/cras_audio_handler.h" | ||
#include "chromeos/chromeos_switches.h" | ||
#include "ui/chromeos/touch_exploration_controller.h" | ||
|
||
namespace ash { | ||
|
||
AshTouchExplorationManager::AshTouchExplorationManager( | ||
RootWindowController* root_window_controller) | ||
: root_window_controller_(root_window_controller), | ||
audio_handler_(chromeos::CrasAudioHandler::Get()) { | ||
Shell::GetInstance()->system_tray_notifier()->AddAccessibilityObserver(this); | ||
UpdateTouchExplorationState(); | ||
} | ||
|
||
AshTouchExplorationManager::~AshTouchExplorationManager() { | ||
SystemTrayNotifier* system_tray_notifier = | ||
Shell::GetInstance()->system_tray_notifier(); | ||
if (system_tray_notifier) | ||
system_tray_notifier->RemoveAccessibilityObserver(this); | ||
} | ||
|
||
void AshTouchExplorationManager::OnAccessibilityModeChanged( | ||
AccessibilityNotificationVisibility notify) { | ||
UpdateTouchExplorationState(); | ||
} | ||
|
||
void AshTouchExplorationManager::PlayVolumeAdjustSound() { | ||
if (!VolumeAdjustSoundEnabled()) | ||
return; | ||
if ((!audio_handler_->IsOutputMuted()) || | ||
!(audio_handler_->GetOutputVolumePercent() == 100)) | ||
PlaySystemSoundIfSpokenFeedback(chromeos::SOUND_VOLUME_ADJUST); | ||
} | ||
|
||
void AshTouchExplorationManager::SetOutputLevel(int volume) { | ||
if (volume > 0) { | ||
if (audio_handler_->IsOutputMuted()) { | ||
audio_handler_->SetOutputMute(false); | ||
} | ||
} | ||
audio_handler_->SetOutputVolumePercent(volume); | ||
// Avoid negative volume. | ||
if (audio_handler_->IsOutputVolumeBelowDefaultMuteLevel()) | ||
audio_handler_->SetOutputMute(true); | ||
} | ||
|
||
void AshTouchExplorationManager::UpdateTouchExplorationState() { | ||
AccessibilityDelegate* delegate = | ||
Shell::GetInstance()->accessibility_delegate(); | ||
bool enabled = delegate->IsSpokenFeedbackEnabled(); | ||
|
||
if (enabled && !touch_exploration_controller_.get()) { | ||
touch_exploration_controller_.reset(new ui::TouchExplorationController( | ||
root_window_controller_->GetRootWindow(), this)); | ||
} else if (!enabled) { | ||
touch_exploration_controller_.reset(); | ||
} | ||
} | ||
|
||
bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { | ||
return !CommandLine::ForCurrentProcess()->HasSwitch( | ||
chromeos::switches::kDisableVolumeAdjustSound); | ||
} | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ASH_TOUCH_EXPLORATION_MANAGER_CHROMEOS_H_ | ||
#define ASH_TOUCH_EXPLORATION_MANAGER_CHROMEOS_H_ | ||
|
||
#include "ash/ash_export.h" | ||
#include "ash/system/tray_accessibility.h" | ||
#include "ui/chromeos/touch_exploration_controller.h" | ||
|
||
namespace chromeos { | ||
class CrasAudioHandler; | ||
} | ||
|
||
namespace ash { | ||
class RootWindowController; | ||
|
||
// Responsible for initializing TouchExplorationController when spoken | ||
// feedback is on for ChromeOS only. This class implements | ||
// TouchExplorationControllerDelegate which allows touch gestures to manipulate | ||
// the system. | ||
class ASH_EXPORT AshTouchExplorationManager | ||
: public ash::AccessibilityObserver, | ||
public ui::TouchExplorationControllerDelegate { | ||
public: | ||
explicit AshTouchExplorationManager( | ||
RootWindowController* root_window_controller); | ||
virtual ~AshTouchExplorationManager(); | ||
|
||
// AccessibilityObserver overrides: | ||
virtual void OnAccessibilityModeChanged( | ||
AccessibilityNotificationVisibility notify) OVERRIDE; | ||
|
||
// TouchExplorationControllerDelegate overrides: | ||
virtual void PlayVolumeAdjustSound() OVERRIDE; | ||
virtual void SetOutputLevel(int volume) OVERRIDE; | ||
|
||
private: | ||
void UpdateTouchExplorationState(); | ||
bool VolumeAdjustSoundEnabled(); | ||
|
||
scoped_ptr<ui::TouchExplorationController> touch_exploration_controller_; | ||
RootWindowController* root_window_controller_; | ||
chromeos::CrasAudioHandler* audio_handler_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(AshTouchExplorationManager); | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // ASH_TOUCH_EXPLORATION_MANAGER_CHROMEOS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ash/ash_touch_exploration_manager_chromeos.h" | ||
|
||
#include "ash/root_window_controller.h" | ||
#include "ash/shell.h" | ||
#include "ash/test/ash_test_base.h" | ||
#include "chromeos/audio/cras_audio_handler.h" | ||
|
||
namespace ash { | ||
|
||
typedef test::AshTestBase AshTouchExplorationManagerTest; | ||
|
||
TEST_F(AshTouchExplorationManagerTest, AdjustSound) { | ||
RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | ||
AshTouchExplorationManager touch_exploration_manager(controller); | ||
chromeos::CrasAudioHandler* audio_handler = | ||
chromeos::CrasAudioHandler::Get(); | ||
|
||
touch_exploration_manager.SetOutputLevel(10); | ||
EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 10); | ||
EXPECT_FALSE(audio_handler->IsOutputMuted()); | ||
|
||
touch_exploration_manager.SetOutputLevel(100); | ||
EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 100); | ||
EXPECT_FALSE(audio_handler->IsOutputMuted()); | ||
|
||
touch_exploration_manager.SetOutputLevel(0); | ||
EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 0); | ||
EXPECT_TRUE(audio_handler->IsOutputMuted()); | ||
|
||
touch_exploration_manager.SetOutputLevel(-10); | ||
EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 0); | ||
EXPECT_TRUE(audio_handler->IsOutputMuted()); | ||
} | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.