Spaces:
Sleeping
Sleeping
Fadhili Sumaye commited on
Commit ·
81658f5
1
Parent(s): e1b9530
UX: Combine launcher icon and instructions in centered placeholder layout inside imageCard
Browse files
app/src/main/java/com/example/pestdetection/MainActivity.java
CHANGED
|
@@ -34,7 +34,7 @@ public class MainActivity extends AppCompatActivity {
|
|
| 34 |
|
| 35 |
// View references for enhanced UX
|
| 36 |
ScrollView mainScrollView;
|
| 37 |
-
|
| 38 |
View loadingOverlay;
|
| 39 |
ProgressBar progressBar;
|
| 40 |
Button btnSelect, btnCamera, btnUpload;
|
|
@@ -47,8 +47,8 @@ public class MainActivity extends AppCompatActivity {
|
|
| 47 |
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
| 48 |
imageUri = result.getData().getData();
|
| 49 |
imageView.setImageURI(imageUri);
|
| 50 |
-
if (
|
| 51 |
-
|
| 52 |
}
|
| 53 |
if (btnUpload != null) {
|
| 54 |
btnUpload.setEnabled(true);
|
|
@@ -60,8 +60,8 @@ public class MainActivity extends AppCompatActivity {
|
|
| 60 |
registerForActivityResult(new ActivityResultContracts.TakePicture(), success -> {
|
| 61 |
if (success) {
|
| 62 |
imageView.setImageURI(imageUri);
|
| 63 |
-
if (
|
| 64 |
-
|
| 65 |
}
|
| 66 |
if (btnUpload != null) {
|
| 67 |
btnUpload.setEnabled(true);
|
|
@@ -85,7 +85,7 @@ public class MainActivity extends AppCompatActivity {
|
|
| 85 |
|
| 86 |
mainScrollView = findViewById(R.id.mainScrollView);
|
| 87 |
imageView = findViewById(R.id.imageView);
|
| 88 |
-
|
| 89 |
loadingOverlay = findViewById(R.id.loadingOverlay);
|
| 90 |
progressBar = findViewById(R.id.progressBar);
|
| 91 |
btnSelect = findViewById(R.id.btnSelect);
|
|
@@ -146,8 +146,8 @@ public class MainActivity extends AppCompatActivity {
|
|
| 146 |
if (imageView != null) {
|
| 147 |
imageView.setImageDrawable(null);
|
| 148 |
}
|
| 149 |
-
if (
|
| 150 |
-
|
| 151 |
}
|
| 152 |
if (btnUpload != null) {
|
| 153 |
btnUpload.setEnabled(false);
|
|
|
|
| 34 |
|
| 35 |
// View references for enhanced UX
|
| 36 |
ScrollView mainScrollView;
|
| 37 |
+
View placeholderContainer;
|
| 38 |
View loadingOverlay;
|
| 39 |
ProgressBar progressBar;
|
| 40 |
Button btnSelect, btnCamera, btnUpload;
|
|
|
|
| 47 |
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
| 48 |
imageUri = result.getData().getData();
|
| 49 |
imageView.setImageURI(imageUri);
|
| 50 |
+
if (placeholderContainer != null) {
|
| 51 |
+
placeholderContainer.setVisibility(View.GONE);
|
| 52 |
}
|
| 53 |
if (btnUpload != null) {
|
| 54 |
btnUpload.setEnabled(true);
|
|
|
|
| 60 |
registerForActivityResult(new ActivityResultContracts.TakePicture(), success -> {
|
| 61 |
if (success) {
|
| 62 |
imageView.setImageURI(imageUri);
|
| 63 |
+
if (placeholderContainer != null) {
|
| 64 |
+
placeholderContainer.setVisibility(View.GONE);
|
| 65 |
}
|
| 66 |
if (btnUpload != null) {
|
| 67 |
btnUpload.setEnabled(true);
|
|
|
|
| 85 |
|
| 86 |
mainScrollView = findViewById(R.id.mainScrollView);
|
| 87 |
imageView = findViewById(R.id.imageView);
|
| 88 |
+
placeholderContainer = findViewById(R.id.placeholderContainer);
|
| 89 |
loadingOverlay = findViewById(R.id.loadingOverlay);
|
| 90 |
progressBar = findViewById(R.id.progressBar);
|
| 91 |
btnSelect = findViewById(R.id.btnSelect);
|
|
|
|
| 146 |
if (imageView != null) {
|
| 147 |
imageView.setImageDrawable(null);
|
| 148 |
}
|
| 149 |
+
if (placeholderContainer != null) {
|
| 150 |
+
placeholderContainer.setVisibility(View.VISIBLE);
|
| 151 |
}
|
| 152 |
if (btnUpload != null) {
|
| 153 |
btnUpload.setEnabled(false);
|
app/src/main/res/layout/activity_main.xml
CHANGED
|
@@ -200,18 +200,35 @@
|
|
| 200 |
android:layout_height="match_parent"
|
| 201 |
android:scaleType="centerCrop" />
|
| 202 |
|
| 203 |
-
<!-- Placeholder
|
| 204 |
-
<
|
| 205 |
-
android:id="@+id/
|
| 206 |
android:layout_width="wrap_content"
|
| 207 |
android:layout_height="wrap_content"
|
| 208 |
android:layout_gravity="center"
|
| 209 |
-
android:
|
| 210 |
-
android:
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
<!-- Semi-transparent overlay to dim image when analyzing -->
|
| 217 |
<View
|
|
|
|
| 200 |
android:layout_height="match_parent"
|
| 201 |
android:scaleType="centerCrop" />
|
| 202 |
|
| 203 |
+
<!-- Placeholder container when no image is selected -->
|
| 204 |
+
<LinearLayout
|
| 205 |
+
android:id="@+id/placeholderContainer"
|
| 206 |
android:layout_width="wrap_content"
|
| 207 |
android:layout_height="wrap_content"
|
| 208 |
android:layout_gravity="center"
|
| 209 |
+
android:orientation="vertical"
|
| 210 |
+
android:gravity="center">
|
| 211 |
+
|
| 212 |
+
<ImageView
|
| 213 |
+
android:id="@+id/placeholderIcon"
|
| 214 |
+
android:layout_width="64dp"
|
| 215 |
+
android:layout_height="64dp"
|
| 216 |
+
android:src="@mipmap/ic_launcher"
|
| 217 |
+
android:contentDescription="App Icon"
|
| 218 |
+
android:layout_marginBottom="12dp" />
|
| 219 |
+
|
| 220 |
+
<TextView
|
| 221 |
+
android:id="@+id/tvImagePlaceholder"
|
| 222 |
+
android:layout_width="wrap_content"
|
| 223 |
+
android:layout_height="wrap_content"
|
| 224 |
+
android:gravity="center"
|
| 225 |
+
android:text="No crop image selected\nTap Gallery or Camera below"
|
| 226 |
+
android:textColor="@color/text_hint"
|
| 227 |
+
android:textSize="14sp"
|
| 228 |
+
android:textStyle="bold"
|
| 229 |
+
android:paddingStart="24dp"
|
| 230 |
+
android:paddingEnd="24dp" />
|
| 231 |
+
</LinearLayout>
|
| 232 |
|
| 233 |
<!-- Semi-transparent overlay to dim image when analyzing -->
|
| 234 |
<View
|