diff --git a/android/src/main/java/com/shinow/qrscan/LightSensorEventListener.java b/android/src/main/java/com/shinow/qrscan/LightSensorEventListener.java index 0377910..1741bc2 100644 --- a/android/src/main/java/com/shinow/qrscan/LightSensorEventListener.java +++ b/android/src/main/java/com/shinow/qrscan/LightSensorEventListener.java @@ -1,35 +1,35 @@ -package com.shinow.qrscan; +// package com.shinow.qrscan; -import android.widget.LinearLayout; -import android.view.View; +// import android.widget.LinearLayout; +// import android.view.View; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; +// import android.hardware.Sensor; +// import android.hardware.SensorEvent; +// import android.hardware.SensorEventListener; -class LightSensorEventListener implements SensorEventListener { +// class LightSensorEventListener implements SensorEventListener { - private LinearLayout lightLayout; +// private LinearLayout lightLayout; - public LightSensorEventListener(LinearLayout lightLayout) { - this.lightLayout = lightLayout; - } +// public LightSensorEventListener(LinearLayout lightLayout) { +// this.lightLayout = lightLayout; +// } - @Override - public void onSensorChanged(SensorEvent event) { - // System.out.println("---------------------|||||||||||||---light strength: " + light_strength + "---|||||||||||-------------------------"); - if (event.sensor.getType() == Sensor.TYPE_LIGHT) { - float light_strength = event.values[0]; - if (lightLayout.getVisibility() == View.VISIBLE && light_strength > 300 && !SecondActivity.isLightOpen) { - lightLayout.setVisibility(View.INVISIBLE); - } else if (lightLayout.getVisibility() == View.INVISIBLE && light_strength <= 200) { - lightLayout.setVisibility(View.VISIBLE); - } - } - } +// @Override +// public void onSensorChanged(SensorEvent event) { +// // System.out.println("---------------------|||||||||||||---light strength: " + light_strength + "---|||||||||||-------------------------"); +// if (event.sensor.getType() == Sensor.TYPE_LIGHT) { +// float light_strength = event.values[0]; +// if (lightLayout.getVisibility() == View.VISIBLE && light_strength > 300 && !SecondActivity.isLightOpen) { +// lightLayout.setVisibility(View.INVISIBLE); +// } else if (lightLayout.getVisibility() == View.INVISIBLE && light_strength <= 200) { +// lightLayout.setVisibility(View.VISIBLE); +// } +// } +// } - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - System.out.println("---------------------|||||||||||||---onAccuracyChanged---|||||||||||-------------------------"); - } -} \ No newline at end of file +// @Override +// public void onAccuracyChanged(Sensor sensor, int accuracy) { +// System.out.println("---------------------|||||||||||||---onAccuracyChanged---|||||||||||-------------------------"); +// } +// } diff --git a/android/src/main/java/com/shinow/qrscan/SecondActivity.java b/android/src/main/java/com/shinow/qrscan/SecondActivity.java index 01ee997..800545e 100644 --- a/android/src/main/java/com/shinow/qrscan/SecondActivity.java +++ b/android/src/main/java/com/shinow/qrscan/SecondActivity.java @@ -12,6 +12,7 @@ import android.util.Log; import android.view.View; +import android.widget.Button; import android.widget.LinearLayout; import android.hardware.Sensor; @@ -26,9 +27,10 @@ public class SecondActivity extends AppCompatActivity { public static boolean isLightOpen = false; private int REQUEST_IMAGE = 101; - private LinearLayout lightLayout; - private LinearLayout backLayout; - private LinearLayout photoLayout; +// private LinearLayout lightLayout; +// private LinearLayout backLayout; + // private LinearLayout photoLayout; + private Button back_button; private SensorManager sensorManager; private Sensor lightSensor; private SensorEventListener sensorEventListener; @@ -42,13 +44,14 @@ protected void onCreate(Bundle savedInstanceState) { captureFragment.setAnalyzeCallback(analyzeCallback); getSupportFragmentManager().beginTransaction().replace(R.id.fl_my_container, captureFragment).commit(); - lightLayout = findViewById(R.id.scan_light); - backLayout = findViewById(R.id.scan_back); - photoLayout = findViewById(R.id.choose_photo); +// lightLayout = findViewById(R.id.scan_light); +// backLayout = findViewById(R.id.scan_back); + // photoLayout = findViewById(R.id.choose_photo); + back_button = findViewById(R.id.back_button); sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); - sensorEventListener = new LightSensorEventListener(lightLayout); +// sensorEventListener = new LightSensorEventListener(lightLayout); initView(); } @@ -57,9 +60,9 @@ protected void onCreate(Bundle savedInstanceState) { protected void onResume() { // System.out.println("---------------------|||||||||||||---onResume---|||||||||||-------------------------"); super.onResume(); - if (lightSensor != null) { - sensorManager.registerListener(sensorEventListener, lightSensor, SensorManager.SENSOR_DELAY_NORMAL); - } +// if (lightSensor != null) { +// sensorManager.registerListener(sensorEventListener, lightSensor, SensorManager.SENSOR_DELAY_NORMAL); +// } } @Override @@ -70,33 +73,39 @@ protected void onPause() { } private void initView() { - lightLayout.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (!isLightOpen) { - CodeUtils.isLightEnable(true); - isLightOpen = true; - } else { - CodeUtils.isLightEnable(false); - isLightOpen = false; - } - } - }); - backLayout.setOnClickListener(new View.OnClickListener() { +// lightLayout.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// if (!isLightOpen) { +// CodeUtils.isLightEnable(true); +// isLightOpen = true; +// } else { +// CodeUtils.isLightEnable(false); +// isLightOpen = false; +// } +// } +// }); + back_button.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { SecondActivity.this.finish(); } }); - photoLayout.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(); - intent.setAction(Intent.ACTION_PICK); - intent.setType("image/*"); - SecondActivity.this.startActivityForResult(intent, REQUEST_IMAGE); - } - }); +// backLayout.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// SecondActivity.this.finish(); +// } +// }); + // photoLayout.setOnClickListener(new View.OnClickListener() { + // @Override + // public void onClick(View v) { + // Intent intent = new Intent(); + // intent.setAction(Intent.ACTION_PICK); + // intent.setType("image/*"); + // SecondActivity.this.startActivityForResult(intent, REQUEST_IMAGE); + // } + // }); } @Override diff --git a/android/src/main/res/drawable/button_rounded.xml b/android/src/main/res/drawable/button_rounded.xml new file mode 100644 index 0000000..c1bdd34 --- /dev/null +++ b/android/src/main/res/drawable/button_rounded.xml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/android/src/main/res/drawable/scan_blue.png b/android/src/main/res/drawable/scan_blue.png index 0ed22ab..9ea7e5b 100644 Binary files a/android/src/main/res/drawable/scan_blue.png and b/android/src/main/res/drawable/scan_blue.png differ diff --git a/android/src/main/res/drawable/scan_green.png b/android/src/main/res/drawable/scan_green.png index 2f6a537..9ea7e5b 100644 Binary files a/android/src/main/res/drawable/scan_green.png and b/android/src/main/res/drawable/scan_green.png differ diff --git a/android/src/main/res/layout/activity_second.xml b/android/src/main/res/layout/activity_second.xml index 8451c4e..1b4fa9e 100644 --- a/android/src/main/res/layout/activity_second.xml +++ b/android/src/main/res/layout/activity_second.xml @@ -9,62 +9,30 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="visible"> - - - - - - - - - + - - - - - - - - - - + android:layout_gravity="bottom|center_horizontal" + android:layout_alignParentBottom="true" + android:layout_marginBottom="70dp" + android:orientation="vertical" + android:padding="14dp"> +