Fadhili Sumaye commited on
Commit
ac6357c
·
1 Parent(s): 81658f5

UX: Restore original center-cropped launcher icon in imageCard by default

Browse files
app/src/main/java/com/example/pestdetection/MainActivity.java CHANGED
@@ -34,7 +34,6 @@ public class MainActivity extends AppCompatActivity {
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,9 +46,6 @@ 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 (placeholderContainer != null) {
51
- placeholderContainer.setVisibility(View.GONE);
52
- }
53
  if (btnUpload != null) {
54
  btnUpload.setEnabled(true);
55
  }
@@ -60,9 +56,6 @@ public class MainActivity extends AppCompatActivity {
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);
68
  }
@@ -85,7 +78,6 @@ public class MainActivity extends AppCompatActivity {
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);
@@ -144,10 +136,7 @@ public class MainActivity extends AppCompatActivity {
144
  protected void onStop() {
145
  super.onStop();
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);
 
34
 
35
  // View references for enhanced UX
36
  ScrollView mainScrollView;
 
37
  View loadingOverlay;
38
  ProgressBar progressBar;
39
  Button btnSelect, btnCamera, btnUpload;
 
46
  if (result.getResultCode() == RESULT_OK && result.getData() != null) {
47
  imageUri = result.getData().getData();
48
  imageView.setImageURI(imageUri);
 
 
 
49
  if (btnUpload != null) {
50
  btnUpload.setEnabled(true);
51
  }
 
56
  registerForActivityResult(new ActivityResultContracts.TakePicture(), success -> {
57
  if (success) {
58
  imageView.setImageURI(imageUri);
 
 
 
59
  if (btnUpload != null) {
60
  btnUpload.setEnabled(true);
61
  }
 
78
 
79
  mainScrollView = findViewById(R.id.mainScrollView);
80
  imageView = findViewById(R.id.imageView);
 
81
  loadingOverlay = findViewById(R.id.loadingOverlay);
82
  progressBar = findViewById(R.id.progressBar);
83
  btnSelect = findViewById(R.id.btnSelect);
 
136
  protected void onStop() {
137
  super.onStop();
138
  if (imageView != null) {
139
+ imageView.setImageResource(R.mipmap.ic_launcher);
 
 
 
140
  }
141
  if (btnUpload != null) {
142
  btnUpload.setEnabled(false);
app/src/main/res/layout/activity_main.xml CHANGED
@@ -198,37 +198,8 @@
198
  android:id="@+id/imageView"
199
  android:layout_width="match_parent"
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
 
198
  android:id="@+id/imageView"
199
  android:layout_width="match_parent"
200
  android:layout_height="match_parent"
201
+ android:scaleType="centerCrop"
202
+ android:src="@mipmap/ic_launcher" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
 
204
  <!-- Semi-transparent overlay to dim image when analyzing -->
205
  <View