|
26
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
* This component and the accompanying materials are made available
|
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
|
6 |
* which accompanies this distribution, and is available
|
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
|
8 |
*
|
|
|
9 |
* Initial Contributors:
|
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
|
11 |
*
|
|
|
12 |
* Contributors:
|
|
|
13 |
*
|
|
|
14 |
* Description: Button state manager for playback view
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
// INCLUDE FILES
|
|
|
20 |
#include <aknbutton.h>
|
|
|
21 |
#include <mpxcommonplaybackview.rsg>
|
|
|
22 |
#include <AknsUtils.h>
|
|
|
23 |
#include <AknsSkinInstance.h>
|
|
|
24 |
#include <AknsDrawUtils.h>
|
|
|
25 |
#include <barsread.h>
|
|
|
26 |
#include <AknDef.h>
|
|
|
27 |
#include <featmgr.h>
|
|
|
28 |
#include <aknconsts.h>
|
|
|
29 |
#include "mpxbuttonmanager.h"
|
|
|
30 |
#include "mpxplaybackviewlayoutinterface.h"
|
|
|
31 |
#include "mpxcommonplaybackview.hrh"
|
|
|
32 |
#include "mpxlog.h"
|
|
|
33 |
|
|
|
34 |
// CONSTANTS
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
struct TStateAndCommandIds
|
|
|
38 |
{
|
|
|
39 |
TInt iState;
|
|
|
40 |
TInt iEnterCommand;
|
|
|
41 |
TInt iExitCommand;
|
|
|
42 |
TInt iLongEnterCommand;
|
|
|
43 |
TInt iLongExitCommand;
|
|
|
44 |
};
|
|
|
45 |
|
|
|
46 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
|
47 |
|
|
|
48 |
// -----------------------------------------------------------------------------
|
|
|
49 |
// CMPXButtonManager::CMPXButtonManager
|
|
|
50 |
// -----------------------------------------------------------------------------
|
|
|
51 |
//
|
|
|
52 |
CMPXButtonManager::CMPXButtonManager(
|
|
|
53 |
MMPXButtonCmdObserver* aObserver,
|
|
|
54 |
MMPXPlaybackViewLayout* aLayout )
|
|
|
55 |
: iObserver(aObserver),
|
|
|
56 |
iLayout(aLayout),
|
|
|
57 |
iEnabled(ETrue)
|
|
|
58 |
{
|
|
|
59 |
MPX_FUNC("CMPXButtonManager::CMPXButtonManager()");
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
// -----------------------------------------------------------------------------
|
|
|
63 |
// CMPXButtonManager::NewL
|
|
|
64 |
// -----------------------------------------------------------------------------
|
|
|
65 |
//
|
|
|
66 |
CMPXButtonManager* CMPXButtonManager::NewL(
|
|
|
67 |
MMPXButtonCmdObserver* aObserver,
|
|
|
68 |
MMPXPlaybackViewLayout* aLayout,
|
|
|
69 |
const CCoeControl &aContainer)
|
|
|
70 |
{
|
|
|
71 |
MPX_FUNC("CMPXButtonManager::NewL()");
|
|
|
72 |
CMPXButtonManager* self = new (ELeave) CMPXButtonManager(
|
|
|
73 |
aObserver,
|
|
|
74 |
aLayout);
|
|
|
75 |
|
|
|
76 |
CleanupStack::PushL(self);
|
|
|
77 |
//self->ConstructL(aRect, aContainer);
|
|
|
78 |
self->ConstructL(aContainer);
|
|
|
79 |
CleanupStack::Pop();
|
|
|
80 |
return self;
|
|
|
81 |
}
|
|
|
82 |
// -----------------------------------------------------------------------------
|
|
|
83 |
// CMPXButtonManager::~CMPXButtonManager
|
|
|
84 |
// -----------------------------------------------------------------------------
|
|
|
85 |
//
|
|
|
86 |
CMPXButtonManager::~CMPXButtonManager()
|
|
|
87 |
{
|
|
|
88 |
MPX_FUNC("CMPXButtonManager::~CMPXButtonManager()");
|
|
|
89 |
// iButtons.ResetAndDestroy();
|
|
|
90 |
iAvkonButtons.ResetAndDestroy();
|
|
|
91 |
if (iLongKeyTimer)
|
|
|
92 |
{
|
|
|
93 |
iLongKeyTimer->Cancel();
|
|
|
94 |
delete iLongKeyTimer;
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
// -----------------------------------------------------------------------------
|
|
|
99 |
// CMPXButtonManager::ConstructL (overloaded for avkon button rocker)
|
|
|
100 |
// -----------------------------------------------------------------------------
|
|
|
101 |
//
|
|
|
102 |
void CMPXButtonManager::ConstructL(const CCoeControl &aContainer)
|
|
|
103 |
{
|
|
|
104 |
MPX_FUNC("CMPXButtonManager::ConstructL()");
|
|
|
105 |
iIsLongPress = EFalse;
|
|
|
106 |
iVolumeInRocker = (!FeatureManager::FeatureSupported( KFeatureIdSideVolumeKeys ));
|
|
|
107 |
|
|
|
108 |
if( AknLayoutUtils::PenEnabled() )
|
|
|
109 |
{
|
|
|
110 |
iIsTouchUi = ETrue;
|
|
|
111 |
}
|
|
|
112 |
else
|
|
|
113 |
{
|
|
|
114 |
iIsTouchUi = EFalse;
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
if (!iVolumeInRocker)
|
|
|
118 |
{
|
|
|
119 |
iStopInRocker = ETrue;
|
|
|
120 |
}
|
|
|
121 |
else
|
|
|
122 |
{
|
|
|
123 |
iStopInRocker = EFalse;
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
if( !iIsTouchUi)
|
|
|
127 |
{
|
|
|
128 |
CreateRockerAvkonButtonsL(aContainer);
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
ActivateL();
|
|
|
132 |
|
|
|
133 |
iLongKeyTimer = CPeriodic::NewL(CActive::EPriorityStandard);
|
|
|
134 |
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
// -----------------------------------------------------------------------------
|
|
|
138 |
// CMPXButtonManager::UpdateButtonStates
|
|
|
139 |
// -----------------------------------------------------------------------------
|
|
|
140 |
//
|
|
|
141 |
void CMPXButtonManager::UpdateButtonStates( TMPXPlaybackState aState )
|
|
|
142 |
{
|
|
|
143 |
MPX_DEBUG2("CMPXButtonManager::UpdateButtonStates(%d) entering", aState);
|
|
|
144 |
if( !iIsTouchUi && !iIsSeeking )
|
|
|
145 |
{
|
|
|
146 |
if (aState == EPbStatePlaying)
|
|
|
147 |
{
|
|
|
148 |
// Playing
|
|
|
149 |
if (iAvkonButtons[EButtonPlay]->IsVisible())
|
|
|
150 |
{
|
|
|
151 |
iAvkonButtons[EButtonPlay]->MakeVisible(EFalse);
|
|
|
152 |
}
|
|
|
153 |
if (!iAvkonButtons[EButtonPause]->IsVisible())
|
|
|
154 |
{
|
|
|
155 |
iAvkonButtons[EButtonPause]->MakeVisible(ETrue);
|
|
|
156 |
}
|
|
|
157 |
}
|
|
|
158 |
else
|
|
|
159 |
{
|
|
|
160 |
// Not playing
|
|
|
161 |
if (!iAvkonButtons[EButtonPlay]->IsVisible())
|
|
|
162 |
{
|
|
|
163 |
iAvkonButtons[EButtonPlay]->MakeVisible(ETrue);
|
|
|
164 |
}
|
|
|
165 |
if (iAvkonButtons[EButtonPause]->IsVisible())
|
|
|
166 |
{
|
|
|
167 |
iAvkonButtons[EButtonPause]->MakeVisible(EFalse);
|
|
|
168 |
}
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
if (iAvkonButtons[EButtonPlay]->IsVisible())
|
|
|
172 |
{
|
|
|
173 |
if (aState == EPbStateNotInitialised &&
|
|
|
174 |
!iAvkonButtons[EButtonPlay]->IsDimmed())
|
|
|
175 |
{
|
|
|
176 |
iAvkonButtons[EButtonPlay]->SetDimmed(ETrue);
|
|
|
177 |
}
|
|
|
178 |
if (aState != EPbStateNotInitialised &&
|
|
|
179 |
iAvkonButtons[EButtonPlay]->IsDimmed())
|
|
|
180 |
{
|
|
|
181 |
iAvkonButtons[EButtonPlay]->SetDimmed(EFalse);
|
|
|
182 |
}
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
for (TInt i = 0; i< iRockerAvkonButtonCount; i++)
|
|
|
186 |
{
|
|
|
187 |
iAvkonButtons[i]->SetCurrentState(0, ETrue);
|
|
|
188 |
}
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
MPX_DEBUG1("CMPXButtonManager::UpdateButtonStates() exiting");
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
// -----------------------------------------------------------------------------
|
|
|
196 |
// CMPXButtonManager::OfferKeyEventL
|
|
|
197 |
// -----------------------------------------------------------------------------
|
|
|
198 |
//
|
|
|
199 |
TKeyResponse CMPXButtonManager::OfferKeyEventL(
|
|
|
200 |
const TKeyEvent& aKeyEvent,
|
|
|
201 |
TEventCode aType )
|
|
|
202 |
{
|
|
|
203 |
MPX_DEBUG3("CMPXButtonManager::OfferKeyEventL(%d, %d) entering", aKeyEvent.iScanCode, aType);
|
|
|
204 |
|
|
|
205 |
TKeyResponse response( EKeyWasNotConsumed );
|
|
|
206 |
response = SetAvkonButtonStateL(aKeyEvent, aType);
|
|
|
207 |
MPX_DEBUG2("CMPXButtonManager::OfferKeyEventL() exiting %d", response);
|
|
|
208 |
return response;
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
// -----------------------------------------------------------------------------
|
|
|
212 |
// CMPXButtonManager::SetParentRect
|
|
|
213 |
// -----------------------------------------------------------------------------
|
|
|
214 |
//
|
|
|
215 |
void CMPXButtonManager::SetParentRect(
|
|
|
216 |
const TRect& aRect )
|
|
|
217 |
{
|
|
|
218 |
iParentRect = aRect;
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
// -----------------------------------------------------------------------------
|
|
|
222 |
// CMPXButtonManager::SetEnabled
|
|
|
223 |
// -----------------------------------------------------------------------------
|
|
|
224 |
//
|
|
|
225 |
void CMPXButtonManager::SetEnabled( TBool aEnabled )
|
|
|
226 |
{
|
|
|
227 |
MPX_DEBUG2("CMPXButtonManager::SetEnabled(%d) entering", aEnabled);
|
|
|
228 |
iEnabled = aEnabled;
|
|
|
229 |
MPX_DEBUG1("CMPXButtonManager::SetEnabled() exiting");
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
// -----------------------------------------------------------------------------
|
|
|
233 |
// CMPXButtonManager::HandleForegroundLostL
|
|
|
234 |
// -----------------------------------------------------------------------------
|
|
|
235 |
//
|
|
|
236 |
void CMPXButtonManager::HandleForegroundLostL()
|
|
|
237 |
{
|
|
|
238 |
MPX_FUNC( "CMPXButtonManager::HandleForegroundLostL" );
|
|
|
239 |
iIsSeeking = EFalse;
|
|
|
240 |
|
|
|
241 |
if (iIsLongPress)
|
|
|
242 |
{
|
|
|
243 |
iIsLongPress = EFalse;
|
|
|
244 |
iObserver->HandleButtonCommandL(EMPXPbvCmdEndSeek);
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
if(iLongKeyTimer)
|
|
|
248 |
{
|
|
|
249 |
iLongKeyTimer->Cancel();
|
|
|
250 |
}
|
|
|
251 |
}
|
|
|
252 |
|
|
|
253 |
// -----------------------------------------------------------------------------
|
|
|
254 |
// CMPXCommonPlaybackViewContainer::CreateRockerAvkonButtonsL
|
|
|
255 |
// -----------------------------------------------------------------------------
|
|
|
256 |
//
|
|
|
257 |
void CMPXButtonManager::CreateRockerAvkonButtonsL(const CCoeControl &aContainer)
|
|
|
258 |
{
|
|
|
259 |
TResourceReader reader;
|
|
|
260 |
iRockerAvkonButtonCount = 0;
|
|
|
261 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_MPX_PBV_ROCKER_AVKON_BUTTONS );
|
|
|
262 |
TInt numButtons( reader.ReadInt16() );
|
|
|
263 |
|
|
|
264 |
CCoeControl::SetContainerWindowL(aContainer);
|
|
|
265 |
|
|
|
266 |
for (TInt i = 0; i < numButtons; i++ )
|
|
|
267 |
{
|
|
|
268 |
CAknButton* aknButton = CAknButton::NewL();
|
|
|
269 |
CleanupStack::PushL( aknButton );
|
|
|
270 |
aknButton->SetContainerWindowL(*this);
|
|
|
271 |
aknButton->SetParent( this );
|
|
|
272 |
aknButton->ConstructFromResourceL( reader );
|
|
|
273 |
aknButton->SetObserver( this );
|
|
|
274 |
aknButton->SetLongPressInterval(1000);//KAknKeyboardRepeatInitialDelay / 1000);
|
|
|
275 |
aknButton->SetKeyRepeatInterval(0, KAknKeyboardRepeatInitialDelay / 1000);
|
|
|
276 |
aknButton->ActivateL();
|
|
|
277 |
iAvkonButtons.AppendL( aknButton );
|
|
|
278 |
CleanupStack::Pop( aknButton );
|
|
|
279 |
iRockerAvkonButtonCount++;
|
|
|
280 |
}
|
|
|
281 |
|
|
|
282 |
CleanupStack::PopAndDestroy(); // reader;
|
|
|
283 |
|
|
|
284 |
TResourceReader reader2;
|
|
|
285 |
if (iVolumeInRocker)
|
|
|
286 |
{
|
|
|
287 |
CCoeEnv::Static()->CreateResourceReaderLC( reader2, R_MPX_PBV_ROCKER_VOLUME_AVKON_BUTTONS );
|
|
|
288 |
numButtons = reader2.ReadInt16();
|
|
|
289 |
for (TInt i = 0; i < numButtons; i++ )
|
|
|
290 |
{
|
|
|
291 |
CAknButton* aknButton = CAknButton::NewL();
|
|
|
292 |
CleanupStack::PushL( aknButton );
|
|
|
293 |
aknButton->SetContainerWindowL( *this );
|
|
|
294 |
aknButton->SetParent( this );
|
|
|
295 |
aknButton->ConstructFromResourceL( reader2 );
|
|
|
296 |
aknButton->SetObserver( this );
|
|
|
297 |
aknButton->SetLongPressInterval(1000);//KAknKeyboardRepeatInitialDelay / 1000);
|
|
|
298 |
aknButton->SetKeyRepeatInterval(0, KAknKeyboardRepeatInitialDelay / 1000);
|
|
|
299 |
aknButton->ActivateL();
|
|
|
300 |
iAvkonButtons.AppendL( aknButton );
|
|
|
301 |
CleanupStack::Pop( aknButton );
|
|
|
302 |
iRockerAvkonButtonCount++;
|
|
|
303 |
}
|
|
|
304 |
}
|
|
|
305 |
else
|
|
|
306 |
{
|
|
|
307 |
CCoeEnv::Static()->CreateResourceReaderLC( reader2, R_MPX_PBV_ROCKER_STOP_AVKON_BUTTON );
|
|
|
308 |
CAknButton* aknButton = CAknButton::NewL();
|
|
|
309 |
CleanupStack::PushL( aknButton );
|
|
|
310 |
aknButton->SetContainerWindowL( *this );
|
|
|
311 |
aknButton->SetParent( this );
|
|
|
312 |
aknButton->ConstructFromResourceL( reader2 );
|
|
|
313 |
aknButton->SetObserver( this );
|
|
|
314 |
aknButton->SetLongPressInterval(1000);//KAknKeyboardRepeatInitialDelay / 1000);
|
|
|
315 |
aknButton->SetKeyRepeatInterval(0, KAknKeyboardRepeatInitialDelay / 1000);
|
|
|
316 |
aknButton->ActivateL();
|
|
|
317 |
iAvkonButtons.AppendL( aknButton );
|
|
|
318 |
CleanupStack::Pop( aknButton );
|
|
|
319 |
iRockerAvkonButtonCount++;
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
CleanupStack::PopAndDestroy(); // reader2;
|
|
|
323 |
|
|
|
324 |
}
|
|
|
325 |
|
|
|
326 |
// -----------------------------------------------------------------------------
|
|
|
327 |
// CMPXCommonPlaybackViewContainer::SetAvkonButtonState
|
|
|
328 |
// -----------------------------------------------------------------------------
|
|
|
329 |
//
|
|
|
330 |
TKeyResponse CMPXButtonManager::SetAvkonButtonStateL(const TKeyEvent& aKeyEvent,
|
|
|
331 |
TEventCode aType)
|
|
|
332 |
{
|
|
|
333 |
|
|
|
334 |
TKeyResponse response = EKeyWasNotConsumed;
|
|
|
335 |
|
|
|
336 |
if (aKeyEvent.iScanCode == EStdKeyLeftArrow || aKeyEvent.iCode == EKeyLeftArrow)
|
|
|
337 |
{
|
|
|
338 |
MPX_DEBUG1( "CMPXButtonManager::SetAvkonButtonStateL LeftArrow" );
|
|
|
339 |
if (aType == EEventKeyDown)
|
|
|
340 |
{
|
|
|
341 |
if (!iIsTouchUi)
|
|
|
342 |
{
|
|
|
343 |
iAvkonButtons[EButtonRewind]->SetCurrentState(1, ETrue);
|
|
|
344 |
}
|
|
|
345 |
iLongKeyTimer->Cancel();
|
|
|
346 |
iLongKeyTimer->Start(KAknKeyboardRepeatInitialDelay,
|
|
|
347 |
KAknKeyboardRepeatInitialDelay,
|
|
|
348 |
TCallBack(TimerCallback, this));
|
|
|
349 |
iLongPressCommandId = EMPXPbvCmdSeekBackward;
|
|
|
350 |
iIsSeeking = ETrue;
|
|
|
351 |
}
|
|
|
352 |
else if (aType == EEventKeyUp)
|
|
|
353 |
{
|
|
|
354 |
if (!iIsTouchUi)
|
|
|
355 |
{
|
|
|
356 |
iAvkonButtons[EButtonRewind]->SetCurrentState(0, ETrue);
|
|
|
357 |
}
|
|
|
358 |
iLongKeyTimer->Cancel();
|
|
|
359 |
if (iIsLongPress)
|
|
|
360 |
{
|
|
|
361 |
MPX_DEBUG1( "CMPXButtonManager::SetAvkonButtonStateL LeftArrow long press" );
|
|
|
362 |
iIsLongPress = EFalse;
|
|
|
363 |
iObserver->HandleButtonCommandL(EMPXPbvCmdEndSeek);
|
|
|
364 |
}
|
|
|
365 |
else
|
|
|
366 |
{
|
|
|
367 |
MPX_DEBUG1( "CMPXButtonManager::SetAvkonButtonStateL LeftArrow short press" );
|
|
|
368 |
iObserver->HandleButtonCommandL(EMPXPbvCmdPreviousListItem);
|
|
|
369 |
}
|
|
|
370 |
iIsLongPress = EFalse;
|
|
|
371 |
response = EKeyWasConsumed;
|
|
|
372 |
iIsSeeking = EFalse;
|
|
|
373 |
}
|
|
|
374 |
}
|
|
|
375 |
else if (aKeyEvent.iScanCode == EStdKeyRightArrow || aKeyEvent.iCode == EKeyRightArrow)
|
|
|
376 |
{
|
|
|
377 |
if (aType == EEventKeyDown)
|
|
|
378 |
{
|
|
|
379 |
if (!iIsTouchUi)
|
|
|
380 |
{
|
|
|
381 |
iAvkonButtons[EButtonFastForward]->SetCurrentState(1, ETrue);
|
|
|
382 |
}
|
|
|
383 |
iLongKeyTimer->Cancel();
|
|
|
384 |
iLongKeyTimer->Start(KAknKeyboardRepeatInitialDelay,
|
|
|
385 |
KAknKeyboardRepeatInitialDelay,
|
|
|
386 |
TCallBack(TimerCallback, this));
|
|
|
387 |
iLongPressCommandId = EMPXPbvCmdSeekForward;
|
|
|
388 |
iIsSeeking = ETrue;
|
|
|
389 |
}
|
|
|
390 |
else if (aType == EEventKeyUp)
|
|
|
391 |
{
|
|
|
392 |
if (!iIsTouchUi)
|
|
|
393 |
{
|
|
|
394 |
iAvkonButtons[EButtonFastForward]->SetCurrentState(0, ETrue);
|
|
|
395 |
}
|
|
|
396 |
iLongKeyTimer->Cancel();
|
|
|
397 |
if (iIsLongPress)
|
|
|
398 |
{
|
|
|
399 |
MPX_DEBUG1( "CMPXButtonManager::SetAvkonButtonStateL RightArrow long press" );
|
|
|
400 |
iIsLongPress = EFalse;
|
|
|
401 |
iObserver->HandleButtonCommandL(EMPXPbvCmdEndSeek);
|
|
|
402 |
}
|
|
|
403 |
else
|
|
|
404 |
{
|
|
|
405 |
MPX_DEBUG1( "CMPXButtonManager::SetAvkonButtonStateL RightArrow short press" );
|
|
|
406 |
iObserver->HandleButtonCommandL(EMPXPbvCmdNextListItem);
|
|
|
407 |
}
|
|
|
408 |
iIsLongPress = EFalse;
|
|
|
409 |
iIsSeeking = EFalse;
|
|
|
410 |
response = EKeyWasConsumed;
|
|
|
411 |
}
|
|
|
412 |
}
|
|
|
413 |
else if (aKeyEvent.iScanCode == EStdKeyDevice3 || aKeyEvent.iCode == EKeyDevice3
|
|
|
414 |
|| aKeyEvent.iScanCode == EStdKeyEnter || aKeyEvent.iCode == EKeyEnter)
|
|
|
415 |
{
|
|
|
416 |
MPX_DEBUG1( "CMPXButtonManager::SetAvkonButtonStateL EStdKeyDevice3 or EStdKeyEnter pressed" );
|
|
|
417 |
if (!iIsTouchUi)
|
|
|
418 |
{
|
|
|
419 |
if (aType == EEventKeyDown)
|
|
|
420 |
{
|
|
|
421 |
iKeyDownEventReceived = ETrue;
|
|
|
422 |
|
|
|
423 |
if (iAvkonButtons[EButtonPause]->IsVisible())
|
|
|
424 |
{
|
|
|
425 |
iAvkonButtons[EButtonPause]->SetCurrentState(1, ETrue);
|
|
|
426 |
}
|
|
|
427 |
else
|
|
|
428 |
{
|
|
|
429 |
iAvkonButtons[EButtonPlay]->SetCurrentState(1, ETrue);
|
|
|
430 |
}
|
|
|
431 |
}
|
|
|
432 |
else if (aType == EEventKeyUp)
|
|
|
433 |
{
|
|
|
434 |
if ( iKeyDownEventReceived )
|
|
|
435 |
{
|
|
|
436 |
if (iAvkonButtons[EButtonPause]->IsVisible())
|
|
|
437 |
{
|
|
|
438 |
iAvkonButtons[EButtonPause]->SetCurrentState(0, ETrue);
|
|
|
439 |
iObserver->HandleButtonCommandL(EMPXPbvCmdPause);
|
|
|
440 |
response = EKeyWasConsumed;
|
|
|
441 |
}
|
|
|
442 |
else
|
|
|
443 |
{
|
|
|
444 |
iAvkonButtons[EButtonPlay]->SetCurrentState(0, ETrue);
|
|
|
445 |
iObserver->HandleButtonCommandL(EMPXPbvCmdPlay);
|
|
|
446 |
response = EKeyWasConsumed;
|
|
|
447 |
}
|
|
|
448 |
}
|
|
|
449 |
iKeyDownEventReceived= EFalse;
|
|
|
450 |
}
|
|
|
451 |
}
|
|
|
452 |
else //iIsTouchUi
|
|
|
453 |
{
|
|
|
454 |
if (aType == EEventKeyDown)
|
|
|
455 |
{
|
|
|
456 |
iKeyDownEventReceived = ETrue;
|
|
|
457 |
}
|
|
|
458 |
else if (aType == EEventKeyUp)
|
|
|
459 |
{
|
|
|
460 |
if ( iKeyDownEventReceived )
|
|
|
461 |
{
|
|
|
462 |
iObserver->HandleButtonCommandL(EMPXPbvCmdPlayPause );
|
|
|
463 |
response = EKeyWasConsumed;
|
|
|
464 |
}
|
|
|
465 |
iKeyDownEventReceived = EFalse;
|
|
|
466 |
}
|
|
|
467 |
}
|
|
|
468 |
}
|
|
|
469 |
else if (aKeyEvent.iScanCode == EStdKeyDownArrow || aKeyEvent.iCode == EKeyDownArrow)
|
|
|
470 |
{
|
|
|
471 |
MPX_DEBUG1( "CMPXButtonManager::SetAvkonButtonStateL EStdKeyDownArrow pressed" );
|
|
|
472 |
if (iVolumeInRocker || iStopInRocker)
|
|
|
473 |
{
|
|
|
474 |
if (!iIsTouchUi)
|
|
|
475 |
{
|
|
|
476 |
if (aType == EEventKeyDown)
|
|
|
477 |
{
|
|
|
478 |
iAvkonButtons[EButtonVolumeDown]->SetCurrentState(1, ETrue);
|
|
|
479 |
}
|
|
|
480 |
else if (aType == EEventKeyUp)
|
|
|
481 |
{
|
|
|
482 |
iAvkonButtons[EButtonVolumeDown]->SetCurrentState(0, ETrue);
|
|
|
483 |
if(iVolumeInRocker)
|
|
|
484 |
{
|
|
|
485 |
iObserver->HandleButtonCommandL(EMPXPbvCmdDecreaseVolume);
|
|
|
486 |
}
|
|
|
487 |
else
|
|
|
488 |
{
|
|
|
489 |
iObserver->HandleButtonCommandL(EMPXPbvCmdStop);
|
|
|
490 |
}
|
|
|
491 |
response = EKeyWasConsumed;
|
|
|
492 |
}
|
|
|
493 |
}
|
|
|
494 |
else //iIsTouchUi
|
|
|
495 |
{
|
|
|
496 |
if (iVolumeInRocker && aType == EEventKeyUp )
|
|
|
497 |
{
|
|
|
498 |
iObserver->HandleButtonCommandL(EMPXPbvCmdDecreaseVolume);
|
|
|
499 |
}
|
|
|
500 |
else if (iStopInRocker && aType == EEventKeyUp)
|
|
|
501 |
{
|
|
|
502 |
iObserver->HandleButtonCommandL(EMPXPbvCmdStop);
|
|
|
503 |
}
|
|
|
504 |
response = EKeyWasConsumed;
|
|
|
505 |
}
|
|
|
506 |
}
|
|
|
507 |
}
|
|
|
508 |
else if (aKeyEvent.iScanCode == EStdKeyUpArrow || aKeyEvent.iCode == EKeyUpArrow)
|
|
|
509 |
{
|
|
|
510 |
MPX_DEBUG1( "CMPXButtonManager::SetAvkonButtonStateL EStdKeyUpArrow pressed" );
|
|
|
511 |
if(iVolumeInRocker)
|
|
|
512 |
{
|
|
|
513 |
if (!iIsTouchUi)
|
|
|
514 |
{
|
|
|
515 |
if (aType == EEventKeyDown)
|
|
|
516 |
{
|
|
|
517 |
iAvkonButtons[EButtonVolumeUp]->SetCurrentState(1, ETrue);
|
|
|
518 |
}
|
|
|
519 |
else if (aType == EEventKeyUp)
|
|
|
520 |
{
|
|
|
521 |
iAvkonButtons[EButtonVolumeUp]->SetCurrentState(0, ETrue);
|
|
|
522 |
iObserver->HandleButtonCommandL(EMPXPbvCmdIncreaseVolume);
|
|
|
523 |
response = EKeyWasConsumed;
|
|
|
524 |
}
|
|
|
525 |
}
|
|
|
526 |
else //iIsTouchUi
|
|
|
527 |
{
|
|
|
528 |
if (aType == EEventKeyUp)
|
|
|
529 |
{
|
|
|
530 |
iObserver->HandleButtonCommandL(EMPXPbvCmdIncreaseVolume);
|
|
|
531 |
response = EKeyWasConsumed;
|
|
|
532 |
}
|
|
|
533 |
}
|
|
|
534 |
}
|
|
|
535 |
}
|
|
|
536 |
return response;
|
|
|
537 |
}
|
|
|
538 |
|
|
|
539 |
// -----------------------------------------------------------------------------
|
|
|
540 |
// CMPlayerPlaybackContainer::TimerCallback
|
|
|
541 |
// -----------------------------------------------------------------------------
|
|
|
542 |
//
|
|
|
543 |
TInt CMPXButtonManager::TimerCallback(TAny* aPtr)
|
|
|
544 |
{
|
|
|
545 |
//HandleLongPress();
|
|
|
546 |
MPX_TRAPD( err, static_cast<CMPXButtonManager*>(aPtr)->HandleLongPressL() );
|
|
|
547 |
return err;
|
|
|
548 |
}
|
|
|
549 |
|
|
|
550 |
// -----------------------------------------------------------------------------
|
|
|
551 |
// CMPlayerPlaybackContainer::HandleLongPress
|
|
|
552 |
// -----------------------------------------------------------------------------
|
|
|
553 |
//
|
|
|
554 |
void CMPXButtonManager::HandleLongPressL()
|
|
|
555 |
{
|
|
|
556 |
iObserver->HandleButtonCommandL(iLongPressCommandId);
|
|
|
557 |
iLongKeyTimer->Cancel();
|
|
|
558 |
iIsLongPress = ETrue;
|
|
|
559 |
}
|
|
|
560 |
|
|
|
561 |
// -----------------------------------------------------------------------------
|
|
|
562 |
// void CMPXCommonPlaybackViewContainer::HandleControlEventL
|
|
|
563 |
// ----------------------------------------------------------------------------
|
|
|
564 |
//
|
|
|
565 |
void CMPXButtonManager::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType )
|
|
|
566 |
{
|
|
|
567 |
|
|
|
568 |
if( AknLayoutUtils::PenEnabled() )
|
|
|
569 |
{
|
|
|
570 |
switch( aEventType )
|
|
|
571 |
{
|
|
|
572 |
case EEventStateChanged:
|
|
|
573 |
{
|
|
|
574 |
if (iVolumeInRocker)
|
|
|
575 |
{
|
|
|
576 |
if ( aControl == iAvkonButtons[EButtonVolumeUp] )
|
|
|
577 |
{
|
|
|
578 |
iAvkonButtons[EButtonVolumeUp]->SetCurrentState(0, ETrue);
|
|
|
579 |
iObserver->HandleButtonCommandL(EMPXPbvCmdIncreaseVolume);
|
|
|
580 |
}
|
|
|
581 |
else if ( aControl == iAvkonButtons[EButtonVolumeDown] )
|
|
|
582 |
{
|
|
|
583 |
iAvkonButtons[EButtonVolumeDown]->SetCurrentState(0, ETrue);
|
|
|
584 |
iObserver->HandleButtonCommandL(EMPXPbvCmdDecreaseVolume);
|
|
|
585 |
}
|
|
|
586 |
|
|
|
587 |
}
|
|
|
588 |
|
|
|
589 |
break;
|
|
|
590 |
}
|
|
|
591 |
case CAknButton::ELongPressEvent:
|
|
|
592 |
{
|
|
|
593 |
if ( aControl == iAvkonButtons[EButtonFastForward] )
|
|
|
594 |
{
|
|
|
595 |
iIsLongPress = ETrue;
|
|
|
596 |
iAvkonButtons[EButtonFastForward]->SetCurrentState(0, ETrue);
|
|
|
597 |
iObserver->HandleButtonCommandL(EMPXPbvCmdSeekForward);
|
|
|
598 |
}
|
|
|
599 |
else if ( aControl == iAvkonButtons[EButtonRewind] )
|
|
|
600 |
{
|
|
|
601 |
iIsLongPress = ETrue;
|
|
|
602 |
iAvkonButtons[EButtonRewind]->SetCurrentState(0, ETrue);
|
|
|
603 |
iObserver->HandleButtonCommandL(EMPXPbvCmdSeekBackward);
|
|
|
604 |
}
|
|
|
605 |
break;
|
|
|
606 |
}
|
|
|
607 |
case MCoeControlObserver::EEventRequestExit:
|
|
|
608 |
{
|
|
|
609 |
if ( aControl == iAvkonButtons[EButtonPlay] )
|
|
|
610 |
{
|
|
|
611 |
iAvkonButtons[EButtonPlay]->SetCurrentState(0, ETrue);
|
|
|
612 |
iObserver->HandleButtonCommandL(EMPXPbvCmdPlay);
|
|
|
613 |
}
|
|
|
614 |
else if ( aControl == iAvkonButtons[EButtonPause] )
|
|
|
615 |
{
|
|
|
616 |
iAvkonButtons[EButtonPause]->SetCurrentState(0, ETrue);
|
|
|
617 |
iObserver->HandleButtonCommandL(EMPXPbvCmdPause);
|
|
|
618 |
}
|
|
|
619 |
else if ( aControl == iAvkonButtons[EButtonFastForward] )
|
|
|
620 |
{
|
|
|
621 |
if (iIsLongPress)
|
|
|
622 |
{
|
|
|
623 |
iIsLongPress = EFalse;
|
|
|
624 |
iAvkonButtons[EButtonFastForward]->SetCurrentState(0, ETrue);
|
|
|
625 |
iObserver->HandleButtonCommandL(EMPXPbvCmdEndSeek);
|
|
|
626 |
}
|
|
|
627 |
else
|
|
|
628 |
{
|
|
|
629 |
iAvkonButtons[EButtonFastForward]->SetCurrentState(0, ETrue);
|
|
|
630 |
iObserver->HandleButtonCommandL(EMPXPbvCmdNextListItem);
|
|
|
631 |
}
|
|
|
632 |
}
|
|
|
633 |
else if ( aControl == iAvkonButtons[EButtonRewind] )
|
|
|
634 |
{
|
|
|
635 |
if (iIsLongPress)
|
|
|
636 |
{
|
|
|
637 |
iIsLongPress = EFalse;
|
|
|
638 |
iAvkonButtons[EButtonRewind]->SetCurrentState(0, ETrue);
|
|
|
639 |
iObserver->HandleButtonCommandL(EMPXPbvCmdEndSeek);
|
|
|
640 |
}
|
|
|
641 |
else
|
|
|
642 |
{
|
|
|
643 |
iAvkonButtons[EButtonRewind]->SetCurrentState(0, ETrue);
|
|
|
644 |
iObserver->HandleButtonCommandL(EMPXPbvCmdPreviousListItem);
|
|
|
645 |
}
|
|
|
646 |
}
|
|
|
647 |
else if ( !iVolumeInRocker)
|
|
|
648 |
{
|
|
|
649 |
if(aControl == iAvkonButtons[EButtonVolumeDown])
|
|
|
650 |
{
|
|
|
651 |
iAvkonButtons[EButtonVolumeDown]->SetCurrentState(0, ETrue);
|
|
|
652 |
iObserver->HandleButtonCommandL(EMPXPbvCmdStop);
|
|
|
653 |
}
|
|
|
654 |
}
|
|
|
655 |
break;
|
|
|
656 |
}
|
|
|
657 |
default:
|
|
|
658 |
break;
|
|
|
659 |
}
|
|
|
660 |
}
|
|
|
661 |
|
|
|
662 |
}
|
|
|
663 |
|
|
|
664 |
// ---------------------------------------------------------------------------
|
|
|
665 |
// From CCoeControl
|
|
|
666 |
// Gets the number of controls contained in a compound control.
|
|
|
667 |
// ---------------------------------------------------------------------------
|
|
|
668 |
//
|
|
|
669 |
TInt CMPXButtonManager::CountComponentControls() const
|
|
|
670 |
{
|
|
|
671 |
return iRockerAvkonButtonCount;
|
|
|
672 |
}
|
|
|
673 |
|
|
|
674 |
// ---------------------------------------------------------------------------
|
|
|
675 |
// From CCoeControl
|
|
|
676 |
// Gets an indexed component of a compound control.
|
|
|
677 |
// ---------------------------------------------------------------------------
|
|
|
678 |
//
|
|
|
679 |
CCoeControl* CMPXButtonManager::ComponentControl( TInt aIndex ) const
|
|
|
680 |
{
|
|
|
681 |
ASSERT( aIndex < iRockerAvkonButtonCount );
|
|
|
682 |
return iAvkonButtons[aIndex];
|
|
|
683 |
}
|
|
|
684 |
|
|
|
685 |
// ---------------------------------------------------------------------------
|
|
|
686 |
// From CCoeControl
|
|
|
687 |
// Handles a change to the control's resources.
|
|
|
688 |
// ---------------------------------------------------------------------------
|
|
|
689 |
//
|
|
|
690 |
void CMPXButtonManager::HandleResourceChange( TInt aType )
|
|
|
691 |
{
|
|
|
692 |
|
|
|
693 |
if ( aType == KAknsMessageSkinChange )
|
|
|
694 |
{
|
|
|
695 |
for (TInt i = 0; i< iRockerAvkonButtonCount; i++)
|
|
|
696 |
{
|
|
|
697 |
iAvkonButtons[i]->HandleResourceChange( aType );
|
|
|
698 |
}
|
|
|
699 |
|
|
|
700 |
}
|
|
|
701 |
}
|
|
|
702 |
// ---------------------------------------------------------------------------
|
|
|
703 |
// From CCoeControl
|
|
|
704 |
// Handles a size change
|
|
|
705 |
// ---------------------------------------------------------------------------
|
|
|
706 |
//
|
|
|
707 |
void CMPXButtonManager::SizeChanged()
|
|
|
708 |
{
|
|
|
709 |
iParentRect = Rect();
|
|
|
710 |
TRect rockerRect = iLayout->ButtonLayout(iParentRect);
|
|
|
711 |
TRect controlButtonRect;
|
|
|
712 |
for (TInt i = 0; i< iRockerAvkonButtonCount; i++)
|
|
|
713 |
{
|
|
|
714 |
controlButtonRect = iLayout->ButtonLayout(rockerRect, i);
|
|
|
715 |
iAvkonButtons[i]->SetRect( controlButtonRect );
|
|
|
716 |
}
|
|
|
717 |
}
|
|
|
718 |
|
|
|
719 |
void CMPXButtonManager::Draw(CWindowGc& /*aGc*/, const CCoeControl& /*aControl*/, const TRect& /*aRect*/) const
|
|
|
720 |
{
|
|
|
721 |
// Do Nothing
|
|
|
722 |
}
|
|
|
723 |
|
|
|
724 |
// -----------------------------------------------------------------------------
|
|
|
725 |
// CMPXButtonManager::RestoreButtonStates
|
|
|
726 |
// -----------------------------------------------------------------------------
|
|
|
727 |
//
|
|
|
728 |
void CMPXButtonManager::RestoreButtonStates( TMPXPlaybackState aState )
|
|
|
729 |
{
|
|
|
730 |
MPX_DEBUG2("CMPXButtonManager::RestoreButtonStates(%d) entering", aState);
|
|
|
731 |
if( !iIsTouchUi)
|
|
|
732 |
{
|
|
|
733 |
if (aState == EPbStatePlaying)
|
|
|
734 |
{
|
|
|
735 |
// Playing
|
|
|
736 |
if (!iAvkonButtons[EButtonFastForward]->IsDimmed())
|
|
|
737 |
{
|
|
|
738 |
iAvkonButtons[EButtonFastForward]->SetDimmed(ETrue);
|
|
|
739 |
}
|
|
|
740 |
if (!iAvkonButtons[EButtonRewind]->IsDimmed())
|
|
|
741 |
{
|
|
|
742 |
iAvkonButtons[EButtonRewind]->SetDimmed(ETrue);
|
|
|
743 |
}
|
|
|
744 |
}
|
|
|
745 |
}
|
|
|
746 |
MPX_DEBUG1("CMPXButtonManager::ResoreButtonStates() exiting");
|
|
|
747 |
}
|
|
|
748 |
// End of File
|