diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..603b140
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,14 @@
+*.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
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..f6d22dc
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,37 @@
+apply plugin: 'com.android.application'
+
+apply plugin: 'kotlin-android'
+
+apply plugin: 'kotlin-android-extensions'
+
+android {
+ compileSdkVersion 28
+ defaultConfig {
+ applicationId "pardn.co.barcodescanner"
+ minSdkVersion 23
+ targetSdkVersion 28
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'com.android.support:appcompat-v7:28.1.0'
+ implementation 'com.google.android.gms:play-services-vision:17.0.2'
+
+ implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
+ implementation 'androidx.core:core-ktx:1.1.0-alpha05'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:runner:1.1.2-alpha02'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02'
+}
\ No newline at end of file
diff --git a/app/src/androidTest/java/ru/panorobot/fc/ExampleInstrumentedTest.kt b/app/src/androidTest/java/ru/panorobot/fc/ExampleInstrumentedTest.kt
new file mode 100644
index 0000000..6fb0d86
--- /dev/null
+++ b/app/src/androidTest/java/ru/panorobot/fc/ExampleInstrumentedTest.kt
@@ -0,0 +1,24 @@
+package ru.panorobot.fc
+
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import org.junit.Assert.*
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class ExampleInstrumentedTest {
+ @Test
+ fun useAppContext() {
+ // Context of the app under test.
+ val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+ assertEquals("ru.panorobot.fc", appContext.packageName)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..c643811
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/ru/panorobot/fc/MainActivity.kt b/app/src/main/java/ru/panorobot/fc/MainActivity.kt
new file mode 100644
index 0000000..33b59cf
--- /dev/null
+++ b/app/src/main/java/ru/panorobot/fc/MainActivity.kt
@@ -0,0 +1,112 @@
+package ru.panorobot.fc
+
+import android.annotation.SuppressLint
+import android.content.Intent
+import android.content.pm.PackageManager
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.os.Handler
+import android.view.SurfaceHolder
+import android.view.SurfaceView
+import android.widget.Toast
+import androidx.core.app.ActivityCompat
+import androidx.core.content.ContextCompat
+import com.google.android.gms.vision.CameraSource
+import com.google.android.gms.vision.Detector
+import com.google.android.gms.vision.barcode.Barcode
+import com.google.android.gms.vision.barcode.BarcodeDetector
+
+class MainActivity : AppCompatActivity() {
+
+ private lateinit var svBarcode: SurfaceView
+
+ private lateinit var detector: BarcodeDetector
+ private lateinit var cameraSource: CameraSource
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+
+ var taskHandler = Handler()
+ var runnable = object:Runnable{
+ override fun run() {
+ cameraSource.stop()
+// val alert = builder.create()
+// alert.show()
+// startActivity(Intent(this@MainActivity, Photo::class.java))
+
+ taskHandler.removeCallbacksAndMessages(null)
+ }
+ }
+
+ svBarcode = findViewById(R.id.sv_barcode)
+
+ detector = BarcodeDetector.Builder(this).setBarcodeFormats(Barcode.ALL_FORMATS).build()
+ detector.setProcessor(object : Detector.Processor {
+ override fun release() {}
+ @SuppressLint("MissingPermission")
+ override fun receiveDetections(p0: Detector.Detections?) {
+ val barcodes = p0?.detectedItems
+ if (barcodes!!.size() > 0) {
+ val intent = Intent(this@MainActivity, Photo::class.java)
+ intent.putExtra("USER", barcodes.valueAt(0).displayValue)
+ startActivity(intent)
+
+ // TODO: 26.06.2020 Добавить коллбэк
+// cameraSource.stop()
+// cameraSource.start(svBarcode.holder) // TODO: 24.06.2020 Стартовать камеру по закрытию активити Фото
+// }
+
+ svBarcode.setOnClickListener {
+ svBarcode.setBackgroundResource(0); // Убираем каритинку
+ cameraSource.start(svBarcode.holder) }
+ taskHandler.post(runnable)
+ }
+ }
+ })
+ cameraSource = CameraSource.Builder(this, detector).setRequestedPreviewSize(1024, 768)
+ .setRequestedFps(30f).setAutoFocusEnabled(true).build()
+ svBarcode.holder.addCallback(object : SurfaceHolder.Callback2 {
+ override fun surfaceRedrawNeeded(holder: SurfaceHolder?) {
+ print("1")
+ }
+ override fun surfaceChanged(holder: SurfaceHolder?, format: Int, width: Int, height: Int) {
+ print("2")
+ }
+ override fun surfaceDestroyed(holder: SurfaceHolder?) {
+ print("3")
+ cameraSource.stop()
+ }
+ override fun surfaceCreated(holder: SurfaceHolder?) {
+ print("4")
+ if (ContextCompat.checkSelfPermission(this@MainActivity, android.Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED)
+// && (ContextCompat.checkSelfPermission(this@MainActivity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) == PackageManager.PERMISSION_GRANTED))
+ cameraSource.start(svBarcode.holder)
+ else ActivityCompat.requestPermissions(this@MainActivity, arrayOf(android.Manifest.permission.CAMERA), 321)
+ }
+
+ })
+ }
+
+ @SuppressLint("MissingPermission")
+ override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+ if (requestCode == 123) {
+ if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)
+ cameraSource.start(svBarcode.holder)
+ else Toast.makeText(this, "scanner", Toast.LENGTH_SHORT).show()
+ }
+ if (requestCode == 321) {
+ if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)
+// cameraSource.start(svBarcode.holder)
+ else Toast.makeText(this, "scanner", Toast.LENGTH_SHORT).show()
+ }
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ detector.release()
+ cameraSource.stop()
+ cameraSource.release()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/ru/panorobot/fc/Photo.kt b/app/src/main/java/ru/panorobot/fc/Photo.kt
new file mode 100644
index 0000000..a4af369
--- /dev/null
+++ b/app/src/main/java/ru/panorobot/fc/Photo.kt
@@ -0,0 +1,55 @@
+package ru.panorobot.fc
+
+import android.content.Intent
+import android.content.pm.PackageManager
+import android.graphics.Bitmap
+import android.graphics.BitmapFactory
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.os.Environment
+import androidx.core.app.ActivityCompat
+import androidx.core.content.ContextCompat
+import kotlinx.android.synthetic.main.activity_photo.*
+import java.io.File
+import java.io.FileInputStream
+import java.lang.Exception
+
+class Photo : AppCompatActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_photo)
+
+ im_photo.setOnClickListener {
+ val intent = Intent(this@Photo, MainActivity::class.java)
+ startActivity(intent)
+ }
+
+ val user = intent.getStringExtra("USER")
+ val fileName = "/MeridianFC/" + user + ".jpg"
+
+ var f = File(Environment.getExternalStorageDirectory(), fileName)
+
+ if (ContextCompat.checkSelfPermission(
+ this@Photo,
+ android.Manifest.permission.READ_EXTERNAL_STORAGE
+ ) != PackageManager.PERMISSION_GRANTED
+ ) {
+ ActivityCompat.requestPermissions(
+ this@Photo,
+ arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE),
+ 123
+ )
+ // TODO: 26.06.2020 Добавить коллбэк
+ } else {
+ try {
+ var fso = FileInputStream(f)
+ var b: Bitmap = BitmapFactory.decodeStream(fso)
+ im_photo.setImageBitmap(b)
+ getSupportActionBar()?.setTitle(user)
+ } catch (e: Exception) {
+ im_photo.setImageBitmap(null)
+ getSupportActionBar()?.setTitle("Не найден! " + user)
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 0000000..2b068d1
--- /dev/null
+++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..07d5da9
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..84abef4
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_photo.xml b/app/src/main/res/layout/activity_photo.xml
new file mode 100644
index 0000000..a0c3708
--- /dev/null
+++ b/app/src/main/res/layout/activity_photo.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..a571e60
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..61da551
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c41dd28
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..db5080a
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..6dba46d
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..da31a87
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..15ac681
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..b216f2d
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..f25a419
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..e96783c
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..4faecfa
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #6200EE
+ #3700B3
+ #03DAC5
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..718aa46
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ Face Control
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..fac9291
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/test/java/ru/panorobot/fc/ExampleUnitTest.kt b/app/src/test/java/ru/panorobot/fc/ExampleUnitTest.kt
new file mode 100644
index 0000000..547c5a7
--- /dev/null
+++ b/app/src/test/java/ru/panorobot/fc/ExampleUnitTest.kt
@@ -0,0 +1,17 @@
+package ru.panorobot.fc
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..b183947
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,28 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ ext.kotlin_version = '1.3.21'
+ repositories {
+ google()
+ jcenter()
+
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.3.2'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..596984c
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,2 @@
+include ':app'
+rootProject.name = "FaceControl"
\ No newline at end of file