Back to project page NotATop.
The source code is released under:
GNU General Public License
If you think the Android project NotATop listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.gg.view; /*w w w.ja v a 2s . com*/ import com.gg.util.Constant; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.widget.Toast; public class FirstTimeSurfaceView extends SurfaceView implements SurfaceHolder.Callback //???????????????? { MainActivity mainActivity; Paint paint;//???? Bitmap background;//???logo?????? private Toast helpToast; public FirstTimeSurfaceView(MainActivity mainActivity) { super(mainActivity); this.mainActivity = mainActivity; this.getHolder().addCallback(this);//??????????????????????? paint = new Paint();//???????? paint.setAntiAlias(true);//?????? //?????? background=BitmapFactory.decodeResource(mainActivity.getResources(), R.drawable.first_time_bg); helpToast = Toast.makeText(mainActivity, "???????????", Toast.LENGTH_SHORT); } public void onDraw(Canvas canvas){ //??????????????? paint.setColor(Color.WHITE);//????????? paint.setAlpha(255); canvas.drawRect(0, 0, Constant.SCREEN_WIDTH, Constant.SCREEN_WIDTH, paint); canvas.drawBitmap(background, new Rect(0, 0, (int) background.getWidth(), (int) background .getHeight()), new Rect(0, 0, (int) Constant.SCREEN_WIDTH, (int) Constant.SCREEN_HEIGHT), paint); } public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) { } public void surfaceCreated(SurfaceHolder holder) {//??????????? SurfaceHolder myholder=FirstTimeSurfaceView.this.getHolder(); Canvas canvas = myholder.lockCanvas();//??????? try{ synchronized(myholder){ onDraw(canvas);//???? } } catch(Exception e){ e.printStackTrace(); } finally{ if(canvas != null){ myholder.unlockCanvasAndPost(canvas); } } } public void surfaceDestroyed(SurfaceHolder arg0) {//??????????? } @Override public boolean onTouchEvent(MotionEvent event) { // TODO Auto-generated method stub double x = Constant.convertX(event.getX()); double y = Constant.convertY(event.getY()); SharedPreferences settings = mainActivity.getSettings(); //voiceControlFlag = settings.getBoolean("voiceControlFlag", true); SharedPreferences.Editor editor = settings.edit(); // editor.putBoolean("voiceControlFlag", false); // editor.commit(); if(x>-1 && x<-0.2 && y>-0.8 && y<-0.2){ editor.putBoolean("voiceControlFlag", true); editor.commit(); mainActivity.getVoiceControl().setFlag(true); helpToast.show(); mainActivity.getHandler().sendEmptyMessage(SurfaceViewFactory.HELP); }else if(x>0.2 && x<1 && y>-0.8 && y<-0.2){ editor.putBoolean("voiceControlFlag", false); editor.commit(); helpToast.show(); mainActivity.getHandler().sendEmptyMessage(SurfaceViewFactory.HELP); } //return super.onTouchEvent(event); return false; } }