Первое

This commit is contained in:
2021-05-25 07:43:51 +06:00
commit 5f3680ad20
51 changed files with 2031 additions and 0 deletions

1
app/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

41
app/build.gradle Normal file
View File

@ -0,0 +1,41 @@
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "kz.pomarka"
minSdkVersion 19
targetSdkVersion 29
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.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-vision:20.1.2'
}

21
app/proguard-rules.pro vendored Normal file
View File

@ -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

View File

@ -0,0 +1,26 @@
package kz.pomarka;
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("kz.pomarka", appContext.getPackageName());
}
}

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="kz.pomarka">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Pomarka">
<activity android:name=".PhotoActivity"></activity>
<activity
android:name=".EmailActivity"
android:windowSoftInputMode="adjustPan" />
<activity android:name=".ScanActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/photos" />
</provider>
</application>
</manifest>

View File

@ -0,0 +1,449 @@
package kz.shopmaster.shopmasterbarcode;
import java.util.ArrayList;
/**
* Created by Igor on 07.12.2017.
* На вход массив float на выход стрих код в виде строки
* Распознавание только для EAN-8 и EAN-13
*/
public class BarCode {
public BarCode()
{
super();
}
class BarLine
{
boolean black; //Чёрная то 1
float width; //Ширина в пикселях (вещественное число так как гребень может быть одинаковой высоты подподрят тогда будет +-0,5 покселя)
boolean del;
int lines; //Ширина в полосках
public BarLine(boolean black,float width)
{
this.black=black;
this.width=width;
this.del=false;
lines=0;
}
};
//mas это полоска уже просумированных по вертикали данных с рисунка
//Если просумировали около 5 или 10 пикселей то сглаживание не нужно
public String getBarCode(float mas[])
{
if(mas.length<10) return "";
float dUDp=0; //Для среднего в плюсовых значениях
int cntp=0; //Количество плюсовых значений (для среднего)
float dUDm=0; //Для среднего в минусовых значениях
int cntm=0; //Количество минусовых значений (для среднего)
//Преобразуем в таблицу переходов между светлой и тёмной частью
float[] masUD = new float[mas.length];
for(int i=0;i<mas.length-1;i++)
{
masUD[i]=mas[i+1]-mas[i];
//Нахожу среднее значение
if(masUD[i]>0)
{
dUDp+=masUD[i];
cntp++;
}
if(masUD[i]<0)
{
dUDm+=masUD[i];
cntm++;
}
}
if(cntp<10 || cntm<10) return ""; //Обычно если чёрный экран
masUD[mas.length-1]=0;
dUDp=dUDp/cntp*0.9f; //Плюсовые ()
dUDm=dUDm/cntm*0.9f; //Минусовые ()
//Список для записи полосок и их размера
//Если подподрят идут несколько светлых или тёмных пропускаем они должны обязательно чередоваться!
ArrayList<BarLine> zbr = new ArrayList<BarLine>(25);
boolean black=false; //Для чередования начиная с чёрной
int pmin=0; //Предыдущая позиция перехода с белого на чёрный
int pmax=0; //Предыдущая позиция перехода с чёрного на белый
int pCntr=0; //Позиция центра (чёрная полоска) она должна всегда быть на штрих коде
for(int i=0;i<mas.length;i++)
{
if(i>mas.length/2 && pCntr==0)
pCntr=zbr.size();
if(!black) //Ищем начало чёрной так как находимся на белой полоске
{
//Начало чёрной полоски (минусовые значения)
if(masUD[i]<dUDm) //Меньше среднего
{
float min=masUD[i];
pmin=i;
//Ищем минусовой гребень
int j;
for(j=i+1;j<mas.length;j++)
{
if(masUD[j]>dUDm)
break;
if(min>masUD[j]) {
min = masUD[j];
pmin=j;
}
}
i=j-1;
//Создаю белую полоску
zbr.add(new BarLine(false,pmin-pmax));
black=!black;
}
}else
{
//Начало белой полоски (плюсовые значения)
if(masUD[i]>dUDp) //Больше среднего
{
float max=masUD[i];
pmax=i;
//Ищем плюсовой гребень
int j;
for(j=i+1;j<mas.length;j++)
{
if(masUD[j]<dUDp)
break;
if(max<masUD[j]) {
max = masUD[j];
pmax=j;
}
}
i=j-1;
//Создаю чёрную полоску
zbr.add(new BarLine(true,pmax-pmin));
black=!black;
}
}
}
//От центра в право и лево ищу границы штрих кода (по госту различия не больше чем 4 к 1)
int pR=0; //Граница штрих кода с права
for(int i=pCntr;i<zbr.size()-1;i++)
{
if(zbr.get(i).black)
{
pR=i;
if(zbr.get(i).width*8<zbr.get(i+1).width)
break;
}
}
int pL=0; //граница штрих кода с лева
for(int i=pCntr;i>0;i--)
{
if(zbr.get(i).black)
{
pL=i;
if(i-1>=0 && zbr.get(i).width*8<zbr.get(i-1).width)
break;
}
}
//Отмечаем как удаленные за пределами штрих кода (больших белых полосок)
for(int i=0;i<zbr.size();i++)
if(i<pL || i>pR)
zbr.get(i).del=true;
//Удяляю элементы
for(int i=0;i<zbr.size();i++) {
if (zbr.get(i).del)
{
zbr.remove(i);
i--;
}
}
/*
ArrayList<BarLine> zbr2=(ArrayList<BarLine>)zbr.clone();
//Сортируем (новый) список по возрастанию ширины (пузырьком)
for(int i=0;i<zbr2.size()-1;i++)
{
for(int j=i+1;j<zbr2.size();j++)
{
if(zbr2.get(i).width>zbr2.get(j).width)
{
BarLine tmp=zbr2.get(i);
zbr2.set(i,zbr2.get(j));
zbr2.set(j,tmp);
}
}
}
*/
//Считая что первая линия всегда еденияная следи белых и чёрных вычисляем ширину каждой полоски
float wB=0;
float wW=0;
//Строим массив из 1 и 0 по делению на ширину 1й полоски
int bwb=1; //Предыдущее кол-во линий на 1 полоску для чёрного цвета
int bww=1; //Предыдущее кол-во линий на 1 полоску для белого цвета
float sumB=0,sumW=0; //Для подсчёта среднего
int sumBC=0,sumWC=0;
for(int i=0;i<zbr.size();i++)
{
if(zbr.get(i).black)
{
if(wB==0) wB=zbr.get(i).width; //Первая всегда единичная
zbr.get(i).lines=Math.round(zbr.get(i).width/wB);
if(zbr.get(i).lines==0)
return "";//break;
if(bwb!=zbr.get(i).lines) //Так как бывает что увеличение ширины полоски бывает не равномерно
{
sumB=0;
sumBC=0;
bwb=zbr.get(i).lines;
//Memo1->Lines->Add("wB = "+FloatToStrF(wB,ffFixed, 8, 3) + " zbr.get(i).lines=" +FloatToStrF(zbr.get(i).lines,ffFixed, 8, 1));
}
//Вычисляем новое среднее значение ширины единичной полоски для разных по ширине полосок
sumB+=zbr.get(i).width;
sumBC++;
wB=sumB/(float)sumBC/(float)bwb;
}else
{
if(wW==0) wW=zbr.get(i).width; //Первая всегда единичная
zbr.get(i).lines=Math.round(zbr.get(i).width/wW);
if(zbr.get(i).lines==0)
return "";//break;
if(bww!=zbr.get(i).lines) //Так как бывает что увеличение ширины полоски бывает не равномерно
{
sumW=0;
sumWC=0;
bww=zbr.get(i).lines;
//Memo1->Lines->Add("wW = "+FloatToStrF(wW,ffFixed, 8, 3) + " zbr.get(i).lines=" +FloatToStrF(zbr.get(i).lines,ffFixed, 8, 1));
}
//Вычисляем новое среднее значение ширины единичной полоски для разных по ширине полосок
sumW+=zbr.get(i).width;
sumWC++;
wW=sumW/(float)sumWC/(float)bww;
}
}
//Переводим штрих код в строку из 1 и 0
String str="";
String ch;
for(int i=0;i<zbr.size();i++)
{
if(zbr.get(i).black) ch="1"; else ch="0";
for(int j=0;j<zbr.get(i).lines;j++)
str+=ch;
}
//Если это EAN8 то длина строки должна быть 67 !
//Если это EAN13 то длина строки должна быть 95 !
if(str.length()==12*7+3+3+5)
{
int[] ean13 = new int[13];
int ean13n=12;
//Распознование
int num;
int spos=str.length();
spos-=1;
if(str.substring(spos).equals("101")) //Первые 2 чёрные полоски
{
//Остальные циферки
for(int i=0;i<6;i++)
{
spos-=7;
ean13[ean13n]=getNumC(str.substring(spos,7));
ean13n--;
//Memo1->Lines->Add(str.SubString(spos,7)+" = С n = "+IntToStr(num));
}
String num13="";
spos-=5;
if(str.substring(spos,5).equals("01010")) //Центральная двойная полоска
{
for(int i=0;i<5;i++)
{
spos-=7;
if(getOdd(str.substring(spos,7))) //Если не чётное
{
ean13[ean13n]=getNumA(str.substring(spos,7));
//if(ean13[ean13n]==-1) ean13[ean13n]=getNumB(str.SubString(spos,7)); //Так как некоторые неправильно генерят код...
//if(ean13[ean13n]==-1) ean13[ean13n]=getNumC(str.SubString(spos,7)); //Так как некоторые неправильно генерят код...
ean13n--;
//Memo1->Lines->Add(str.SubString(spos,7)+ " = A n = "+IntToStr(num));
num13="1"+num13;
}else //Если чётное
{
ean13[ean13n]=getNumB(str.substring(spos,7));
//if(ean13[ean13n]==-1) ean13[ean13n]=getNumA(str.SubString(spos,7)); //Так как некоторые неправильно генерят код...
//if(ean13[ean13n]==-1) ean13[ean13n]=getNumC(str.SubString(spos,7)); //Так как некоторые неправильно генерят код...
ean13n--;
//Memo1->Lines->Add(str.SubString(spos,7)+ " = B n = "+IntToStr(num));
num13="0"+num13;
}
}
spos-=7;
ean13[ean13n]=getNumA(str.substring(spos,7));
ean13n--;
//Memo1->Lines->Add(str.SubString(spos,7) + " = A n = "+IntToStr(num));
}
spos-=3;
if(str.substring(spos,3).equals("101")) //13й символ находим
{
ean13[ean13n]=getNum13(num13);
ean13n--;
//Memo1->Lines->Add(num13 + " = A n = "+IntToStr(num));
//for(int i=0;i<13;i++)
//{
// Memo1->Lines->Add(IntToStr(i)+") "+IntToStr(ean13[i]));
//}
//Проверяем CRC
/*int s1=0,s2=0;
for(int i=0;i<12;i++)
{
if(i % 2 == 0)
s1+=ean13[i];
else
s2+=ean13[i];
}
int crc=(s2*3)+s1;
crc=Math.ceil(crc/10.0f)*10-crc;
Memo1->Lines->Add("crc = "+IntToStr(crc)+" ean13[12]="+IntToStr(ean13[12]));
if(ean13[12]==crc) Memo1->Lines->Add("crc is OK!");
else Memo1->Lines->Add("CRC is ERROR!");*/
}
}
}
return "";
}
//---------------------------------------------------------------------------
//Проверка на нечётность
boolean getOdd(String str)
{
int cnt=0;
for(int i=0;i<str.length();i++)
{
if(str.charAt(i+1)=='1')
cnt++;
}
return cnt % 2 != 0;
}
//---------------------------------------------------------------------------
int getNumA(String str)
{
//Комбинация А (не чётные)
String[] masA = new String[10];
masA[0]="0001101";
masA[1]="0011001";
masA[2]="0010011";
masA[3]="0111101";
masA[4]="0100011";
masA[5]="0110001";
masA[6]="0101111";
masA[7]="0111011";
masA[8]="0110111";
masA[9]="0001011";
int num=-1;
for(int i=0;i<10;i++)
{
if(str.equals(masA[i]))
{
num=i;
break;
}
}
return num;
}
//---------------------------------------------------------------------------
int getNumB(String str)
{
//Комбинация В (чётные)
String[] masB = new String[10];
masB[0]="0100111";
masB[1]="0110011";
masB[2]="0011011";
masB[3]="0100001";
masB[4]="0011101";
masB[5]="0111001";
masB[6]="0000101";
masB[7]="0010001";
masB[8]="0001001";
masB[9]="0010111";
int num=-1;
for(int i=0;i<10;i++)
{
if(str.equals(masB[i]))
{
num=i;
break;
}
}
return num;
}
//---------------------------------------------------------------------------
int getNumC(String str)
{
//Комбинация С (чётные, правая сторона EAN13)
String[] masC = new String[10];
masC[0]="1110010";
masC[1]="1100110";
masC[2]="1101100";
masC[3]="1000010";
masC[4]="1011100";
masC[5]="1001110";
masC[6]="1010000";
masC[7]="1000100";
masC[8]="1001000";
masC[9]="1110100";
int num=-1;
for(int i=0;i<10;i++)
{
if(str.equals(masC[i]))
{
num=i;
break;
}
}
return num;
}
//---------------------------------------------------------------------------
int getNum13(String str)
{
//Комбинация С (чётные)
String[] mas13 = new String[10];
mas13[0]="11111";
mas13[1]="10100";
mas13[2]="10010";
mas13[3]="10001";
mas13[4]="01100";
mas13[5]="00110";
mas13[6]="00011";
mas13[7]="01010";
mas13[8]="01001";
mas13[9]="00101";
int num=-1;
for(int i=0;i<10;i++)
{
if(str.equals(mas13[i]))
{
num=i;
break;
}
}
return num;
}
}

View File

@ -0,0 +1,59 @@
package kz.pomarka;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class EmailActivity extends AppCompatActivity implements View.OnClickListener {
EditText inSubject, inBody;
TextView txtEmailAddress;
Button btnSendEmail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_email);
initViews();
}
private void initViews() {
inSubject = findViewById(R.id.inSubject);
inBody = findViewById(R.id.inBody);
txtEmailAddress = findViewById(R.id.txtEmailAddress);
btnSendEmail = findViewById(R.id.btnSendEmail);
if (getIntent().getStringExtra("email_address") != null) {
txtEmailAddress.setText("Recipient : " + getIntent().getStringExtra("email_address"));
}
btnSendEmail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{txtEmailAddress.getText().toString()});
intent.putExtra(Intent.EXTRA_SUBJECT, inSubject.getText().toString().trim());
intent.putExtra(Intent.EXTRA_TEXT, inBody.getText().toString().trim());
startActivity(Intent.createChooser(intent, "Send EmailActivity"));
}
});
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnScanBarcode:
startActivity(new Intent(EmailActivity.this, ScanActivity.class));
break;
}
}
}

View File

@ -0,0 +1,99 @@
package kz.pomarka;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private static final int PERMISSION_REQUEST_CODE = 0;
Button btnScanBarcode;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnScanBarcode = findViewById(R.id.btnScanBarcode);
btnScanBarcode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onGetPermissions();
}
});
}
//Запрашиваю разрешения сдесь хотя GPS на другой форме использую
public void onGetPermissions()
{
boolean granted=false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
List<String> list = new ArrayList<String>();
/*if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
list.add(Manifest.permission.ACCESS_COARSE_LOCATION);
}
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
list.add(Manifest.permission.ACCESS_FINE_LOCATION);
}
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
list.add(Manifest.permission.CAMERA);
}*/
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
list.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
/*if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
list.add(Manifest.permission.READ_EXTERNAL_STORAGE);
}*/
if(!list.isEmpty())
{
ActivityCompat.requestPermissions(MainActivity.this,list.toArray(new String[list.size()]),PERMISSION_REQUEST_CODE);
granted=false;
}else
{
granted=true;
}
}else
{
granted=true;
}
if(granted)
{
startActivity(new Intent(MainActivity.this, ScanActivity.class));
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
{
if (requestCode == PERMISSION_REQUEST_CODE) {
boolean grant=true;
for(int i=0;i<grantResults.length;i++)
{
grant = grant && grantResults[i] == PackageManager.PERMISSION_GRANTED;
}
if(grant) {
startActivity(new Intent(MainActivity.this, ScanActivity.class));
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}

View File

@ -0,0 +1,195 @@
package kz.pomarka;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.ImageFormat;
import android.graphics.Rect;
import android.graphics.YuvImage;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.util.Log;
import android.util.SparseArray;
import androidx.core.content.FileProvider;
import com.google.android.gms.vision.Detector;
import com.google.android.gms.vision.Frame;
import com.google.android.gms.vision.barcode.Barcode;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;
import static android.content.ContentValues.TAG;
//Клас для обрезки изображения и передачи его дальше гугловскому распознавателю
class MyDetector extends Detector<Barcode> {
private Detector<Barcode> mDelegate;
MyDetector(Detector<Barcode> delegate) {
mDelegate = delegate;
}
@Override
public SparseArray<Barcode> detect(Frame frame) {
// *** crop the frame here
int boxx = 300;
int width = frame.getMetadata().getWidth();
int height = frame.getMetadata().getHeight();
int ay = (width/2) + (boxx/2);
int by = (width/2) - (boxx/2);
int ax = (height/2) + (boxx/2);
int bx = (height/2) - (boxx/2);
YuvImage yuvimage=new YuvImage(frame.getGrayscaleImageData().array(), ImageFormat.NV21, frame.getMetadata().getWidth(), frame.getMetadata().getHeight(), null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
yuvimage.compressToJpeg(new Rect(by, bx, ay, ax), 100, baos); // Where 100 is the quality of the generated jpeg
byte[] jpegArray = baos.toByteArray();
Bitmap bitmap = BitmapFactory.decodeByteArray(jpegArray, 0, jpegArray.length);
Frame outputFrame = new Frame.Builder().setBitmap(bitmap).build();
return mDelegate.detect(outputFrame);
/* int newHeight=100;
Frame.Metadata metadata = originalFrame.getMetadata();
int width = metadata.getWidth();
int height = metadata.getHeight();
Log.i(TAG, "Padded image from: " + width + "x" + height + " to " + width + "x" + newHeight);
ByteBuffer origBuffer = originalFrame.getGrayscaleImageData();
int origOffset = origBuffer.arrayOffset();
byte[] origBytes = origBuffer.array();
// This can be changed to just .allocate in the future, when Frame supports non-direct
// byte buffers.
ByteBuffer paddedBuffer = ByteBuffer.allocateDirect(width * newHeight);
int paddedOffset = paddedBuffer.arrayOffset();
byte[] paddedBytes = paddedBuffer.array();
Arrays.fill(paddedBytes, (byte) 0);
// Copy the image content from the original, without bothering to fill in the padded bottom
// part.
for (int y = 0; y < newHeight; y++) {
int origStride = origOffset + y * width;
int paddedStride = paddedOffset + y * width;
System.arraycopy(origBytes, origStride, paddedBytes, paddedStride, width);
}
Frame newFrame = new Frame.Builder()
.setImageData(paddedBuffer, width, newHeight, ImageFormat.NV21)
.setId(metadata.getId())
.setRotation(metadata.getRotation())
.setTimestampMillis(metadata.getTimestampMillis())
.build();
//SaveImage(bitmap);
return mDelegate.detect(newFrame);
*/
/*
//Какой кусок собираемся вырезать из изображения
int newW=640;
int newH=480;
//Реальные резмеры изображения
Frame.Metadata metadata = frame.getMetadata();
int width = metadata.getWidth();
int height = metadata.getHeight();
//Не вылезаем за реальные размеры
if(newW>width) newW=width;
if(newH>height) newH=height;
//Исходные данные
ByteBuffer origBuffer = frame.getGrayscaleImageData();
int origOffset = origBuffer.arrayOffset();
byte[] origBytes = origBuffer.array();
//Куда копируем
ByteBuffer paddedBuffer = ByteBuffer.allocateDirect(newW * newH); //Типа так быстрей
int paddedOffset = paddedBuffer.arrayOffset(); //Где он в памяти
byte[] paddedBytes = paddedBuffer.array();
Arrays.fill(paddedBytes, (byte) 0);
int posW=0; //С какой позиции копировать видео по X
int posV=0; //С какой позиции копировать видео по Y
//Копирую данные из первого буфера во второй построчно
for (int y = 0; y < newH; y++) {
int origStride = origOffset + y * width; //Позиция с которой копируем
int paddedStride = paddedOffset + y * newW; //Позиция куда копируем
System.arraycopy(origBytes, origStride, paddedBytes, paddedStride, width);
}
Frame newFrame = new Frame.Builder()
.setImageData(paddedBuffer, newW, newH, ImageFormat.NV21)
.setId(metadata.getId())
.setRotation(metadata.getRotation())
.setTimestampMillis(metadata.getTimestampMillis())
.build();
SaveImage(newFrame.getBitmap());
return mDelegate.detect(newFrame);
*/
/*
int width = frame.getMetadata().getWidth();
int height = frame.getMetadata().getHeight();
int right = (width / 2) + (mBoxHeight / 2);
int left = (width / 2) - (mBoxHeight / 2);
int bottom = (height / 2) + (mBoxWidth / 2);
int top = (height / 2) - (mBoxWidth / 2);
YuvImage yuvImage = new YuvImage(frame.getGrayscaleImageData().array(), ImageFormat.NV21, width, height, null);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
yuvImage.compressToJpeg(new Rect(left, top, right, bottom), 100, byteArrayOutputStream);
byte[] jpegArray = byteArrayOutputStream.toByteArray();
Bitmap bitmap = BitmapFactory.decodeByteArray(jpegArray, 0, jpegArray.length);
Frame croppedFrame =
new Frame.Builder()
.setBitmap(bitmap)
.setRotation(frame.getMetadata().getRotation())
.build();
return mDelegate.detect(croppedFrame);
// *** crop the frame here
return mDelegate.detect(frame);
*/
}
public boolean isOperational() {
return mDelegate.isOperational();
}
public boolean setFocus(int id) {
return mDelegate.setFocus(id);
}
private void SaveImage(Bitmap finalBitmap) {
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Pictures" + File.separator +"test.jpg";
File file = new File(path);
try {
FileOutputStream out = new FileOutputStream(file);
finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,66 @@
package kz.pomarka;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
class MySurface extends SurfaceView {
private Paint mPaint;
private Path mPath;
private Canvas mCanvas;
private SurfaceHolder mSurfaceHolder;
private float mX, mY, newX, newY;
public MySurface(Context context) {
super(context);
initi(context);
}
private void initi(Context context) {
mSurfaceHolder = getHolder();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setTextSize(12);
mPaint.setColor(Color.RED);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mX = event.getX();
mY = event.getY();
break;
case MotionEvent.ACTION_MOVE:
newX = event.getX();
newY = event.getY();
break;
default:
// Do nothing
}
drawRect();
invalidate();
return true;
}
private void drawRect() {
mPath = new Path();
mPath.moveTo(mX, mY);
mCanvas = mSurfaceHolder.lockCanvas();
mCanvas.save();
mPath.addRect(mX, mY, newX, newY, Path.Direction.CCW);
mCanvas.drawPath(mPath, mPaint);
mCanvas.restore();
mSurfaceHolder.unlockCanvasAndPost(mCanvas);
mX = newX;
mY = newY;
}
}

View File

@ -0,0 +1,14 @@
package kz.pomarka;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class PhotoActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photo);
}
}

View File

@ -0,0 +1,155 @@
package kz.pomarka;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
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;
import java.io.IOException;
public class ScanActivity extends AppCompatActivity {
SurfaceView surfaceView;
SurfaceView surfaceViewT;
TextView txtBarcodeValue;
private Detector barcodeDetector;
private CameraSource cameraSource;
private static final int REQUEST_CAMERA_PERMISSION = 201;
Button btnAction;
String intentData = "";
boolean isEmail = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scan);
initViews();
}
private void initViews() {
txtBarcodeValue = findViewById(R.id.txtBarcodeValue);
surfaceView = findViewById(R.id.surfaceView);
surfaceView.setZOrderOnTop(false); //CODE TO SET VIDEO VIEW TO BACK
surfaceViewT = findViewById(R.id.surfaceViewT);
surfaceViewT.setZOrderOnTop(true);
btnAction = findViewById(R.id.btnAction);
btnAction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (intentData.length() > 0) {
if (isEmail)
startActivity(new Intent(ScanActivity.this, EmailActivity.class).putExtra("email_address", intentData));
else {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(intentData)));
}
}
}
});
}
private void initialiseDetectorsAndSources() {
Toast.makeText(getApplicationContext(), "Barcode scanner started", Toast.LENGTH_SHORT).show();
barcodeDetector = new BarcodeDetector.Builder(this)
.setBarcodeFormats(Barcode.ALL_FORMATS)
.build();
barcodeDetector = new MyDetector(barcodeDetector);
cameraSource = new CameraSource.Builder(this, barcodeDetector)
.setRequestedPreviewSize(1920, 1080)
.setAutoFocusEnabled(true) //you should add this feature
.build();
surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) {
try {
if (ActivityCompat.checkSelfPermission(ScanActivity.this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
cameraSource.start(surfaceView.getHolder());
} else {
ActivityCompat.requestPermissions(ScanActivity.this, new
String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA_PERMISSION);
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
cameraSource.stop();
}
});
barcodeDetector.setProcessor(new Detector.Processor<Barcode>() {
@Override
public void release() {
Toast.makeText(getApplicationContext(), "Для предотвращения утечки памяти сканер штрих-кода остановлен", Toast.LENGTH_SHORT).show();
}
@Override
public void receiveDetections(Detector.Detections<Barcode> detections) {
final SparseArray<Barcode> barcodes = detections.getDetectedItems();
if (barcodes.size() != 0) {
txtBarcodeValue.post(new Runnable() {
@Override
public void run() {
if (barcodes.valueAt(0).email != null) {
txtBarcodeValue.removeCallbacks(null);
intentData = barcodes.valueAt(0).email.address;
txtBarcodeValue.setText(intentData);
isEmail = true;
btnAction.setText("ADD CONTENT TO THE MAIL");
} else {
isEmail = false;
btnAction.setText("LAUNCH URL");
intentData = barcodes.valueAt(0).displayValue;
txtBarcodeValue.setText(intentData);
}
}
});
}
}
});
}
@Override
protected void onPause() {
super.onPause();
cameraSource.release();
}
@Override
protected void onResume() {
super.onResume();
initialiseDetectorsAndSources();
}
}

View File

@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".EmailActivity">
<Button
android:id="@+id/btnSendEmail"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="@+id/inBody"
android:layout_centerHorizontal="true"
android:layout_marginBottom="64dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="@string/send_email"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/txtEmailAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Email Address: "
android:textSize="16dp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/inSubject"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/inSubject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/txtEmailAddress"
android:layout_centerHorizontal="true"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="88dp"
android:ems="10"
android:hint="Subject"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/inBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/inSubject"
android:layout_centerHorizontal="true"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="164dp"
android:ems="10"
android:hint="Body"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/btnScanNumText"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="250dp"
android:text="@string/scan_photo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.673"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/btnScanNumText"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="144dp"
android:text="@string/scan_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.673"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/btnScanBarcode"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="44dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="@string/scan_barcode"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.676"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PhotoActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/activity_horizontal_margin">
<SurfaceView
android:id="@+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/btnAction"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true" />
<SurfaceView
android:id="@+id/surfaceViewT"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/btnAction"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true" />
<TextView
android:id="@+id/txtBarcodeValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginTop="20dp"
android:text="No Barcode Detected"
android:textColor="@android:color/white"
android:textSize="20sp" />
<Button
android:id="@+id/btnAction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="ADD CONTENT IN THE MAIL" />
</RelativeLayout>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,16 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Pomarka" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="activity_horizontal_margin">16dp</dimen>
</resources>

View File

@ -0,0 +1,7 @@
<resources>
<string name="app_name">Pomarka</string>
<string name="scan_text">Сканировать NUM текст</string>
<string name="scan_photo">Фото с рамкой</string>
<string name="scan_barcode">Сканировать barcode</string>
<string name="send_email">Отправить Email</string>
</resources>

View File

@ -0,0 +1,16 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Pomarka" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="photos" path="." />
</paths>

View File

@ -0,0 +1,17 @@
package kz.pomarka;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}