10.31 update_app_test

yuying
王宇洋 3 years ago
parent 1991f80cfe
commit 91d53bd1ca

@ -1,17 +0,0 @@
<?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">
<Button
android:id="@+id/ChooseImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ChooseImageButton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -45,6 +45,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation project(path: ':photo_editor')
implementation project(path: ':stinger_game')
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

@ -21,6 +21,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Image_information_activity"
android:exported="true">
</activity>
</application>
</manifest>

@ -0,0 +1,111 @@
package com.echo.appliaction_test;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.echo.appliaction_test.databinding.ImageInformationBinding;
import org.tensorflow.lite.support.image.TensorImage;
import java.util.Arrays;
/**
* @Author: WangYuyang
* @Date: 2021/10/31-14:53
* @Project: My Application
* @Package: com.echo.appliaction_test
* @Description:
**/
public class Image_information_activity extends AppCompatActivity {
private ImageInformationBinding binding;
private Image_information_activity _this = this;
private String sourceFilePath;
private Bitmap image;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ImageInformationBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
Intent intent = getIntent();
sourceFilePath = intent.getStringExtra("sourceFilePath");
image = BitmapFactory.decodeFile(sourceFilePath);
TensorImage Timage = TensorImage.fromBitmap(image);
binding.imageView2.setImageBitmap(image);
TextView information = new TextView(this);
information.append("getHeight: " + image.getHeight());
information.append("\n");
information.append("getWidth: " + image.getWidth());
information.append("\n");
information.append("describeContents: " + image.describeContents());
information.append("\n");
information.append("getRowBytes: " + image.getRowBytes());
information.append("\n");
information.append("hasAlpha: " + image.hasAlpha());
information.append("\n");
information.append("hasMipMap: " + image.hasMipMap());
information.append("\n");
information.append("isPremultiplied: " + image.isPremultiplied());
information.append("\n");
information.append("isMutable: " + image.isMutable());
information.append("\n");
information.append("isRecycled: " + image.isRecycled());
information.append("\n");
information.append("toString: " + image.toString());
information.append("\n");
information.append("getAllocationByteCount: " + image.getAllocationByteCount());
information.append("\n");
information.append("getByteCount: " + image.getByteCount());
information.append("\n");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
information.append("getColorSpace: " + image.getColorSpace());
}
information.append("\n");
information.append("getConfig: " + image.getConfig());
information.append("\n");
information.append("getDensity: " + image.getDensity());
information.append("\n");
information.append("getGenerationId: " + image.getGenerationId());
information.append("\n");
information.append("-----------------Tensor---------------------");
information.append("\n");
information.append("getDataType: " + Timage.getDataType());
information.append("\n");
information.append("getDataType.byteSize: " + Timage.getDataType().byteSize());
information.append("\n");
information.append("toString: " + Timage.toString());
information.append("\n");
information.append("getFlatSize: " + Timage.getTensorBuffer().getFlatSize());
information.append("\n");
information.append("getShape: " + Arrays.toString(Timage.getTensorBuffer().getShape()));
information.append("\n");
information.append("getTypeSize: " + Timage.getTensorBuffer().getTypeSize());
information.append("\n");
information.append("isDynamic: " + Timage.getTensorBuffer().isDynamic());
information.append("\n");
if (Timage.getTensorBuffer().getFlatSize() < 10000000) {
information.append("getIntArray length: " + Timage.getTensorBuffer().getIntArray().length);
information.append("\n");
int[] array;
if (Timage.getTensorBuffer().getIntArray().length > 200)
array = Arrays.copyOfRange(Timage.getTensorBuffer().getIntArray(), 0, 200);
else
array = Timage.getTensorBuffer().getIntArray();
information.append("getIntArray(0..200): " + Arrays.toString(array));
}
binding.informationArea.addView(information);
}
}

@ -1,18 +1,17 @@
package com.echo.appliaction_test;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.echo.appliaction_test.databinding.ActivityMainBinding;
import com.echo.photo_editor.photo_editor_view.PhotoEditorView;
import com.echo.photo_editor.thirdparty.GlideEngine;
import com.echo.stinger_game.myganme.GameActivity;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
@ -21,7 +20,9 @@ import com.luck.picture.lib.listener.OnResultCallbackListener;
import org.tensorflow.lite.support.image.TensorImage;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Random;
@ -40,6 +41,33 @@ public class MainActivity extends AppCompatActivity {
// intent.putExtra("sourceFilePath", sourceFilePath);
// startActivity(intent);
setContentView(binding.getRoot());
TextView textView = binding.textView2;
TextView textView1 = binding.textView3;
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SS");// HH:mm:ss
Date date = new Date(System.currentTimeMillis());
textView1.setText(simpleDateFormat.format(date));
textView.setText(String.valueOf(System.currentTimeMillis()));
} catch (Exception e) {
}
}
});
try {
Thread.sleep(10);
} catch (InterruptedException e) {
return;
}
}
}
}).start();
binding.ChooseImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -53,42 +81,37 @@ public class MainActivity extends AppCompatActivity {
public void onResult(List<LocalMedia> result) {
sourceFilePath = result.get(0).getRealPath();
Bitmap img = BitmapFactory.decodeFile(sourceFilePath);
if (!check_is_grayscale(img)) {
final AlertDialog.Builder alterDialog = new AlertDialog.Builder(_this);
alterDialog.setTitle("Is this a grayscale image ?");//文字
alterDialog.setMessage("We think the image you choose is not a grayscale image, are you sure you want to upload ?");//提示消息
alterDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(_this, PhotoEditorView.class);
intent.putExtra("sourceFilePath", sourceFilePath);
startActivity(intent);
}
});
alterDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alterDialog.show();
} else {
// System.out.println(img.describeContents());
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// System.out.println(img.getColorSpace());
// }
// TensorImage tensorImage = TensorImage.fromBitmap(img);
// System.out.println(Arrays.toString(tensorImage.getTensorBuffer().getShape()));
// System.out.println(Arrays.toString(tensorImage.getTensorBuffer().getIntArray()));
// System.out.println(tensorImage.getTensorBuffer().getIntArray().length);
Intent intent = new Intent(_this, PhotoEditorView.class);
intent.putExtra("sourceFilePath", sourceFilePath);
startActivity(intent);
}
// Bitmap img = BitmapFactory.decodeFile(sourceFilePath);
Intent intent = new Intent(_this, PhotoEditorView.class);
intent.putExtra("sourceFilePath", sourceFilePath);
startActivity(intent);
}
@Override
public void onCancel() {
// 取消
}
});
}
});
binding.ImageInformationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PictureSelector.create(_this)
.openGallery(PictureMimeType.ofAll())
.imageEngine(GlideEngine.createGlideEngine())
.selectionMode(PictureConfig.SINGLE)
.forResult(new OnResultCallbackListener<LocalMedia>() {
@Override
public void onResult(List<LocalMedia> result) {
sourceFilePath = result.get(0).getRealPath();
// Bitmap img = BitmapFactory.decodeFile(sourceFilePath);
Intent intent = new Intent(_this, Image_information_activity.class);
intent.putExtra("sourceFilePath", sourceFilePath);
startActivity(intent);
}
@Override
@ -98,6 +121,17 @@ public class MainActivity extends AppCompatActivity {
});
}
});
binding.gameButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(_this, GameActivity.class);
startActivity(intent);
}
});
}
public static Boolean check_is_grayscale(Bitmap img) {

@ -0,0 +1,67 @@
<?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">
<Button
android:id="@+id/ChooseImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DEBUG_PhotoEditor"
android:textAllCaps="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/ImageInformationButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="Image_Information"
android:textAllCaps="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ChooseImageButton" />
<Button
android:id="@+id/game_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="DEBUG_Game"
android:textAllCaps="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ImageInformationButton" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:fontFamily="serif-monospace"
android:text="TextView"
android:textSize="34sp"
app:layout_constraintBottom_toTopOf="@+id/ChooseImageButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="serif-monospace"
android:text="TextView"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_wrapBehaviorInParent="included" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,38 @@
<?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">
<ImageView
android:id="@+id/imageView2"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginTop="32dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView2"
tools:ignore="SpeakableTextPresentCheck">
<LinearLayout
android:id="@+id/information_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -11,4 +11,4 @@ rootProject.name = "My Application"
include ':app'
include ':photo_editor'
include ':stinger_game'
include ':appliaction_test'
include ':photoEditor_test'

Loading…
Cancel
Save