android手势动画

在PhoneWindowManager.java中

interceptKeyBeforeQueueing方法中添加如下代码

switch (keyCode) {

case KeyEvent.KEYCODE_C: {

if (down && SystemProperties.getBoolean("persist.sys.gesture.enable", false)

&& SystemProperties.getBoolean("persist.sys.gesture.c", false)) {

playGestureAnimation(‘c‘); //这个地方是播放手势动画

//wakeScreenHandler.sendEmptyMessageDelayed(MSG_WAKE_SCREEN, 220);

myHandler.sendEmptyMessageDelayed(MSG_OPEN_CAMERA, 1000);//这个地方是手势动画伴随的动作,比如打开相机

setSleep();//播放手势动画不在主线程中,所以要主线程睡眠下,等待启动手势动画

dismissKeyguardOnNextActivity();//这个是解锁

result |= ACTION_WAKE_UP;//这个地方是唤醒屏幕

}

break;

}

case KeyEvent.KEYCODE_E: {

if (down && SystemProperties.getBoolean("persist.sys.gesture.enable", false)

&& SystemProperties.getBoolean("persist.sys.gesture.e", false)) {

playGestureAnimation(‘e‘);

//wakeScreenHandler.sendEmptyMessageDelayed(MSG_WAKE_SCREEN, 220);

myHandler.sendEmptyMessageDelayed(MSG_OPEN_BROWSER, 1000);

setSleep();

dismissKeyguardOnNextActivity();

result |= ACTION_WAKE_UP;

}

break;

}

case KeyEvent.KEYCODE_W: {

if (down && SystemProperties.getBoolean("persist.sys.gesture.enable", false)

&& SystemProperties.getBoolean("persist.sys.gesture.w", false)) {

playGestureAnimation(‘w‘);

//wakeScreenHandler.sendEmptyMessageDelayed(MSG_WAKE_SCREEN, 220);

myHandler.sendEmptyMessageDelayed(MSG_OPEN_FILE, 1000);

setSleep();

dismissKeyguardOnNextActivity();

result |= ACTION_WAKE_UP;

}

break;

}

case KeyEvent.KEYCODE_M: {

if (down && SystemProperties.getBoolean("persist.sys.gesture.enable", false)

&& SystemProperties.getBoolean("persist.sys.gesture.m",false)) {

playGestureAnimation(‘m‘);

//wakeScreenHandler.sendEmptyMessageDelayed(MSG_WAKE_SCREEN, 220);

myHandler.sendEmptyMessageDelayed(MSG_OPEN_MUSIC, 1000);

setSleep();

dismissKeyguardOnNextActivity();

result |= ACTION_WAKE_UP;

}

break;

}

case KeyEvent.KEYCODE_O: {

if (down && SystemProperties.getBoolean("persist.sys.gesture.enable", false)

&& SystemProperties.getBoolean("persist.sys.gesture.o",false)) {

playGestureAnimation(‘o‘);

//wakeScreenHandler.sendEmptyMessageDelayed(MSG_WAKE_SCREEN, 220);

myHandler.sendEmptyMessageDelayed(MSG_OPEN_DIALER, 1000);

setSleep();

dismissKeyguardOnNextActivity();

result |= ACTION_WAKE_UP;

}

break;

}

case KeyEvent.KEYCODE_F9: {

if (down && SystemProperties.getBoolean("persist.sys.gesture.enable", false)

&& SystemProperties.getBoolean("persist.sys.gesture.down",false)) {

KeyEvent e = new KeyEvent(KeyEvent.ACTION_DOWN,

KeyEvent.KEYCODE_MEDIA_PAUSE);

if (down && (result & ACTION_PASS_TO_USER) == 0) {

android.util.Log.v(TAG, "KEYCODE_F11");

mBroadcastWakeLock.acquire();

Message msg = mHandler.obtainMessage(

MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK,

new KeyEvent(e));

msg.setAsynchronous(true);

msg.sendToTarget();

}

}

break;

}

case KeyEvent.KEYCODE_F11: {

if (down && SystemProperties.getBoolean("persist.sys.gesture.enable", false)

&& SystemProperties.getBoolean("persist.sys.gesture.right",false)) {

KeyEvent e = new KeyEvent(KeyEvent.ACTION_DOWN,

KeyEvent.KEYCODE_MEDIA_NEXT);

if (down && (result & ACTION_PASS_TO_USER) == 0) {

android.util.Log.v(TAG, "KEYCODE_F11");

mBroadcastWakeLock.acquire();

Message msg = mHandler.obtainMessage(

MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK,

new KeyEvent(e));

msg.setAsynchronous(true);

msg.sendToTarget();

}

}

break;

}

case KeyEvent.KEYCODE_F12: {

if (down && SystemProperties.getBoolean("persist.sys.gesture.enable", false)

&& SystemProperties.getBoolean("persist.sys.gesture.left",false)) {

KeyEvent e = new KeyEvent(KeyEvent.ACTION_DOWN,

KeyEvent.KEYCODE_MEDIA_PREVIOUS);

if (down && (result & ACTION_PASS_TO_USER) == 0) {

android.util.Log.v(TAG, "KEYCODE_F11");

mBroadcastWakeLock.acquire();

Message msg = mHandler.obtainMessage(

MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK,

new KeyEvent(e));

msg.setAsynchronous(true);

msg.sendToTarget();

}

}

break;

}

case KeyEvent.KEYCODE_F10: {

if (down && SystemProperties.getBoolean("persist.sys.gesture.enable", false)

&& SystemProperties.getBoolean("persist.sys.gesture.up",false)) {

playGestureAnimation(‘u‘);

setSleep();

dismissKeyguardOnNextActivity();

result |= ACTION_WAKE_UP;

//wakeScreenHandler.sendEmptyMessageDelayed(MSG_WAKE_SCREEN, 220);

}

break;

}

case KeyEvent.KEYCODE_F1: {

if (down) {

// NOTE: add for QuickWindow case

Slog.d(TAG, "[justin]interceptKeyBeforeQueueing KEYCODE_VOLUME_UP(HALL OPEN)->QuickWindow hide or show big phone UI or small clock UI");

if (isQuickWindowShow) {

mContext.stopService(new Intent("com.sprd.quickwindow.QuickWindowService.action"));

ContentValues values = new ContentValues();

values.put("hallvalue", -1);

final Uri uri = Uri.parse("content://com.sprd.quickwindow.provider");

mContext.getContentResolver().update(uri, values, "id=1", null);

mContext.sendBroadcast(new Intent(ACTION_QUICKWINDOW_HIDE));

/**[email protected] 2015.3.17 begin */

isQuickWindowShow = false;

/**[email protected] 2015.3.17 end */

}

screenOffHandler.removeMessages(MSG_GO_TO_SLEEP);

result |= ACTION_WAKE_UP;

}

break;

}

case KeyEvent.KEYCODE_F2: {

android.util.Log.v("liuxinwen", "isScreenOn = " + isScreenOn);

if (down && isScreenOn) {

android.util.Log.v("liuxinwen", "KEYCODE_F2");

// NOTE: add for QuickWindow case

Slog.d(TAG,

"[justin]interceptKeyBeforeQueueing KEYCODE_VOLUME_DOWN(HALL CLOSE)->QuickWindow show or small window");

ContentValues values = new ContentValues();

values.put("hallvalue", 1);

final Uri uri = Uri

.parse("content://com.sprd.quickwindow.provider");

mContext.getContentResolver().update(uri, values, "id=1", null);

ITelephony telephonyService = getTelephonyService();

if (telephonyService != null) {

Slog.d(TAG, "[justin]telephonyService is not null");

try {

Slog.d(TAG, "quickwindow case. isRinging:"

+ telephonyService.isRinging() + " isOffhook:"

+ telephonyService.isOffhook());

if (!telephonyService.isRinging()

&& !telephonyService.isOffhook()

&& mAlarmState != ALARM_ALERT) {// no ring and

// no clock

Slog.d(TAG,

"[justin]not ringing and not clock, need show quickwindow.");

mContext.startService(new Intent(

"com.sprd.quickwindow.QuickWindowService.action"));

}

Slog.d(TAG,

"[justin]ringing or clock, show small phone UI or small clock UI.");

mContext.sendBroadcast(new Intent(

ACTION_QUICKWINDOW_SHOW));

isQuickWindowShow = true;

} catch (RemoteException ex) {

Slog.w(TAG, "ITelephony threw RemoteException", ex);

}

}

}

if (down && isScreenOn) {

screenOffHandler.sendEmptyMessageDelayed(MSG_GO_TO_SLEEP, 5000);

}

break;

}

case KeyEvent.KEYCODE_F3: {

Log.d("lizhihong","KEYCODE_F3-->" + down);

if (down && SystemProperties.getBoolean("persist.sys.air.distance", false)) {

mContext.sendBroadcast(new Intent(ACTION_NO_TOUCH_TURN_PAGE));

}

break;

}

case KeyEvent.KEYCODE_U: {

if (down && SystemProperties.getBoolean("persist.sys.gesture.enable", false)

&& SystemProperties.getBoolean("persist.sys.gesture.double", false)) {

android.util.Log.v(TAG, "persist.sys.gesture.doubleclicke");

result |= ACTION_WAKE_UP;

}

break;

}

}

//播放手势动画

private void playGestureAnimation(char keyCode) {

String[] cmd = {"bootanimation",keyCode + "x"};

try {

Runtime.getRuntime().exec(cmd);

} catch (Exception e) {

Log.e(TAG, " command exe err!");

}

}

//这个是伴随手势动画的动作

Handler myHandler = new Handler() {

public void handleMessage(Message msg) {

Intent intent = new Intent();

switch (msg.what) {

case MSG_OPEN_CAMERA:

intent.setAction("android.intent.action.VIEW");

intent.setClassName("com.android.camera2",

"com.android.camera.CameraLauncher");

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK

| Intent.FLAG_ACTIVITY_SINGLE_TOP

| Intent.FLAG_ACTIVITY_CLEAR_TOP);

mContext.startActivityAsUser(intent, UserHandle.CURRENT);

break;

case MSG_OPEN_BROWSER:

intent.setAction("android.intent.action.VIEW");

intent.setClassName("com.android.browser",

"com.android.browser.BrowserActivity");

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK

| Intent.FLAG_ACTIVITY_SINGLE_TOP

| Intent.FLAG_ACTIVITY_CLEAR_TOP);

mContext.startActivityAsUser(intent, UserHandle.CURRENT);

break;

case MSG_OPEN_FILE:

intent.setClassName("com.sprd.fileexplorer",

"com.sprd.fileexplorer.activities.FileExploreActivity");

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK

| Intent.FLAG_ACTIVITY_SINGLE_TOP

| Intent.FLAG_ACTIVITY_CLEAR_TOP);

mContext.startActivityAsUser(intent, UserHandle.CURRENT);

break;

case MSG_OPEN_MUSIC:

intent.setClassName("com.android.music",

"com.android.music.MusicBrowserActivity");

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK

| Intent.FLAG_ACTIVITY_SINGLE_TOP

| Intent.FLAG_ACTIVITY_CLEAR_TOP);

mContext.startActivityAsUser(intent, UserHandle.CURRENT);

break;

case MSG_OPEN_DIALER:

intent.setClassName("com.android.dialer",

"com.android.dialer.DialtactsActivity");

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK

| Intent.FLAG_ACTIVITY_SINGLE_TOP

| Intent.FLAG_ACTIVITY_CLEAR_TOP);

mContext.startActivityAsUser(intent, UserHandle.CURRENT);

break;

default:

break;

}

super.handleMessage(msg);

}

};

private void setSleep() {

try {

Thread.sleep(170);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

//唤醒屏幕,解锁

private void dismissKeyguardOnNextActivity() {

PowerManager pm=(PowerManager) mContext.getSystemService(Context.POWER_SERVICE);

PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK,"bright");

wl.acquire();

wl.release();

if (mLockPatternUtils.getActivePasswordQuality() == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {

mKeyguardDelegate.keyguardDone(false,true);

}

/**[email protected] 2015.3.23 begin */

if (SystemProperties.getBoolean("persist.sys.gesture.vibrate", false)) {

mVibrator.vibrate(200l);

}

/**[email protected] 2015.3.23 end */

}

播放手势动画

在frameworks/base/cmds/bootanimation下bootanimation_main.cpp中

switch(argv[1][0]) {

case ‘c‘:

bootanimation_path = "/system/media/gesture_c_animation.zip";

bootanimation_sound_path = "";

break;

case ‘e‘:

bootanimation_path = "/system/media/gesture_e_animation.zip";

bootanimation_sound_path = "";

break;

case ‘o‘:

bootanimation_path = "/system/media/gesture_o_animation.zip";

bootanimation_sound_path = "";

break;

case ‘w‘:

bootanimation_path = "/system/media/gesture_w_animation.zip";

bootanimation_sound_path = "";

break;

case ‘m‘:

bootanimation_path = "/system/media/gesture_m_animation.zip";

bootanimation_sound_path = "";

break;

case ‘l‘:

bootanimation_path = "/system/media/gesture_left_animation.zip";

bootanimation_sound_path = "";

break;

case ‘r‘:

bootanimation_path = "/system/media/gesture_right_animation.zip";

bootanimation_sound_path = "";

break;

case ‘u‘:

bootanimation_path = "/system/media/gesture_up_animation.zip";

bootanimation_sound_path = "";

break;

case ‘d‘:

bootanimation_path = "/system/media/gesture_down_animation.zip";

bootanimation_sound_path = "";

break;

default:

break;

}

时间: 2024-12-12 02:27:06

android手势动画的相关文章

Android 手势检测实战 打造支持缩放平移的图片预览效果(下)

转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/39480503,本文出自:[张鸿洋的博客] 上一篇已经带大家实现了自由的放大缩小图片,简单介绍了下Matrix:具体请参考:Android 手势检测实战 打造支持缩放平移的图片预览效果(上):本篇继续完善我们的ImageView~~ 首先加入放大后的移动~~ 1.自由的进行移动 我们在onTouchEvent里面,加上移动的代码,当然了,必须长或宽大于屏幕才可以移动~~~ @Ov

【转】android 属性动画之 ObjectAnimator

原文网址:http://blog.csdn.net/feiduclear_up/article/details/39255083 前面一篇博客讲解了 android 简单动画之 animtion,这里来讲解一下android 3.0之后添加的一些动画   animator 中的 ObjectAnimator . 属性动画概念: 所谓属性动画:改变一切能改变的对象的属性值,不同于补间动画:只能改变 alpha,scale,rotate,translate.听着有点抽象,举例子说明 补间动画能实现的

Android属性动画之ObjectAnimator

相信对于Android初学者,对于Android中的动画效果一定很感兴趣,今天为大家总结一下刚刚学到的属性动画案例. 首先和一般的Android应用一样,我们先建一个工程,为了方便,我们的布局文件中就只添加一个ImageView和button按钮,代码如下: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.andr

android 属性动画之 ObjectAnimator

前面一篇博客讲解了 android 简单动画之 animtion,这里来讲解一下android 3.0之后添加的一些动画   animator 中的 ObjectAnimator . 1.alpha //第一个参数为 view对象,第二个参数为 动画改变的类型,第三,第四个参数依次是开始透明度和结束透明度. ObjectAnimator alpha = ObjectAnimator.ofFloat(text, "alpha", 0f, 1f); alpha.setDuration(20

Android Tween动画

View Animation, 即显示在view上的Tween Animation Tween动画,本质上不改变View对象本身,只改变它的绘制方式 两种实现方式,一种在xml中定义,一种直接在代码里定义 xml定义方式: 位移动画translate <?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk

android开机动画启动流程

从android的Surface Flinger服务启动分析知道,开机动画是在SurfaceFlinger实例通过调用startBootAnim()启动的. 下面我们就一起学习BootAnim是如何启动和结束的,我精读代码前都喜欢先描出框架图,以此图为基础再去研读会达到事半功倍的效果.好吧,直接上图. 内核起来后会启动第一个进程,即init进程. init进程会根据init.rc配置启动surfaceflinger进程. service surfaceflinger /system/bin/su

[转]android logo:内核、android开机动画

平台信息:内核:linux2.6/linux3.0系统:android/android平台:S5PV310(samsungexynos4210/4412) 作者:xubin341719(欢迎转载,请注明作者) android开logo,这一块在工作改动的也是比较多的,也比较简单,不同的公司,不同型号的产品,开机的标识不一样. 我们平时目测的开机logo一般是两种:静态的和动画的.其实在实现logo的过程中,有四幅图片:(1).uboot显示:(2).kernel显示logo_linux_clut

Android属性动画初步学习笔记

近期学习Android属性动画和VetcorDrawable实现属性动画,以此记录一下学习笔记. 首先是属性动画,小白没截过动态图,方三张静态图吧       效果是点击红色图片,7个选项以属性动画的方式弹出并旋转,最后成一个1/4圆弧排列,再次点击则收回到红色原点下. 布局文件很简单,就是一个RelativeLayout下八个ImageView: 1 <?xml version="1.0" encoding="utf-8"?> 2 <Linear

Android手势源码浅析-----手势绘制(GestureOverlayView)

Android手势源码浅析-----手势绘制(GestureOverlayView)