Ô´Âë¼ò½é
¿ÉÒÔʵÏÖÈ«¾ÖÅú×¢£¬ÔÚÈκνçÃ涼¿ÉÒÔ½«Åú×¢±Êµ÷³öÀ´½øÐÐÅú×¢£¬Ö§³Ö¸ü»»±ÊµÄÑÕÉ«£¬´Öϸ£¬Ö§³ÖÈý¸öÊÖÖ¸²Á³ý£¬¿ÉÒÔ¸ù¾ÝÊÖÖ¸¼ä¾à¾ö¶¨ÏðƤµÄÃæ»ý£¬·½±ãÓÖÊ¡ÐÄ£¡
Ô´ÂëÔËÐнØͼ
Ô´ÂëƬ¶Î£º
- package com.hht.annotation;
- import java.io.File;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.List;
- import android.app.AlertDialog;
- import android.app.Dialog;
- import android.app.Service;
- import android.content.BroadcastReceiver;
- import android.content.ComponentName;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.content.ServiceConnection;
- import android.content.SharedPreferences;
- import android.content.SharedPreferences.Editor;
- import android.gesture.GestureLibrary;
- import android.graphics.Color;
- import android.graphics.PixelFormat;
- import android.graphics.drawable.BitmapDrawable;
- import android.net.Uri;
- import android.os.Bundle;
- import android.os.Environment;
- import android.os.Handler;
- import android.os.IBinder;
- import android.os.Message;
- import android.os.Messenger;
- import android.os.RemoteException;
- import android.util.Log;
- import android.view.Gravity;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.View.OnLongClickListener;
- import android.view.Window;
- import android.view.WindowManager;
- import android.view.WindowManager.LayoutParams;
- import android.view.animation.Animation;
- import android.view.animation.AnimationUtils;
- import android.widget.Button;
- import android.widget.CompoundButton;
- import android.widget.CompoundButton.OnCheckedChangeListener;
- import android.widget.ImageView;
- import android.widget.PopupWindow;
- import android.widget.PopupWindow.OnDismissListener;
- import android.widget.RadioButton;
- import android.widget.RadioGroup;
- import android.widget.TextView;
- import android.widget.ToggleButton;
- import com.hht.annotation.whiteboard.WhiteboardView;
- import com.hht.annotation.R;
- public class SuspendService extends Service implements OnClickListener,
- OnCheckedChangeListener,OnLongClickListener {
- private WhiteboardView mView;
- private WindowManager wm;
- private LayoutParams wmParams;
- private LayoutParams wmParamsBg,wmGestrueBg,wmPPtLayout;
- private LayoutParams wmview_l;
- private ImageView arror_l;
- protected boolean isMove = false;
- protected float mXd;
- protected float mYd;
- private View bgView,ppt_left_and_right,gestrueBg,flort,homebar;
- private ToggleButton tg_black_l,tg_bule_l,tg_red_l, tg_glitterpen_orange,tg_glitterpen_green,tg_glitterpen_yellow,tg_laserpen_red, tg_eraser_l,tg_allapp;
- private Button home_screenshot, home_usb, home_settings, home_dockbar_ic_browser,btn_app2;
- private PopupWindow pw_usb,pw_l,pw_menu,pw_pen,pw_glitterpen,pw_laserpen;
- private View contentView_l,contentView_pw_pen,contentView_pw_glitterpen;
- private View layout_clear_l;
- private View layout_screenshot_l;
- private View layout_print_l;
- private Animation tool_in_l_anim, tool_out_l_anim;
- private Button btn_per,btn_next,btn_undo_l,btn_screenshot,btn_toolbox,btn_down,btn_menu,btn_home_down;
- private boolean isPencilChecked = false;// ʾǷѡ
- private BroadcastReceiver myReceiver;
- private static final int HIDESMARTBAR = 1;
- private static final int STARTSMARTBAR = 2;
- private static final int SCREENSHOT = 3;
- protected static final int CHECKEDPEN = 4;
- private static final int HIDEINTVSETTINGS = 8;
- private static final int CLEARVIEW = 12;
- private static final int ISSCREENSHOTING = 13;
- private static final int WHITEBOARDSCREENSHOT = 15;
- private static final int SHOWSMARTBAR = 17;
- private static final int SHOWLAUCHER = 18;
- private static final int SHOWALLAPP = 19;
- protected int size = 5;
- protected int pen = 0;
- protected int color = Color.BLACK;
- protected int glitterpen = 7;
- protected int glitterpenSize = 30;
- protected int glitterpenColor = Color.parseColor("#2bdb00");
- protected int laserpen = 7;
- protected int laserpenSize = 30;
- protected int laserpenColor = Color.GREEN;
- private ToggleButton currentToggleButton_l = null;
- private String mStrSavePath = "";
- private boolean mIsPrinting = false;
- public static final String PRINT_PREPARE_ACTION = "com.hht.printer.prepare";
- public static boolean ActionShowScreenshots = false;
- private boolean isViewShow = false;
- public static List<string> imagesList ;
- private GestureLibrary mLibrary;
- private boolean needShowAnnotationBar = false;
- private boolean needTouchPen = false;
- private boolean needShowLeftAndRight;
- String cmpNameTemp = null;
- protected boolean isFileBrowser;
- @Override
- public IBinder onBind(Intent arg0) {
- return null;
- }
- private Handler handler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case SHOWSMARTBAR:
- break;
- case STARTSMARTBAR:
- if(!isFileBrowser && !isWidgetBar){
- if(isHome){
- homebar.setVisibility(View.VISIBLE);
- flort.setVisibility(View.GONE);
- isShowPw_l =false;
- dismissPopupWindow_l();
- checkIfshowView(false, false);
- hiteGesture(true);
- ppt_left_and_right.setVisibility(View.GONE);
- }else{
- homebar.setVisibility(View.GONE);
- flort.setVisibility(View.VISIBLE);
- if (pw_usb != null && pw_usb.isShowing()) {
- pw_usb.dismiss();
- }
- }
- if(isWhiteBoard ||isRecents){
- hiteGesture(true);
- }
- }
- Log.e("Others77", "isScreenshot"+isScreenshot+"currentToggleButton_l"+currentToggleButton_l);
- break;
- case HIDESMARTBAR:
- tg_eraser_l.setChecked(false);
- setPenciIsChecked(tg_black_l,tg_bule_l,tg_red_l,tg_glitterpen_orange,tg_glitterpen_green,tg_glitterpen_yellow,tg_laserpen_red);
- bgView.setVisibility(View.GONE);
- mView.setVisibility(View.GONE);
- flort.setVisibility(View.GONE);
- homebar.setVisibility(View.GONE);
- isShowPw_l =false;
- dismissPopupWindow_l();
- if (pw_usb != null && pw_usb.isShowing()) {
- pw_usb.dismiss();
- }
- break;
- case HIDEINTVSETTINGS:
- Intent wintent = new Intent("mstar.tv.broadcast.service");
- wintent.putExtra(Intent.EXTRA_KEY_EVENT, 920);
- sendOrderedBroadcast(wintent, null);
- noHide = true;
- hiteSmartBar(false);
- break;
- case SCREENSHOT:
- takeScreenshot(true);
- break;
- case WHITEBOARDSCREENSHOT:
- Intent intent = new Intent("com.hht.whiteboard.getaction");
- intent.putExtra("snapshot", 1);
- sendBroadcast(intent);
- break;
- case ISSCREENSHOTING:
- isScreenshoting = false;
- btn_screenshot.setEnabled(true);
- if(layout_print_l!=null){
- layout_print_l.setEnabled(true);
- }
- break;
- case CHECKEDPEN:
- if(currentToggleButton_l!=null){
- currentToggleButton_l.setChecked(false);
- }
- hiteGesture(true);
- checkIfshowView(false,false);
- break;
- case CLEARVIEW:
- clear();
- break;
- case SHOWALLAPP:
- sendBroadcast(new Intent("INTENT.ACTION.SHOW.ALLAPP"));
- break;
- case SHOWLAUCHER:
- sendBroadcast(new Intent("INTENT.ACTION.SHOW.HOME"));
- break;
- default:
- break;
- }
- super.handleMessage(msg);
- }
- };
- private boolean removeAllView;
- private boolean removeView;
- private boolean noHide;
- private boolean isScreenshot;
- private boolean isHome;
- private boolean isWhiteBoard =false;
- public boolean isRecents;
- public boolean isWidgetBar;
- private RadioButton myRadioButton2;
- private boolean isCrash;
- private boolean isScreenshoting;
- private boolean isShowPw_l;
- private boolean isShowPw_l2;
- @Override
- public void onCreate() {
- sp = getSharedPreferences("smart_config", MODE_PRIVATE);
- tool_in_l_anim = AnimationUtils
- .loadAnimation(this, R.anim.translate_in);
- tool_out_l_anim = AnimationUtils.loadAnimation(this,
- R.anim.translate_out);
- //ppt
- ppt_left_and_right = LayoutInflater.from(this).inflate(R.layout.ppt_left_and_right, null);
- btn_per = (Button) ppt_left_and_right.findViewById(R.id.btn_per);
- btn_next = (Button) ppt_left_and_right.findViewById(R.id.btn_next);
- btn_per.setOnClickListener(this);
- btn_next.setOnClickListener(this);
- // Ҷߵlayout
- flort = LayoutInflater.from(this).inflate(R.layout.flort_pad_lf, null);
- isShowPw_l =false;
- dismissPopupWindow_l();
- if (pw_usb != null && pw_usb.isShowing()) {
- pw_usb.dismiss();
- }
- // ؼijʼͼ
- tg_black_l = (ToggleButton) flort.findViewById(R.id.tg_black_l);
- currentToggleButton_l = tg_black_l;
- tg_black_l.setChecked(true);
- tg_bule_l = (ToggleButton) flort.findViewById(R.id.tg_bule_l);
- tg_red_l = (ToggleButton) flort.findViewById(R.id.tg_red_l);
- tg_glitterpen_orange = (ToggleButton) flort.findViewById(R.id.tg_glitterpen_orange);
- tg_glitterpen_green = (ToggleButton) flort.findViewById(R.id.tg_glitterpen_green);
- tg_glitterpen_yellow = (ToggleButton) flort.findViewById(R.id.tg_glitterpen_yellow);
- tg_laserpen_red = (ToggleButton) flort.findViewById(R.id.tg_laserpen_red);
- tg_eraser_l = (ToggleButton) flort.findViewById(R.id.tg_eraser_l);
- arror_l = (ImageView) flort.findViewById(R.id.arror_l);
- btn_undo_l = (Button) flort.findViewById(R.id.btn_undo_l);
- btn_screenshot = (Button) flort.findViewById(R.id.btn_screenshot);
- btn_toolbox = (Button) flort.findViewById(R.id.btn_toolbox);
- btn_down = (Button) flort.findViewById(R.id.btn_down);
- btn_menu = (Button) flort.findViewById(R.id.btn_menu);
- tg_black_l.setOnCheckedChangeListener(this);
- tg_bule_l.setOnCheckedChangeListener(this);
- tg_red_l.setOnCheckedChangeListener(this);
- tg_glitterpen_orange.setOnCheckedChangeListener(this);
- tg_glitterpen_green.setOnCheckedChangeListener(this);
- tg_glitterpen_yellow.setOnCheckedChangeListener(this);
- tg_laserpen_red.setOnCheckedChangeListener(this);
- tg_eraser_l.setOnCheckedChangeListener(this);
- tg_bule_l.setOnCheckedChangeListener(this);
- tg_black_l.setOnLongClickListener(this);
- tg_bule_l.setOnLongClickListener(this);
- tg_red_l.setOnLongClickListener(this);
- tg_glitterpen_orange.setOnLongClickListener(this);
- tg_glitterpen_green.setOnLongClickListener(this);
- tg_glitterpen_yellow.setOnLongClickListener(this);
- tg_bule_l.setOnLongClickListener(this);
- tg_laserpen_red.setOnLongClickListener(this);
- arror_l.setOnClickListener(this);
- btn_undo_l.setOnClickListener(this);
- btn_screenshot.setOnClickListener(this);
- btn_toolbox.setOnClickListener(this);
- btn_down.setOnClickListener(this);
- btn_menu.setOnClickListener(this);
- // homeBarLayout
- homebar = LayoutInflater.from(this).inflate(R.layout.homebar, null);
- // ؼijʼͼ
- home_screenshot = (Button) homebar.findViewById(R.id.home_screenshot);
- home_usb = (Button) homebar.findViewById(R.id.home_usb);
- home_settings = (Button) homebar.findViewById(R.id.home_settings);
- home_dockbar_ic_browser = (Button) homebar.findViewById(R.id.home_dockbar_ic_browser);
- btn_app2 = (Button) homebar.findViewById(R.id.btn_app2);
- tg_allapp = (ToggleButton) homebar.findViewById(R.id.tg_allapp);
- btn_home_down = (Button) homebar.findViewById(R.id.btn_home_down);
- home_screenshot.setOnClickListener(this);
- home_usb.setOnClickListener(this);
- home_settings.setOnClickListener(this);
- home_dockbar_ic_browser.setOnClickListener(this);
- btn_app2.setOnClickListener(this);
- tg_allapp.setOnCheckedChangeListener(this);
- btn_home_down.setOnClickListener(this);
- bgView = LayoutInflater.from(this).inflate(R.layout.annotation_bg, null);
- gestrueBg = LayoutInflater.from(this).inflate(R.layout.gestrue_bg, null);
- //
- mView = new WhiteboardView(getBaseContext());
- mView.setBackgroundColor(Color.TRANSPARENT);
- mView.setFocusable(true);
- mView.requestFocus();
- mView.setFocusableInTouchMode(true);
- // ʽӻÈÉʵֵ§¹
- wm = (WindowManager) getApplicationContext().getSystemService("window");
- initUI();
- }
- private void initUI(){
- smartbar_translate_in = AnimationUtils.loadAnimation(this,
- R.anim.smartbar_translate_in);
- smartbar_translate_out = AnimationUtils.loadAnimation(this,
- R.anim.smartbar_translate_out);
- wmParamsBg = new WindowManager.LayoutParams();
- wmParamsBg.type = 2002;
- wmParamsBg.format = 1;
- wmParamsBg.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
- | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ;
- wmParamsBg.width = WindowManager.LayoutParams.FILL_PARENT;
- wmParamsBg.height = WindowManager.LayoutParams.FILL_PARENT;
- bgView.setVisibility(View.VISIBLE);
- wm.addView(bgView, wmParamsBg);
- wmGestrueBg = new WindowManager.LayoutParams();
- wmGestrueBg.type = 2002;
- wmGestrueBg.format = 1;
- wmGestrueBg.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
- | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ;
- wmGestrueBg.width = WindowManager.LayoutParams.FILL_PARENT;
- wmGestrueBg.height = WindowManager.LayoutParams.FILL_PARENT;
- wm.addView(gestrueBg, wmGestrueBg);
- gestrueBg.setVisibility(View.GONE);
- wmPPtLayout = new WindowManager.LayoutParams();
- wmPPtLayout.type = 2002;
- wmPPtLayout.format = PixelFormat.TRANSLUCENT;
- // wmview_l.x = 200;
- wmPPtLayout.y = 215;
- wmPPtLayout.gravity = Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM;
- wmPPtLayout.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
- | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ;
- wmPPtLayout.type = WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
- wmPPtLayout.width = WindowManager.LayoutParams.WRAP_CONTENT;
- wmPPtLayout.height = WindowManager.LayoutParams.WRAP_CONTENT;
- wm.addView(ppt_left_and_right, wmPPtLayout);
- ppt_left_and_right.setVisibility(View.GONE);
- wmParams = new WindowManager.LayoutParams();
- wmParams.type = 2002;
- wmParams.format = 1;
- wmParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
- | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ;
- wmParams.width = WindowManager.LayoutParams.FILL_PARENT;
- wmParams.height = WindowManager.LayoutParams.FILL_PARENT;
- mView.setVisibility(View.VISIBLE);
- wm.addView(mView, wmParams);
- // ߱ѡ˵
- wmview_l = new WindowManager.LayoutParams();
- wmview_l.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
- | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
- wmview_l.gravity = Gravity.LEFT|Gravity.TOP;
- wmview_l.format = PixelFormat.TRANSLUCENT;
- // wmview_l.x = 800 ;
- wmview_l.y = 98;
- wmview_l.width =WindowManager.LayoutParams.WRAP_CONTENT;;
- wmview_l.height = WindowManager.LayoutParams.WRAP_CONTENT;;// λƶҪˢ£ȡԺ
- wmview_l.type = WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
- wm.addView(flort, wmview_l);
- wmview_l.height = 150;
- wm.addView(homebar, wmview_l);
- homebar.setVisibility(View.GONE);
- if (isPencilChecked == false) {
- isViewShow = false;
- }
- Log.e("Others77","oncreate==isFileBrowser="+isFileBrowser+"isWhiteBoard="+isWhiteBoard+"isHome="+isHome+"====");
- // չ㲥ز
- myReceiver = new MyReceiver();
- filter = new IntentFilter();
- filter.addAction("com.hht.hidesmartbar");
- filter.addAction("com.hht.hidesmartbar.for.ppt");
- filter.addAction("com.hht.showsmartbar");
- filter.addAction("com.widget.open");
- filter.addAction("com.widget.close");
- filter.addAction("com.hht.hidemartbar.new");
- filter.addAction("com.hht.hidemartbar.system");
- filter.addAction("com.hht.toolbar.anno.paint_gone");
- filter.addAction("com.hht.toolbar.anno.paint_show");
- filter.addAction("com.hht.showmartbar.system");
- filter.addAction("com.hht.showmartbar.system.recents");
- filter.addAction("com.hht.hidemartbar.new.home");
- filter.addAction("com.hht.showmartbar.new.home");
- filter.addAction("com.hht.showmartbar.new.screenshot");
- filter.addAction("com.hht.hidemartbar.new.fb");
- filter.addAction("com.hht.showmartbar.new.fb");
- filter.addAction("com.hht.showmartbar.new.wb");
- filter.addAction("com.hht.showmartbar.new.wb.set");
- filter.addAction("com.hht.showmartbar.new.crash");
- filter.addAction("com.hht.showmartbar.new");
- filter.addAction("com.hht.hidesmartbar.dismisspop");
- filter.setPriority(1000);
- registerReceiver(myReceiver, filter);
- }
- private void checkIfshowView(boolean showView,boolean screenshot){
- if(showView){
- if(flort.getVisibility() ==View.GONE && homebar.getVisibility() ==View.GONE ){
- }else{
- mView.setVisibility(View.VISIBLE);
- bgView.setVisibility(View.VISIBLE);
- }
- }else{
- if(screenshot){
- mView.setVisibility(View.INVISIBLE);
- bgView.setVisibility(View.INVISIBLE);
- }else{
- mView.setVisibility(View.GONE);
- bgView.setVisibility(View.GONE);
- }
- }
- }
- private void isLaucher() {
- noHide = false;
- checkIfshowView(false, false);
- hiteGesture(true);
- homebar.setVisibility(View.VISIBLE);
- flort.setVisibility(View.GONE);
- dismissPopupWindow_l();
- tg_eraser_l.setChecked(false);
- setPenciIsChecked(tg_black_l,tg_bule_l,tg_red_l,tg_glitterpen_orange,tg_glitterpen_green,tg_glitterpen_yellow,tg_laserpen_red);
- Log.e("Others77", "1515");
- }
- private void hiteGesture(boolean hite) {
- if(hite){
- ppt_left_and_right.setVisibility(View.GONE);
- gestrueBg.setVisibility(View.GONE);
- }else{
- ppt_left_and_right.setVisibility(View.VISIBLE);
- gestrueBg.setVisibility(View.VISIBLE);
- }
- }
- class MyReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- Editor editor = sp.edit();
- if(intent.getAction().equals("com.hht.hidesmartbar.dismisspop")){
- if (pw_l != null && pw_l.isShowing()) {
- pw_l.dismiss();
- }
Ô´ÂëµØÖ·£ºhttp://down.51cto.com/data/1978601