Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customized and more look #118

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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---|||||||||||-------------------------");
}
}
// @Override
// public void onAccuracyChanged(Sensor sensor, int accuracy) {
// System.out.println("---------------------|||||||||||||---onAccuracyChanged---|||||||||||-------------------------");
// }
// }
73 changes: 41 additions & 32 deletions android/src/main/java/com/shinow/qrscan/SecondActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import android.hardware.Sensor;
Expand All @@ -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;
Expand All @@ -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();
}
Expand All @@ -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
Expand All @@ -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
Expand Down
17 changes: 17 additions & 0 deletions android/src/main/res/drawable/button_rounded.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<gradient
android:startColor="#F67337"
android:type="linear"
android:angle="0"
android:endColor="#FF3741"
/>

<corners
android:radius="35dp">

</corners>

</shape>
Binary file modified android/src/main/res/drawable/scan_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/src/main/res/drawable/scan_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 20 additions & 52 deletions android/src/main/res/layout/activity_second.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,62 +9,30 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"></FrameLayout>


<LinearLayout
android:id="@+id/scan_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:layout_marginTop="450dp"
android:orientation="vertical">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_light" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:background="#AA333333"
android:orientation="horizontal">


<LinearLayout
android:id="@+id/scan_back"
android:layout_width="50dp"
android:layout_height="50dp"
android:orientation="vertical"
android:padding="14dp">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@mipmap/ic_back" />
</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />

<LinearLayout
android:id="@+id/choose_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">

<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="right"
android:padding="14dp"
android:src="@mipmap/ic_photo" />
</LinearLayout>
android:layout_gravity="bottom|center_horizontal"
android:layout_alignParentBottom="true"
android:layout_marginBottom="70dp"
android:orientation="vertical"
android:padding="14dp">
<Button
android:id="@+id/back_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_rounded"
android:text="Cancel Scanning"
android:textColor="#ffffff"
android:textAllCaps="false"
android:paddingTop="14dp"
android:paddingBottom="14dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:textSize="20sp" />

</LinearLayout>

</FrameLayout>
5 changes: 1 addition & 4 deletions android/src/main/res/layout/my_camera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
app:inner_corner_color="@color/scan_corner_color_blue"
app:inner_corner_length="20dp"
app:inner_corner_width="4dp"
app:inner_scan_bitmap="@drawable/scan_blue"
app:inner_scan_speed="20"
app:inner_scan_iscircle="true"
/>

</FrameLayout>
</FrameLayout>
10 changes: 5 additions & 5 deletions android/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorPrimary">#FF6E40</color>
<color name="colorPrimaryDark">#FF6E40</color>
<color name="colorAccent">#FF6E40</color>

<color name="scan_corner_color_green">#0effc2</color>
<color name="scan_corner_color_blue">#12C4FF</color>
<color name="scan_corner_color_green">#FF6E40</color>
<color name="scan_corner_color_blue">#FF6E40</color>
</resources>