diff --git a/src/WIFIRobot-android_code_public b/src/WIFIRobot-android_code_public deleted file mode 160000 index 7b77e15..0000000 --- a/src/WIFIRobot-android_code_public +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7b77e1557b2185a361eb64db6ec6b173a679a10c diff --git a/src/WIFIRobot-android_code_public.iml b/src/WIFIRobot-android_code_public.iml new file mode 100644 index 0000000..b6afaed --- /dev/null +++ b/src/WIFIRobot-android_code_public.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/build.gradle b/src/app/build.gradle new file mode 100644 index 0000000..a2f506b --- /dev/null +++ b/src/app/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.android.application' + +android { + compileSdk 34 + + compileOptions.encoding = "GBK" + defaultConfig { + applicationId "my.wificar" + minSdkVersion 21 + + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } + namespace 'my.wificar' +} + +dependencies { + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.8.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' +} diff --git a/src/app/src/main/AndroidManifest.xml b/src/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..4f2eb3c --- /dev/null +++ b/src/app/src/main/AndroidManifest.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/src/main/java/wificar/BgPictureShowActivity.java b/src/app/src/main/java/wificar/BgPictureShowActivity.java new file mode 100644 index 0000000..62709f8 --- /dev/null +++ b/src/app/src/main/java/wificar/BgPictureShowActivity.java @@ -0,0 +1,184 @@ +package wificar; + +import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; + +import android.app.Activity; +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.net.Uri; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.view.animation.AnimationUtils; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.BaseAdapter; +import android.widget.Gallery; +import android.widget.Gallery.LayoutParams; +import android.widget.ImageSwitcher; +import android.widget.ImageView; +import android.widget.Toast; +import android.widget.ViewSwitcher; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import my.wificar.R; + +public class BgPictureShowActivity extends Activity implements + AdapterView.OnItemSelectedListener, ViewSwitcher.ViewFactory { + /* + * + * ʾͼƬͨgalleryؼSDָ·еͼƬ + * һһʾĻϡ + * + * */ + private List ImageList; + private String[] list; + private ImageSwitcher mSwitcher; + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.pictureshow); + try { + ImageList = getSD(); + list = ImageList.toArray(new String[ImageList.size()]); + + mSwitcher = findViewById(R.id.switcher); + mSwitcher.setFactory(this); + + mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, + android.R.anim.fade_in)); + + mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, + android.R.anim.fade_out)); + mSwitcher.setOnClickListener(new OnClickListener() { + + + public void onClick(View v) { + //Toast.makeText(BgPictureShowActivity.this, "", Toast.LENGTH_SHORT).show(); + + } + + }); + + Gallery g = findViewById(R.id.mygallery); + g.setAdapter(new ImageAdapter(this, getSD())); + g.setOnItemSelectedListener(this); + g.setOnItemClickListener(new OnItemClickListener() { + public void onItemClick(AdapterView parent, + View v, int position, long id) { + Toast.makeText(BgPictureShowActivity.this, "" + (position + 1) + "ͼƬ", Toast.LENGTH_SHORT).show(); + } + }); + } catch (Exception e) { + Toast.makeText(this, "ûͼƬ", Toast.LENGTH_SHORT).show(); + } + + } + + private List getSD() { + + List it = new ArrayList(); + File f = new File("/sdcard/demo/"); + File[] files = f.listFiles(); + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (getImageFile(file.getPath())) + it.add(file.getPath()); + } + return it; + } + + private boolean getImageFile(String fName) { + boolean re; + String end = fName.substring(fName.lastIndexOf(".") + 1 + ).toLowerCase(); + re = end.equals("jpg") || end.equals("gif") || end.equals("png") + || end.equals("jpeg") || end.equals("bmp"); + return re; + } + + public void onItemSelected(AdapterView parent, View view, int position, + long id) { + String photoURL = list[position]; + Log.i("A", String.valueOf(position)); + + mSwitcher.setImageURI(Uri.parse(photoURL)); + + } + + public void onNothingSelected(AdapterView parent) { + // TODO Auto-generated method stub + + } + + public View makeView() { + ImageView i = new ImageView(this); + i.setBackgroundColor(0xFF000000); + i.setScaleType(ImageView.ScaleType.FIT_CENTER); + i.setLayoutParams(new ImageSwitcher.LayoutParams( + LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); + return i; + } + + public class ImageAdapter extends BaseAdapter { + + int mGalleryItemBackground; + private final Context mContext; + private final List lis; + + + public ImageAdapter(Context c, List li) { + mContext = c; + lis = li; + + TypedArray a = obtainStyledAttributes(R.styleable.Gallery); + + mGalleryItemBackground = a.getResourceId( + R.styleable.Gallery_android_galleryItemBackground, 0); + + a.recycle(); + } + + + public int getCount() { + return lis.size(); + } + + public Object getItem(int position) { + return position; + } + + + public long getItemId(int position) { + return position; + } + + + public View getView(int position, View convertView, + ViewGroup parent) { + + ImageView i = new ImageView(mContext); + + Bitmap bm = BitmapFactory.decodeFile(lis. + get(position)); + i.setImageBitmap(bm); + + i.setScaleType(ImageView.ScaleType.FIT_XY); + + i.setLayoutParams(new Gallery.LayoutParams(480, 320)); + + i.setBackgroundResource(mGalleryItemBackground); + + return i; + } + } +} \ No newline at end of file diff --git a/src/app/src/main/java/wificar/Constant.java b/src/app/src/main/java/wificar/Constant.java new file mode 100644 index 0000000..7fc268c --- /dev/null +++ b/src/app/src/main/java/wificar/Constant.java @@ -0,0 +1,14 @@ +package wificar; +/*СRƼwww.xiao-r.com + * йFPV-WIFI˴⹤ңwww.wifi-robots.comԴԴӵȨ + * Դûѧϰ֮ãϽҵIJ + * 緢ȨΪСRƼͨ;ߣ + * */ + +import android.content.Context; +import android.os.Handler; + +public class Constant { + public static Context context; + public static Handler handler = null; +} diff --git a/src/app/src/main/java/wificar/MyMainFrm.java b/src/app/src/main/java/wificar/MyMainFrm.java new file mode 100644 index 0000000..336184e --- /dev/null +++ b/src/app/src/main/java/wificar/MyMainFrm.java @@ -0,0 +1,104 @@ +package wificar; +/*СRƼwww.xiao-r.com + * йFPV-WIFI˴⹤ңwww.wifi-robots.comԴԴӵȨ + * Դûѧϰ֮ãϽҵIJ + * 緢ȨΪСRƼͨ;ߣ + * */ + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import my.wificar.R; + +public class MyMainFrm extends Activity { + + public static String CameraIp; + EditText CameraIP, ControlIP, Port; + Button Button_go; + String videoUrl, controlUrl, port; + /* + * Ϊһ·ؼʾٰһ˳ + * */ + private long exitTime = 0; + + /** + * Called when the activity is first created. + */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.requestWindowFeature(Window.FEATURE_NO_TITLE); + this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); + /* + * ǵһ棬ڽпͷĻȡƵַ + * edIPƵַı + * Button_go ť + * + * */ + + setContentView(R.layout.mymainfrm); + + CameraIP = findViewById(R.id.editIP); + ControlIP = findViewById(R.id.ip); + Port = findViewById(R.id.port); + + Button_go = findViewById(R.id.button_go); + + videoUrl = CameraIP.getText().toString(); + controlUrl = ControlIP.getText().toString(); + port = Port.getText().toString(); + + Button_go.requestFocusFromTouch(); + + + Button_go.setOnClickListener(new Button.OnClickListener() { + public void onClick(View v) { + // TODO Auto-generated method stub + //һIntent + Intent intent = new Intent(); + //Intentһֵ + intent.putExtra("CameraIp", videoUrl); + intent.putExtra("ControlUrl", controlUrl); + intent.putExtra("Port", port); + + intent.putExtra("Is_Scale", true); + //IntentҪActivity + intent.setClass(MyMainFrm.this, MyVideo.class); + //ͨIntentһActivity + MyMainFrm.this.startActivity(intent); + finish(); + } + }); + + } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { + + if ((System.currentTimeMillis() - exitTime) > 2000) //System.currentTimeMillis()ۺʱã϶2000 + { + Toast.makeText(getApplicationContext(), "ٰһ˳", Toast.LENGTH_SHORT).show(); + exitTime = System.currentTimeMillis(); + } else { + finish(); + System.exit(0); + } + + return true; + } + return super.onKeyDown(keyCode, event); + } + + +} + + diff --git a/src/app/src/main/java/wificar/MySurfaceView.java b/src/app/src/main/java/wificar/MySurfaceView.java new file mode 100644 index 0000000..d8d3461 --- /dev/null +++ b/src/app/src/main/java/wificar/MySurfaceView.java @@ -0,0 +1,380 @@ +package wificar; +/*СRƼwww.xiao-r.com + * йFPV-WIFI˴⹤ңwww.wifi-robots.comԴԴӵȨ + * Դûѧϰ֮ãϽҵIJ + * 緢ȨΪСRƼͨ;ߣ + * */ + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.os.Handler; +import android.os.Message; +import android.util.AttributeSet; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.SurfaceHolder; +import android.view.SurfaceHolder.Callback; +import android.view.SurfaceView; +import android.widget.Toast; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +public class MySurfaceView extends SurfaceView implements Callback { + private static int mScreenWidth; + private static int mScreenHeight; + public boolean Is_Scale = false; + URL videoUrl; + HttpURLConnection conn; + Bitmap bmp; + InputStream inputstream = null; + private final SurfaceHolder sfh; + private Canvas canvas; + private String urlstr; + private final Paint p; + private Bitmap mBitmap; + private boolean isThreadRunning = true; + + public MySurfaceView(Context context, AttributeSet attrs) { + super(context, attrs); + Constant.context = context; + initialize(); + p = new Paint(); + p.setAntiAlias(true); + sfh = this.getHolder(); + sfh.addCallback(this); + this.setKeepScreenOn(true); + setFocusable(true); + this.getWidth(); + this.getHeight(); + Constant.handler = new Handler() { + public void handleMessage(Message msg) { + if (msg.what == 1) { + if (null != mBitmap) { + saveMyBitmap("snapshot", mBitmap); + } else { + Toast.makeText(Constant.context, "ʧܣδܻȡͷͼ", + Toast.LENGTH_SHORT).show(); + } + } + super.handleMessage(msg); + } + + }; + + } + + private void initialize() { + DisplayMetrics dm = getResources().getDisplayMetrics(); + mScreenWidth = dm.widthPixels; + mScreenHeight = dm.heightPixels; + this.setKeepScreenOn(true);// Ļ + } + + public void saveMyBitmap(String bitName, Bitmap mBitmap) { + File f = new File("/sdcard/demo/"); + if (!f.exists()) { + f.mkdirs(); + } + f = new File("/sdcard/demo/" + bitName + System.currentTimeMillis() + ".png"); + try { + f.createNewFile(); + } catch (IOException e) { + // TODO Auto-generated catch block + + } + FileOutputStream fOut = null; + try { + fOut = new FileOutputStream(f); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + Log.d("MySurface", "bitmap is:" + mBitmap + "fout is:" + fOut); + mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); + try { + fOut.flush(); + Toast.makeText(Constant.context, "ճɹ·/SDCard/Demo/", + Toast.LENGTH_SHORT).show(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void surfaceChanged(SurfaceHolder holder, int format, int width, + int height) { + } + + public void surfaceDestroyed(SurfaceHolder holder) { + isThreadRunning = false; + try { + Thread.sleep(300); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public void GetCameraIP(String p) { + urlstr = p; + } + + public void surfaceCreated(SurfaceHolder holder) { + isThreadRunning = true; + new DrawVideo().start(); + } + + class DrawVideo extends Thread { + public DrawVideo() { + } + + @Override + protected Object clone() throws CloneNotSupportedException { + // TODO Auto-generated method stub + return super.clone(); + } + + public void run() { + Paint pt = new Paint(); + pt.setAntiAlias(true); + pt.setColor(Color.GREEN); + pt.setTextSize(20); + pt.setStrokeWidth(1); + + int bufSize = 512 * 1024; // ƵͼƬ + byte[] jpg_buf = new byte[bufSize]; // buffer to read jpg + + int readSize = 4096; // ÿȡ + byte[] buffer = new byte[readSize]; // buffer to read stream + + while (isThreadRunning) { + long Time = 0; + long Span = 0; + int fps = 0; + String str_fps = "0 fps"; + + URL url = null; + HttpURLConnection urlConn = null; + + try { + url = new URL(urlstr); + urlConn = (HttpURLConnection) url.openConnection(); // ʹHTTPURLConnetion + + Time = System.currentTimeMillis(); + + int read = 0; + int status = 0; + int jpg_count = 0; // jpg± + + while (true) { + read = urlConn.getInputStream().read(buffer, 0, + readSize); + + if (read > 0) { + + for (int i = 0; i < read; i++) { + switch (status) { + // Content-Length: + case 0: + if (buffer[i] == (byte) 'C') + status++; + else + status = 0; + break; + case 1: + if (buffer[i] == (byte) 'o') + status++; + else + status = 0; + break; + case 2: + if (buffer[i] == (byte) 'n') + status++; + else + status = 0; + break; + case 3: + if (buffer[i] == (byte) 't') + status++; + else + status = 0; + break; + case 4: + if (buffer[i] == (byte) 'e') + status++; + else + status = 0; + break; + case 5: + if (buffer[i] == (byte) 'n') + status++; + else + status = 0; + break; + case 6: + if (buffer[i] == (byte) 't') + status++; + else + status = 0; + break; + case 7: + if (buffer[i] == (byte) '-') + status++; + else + status = 0; + break; + case 8: + if (buffer[i] == (byte) 'L') + status++; + else + status = 0; + break; + case 9: + if (buffer[i] == (byte) 'e') + status++; + else + status = 0; + break; + case 10: + if (buffer[i] == (byte) 'n') + status++; + else + status = 0; + break; + case 11: + if (buffer[i] == (byte) 'g') + status++; + else + status = 0; + break; + case 12: + if (buffer[i] == (byte) 't') + status++; + else + status = 0; + break; + case 13: + if (buffer[i] == (byte) 'h') + status++; + else + status = 0; + break; + case 14: + if (buffer[i] == (byte) ':') + status++; + else + status = 0; + break; + case 15: + if (buffer[i] == (byte) 0xFF) + status++; + jpg_count = 0; + jpg_buf[jpg_count++] = buffer[i]; + break; + case 16: + if (buffer[i] == (byte) 0xD8) { + status++; + jpg_buf[jpg_count++] = buffer[i]; + } else { + if (buffer[i] != (byte) 0xFF) + status = 15; + + } + break; + case 17: + jpg_buf[jpg_count++] = buffer[i]; + if (buffer[i] == (byte) 0xFF) + status++; + if (jpg_count >= bufSize) + status = 0; + break; + case 18: + jpg_buf[jpg_count++] = buffer[i]; + if (buffer[i] == (byte) 0xD9) { + status = 0; + // jpg + + fps++; + Span = System.currentTimeMillis() + - Time; + if (Span > 1000L) { + Time = System.currentTimeMillis(); + str_fps = fps + + " fps"; + fps = 0; + } + // ʾͼ + //if (null != canvas) + { + canvas = sfh.lockCanvas(); + canvas.drawColor(Color.BLACK); + + Bitmap bmp = BitmapFactory.decodeStream(new ByteArrayInputStream(jpg_buf)); + + int width = mScreenWidth; + int height = mScreenHeight; + + if (null != bmp) { + float rate_width = (float) mScreenWidth / (float) bmp.getWidth(); + float rate_height = (float) mScreenHeight / (float) bmp.getHeight(); + } + +// if (Is_Scale) { +// if (rate_width > rate_height) +// width = (int) ((float) bmp +// .getWidth() * rate_height); +// if (rate_width < rate_height) +// height = (int) ((float) bmp +// .getHeight() * rate_width); +// +// } + + Log.d("bmp", "bmp" + bmp); + Log.d("width", "width" + width); + Log.d("height", "height" + height); + if (null != bmp) { + mBitmap = Bitmap + .createScaledBitmap(bmp, + width, height, + false); + + canvas.drawBitmap( + mBitmap, + (mScreenWidth - width) / 2, + (mScreenHeight - height) / 2, + null); + + canvas.drawText(str_fps, 2, 22, pt); + } + sfh.unlockCanvasAndPost(canvas);// һͼ񣬽 + } + } else { + if (buffer[i] != (byte) 0xFF) + status = 17; + } + break; + default: + status = 0; + break; + + } + } + } + } + } catch (IOException ex) { + urlConn.disconnect(); + ex.printStackTrace(); + } + } + + } + } +} \ No newline at end of file diff --git a/src/app/src/main/java/wificar/MyVideo.java b/src/app/src/main/java/wificar/MyVideo.java new file mode 100644 index 0000000..b4d64ec --- /dev/null +++ b/src/app/src/main/java/wificar/MyVideo.java @@ -0,0 +1,186 @@ +package wificar; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Message; +import android.os.StrictMode; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.Window; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.Toast; + +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.Socket; +import java.net.URL; +import java.net.UnknownHostException; + +import my.wificar.R; + +public class MyVideo extends Activity { + public static String CameraIp; + public static String CtrlIp; + public static String CtrlPort; + URL videoUrl; + MySurfaceView r; + OutputStream socketWriter; + private Button TakePhotos; + private Button ViewPhotos; + private Button BtnForward, BtnBackward, BtnLeft, BtnRight, BtnStop; + private Socket socket; + private long exitTime = 0; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.requestWindowFeature(Window.FEATURE_NO_TITLE);//ȥ⣨ӦõֱҪдsetContentView֮ǰ쳣 + this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); + setContentView(R.layout.myvideo); + if (android.os.Build.VERSION.SDK_INT > 9) { + StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); + StrictMode.setThreadPolicy(policy); + } + r = findViewById(R.id.mySurfaceViewVideo); + TakePhotos = findViewById(R.id.TakePhoto); + ViewPhotos = findViewById(R.id.ViewPhoto); + + BtnForward = findViewById(R.id.button_forward); + BtnBackward = findViewById(R.id.button_backward); + BtnLeft = findViewById(R.id.button_left); + BtnRight = findViewById(R.id.button_right); + BtnStop = findViewById(R.id.button_stop); + + Intent intent = getIntent(); + //Intentиkeyȡvalue + CameraIp = intent.getStringExtra("CameraIp"); + CtrlIp = intent.getStringExtra("ControlUrl"); + CtrlPort = intent.getStringExtra("Port"); + Log.d("wifirobot", "control is :++++" + CtrlIp); + Log.d("wifirobot", "CtrlPort is :++++" + CtrlPort); + r.GetCameraIP(CameraIp); + InitSocket(); + BtnForward.setOnClickListener(new OnClickListener() { + + public void onClick(View arg0) { + // TODO Auto-generated method stub + try { + socketWriter.write(new byte[]{(byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0xff}); + socketWriter.flush(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + + BtnBackward.setOnClickListener(arg0 -> { + // TODO Auto-generated method stub + try { + socketWriter.write(new byte[]{(byte) 0xff, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0xff}); + socketWriter.flush(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }); + BtnRight.setOnClickListener(arg0 -> { + // TODO Auto-generated method stub + try { + socketWriter.write(new byte[]{(byte) 0xff, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0xff}); + socketWriter.flush(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }); + BtnLeft.setOnClickListener(arg0 -> { + // TODO Auto-generated method stub + try { + socketWriter.write(new byte[]{(byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0xff}); + socketWriter.flush(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }); + BtnStop.setOnClickListener(arg0 -> { + // TODO Auto-generated method stub + try { + socketWriter.write(new byte[]{(byte) 0xff, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xff}); + socketWriter.flush(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }); + TakePhotos.setOnClickListener(arg0 -> { + // TODO Auto-generated method stub + if (null != Constant.handler) { + Message message = new Message(); + message.what = 1; + Constant.handler.sendMessage(message); + } + }); + + ViewPhotos.setOnClickListener(arg0 -> { + // TODO Auto-generated method stub + Intent intent1 = new Intent(); + intent1.setClass(MyVideo.this, BgPictureShowActivity.class); + //ͨIntentһActivity + MyVideo.this.startActivity(intent1); + + }); + + } + + public void InitSocket() { + + try { + socket = new Socket(InetAddress.getByName(CtrlIp), Integer.parseInt(CtrlPort)); + } catch (UnknownHostException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + socketWriter = socket.getOutputStream(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //Toast.makeText(this,"ʼʧܣ"+e.getMessage(),Toast.LENGTH_LONG).show(); + } + + public void onDestroy() { + super.onDestroy(); + + } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { + + if ((System.currentTimeMillis() - exitTime) > 2500) //System.currentTimeMillis()ۺʱã϶2500 + { + Toast.makeText(getApplicationContext(), "ٰһ˳", Toast.LENGTH_SHORT).show(); + exitTime = System.currentTimeMillis(); + } else { + finish(); + System.exit(0); + } + + return true; + } + return super.onKeyDown(keyCode, event); + } + +} + + diff --git a/src/app/src/main/java/wificar/SettingsActivity.java b/src/app/src/main/java/wificar/SettingsActivity.java new file mode 100644 index 0000000..92b0b3f --- /dev/null +++ b/src/app/src/main/java/wificar/SettingsActivity.java @@ -0,0 +1,16 @@ +package wificar; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +import my.wificar.R; + +public class SettingsActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_settings); + } +} \ No newline at end of file diff --git a/src/app/src/main/res/drawable-hdpi/icon.png b/src/app/src/main/res/drawable-hdpi/icon.png new file mode 100644 index 0000000..09ae62c Binary files /dev/null and b/src/app/src/main/res/drawable-hdpi/icon.png differ diff --git a/src/app/src/main/res/drawable-ldpi/icon.png b/src/app/src/main/res/drawable-ldpi/icon.png new file mode 100644 index 0000000..09ae62c Binary files /dev/null and b/src/app/src/main/res/drawable-ldpi/icon.png differ diff --git a/src/app/src/main/res/drawable-mdpi/icon.png b/src/app/src/main/res/drawable-mdpi/icon.png new file mode 100644 index 0000000..09ae62c Binary files /dev/null and b/src/app/src/main/res/drawable-mdpi/icon.png differ diff --git a/src/app/src/main/res/layout/activity_settings.xml b/src/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 0000000..2d0fb6b --- /dev/null +++ b/src/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,64 @@ + + + + +