Skip to content

Commit

Permalink
V1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mosect committed Jan 27, 2023
0 parents commit f25aa99
Show file tree
Hide file tree
Showing 75 changed files with 3,554 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
40 changes: 40 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
plugins {
id 'com.android.application'
}

android {
compileSdk 32

defaultConfig {
applicationId "com.mosect.app.scanpanel"
minSdk 19
targetSdk 32
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation project(':lib')
implementation 'com.google.zxing:core:3.5.0'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mosect.app.scanpanel;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.mosect.app.scanpanel", appContext.getPackageName());
}
}
44 changes: 44 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mosect.app.scanpanel">

<uses-permission android:name="android.permission.CAMERA" />

<application
android:name=".MainApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ScanPanel"
tools:targetApi="31">

<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="fullSensor"
android:windowSoftInputMode="adjustNothing|stateAlwaysHidden">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".AutostartActivity"
android:configChanges="orientation|keyboard|keyboardHidden|navigation|layoutDirection|screenLayout"
android:exported="false"
android:screenOrientation="fullSensor"
android:windowSoftInputMode="adjustNothing|stateAlwaysHidden" />
<activity
android:name=".ManualActivity"
android:configChanges="orientation"
android:exported="false"
android:screenOrientation="fullSensor"
android:windowSoftInputMode="adjustNothing|stateAlwaysHidden" />
</application>

</manifest>
5 changes: 5 additions & 0 deletions app/src/main/assets/shader_simple.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
uniform vec4 color;

void main() {
gl_FragColor = color;
}
5 changes: 5 additions & 0 deletions app/src/main/assets/shader_simple.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
attribute vec3 position;

void main() {
gl_Position = vec4(position, 1.0f);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mosect.app.scanpanel;

public class AutostartActivity extends ScanActivity {
@Override
protected void onInitContentView() {
setContentView(R.layout.activity_autostart);
}
}
57 changes: 57 additions & 0 deletions app/src/main/java/com/mosect/app/scanpanel/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.mosect.app.scanpanel;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.widget.CheckBox;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

public class MainActivity extends AppCompatActivity {

private CheckBox cbFront;
private CheckBox cbUseTextureView;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

ActivityResultLauncher<String> cameraLauncher = registerForActivityResult(
new ActivityResultContracts.RequestPermission(),
result -> {
if (result) {
jumpAutostartActivity();
}
});

setContentView(R.layout.activity_main);

findViewById(R.id.btn_autostart).setOnClickListener(v -> {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
jumpAutostartActivity();
} else {
cameraLauncher.launch(Manifest.permission.CAMERA);
}
});
findViewById(R.id.btn_manual).setOnClickListener(v -> {
Intent intent = new Intent(this, ManualActivity.class);
intent.putExtra("facing", cbFront.isChecked() ? "front" : "back");
intent.putExtra("useTextureView", cbUseTextureView.isChecked());
startActivity(intent);
});
cbFront = findViewById(R.id.cb_front);
cbUseTextureView = findViewById(R.id.cb_useTextureView);
}

private void jumpAutostartActivity() {
Intent intent = new Intent(this, AutostartActivity.class);
intent.putExtra("facing", cbFront.isChecked() ? "front" : "back");
intent.putExtra("useTextureView", cbUseTextureView.isChecked());
startActivity(intent);
}
}
91 changes: 91 additions & 0 deletions app/src/main/java/com/mosect/app/scanpanel/MainApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.mosect.app.scanpanel;

import android.app.Application;
import android.graphics.RectF;
import android.opengl.Matrix;

import com.mosect.lib.scanpanel.graphics.ContentMatrix;
import com.mosect.lib.scanpanel.graphics.Matrix3D;

import java.util.Arrays;

public class MainApplication extends Application {

private void testMatrix() {
float[] point1 = {1, 1, 0f, 1f};
float[] point2 = new float[point1.length];
float[] matrix = new float[16 * 3];
Matrix.setIdentityM(matrix, 0);

Matrix.setIdentityM(matrix, 32);
Matrix.rotateM(matrix, 32, 90, 0, 0, -1f);
System.arraycopy(matrix, 0, matrix, 16, 16);
Matrix.multiplyMM(matrix, 0, matrix, 16, matrix, 32);
Matrix.multiplyMV(point2, 0, matrix, 0, point1, 0);
System.out.printf("%s >>> %s%n", Arrays.toString(point1), Arrays.toString(point2));

Matrix.setIdentityM(matrix, 32);
Matrix.translateM(matrix, 32, 5, 5, 0f);
System.arraycopy(matrix, 0, matrix, 16, 16);
Matrix.multiplyMM(matrix, 0, matrix, 16, matrix, 32);
Matrix.multiplyMV(point2, 0, matrix, 0, point1, 0);
System.out.printf("%s >>> %s%n", Arrays.toString(point1), Arrays.toString(point2));

Matrix.setIdentityM(matrix, 32);
Matrix.scaleM(matrix, 32, 2, 2, 1f);
System.arraycopy(matrix, 0, matrix, 16, 16);
Matrix.multiplyMM(matrix, 0, matrix, 16, matrix, 32);
Matrix.multiplyMV(point2, 0, matrix, 0, point1, 0);
System.out.printf("%s >>> %s%n", Arrays.toString(point1), Arrays.toString(point2));
}

private void testMatrix3D() {
Matrix3D matrix3D = new Matrix3D();
float[] point1 = {1, 1, 0f};
float[] point2 = new float[3];

matrix3D.postRotate(90, 0, 0, -1f);
matrix3D.mapPoints(point1, point2);
System.out.printf("%s >>> %s%n", Arrays.toString(point1), Arrays.toString(point2));

matrix3D.postScale(2f, 2f, 1f);
matrix3D.mapPoints(point1, point2);
System.out.printf("%s >>> %s%n", Arrays.toString(point1), Arrays.toString(point2));

matrix3D.postTranslate(5f, 5f, 0f);
matrix3D.mapPoints(point1, point2);
System.out.printf("%s >>> %s%n", Arrays.toString(point1), Arrays.toString(point2));
}

private void testContentMatrix() {
RectF viewportRect = new RectF(0, 1920, 1080, 0);
RectF contentRect = new RectF(0, 300, 400, 0);
ContentMatrix contentMatrix = new ContentMatrix(contentRect, viewportRect);
contentMatrix.update(ContentMatrix.ScaleType.CENTER_CROP, 90, false);
float[] points = {
0, 0, 1,
400, 0, 1,
0, 300, 1,
400, 300, 1,
};
float[] points2 = new float[points.length];
contentMatrix.mapVec3Points(points, points2);
for (int i = 0; i < points.length; i += 3) {
System.out.printf("(%s, %s, %s) >>> (%s, %s, %s) %n",
points[i], points[i + 1], points[i + 2],
points2[i], points2[i + 1], points2[i + 2]);
}
RectF rect1 = new RectF(1000, 0, 1080, 300);
RectF rect2 = new RectF();
contentMatrix.viewportToContent2D(rect1, rect2);
System.out.printf("%s >>> %s%n", rect1, rect2);
}

@Override
public void onCreate() {
super.onCreate();
testContentMatrix();
// testMatrix();
// testMatrix3D();
}
}
Loading

0 comments on commit f25aa99

Please sign in to comment.