CmSdk : Swipe offsets and show lockscreen

Allows live lockscreen to listen to keyguard offsets
and show lockscreen.

Change-Id: I1a06c78b95e4e6940e063c6e0ba0e4db44a3c380
This commit is contained in:
Danesh M 2016-03-31 20:33:18 -07:00 committed by Gerrit Code Review
parent 42a1a85427
commit d549053b2d
7 changed files with 77 additions and 0 deletions

View File

@ -435,11 +435,13 @@ package cyanogenmod.externalviews {
method protected void onDetach(); method protected void onDetach();
method protected abstract void onKeyguardDismissed(); method protected abstract void onKeyguardDismissed();
method protected abstract void onKeyguardShowing(boolean); method protected abstract void onKeyguardShowing(boolean);
method protected void onLockscreenSlideOffsetChanged(float);
method protected abstract void onScreenTurnedOff(); method protected abstract void onScreenTurnedOff();
method protected abstract void onScreenTurnedOn(); method protected abstract void onScreenTurnedOn();
method protected final boolean requestDismiss(); method protected final boolean requestDismiss();
method protected final boolean requestDismissAndStartActivity(android.content.Intent); method protected final boolean requestDismissAndStartActivity(android.content.Intent);
method protected final void setInteractivity(boolean); method protected final void setInteractivity(boolean);
method protected final void slideLockscreenIn();
} }
} }

View File

@ -94,6 +94,11 @@ public class SampleKeyguardProviderService extends KeyguardExternalViewProviderS
mImageView.clearAnimation(); mImageView.clearAnimation();
} }
@Override
protected void onLockscreenSlideOffsetChanged(float slideProgress) {
}
/** /**
* Called when the view has been attached to a window * Called when the view has been attached to a window
*/ */

View File

@ -26,4 +26,5 @@ interface IKeyguardExternalViewCallbacks {
oneway void setInteractivity(boolean isInteractive); oneway void setInteractivity(boolean isInteractive);
oneway void onAttachedToWindow(); oneway void onAttachedToWindow();
oneway void onDetachedFromWindow(); oneway void onDetachedFromWindow();
oneway void slideLockscreenIn();
} }

View File

@ -38,4 +38,5 @@ interface IKeyguardExternalViewProvider
void alterWindow(in int x, in int y, in int width, in int height, in boolean visible, void alterWindow(in int x, in int y, in int width, in int height, in boolean visible,
in Rect clipRect); in Rect clipRect);
oneway void onLockscreenSlideOffsetChanged(float swipeProgress);
} }

View File

@ -198,6 +198,13 @@ public class KeyguardExternalView extends View implements ViewTreeObserver.OnPre
mWindowAttachmentListener.onDetachedFromWindow(); mWindowAttachmentListener.onDetachedFromWindow();
} }
} }
@Override
public void slideLockscreenIn() {
if (mCallback != null) {
mCallback.slideLockscreenIn();
}
}
}; };
private void executeQueue() { private void executeQueue() {
@ -376,6 +383,24 @@ public class KeyguardExternalView extends View implements ViewTreeObserver.OnPre
}); });
} }
/**
* Called from the host when the user is swiping the lockscreen
* to transition into the live lock screen
*
* @param swipeProgress [0-1] represents the progress of the swipe
*/
public void onLockscreenSlideOffsetChanged(final float swipeProgress) {
performAction(new Runnable() {
@Override
public void run() {
try {
mExternalViewProvider.onLockscreenSlideOffsetChanged(swipeProgress);
} catch (RemoteException e) {
}
}
});
}
/** /**
* External views provided by a * External views provided by a
* {@link cyanogenmod.externalviews.KeyguardExternalViewProviderService} can be either * {@link cyanogenmod.externalviews.KeyguardExternalViewProviderService} can be either
@ -453,6 +478,7 @@ public class KeyguardExternalView extends View implements ViewTreeObserver.OnPre
boolean requestDismissAndStartActivity(Intent intent); boolean requestDismissAndStartActivity(Intent intent);
void collapseNotificationPanel(); void collapseNotificationPanel();
void providerDied(); void providerDied();
void slideLockscreenIn();
} }
/** /**

View File

@ -227,6 +227,17 @@ public abstract class KeyguardExternalViewProviderService extends Service {
}); });
} }
@Override
public void onLockscreenSlideOffsetChanged(final float swipeProgress)
throws RemoteException {
mHandler.post(new Runnable() {
@Override
public void run() {
Provider.this.onLockscreenSlideOffsetChanged(swipeProgress);
}
});
}
@Override @Override
public void alterWindow(final int x, final int y, final int width, final int height, public void alterWindow(final int x, final int y, final int width, final int height,
final boolean visible, final Rect clipRect) { final boolean visible, final Rect clipRect) {
@ -324,6 +335,18 @@ public abstract class KeyguardExternalViewProviderService extends Service {
mCallbacks.finishBroadcast(); mCallbacks.finishBroadcast();
} }
public void slideLockscreenIn() {
int N = mCallbacks.beginBroadcast();
for(int i=0; i < N; i++) {
IKeyguardExternalViewCallbacks callback = mCallbacks.getBroadcastItem(0);
try {
callback.slideLockscreenIn();
} catch(RemoteException e) {
}
}
mCallbacks.finishBroadcast();
}
// region Window callbacks // region Window callbacks
@Override @Override
public boolean dispatchKeyEvent(KeyEvent event) { public boolean dispatchKeyEvent(KeyEvent event) {
@ -522,6 +545,14 @@ public abstract class KeyguardExternalViewProviderService extends Service {
*/ */
protected abstract void onScreenTurnedOff(); protected abstract void onScreenTurnedOff();
/**
* Called from the host when the user is swiping the lockscreen
* to transition into the live lock screen
*
* @param swipeProgress [0-1] represents the progress of the swipe
*/
protected void onLockscreenSlideOffsetChanged(float swipeProgress) {}
// callbacks from provider to host // callbacks from provider to host
/** /**
@ -581,6 +612,15 @@ public abstract class KeyguardExternalViewProviderService extends Service {
mImpl.setInteractivity(isInteractive); mImpl.setInteractivity(isInteractive);
} }
/**
* Call this method when you like to slide in the lockscreen on top of
* your live lockscreen. Only relevant if you use
* {@link KeyguardExternalViewProviderService.Provider#setInteractivity(boolean)}
*/
protected final void slideLockscreenIn() {
mImpl.slideLockscreenIn();
}
/*package*/ final int getWindowType() { /*package*/ final int getWindowType() {
return WindowManager.LayoutParams.TYPE_KEYGUARD_PANEL; return WindowManager.LayoutParams.TYPE_KEYGUARD_PANEL;
} }

View File

@ -435,11 +435,13 @@ package cyanogenmod.externalviews {
method protected void onDetach(); method protected void onDetach();
method protected abstract void onKeyguardDismissed(); method protected abstract void onKeyguardDismissed();
method protected abstract void onKeyguardShowing(boolean); method protected abstract void onKeyguardShowing(boolean);
method protected void onLockscreenSlideOffsetChanged(float);
method protected abstract void onScreenTurnedOff(); method protected abstract void onScreenTurnedOff();
method protected abstract void onScreenTurnedOn(); method protected abstract void onScreenTurnedOn();
method protected final boolean requestDismiss(); method protected final boolean requestDismiss();
method protected final boolean requestDismissAndStartActivity(android.content.Intent); method protected final boolean requestDismissAndStartActivity(android.content.Intent);
method protected final void setInteractivity(boolean); method protected final void setInteractivity(boolean);
method protected final void slideLockscreenIn();
} }
} }