From 946a98fe4bf61d4708567b5ae0d91045bdc9a3ac Mon Sep 17 00:00:00 2001 From: zealotzealot Date: Sun, 1 Dec 2019 23:32:28 +0900 Subject: [PATCH] Implement selecting ssid --- android/app/src/main/AndroidManifest.xml | 4 ++ .../hsh0908y/auto_wifi/CameraPreview.java | 17 ++++++-- .../auto_wifi/ProcessingPreActivity.java | 41 +++++++++++++++++++ .../res/layout/activity_processing_pre.xml | 10 +++++ 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 android/app/src/main/java/com/example/hsh0908y/auto_wifi/ProcessingPreActivity.java create mode 100644 android/app/src/main/res/layout/activity_processing_pre.xml diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 01a93c1..b156fba 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -47,6 +47,10 @@ + + \ No newline at end of file diff --git a/android/app/src/main/java/com/example/hsh0908y/auto_wifi/CameraPreview.java b/android/app/src/main/java/com/example/hsh0908y/auto_wifi/CameraPreview.java index 32c4dae..9f4e689 100644 --- a/android/app/src/main/java/com/example/hsh0908y/auto_wifi/CameraPreview.java +++ b/android/app/src/main/java/com/example/hsh0908y/auto_wifi/CameraPreview.java @@ -403,11 +403,20 @@ protected Void doInBackground(byte[]... data) { getContext().sendBroadcast(mediaScanIntent); - Intent intent = new Intent(mContext, ProcessingActivity.class); - intent.putExtra("imageFile", outputFile.getAbsolutePath()); RadioButton IdpwRadioButton = (RadioButton) mActivity.findViewById(R.id.cameraRadioButtonIdpw); - intent.putExtra("hasId", IdpwRadioButton.isChecked()); - mContext.startActivity(intent); + boolean hasId = IdpwRadioButton.isChecked(); + if (hasId) { + Intent intent = new Intent(mContext, ProcessingActivity.class); + intent.putExtra("imageFile", outputFile.getAbsolutePath()); + intent.putExtra("hasId", hasId); + mContext.startActivity(intent); + } + else { + Intent intent = new Intent(mContext, ProcessingPreActivity.class); + intent.putExtra("imageFile", outputFile.getAbsolutePath()); + intent.putExtra("hasId", hasId); + mContext.startActivity(intent); + } diff --git a/android/app/src/main/java/com/example/hsh0908y/auto_wifi/ProcessingPreActivity.java b/android/app/src/main/java/com/example/hsh0908y/auto_wifi/ProcessingPreActivity.java new file mode 100644 index 0000000..e4f3720 --- /dev/null +++ b/android/app/src/main/java/com/example/hsh0908y/auto_wifi/ProcessingPreActivity.java @@ -0,0 +1,41 @@ +package com.example.hsh0908y.auto_wifi; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; + +public class ProcessingPreActivity extends AppCompatActivity { + static final int REQUEST_CODE = 0; + + private boolean hasId; + private String imageFile; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_processing_pre); + + Intent intent = getIntent(); + hasId = intent.getBooleanExtra("hasId", false); + imageFile = intent.getStringExtra("imageFile"); + + + Intent selectIdIntent = new Intent(this, SelectIdActivity.class); + startActivityForResult(selectIdIntent, REQUEST_CODE); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent intent) { + if (!(requestCode == REQUEST_CODE && resultCode == RESULT_OK)) { + return; + } + + String selectedSsid = intent.getStringExtra("id"); + + Intent processingIntent = new Intent(this, ProcessingActivity.class); + processingIntent.putExtra("imageFile", imageFile); + processingIntent.putExtra("hasId", hasId); + processingIntent.putExtra("selectedSsid", selectedSsid); + this.startActivity(processingIntent); + } +} diff --git a/android/app/src/main/res/layout/activity_processing_pre.xml b/android/app/src/main/res/layout/activity_processing_pre.xml new file mode 100644 index 0000000..073aa3b --- /dev/null +++ b/android/app/src/main/res/layout/activity_processing_pre.xml @@ -0,0 +1,10 @@ + + + +