Skip to content

Commit 50cc061

Browse files
committed
improve ui
1 parent 33ea269 commit 50cc061

File tree

2 files changed

+100
-102
lines changed

2 files changed

+100
-102
lines changed

app/src/main/java/io/github/subhamtyagi/ocr/MainActivity.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,8 @@ public class MainActivity extends AppCompatActivity implements TessBaseAPI.Progr
7272
public static final String TAG = "MainActivity";
7373
private static final int REQUEST_CODE_SETTINGS = 797;
7474
private static boolean isRefresh = false;
75-
/**
76-
* a progressDialog to show downloading Dialog
77-
*/
78-
private ProgressDialog mProgressDialog;
79-
/**
80-
* A spinner dialog shown on share menu
81-
*/
8275

8376
private ArrayList<String> languagesNames;
84-
// private ConvertImageToTextTask convertImageToTextTask;
8577
private File dirBest;
8678
private File dirStandard;
8779
private File dirFast;
@@ -461,11 +453,6 @@ protected void onDestroy() {
461453
dialog.dismiss();
462454
dialog = null;
463455
}
464-
if (mProgressDialog != null) {
465-
mProgressDialog.cancel();
466-
mProgressDialog = null;
467-
}
468-
469456
if (mImageTextReader != null) mImageTextReader.tearDownEverything();
470457
}
471458

@@ -613,8 +600,8 @@ private void updateImageView() {
613600
/**
614601
* Download the training Data and save this to external storage
615602
*/
616-
private ProgressBar mProgressSpinner;
617-
private ProgressBar mProgressBar;
603+
private LinearProgressIndicator mProgressSpinner;
604+
private LinearProgressIndicator mProgressBar;
618605
private TextView mProgressTitle;
619606
private TextView mProgressMessage;
620607

app/src/main/res/layout/activity_main.xml

Lines changed: 98 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,134 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:app="http://schemas.android.com/apk/res-auto"
5-
xmlns:tools="http://schemas.android.com/tools"
6-
android:layout_height="match_parent"
7-
android:layout_width="match_parent"
8-
android:orientation="vertical">
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:orientation="vertical">
98

109
<com.google.android.material.progressindicator.LinearProgressIndicator
11-
android:layout_height="wrap_content"
12-
android:layout_width="match_parent"
13-
android:visibility="gone"
14-
android:max="100"
15-
tools:visibility="visible"
16-
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
17-
tools:progress="20"
18-
android:id="@+id/progress_indicator"
19-
app:indicatorColor="@color/colorAccent" />
20-
21-
<LinearLayout
22-
android:layout_height="wrap_content"
23-
android:layout_width="match_parent"
24-
android:foregroundGravity="center"
25-
android:gravity="center_horizontal"
26-
android:orientation="horizontal"
27-
android:layout_gravity="center">
28-
29-
<TextView
30-
android:layout_height="wrap_content"
31-
android:layout_width="match_parent"
32-
android:layout_marginEnd="5sp"
33-
android:gravity="center_horizontal|end"
34-
android:textSize="20sp"
35-
android:layout_weight="1"
36-
android:text="@string/selected_language" />
37-
38-
<TextView
39-
android:layout_height="wrap_content"
40-
android:layout_width="match_parent"
41-
android:gravity="start"
42-
android:textSize="20sp"
43-
android:layout_marginStart="5sp"
44-
android:layout_weight="1"
45-
android:id="@+id/language_name1" />
46-
47-
</LinearLayout>
48-
49-
<FrameLayout
50-
android:layout_height="match_parent"
51-
android:layout_width="match_parent">
52-
53-
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
54-
android:layout_height="match_parent"
55-
android:layout_width="match_parent"
56-
android:id="@+id/swipe_to_refresh">
57-
58-
<ImageView
59-
android:layout_height="match_parent"
60-
android:layout_width="match_parent"
61-
android:contentDescription="@string/generic_image_description"
62-
android:scaleType="fitCenter"
63-
tools:src="@tools:sample/backgrounds/scenic"
64-
android:id="@+id/source_image" />
65-
66-
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
10+
android:id="@+id/progress_indicator"
11+
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
12+
android:layout_width="match_parent"
13+
android:layout_height="wrap_content"
14+
android:max="100"
15+
android:visibility="gone"
16+
app:indicatorColor="@color/colorAccent"
17+
tools:progress="20"
18+
tools:visibility="visible" />
19+
20+
<RelativeLayout
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content"
23+
android:layout_gravity="center"
24+
android:id="@+id/download_layout"
25+
android:foregroundGravity="center"
26+
android:gravity="center_horizontal"
27+
android:orientation="horizontal"
28+
android:visibility="visible">
6729

6830
<TextView
6931
android:id="@+id/progress_title"
7032
android:layout_width="wrap_content"
7133
android:layout_height="wrap_content"
72-
android:text="Downloading"
73-
android:textSize="18sp"
74-
android:layout_centerHorizontal="true"
7534
android:layout_marginTop="16dp"
76-
android:visibility="gone" /> <!-- Initially hidden -->
35+
android:text="Downloading language data"
36+
android:textSize="18sp"
37+
/>
38+
7739

78-
<!-- Message TextView -->
7940
<TextView
8041
android:id="@+id/progress_message"
8142
android:layout_width="wrap_content"
8243
android:layout_height="wrap_content"
83-
android:text="Downloading language data..."
84-
android:textSize="16sp"
8544
android:layout_below="@id/progress_title"
8645
android:layout_centerHorizontal="true"
87-
android:visibility="gone" /> <!-- Initially hidden -->
46+
android:text="0% downloaded of total 10MB..."
47+
android:textSize="16sp"
48+
/>
49+
8850

89-
<!-- Circular indeterminate ProgressBar -->
90-
<ProgressBar
51+
<com.google.android.material.progressindicator.LinearProgressIndicator
9152
android:id="@+id/progress_spinner"
9253
style="?android:attr/progressBarStyleLarge"
9354
android:layout_width="wrap_content"
9455
android:layout_height="wrap_content"
9556
android:layout_below="@id/progress_message"
9657
android:layout_centerHorizontal="true"
9758
android:layout_marginTop="16dp"
98-
android:visibility="gone" /> <!-- Initially hidden -->
59+
app:indicatorColor="@color/colorAccent"
60+
/>
9961

100-
<!-- Horizontal determinate ProgressBar -->
101-
<ProgressBar
62+
<com.google.android.material.progressindicator.LinearProgressIndicator
10263
android:id="@+id/progress_bar"
10364
style="?android:attr/progressBarStyleHorizontal"
10465
android:layout_width="match_parent"
10566
android:layout_height="wrap_content"
10667
android:layout_below="@id/progress_spinner"
10768
android:layout_marginTop="16dp"
108-
android:visibility="gone"
109-
android:max="100" />
69+
android:max="100"
70+
app:indicatorColor="@color/colorAccent"
71+
/>
72+
73+
</RelativeLayout>
74+
75+
<LinearLayout
76+
android:layout_width="match_parent"
77+
android:layout_height="wrap_content"
78+
android:layout_gravity="center"
79+
android:foregroundGravity="center"
80+
android:gravity="center_horizontal"
81+
android:orientation="horizontal">
82+
83+
<TextView
84+
android:layout_width="match_parent"
85+
android:layout_height="wrap_content"
86+
android:layout_marginEnd="5sp"
87+
android:layout_weight="1"
88+
android:gravity="center_horizontal|end"
89+
android:text="@string/selected_language"
90+
android:textSize="20sp" />
91+
92+
<TextView
93+
android:id="@+id/language_name1"
94+
android:layout_width="match_parent"
95+
android:layout_height="wrap_content"
96+
android:layout_marginStart="5sp"
97+
android:layout_weight="1"
98+
android:gravity="start"
99+
android:textSize="20sp" />
100+
101+
</LinearLayout>
102+
103+
<FrameLayout
104+
android:layout_width="match_parent"
105+
android:layout_height="match_parent">
106+
107+
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
108+
android:id="@+id/swipe_to_refresh"
109+
android:layout_width="match_parent"
110+
android:layout_height="match_parent">
111+
112+
<ImageView
113+
android:id="@+id/source_image"
114+
android:layout_width="match_parent"
115+
android:layout_height="match_parent"
116+
android:contentDescription="@string/generic_image_description"
117+
android:scaleType="fitCenter"
118+
tools:src="@tools:sample/backgrounds/scenic" />
119+
120+
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
110121

111122
<com.google.android.material.floatingactionbutton.FloatingActionButton
112-
android:layout_height="wrap_content"
113-
android:layout_width="wrap_content"
114-
android:contentDescription="@string/generic_image_description"
115-
android:clickable="true"
116-
android:layout_margin="16dp"
117-
android:focusable="true"
118-
app:srcCompat="@drawable/ic_baseline_photo_library_24"
119-
android:id="@+id/btn_scan"
120-
android:layout_gravity="bottom|end" />
123+
android:id="@+id/btn_scan"
124+
android:layout_width="wrap_content"
125+
android:layout_height="wrap_content"
126+
android:layout_gravity="bottom|end"
127+
android:layout_margin="16dp"
128+
android:clickable="true"
129+
android:contentDescription="@string/generic_image_description"
130+
android:focusable="true"
131+
app:srcCompat="@drawable/ic_baseline_photo_library_24" />
121132

122133
</FrameLayout>
123134

0 commit comments

Comments
 (0)