Skip to content

Commit

Permalink
Make UI more attractive
Browse files Browse the repository at this point in the history
  • Loading branch information
remmel committed Mar 13, 2021
1 parent 0c89d68 commit e32bcaa
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 89 deletions.
73 changes: 44 additions & 29 deletions Recorder3D/src/main/java/com/remmel/recorder3d/ChooseActivity.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@
/**
* Copyright 2020. Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.remmel.recorder3d;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.remmel.recorder3d.R;
import com.huawei.arengine.demos.common.PermissionManager;
import com.remmel.recorder3d.measure.MeasureActivity;
import com.remmel.recorder3d.recorder.RecorderActivity;
import com.remmel.recorder3d.recorder.RecorderRenderManager;
import com.remmel.recorder3d.recorder.preferences.RecorderPreferenceActivity;

import java.io.File;

/**
* This class provides the permission verification and sub-AR example redirection functions.
*
Expand All @@ -44,9 +31,6 @@
public class ChooseActivity extends Activity {
private static final String TAG = ChooseActivity.class.getSimpleName();

private boolean isFirstClick = true;
TextView textView;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -56,15 +40,21 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
// AR Engine requires the camera permission.
PermissionManager.checkPermission(this);

textView = findViewById(R.id.txt_choose);
textView.setText(BuildConfig.APPLICATION_ID + "/" + BuildConfig.VERSION_NAME);
TextView tvHeader = findViewById(R.id.choose_txt_header);
tvHeader.setText(getString(R.string.app_name) + " v" + BuildConfig.VERSION_NAME);

File dir = this.getExternalFilesDir(null);
TextView tvFolder = findViewById(R.id.choose_txt_filesfolder);
tvFolder.setText(dir + ":");

renderBrowser();

}

@Override
protected void onResume() {
Log.d(TAG, "onResume");
super.onResume();
isFirstClick = true;
}

@Override
Expand All @@ -88,11 +78,6 @@ protected void onDestroy() {
* @param view View
*/
public void onClick(View view) {
if (!isFirstClick) {
return;
} else {
isFirstClick = false;
}
switch (view.getId()) {
case R.id.btn_measure:
startActivity(new Intent(this, MeasureActivity.class));
Expand All @@ -103,8 +88,38 @@ public void onClick(View view) {
case R.id.btn_recorder_settings:
startActivity(new Intent(this, RecorderPreferenceActivity.class));
break;

case R.id.btn_fileexplorer:
File dir = this.getExternalFilesDir(null);
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse(dir.getAbsolutePath());
intent.setDataAndType(uri, "*/*");
startActivity(Intent.createChooser(intent, "Open folder"));

break;
default:
Log.e(TAG, "onClick error!");
}
}

protected void renderBrowser() {
File filesDir = this.getExternalFilesDir(null);
LinearLayout ll = findViewById(R.id.choose_linearlayout);
String[] directories = filesDir.list(FilenameFilterUtils.isDir());

for (String dir : directories) {
TextView tv = new TextView(this);


File f = new File(filesDir, dir);
int nbRgbVga = f.list(FilenameFilterUtils.endsWith(RecorderRenderManager.FN_SUFFIX_IMAGEVGAJPG)).length;
int nbRgb = f.list(FilenameFilterUtils.endsWith(RecorderRenderManager.FN_SUFFIX_IMAGEJPG)).length;
int nbDepth = f.list(FilenameFilterUtils.endsWith(RecorderRenderManager.FN_SUFFIX_DEPTH16BIN)).length;

tv.setText("• " + dir+ " RGBVGA("+nbRgbVga+") RGB("+nbRgb+") Depth("+nbDepth+")");
ll.addView(tv);
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.remmel.recorder3d;

import java.io.File;
import java.io.FilenameFilter;

public class FilenameFilterUtils {
public static FilenameFilter isDir() {
return new FilenameFilter() {
@Override
public boolean accept(File current, String name) {
return new File(current, name).isDirectory();
}
};
}

public static FilenameFilter endsWith(String endsWith) {
return new FilenameFilter() {
@Override
public boolean accept(File current, String name) {
return name.endsWith(endsWith);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class RecorderRenderManager implements GLSurfaceView.Renderer {
private static final float MATRIX_SCALE_SX = -1.0f;

private static final float MATRIX_SCALE_SY = -1.0f;
public static final String FN_SUFFIX_DEPTH16BIN = "_depth16.bin";
public static final String FN_SUFFIX_IMAGEVGAJPG = "_image_vga.jpg";
public static final String FN_SUFFIX_IMAGEJPG = "_image.jpg";

private TextureDisplay mTextureDisplay = new TextureDisplay();

Expand Down Expand Up @@ -205,13 +208,13 @@ private void updateFrameRecording(ARFrame arFrame) {
numFrameSaved++;

if (takePhoto || videoDepth)
ImageUtils.writeImageDepth16(arFrame.acquireDepthImage(), new File(dir, numFrameStr + "_depth16.bin")); // 0.001s
ImageUtils.writeImageDepth16(arFrame.acquireDepthImage(), new File(dir, numFrameStr + FN_SUFFIX_DEPTH16BIN)); // 0.001s

if (takePhoto || videoRgbVga)
ImageUtils.writeImageYuvJpg(arFrame.acquireCameraImage(), new File(dir, numFrameStr + "_image_vga.jpg"));
ImageUtils.writeImageYuvJpg(arFrame.acquireCameraImage(), new File(dir, numFrameStr + FN_SUFFIX_IMAGEVGAJPG));

if (takePhoto || videoRgbPreview)
ImageUtils.writeImageYuvJpg(arFrame.acquirePreviewImage(), new File(dir, numFrameStr + "_image.jpg"));
ImageUtils.writeImageYuvJpg(arFrame.acquirePreviewImage(), new File(dir, numFrameStr + FN_SUFFIX_IMAGEJPG));


// ImageUtils.writeImageN21Bin(arFrame.acquirePreviewImage(), new File(dir, numFrameStr+"_image.bin")); //0.007s
Expand Down
128 changes: 80 additions & 48 deletions Recorder3D/src/main/res/layout/activity_choose.xml
Original file line number Diff line number Diff line change
@@ -1,67 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">
android:layout_height="match_parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:background="#689F38">

<TextView
android:id="@+id/choose_txt_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="HEADER"
android:textColor="#FFFFFF"
android:textSize="25sp"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_above="@+id/footer"
android:layout_below="@+id/header">

<LinearLayout
android:id="@+id/choose_linearlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<Button
android:id="@+id/btn_recorder"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:background="@drawable/selector_reset"
android:gravity="center"
android:onClick="onClick"
android:text="Recorder"
android:textAllCaps="false"
android:textColor="@color/white" />

<Button
android:id="@+id/btn_recorder_settings"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:background="@drawable/selector_reset"
android:gravity="center"
android:onClick="onClick"
android:text="Recorder Settings"
android:textAllCaps="false"
android:textColor="@color/white" />

<Button
android:id="@+id/btn_measure"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:background="@drawable/selector_reset"
android:gravity="center"
android:onClick="onClick"
android:text="Measure"
android:textAllCaps="false"
android:textColor="@color/white" />

<TextView
android:id="@+id/txt_choose"
android:id="@+id/choose_txt_filesfolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="@color/white" />
android:text="/foo/bar/files"
android:textSize="10dp" />

</LinearLayout>
</ScrollView>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/disable_thumb_grey"
android:orientation="horizontal">

<Button
android:id="@+id/btn_measure"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="📏"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn_recorder"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/btn_recorder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="🔴 Record"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn_recorder_settings"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/btn_measure" />

<Button
android:id="@+id/btn_recorder_settings"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="⚙️"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/btn_fileexplorer"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/btn_recorder" />

<Button
android:id="@+id/btn_fileexplorer"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="📂️"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/btn_recorder_settings" />
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
3 changes: 1 addition & 2 deletions Recorder3D/src/main/res/layout/measure_activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<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"
tools:context="com.remmel.recorder3d.measure.MeasureActivity">
android:layout_height="match_parent">

<android.opengl.GLSurfaceView
android:id="@+id/measureSurfaceview"
Expand Down
4 changes: 1 addition & 3 deletions Recorder3D/src/main/res/layout/recorder_activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
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="com.remmel.recorder3d.recorder.RecorderActivity">
android:layout_height="match_parent">

<android.opengl.GLSurfaceView
android:id="@+id/recorderSurfaceview"
Expand All @@ -32,7 +31,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">


<Button
android:id="@+id/btn_recorder_photo"
android:layout_width="wrap_content"
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -30,5 +30,5 @@ ext{
targetSdkVersion = 27

//version
versionName = '0.9'
versionName = '0.9.1'
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Nov 18 18:39:32 CST 2020
#Fri Mar 12 18:38:43 CET 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

0 comments on commit e32bcaa

Please sign in to comment.