Skip to content

Commit 5177788

Browse files
committed
Text Resizing
changed all sp to dp in order to ensure that user selected text size system-wide will not affect the UI of the app.
1 parent 08bcbe7 commit 5177788

File tree

15 files changed

+100
-123
lines changed

15 files changed

+100
-123
lines changed
Binary file not shown.
Binary file not shown.
50 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.

app/src/main/java/com/josh/trackcovid19v2/ui/yourworld/YourworldFragment.java

+27-50
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public void onRefresh() {
5151
Log.v("REFRESHING", "************** APP - SWIPE REFRESH EVENT TRIGGERED!!!!!");
5252
postRequest();
5353
new Handler().postDelayed(new Runnable() {
54-
@Override public void run() {
54+
@Override
55+
public void run() {
5556
// Stop animation (This will be after 3 seconds)
5657
mSwipeRefreshLayout.setRefreshing(false);
5758
}
@@ -110,17 +111,17 @@ public void onRefresh() {
110111
textView3.setText(Html.fromHtml("<b>" + recoveredWithCommas + "</b>"));
111112
textView5.setText(Html.fromHtml("<b>" + activeCasesWithCommas + "</b>"));
112113
textView6.setText(Html.fromHtml("<b><sup>" + affectedCountriesData + "</sup>" + "/<sub>251</sub></b>"));
113-
textView4.setText(Html.fromHtml("Updated on "+ date));
114+
textView4.setText(Html.fromHtml("Updated on " + date));
114115
ImageView img1 = view.findViewById(R.id.image_level);
115116
double recov = world.recovered;
116117
double tcases = world.cases;
117-
double percent = (recov/tcases)*100;
118+
double percent = (recov / tcases) * 100;
118119
String percentlegible = df.format(percent);
119120
textView123.setText(Html.fromHtml("<b><i>" + percentlegible + "%</i></b>"));
120121
Log.d("dfdF", String.valueOf(world.recovered));
121122
Log.d("dfdF", String.valueOf(world.cases));
122123
Log.d("dfdF", String.valueOf(percent));
123-
int x= (int)percent;
124+
int x = (int) percent;
124125
ClipDrawable drawable = (ClipDrawable) img1.getDrawable();
125126
drawable.setLevel(100 * x);
126127
}
@@ -146,41 +147,36 @@ public void onRefresh() {
146147
String dailyRecoveredWithCommas = numberFormat.format(recovered[0] - yRecovered[0]);
147148
Log.d("foo", "I got here");
148149

149-
if ((cases[0] - ycases[0]) >= 0){
150-
Spanned text = Html.fromHtml("<i>Daily Increment: " + "<b>" + "+" + dailyIncWithCommas + "</i></b>");
150+
if ((cases[0] - ycases[0]) >= 0) {
151+
Spanned text = Html.fromHtml("<i>Daily Increment: " + "<b>" + "+" + dailyIncWithCommas + "</i></b>");
151152
SpannableString ss = new SpannableString(text);
152153
ForegroundColorSpan fcsWhite = new ForegroundColorSpan(Color.WHITE);
153154
@SuppressLint("ResourceAsColor") ForegroundColorSpan fcsGreen = new ForegroundColorSpan(R.color.just_cuz);
154155
ss.setSpan(fcsWhite, 0, 16, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
155156
textView8.setText(ss);
156-
}
157-
else {
158-
Spanned text = Html.fromHtml("<i>Daily Increment: " + "<b>" + "-" + dailyIncWithCommas + "</i></b>"); SpannableString ss = new SpannableString(text);
157+
} else {
158+
Spanned text = Html.fromHtml("<i>Daily Increment: " + "<b>" + "-" + dailyIncWithCommas + "</i></b>");
159+
SpannableString ss = new SpannableString(text);
159160
ForegroundColorSpan fcsWhite = new ForegroundColorSpan(Color.WHITE);
160161
@SuppressLint("ResourceAsColor") ForegroundColorSpan fcsGreen = new ForegroundColorSpan(R.color.just_cuz);
161162
ss.setSpan(fcsWhite, 0, 16, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
162163
textView8.setText(ss);
163164
}
164-
if((ACases[0] - yACases[0]) >= 0){
165-
textView9.setText(Html.fromHtml("<b><i>" + "+" + dailyActWithCommas + "</i></b>"));
166-
}
167-
else {
168-
textView9.setText(Html.fromHtml("<b><i>" + "-" + dailyActWithCommas + "</i></b>"));
169-
}
170-
if((recovered[0] - yRecovered[0]) >= 0){
171-
textView10.setText(Html.fromHtml("<b><i>" + "+" + dailyRecoveredWithCommas + "</i></b>"));
165+
if ((ACases[0] - yACases[0]) >= 0) {
166+
textView9.setText(Html.fromHtml("<b><i>" + "+" + dailyActWithCommas + "</i></b>"));
167+
} else {
168+
textView9.setText(Html.fromHtml("<b><i>" + "-" + dailyActWithCommas + "</i></b>"));
172169
}
173-
else {
174-
textView10.setText(Html.fromHtml("<b><i>" + "-" + dailyRecoveredWithCommas + "</i></b>"));
170+
if ((recovered[0] - yRecovered[0]) >= 0) {
171+
textView10.setText(Html.fromHtml("<b><i>" + "+" + dailyRecoveredWithCommas + "</i></b>"));
172+
} else {
173+
textView10.setText(Html.fromHtml("<b><i>" + "-" + dailyRecoveredWithCommas + "</i></b>"));
175174
}
176-
if((Toddeaths[0] - yDeaths[0]) >= 0){
177-
textView11.setText(Html.fromHtml("<b><i>" + "+" + dailyDeathWithCommas + "</i></b>"));
175+
if ((Toddeaths[0] - yDeaths[0]) >= 0) {
176+
textView11.setText(Html.fromHtml("<b><i>" + "+" + dailyDeathWithCommas + "</i></b>"));
177+
} else {
178+
textView11.setText(Html.fromHtml("<b><i>" + "-" + dailyDeathWithCommas + "</i></b>"));
178179
}
179-
else {
180-
textView11.setText(Html.fromHtml("<b><i>" + "-" + dailyDeathWithCommas + "</i></b>"));
181-
}
182-
183-
184180

185181

186182
//setData(vYourworldViewModel,world);
@@ -209,37 +205,18 @@ private void postRequest() {
209205
vYourworldViewModel.postRequest(serviceRequest);
210206

211207
}
208+
212209
@SuppressWarnings("deprecation")
213-
public static Spanned fromHtml(String html){
214-
if(html == null){
210+
public static Spanned fromHtml(String html) {
211+
if (html == null) {
215212
// return an empty spannable if the html is null
216213
return new SpannableString("");
217-
}else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
214+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
218215
// FROM_HTML_MODE_LEGACY is the behaviour that was used for versions below android N
219216
// we are using this flag to give a consistent behaviour
220217
return Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
221218
} else {
222219
return Html.fromHtml(html);
223220
}
224221
}
225-
226-
}
227-
228-
229-
230-
231-
232-
233-
234-
235-
236-
237-
238-
239-
240-
241-
242-
243-
244-
245-
222+
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
android:layout_width="match_parent"
3535
android:layout_height="wrap_content"
3636
android:textColor="#423E3E"
37-
android:textSize="13sp"
37+
android:textSize="13dp"
3838
android:gravity="center"
3939
android:text="Sources: JHU, WHO, corona.lmao.ninja" />
4040
</LinearLayout>

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

+28-28
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
app:layout_constraintWidth_percent=".45"
2323
android:textAlignment="center"
2424
android:textColor="@color/unselected_header_background_color"
25-
android:textSize="20sp"
25+
android:textSize="20dp"
2626
app:layout_constraintEnd_toEndOf="@+id/text_affectedCountries"
2727
app:layout_constraintTop_toTopOf="@+id/text_totalTests" />
2828
<TextView
@@ -32,7 +32,7 @@
3232
android:fontFamily="sans-serif-light"
3333
android:gravity="end"
3434
android:textColor="#FFEB3B"
35-
android:textSize="20sp"
35+
android:textSize="20dp"
3636
app:layout_constraintBottom_toBottomOf="@+id/text_testsPerOneMillion"
3737
app:layout_constraintEnd_toEndOf="@+id/text_testsPerOneMillion"
3838
app:layout_constraintHorizontal_bias="0.734"
@@ -54,7 +54,7 @@
5454
app:layout_constraintWidth_percent=".45"
5555
android:textAlignment="center"
5656
android:textColor="@color/unselected_header_background_color"
57-
android:textSize="20sp"
57+
android:textSize="20dp"
5858
app:layout_constraintEnd_toEndOf="@+id/text_deaths"
5959
app:layout_constraintTop_toBottomOf="@+id/text_deaths" />
6060

@@ -66,7 +66,7 @@
6666
android:text="Total Tests"
6767
android:textAlignment="gravity"
6868
android:textColor="#2196F3"
69-
android:textSize="17sp"
69+
android:textSize="17dp"
7070
app:layout_constraintBottom_toBottomOf="@+id/text_totalTests"
7171
app:layout_constraintStart_toStartOf="@+id/text_activeCasesName6"
7272
app:layout_constraintTop_toTopOf="@+id/text_totalTests"
@@ -104,7 +104,7 @@
104104
android:gravity="center"
105105
android:textAlignment="center"
106106
android:textColor="@color/unselected_header_background_color"
107-
android:textSize="20sp"
107+
android:textSize="20dp"
108108
app:layout_constraintBottom_toBottomOf="parent"
109109
app:layout_constraintEnd_toEndOf="parent"
110110
app:layout_constraintStart_toStartOf="parent"
@@ -125,7 +125,7 @@
125125

126126
android:textAlignment="center"
127127
android:textColor="@color/unselected_header_background_color"
128-
android:textSize="20sp"
128+
android:textSize="20dp"
129129
app:layout_constraintEnd_toEndOf="@+id/text_totalCases"
130130
app:layout_constraintTop_toTopOf="@+id/text_activeCases"
131131
app:layout_constraintWidth_percent=".45"
@@ -142,7 +142,7 @@
142142
android:gravity="center"
143143
android:textAlignment="center"
144144
android:textColor="@color/unselected_header_background_color"
145-
android:textSize="20sp"
145+
android:textSize="20dp"
146146
app:layout_constraintBottom_toBottomOf="parent"
147147
app:layout_constraintStart_toStartOf="@+id/text_totalCases"
148148
app:layout_constraintTop_toBottomOf="@+id/text_totalCases"
@@ -162,7 +162,7 @@
162162

163163
android:textAlignment="center"
164164
android:textColor="@color/unselected_background_color"
165-
android:textSize="20sp"
165+
android:textSize="20dp"
166166
app:layout_constraintBottom_toBottomOf="parent"
167167
app:layout_constraintEnd_toEndOf="@+id/text_totalCases"
168168
app:layout_constraintTop_toTopOf="@+id/text_deaths"
@@ -185,7 +185,7 @@
185185

186186
android:textAlignment="center"
187187
android:textColor="@color/unselected_header_background_color"
188-
android:textSize="20sp"
188+
android:textSize="20dp"
189189
app:layout_constraintBottom_toBottomOf="parent"
190190
app:layout_constraintStart_toStartOf="@+id/text_totalCases"
191191
app:layout_constraintTop_toBottomOf="@+id/text_activeCases"
@@ -214,7 +214,7 @@
214214
android:gravity="start"
215215
android:text="@string/active_cases"
216216
android:textColor="#FFEB3B"
217-
android:textSize="17sp"
217+
android:textSize="17dp"
218218
app:layout_constraintBottom_toBottomOf="@+id/text_activeCases"
219219
app:layout_constraintStart_toStartOf="@+id/text_totalCasesName"
220220
app:layout_constraintTop_toTopOf="@+id/text_activeCases"
@@ -226,7 +226,7 @@
226226
android:layout_height="wrap_content"
227227
android:fontFamily="sans-serif-light"
228228
android:textColor="#44E372"
229-
android:textSize="30sp"
229+
android:textSize="30dp"
230230
app:layout_constraintBottom_toBottomOf="@+id/text_totalCases"
231231
app:layout_constraintEnd_toEndOf="@+id/text_totalCases"
232232
app:layout_constraintHorizontal_bias="0.87"
@@ -241,7 +241,7 @@
241241
android:fontFamily="sans-serif-light"
242242
android:gravity="end"
243243
android:textColor="#44E372"
244-
android:textSize="15sp"
244+
android:textSize="15dp"
245245
app:layout_constraintBottom_toBottomOf="@+id/text_totalCases"
246246
app:layout_constraintEnd_toEndOf="@+id/text_totalCases"
247247
app:layout_constraintHorizontal_bias="0.86"
@@ -257,7 +257,7 @@
257257
android:fontFamily="sans-serif-light"
258258
android:text="@string/total_confirmed_cases"
259259
android:textColor="#FFFFFF"
260-
android:textSize="20sp"
260+
android:textSize="20dp"
261261
app:layout_constraintBottom_toBottomOf="@+id/text_totalCases"
262262
app:layout_constraintEnd_toEndOf="@+id/text_totalCases"
263263
app:layout_constraintHorizontal_bias="0.2"
@@ -274,7 +274,7 @@
274274
android:text="@string/total_deceased"
275275
android:textAlignment="gravity"
276276
android:textColor="#ff0000"
277-
android:textSize="17sp"
277+
android:textSize="17dp"
278278
app:layout_constraintBottom_toBottomOf="@+id/text_deaths"
279279
app:layout_constraintStart_toStartOf="@+id/text_activeCasesName"
280280
app:layout_constraintTop_toTopOf="@+id/text_deaths"
@@ -288,7 +288,7 @@
288288
android:text="Tests Per Million"
289289
android:textAlignment="gravity"
290290
android:textColor="#FFEB3B"
291-
android:textSize="13sp"
291+
android:textSize="13dp"
292292
app:layout_constraintBottom_toBottomOf="@+id/text_testsPerOneMillion"
293293
app:layout_constraintStart_toStartOf="@+id/text_RecoveredName"
294294
app:layout_constraintTop_toTopOf="@+id/text_testsPerOneMillion"
@@ -302,7 +302,7 @@
302302
android:gravity="start"
303303
android:text="@string/recoveredName"
304304
android:textColor="#ffffff"
305-
android:textSize="17sp"
305+
android:textSize="17dp"
306306
app:layout_constraintBottom_toBottomOf="@+id/text_affectedCountries"
307307
app:layout_constraintStart_toStartOf="@+id/text_CriticalName"
308308
app:layout_constraintTop_toTopOf="@+id/text_affectedCountries"
@@ -315,7 +315,7 @@
315315
android:layout_marginTop="10dp"
316316
android:gravity="center"
317317
android:textColor="#000000"
318-
android:textSize="15sp"
318+
android:textSize="15dp"
319319
app:layout_constraintEnd_toEndOf="parent"
320320
app:layout_constraintHorizontal_bias="0.5"
321321
app:layout_constraintStart_toStartOf="parent"
@@ -330,7 +330,7 @@
330330
android:gravity="end"
331331
android:textAlignment="center"
332332
android:textColor="#4CAF50"
333-
android:textSize="20sp"
333+
android:textSize="20dp"
334334
app:layout_constraintBottom_toBottomOf="@+id/text_recovered"
335335
app:layout_constraintEnd_toEndOf="@+id/text_totalCasesData"
336336
app:layout_constraintTop_toTopOf="@+id/text_recovered"
@@ -346,7 +346,7 @@
346346
android:text="@string/critical"
347347
android:textAlignment="center"
348348
android:textColor="#4CAF50"
349-
android:textSize="17sp"
349+
android:textSize="17dp"
350350
app:layout_constraintBottom_toBottomOf="@+id/text_recovered"
351351
app:layout_constraintEnd_toEndOf="@+id/text_recovered"
352352
app:layout_constraintHorizontal_bias="0.2"
@@ -362,7 +362,7 @@
362362
android:fontFamily="sans-serif-light"
363363
android:gravity="end"
364364
android:textColor="#ff0000"
365-
android:textSize="20sp"
365+
android:textSize="20dp"
366366
app:layout_constraintBottom_toBottomOf="@+id/text_deaths"
367367
app:layout_constraintEnd_toEndOf="@+id/text_deaths"
368368
app:layout_constraintHorizontal_bias="0.734"
@@ -377,7 +377,7 @@
377377
android:fontFamily="sans-serif-light"
378378
android:gravity="end"
379379
android:textColor="#FFEB3B"
380-
android:textSize="15sp"
380+
android:textSize="15dp"
381381
app:layout_constraintBottom_toBottomOf="@+id/text_activeCases"
382382
app:layout_constraintEnd_toEndOf="@+id/text_activeCases"
383383
app:layout_constraintHorizontal_bias="0.8"
@@ -392,7 +392,7 @@
392392
android:fontFamily="sans-serif-light"
393393
android:gravity="end"
394394
android:textColor="#ff0000"
395-
android:textSize="15sp"
395+
android:textSize="15dp"
396396
app:layout_constraintBottom_toBottomOf="@+id/text_deaths"
397397
app:layout_constraintEnd_toEndOf="@+id/text_deaths"
398398
app:layout_constraintHorizontal_bias="0.8"
@@ -407,7 +407,7 @@
407407
android:fontFamily="sans-serif-light"
408408
android:gravity="end"
409409
android:textColor="#2196F3"
410-
android:textSize="20sp"
410+
android:textSize="20dp"
411411
app:layout_constraintBottom_toBottomOf="@+id/text_totalTests"
412412
app:layout_constraintEnd_toEndOf="@+id/text_totalTests"
413413
app:layout_constraintHorizontal_bias="0.734"
@@ -421,7 +421,7 @@
421421
android:layout_height="wrap_content"
422422
android:gravity="end"
423423
android:textColor="#4CAF50"
424-
android:textSize="15sp"
424+
android:textSize="15dp"
425425
app:layout_constraintBottom_toBottomOf="@+id/text_recovered"
426426
app:layout_constraintEnd_toEndOf="@+id/text_recovered"
427427
app:layout_constraintHorizontal_bias=".8"
@@ -437,7 +437,7 @@
437437
android:fontFamily="sans-serif-light"
438438
android:gravity="end"
439439
android:textColor="#FFEB3B"
440-
android:textSize="20sp"
440+
android:textSize="20dp"
441441
app:layout_constraintBottom_toBottomOf="@+id/text_activeCases"
442442
app:layout_constraintEnd_toEndOf="@+id/text_activeCases"
443443
app:layout_constraintHorizontal_bias="0.734"
@@ -450,7 +450,7 @@
450450
android:layout_width="wrap_content"
451451
android:layout_height="wrap_content"
452452
android:textColor="@android:color/white"
453-
android:textSize="20sp"
453+
android:textSize="20dp"
454454
app:layout_constraintBottom_toBottomOf="@+id/text_affectedCountries"
455455
app:layout_constraintEnd_toEndOf="@+id/text_CriticalData"
456456
app:layout_constraintTop_toTopOf="@+id/text_affectedCountries"
@@ -463,7 +463,7 @@
463463
android:fontFamily="sans-serif-light"
464464
android:gravity="start"
465465
android:textColor="#ffffff"
466-
android:textSize="15sp"
466+
android:textSize="15dp"
467467
app:layout_constraintBottom_toBottomOf="@+id/text_affectedCountries"
468468
app:layout_constraintEnd_toEndOf="@+id/text_affectedCountries"
469469
app:layout_constraintHorizontal_bias="0.8"
@@ -477,7 +477,7 @@
477477
android:layout_marginBottom="10dp"
478478
android:gravity="center"
479479
android:textAlignment="center"
480-
android:textSize="15sp"
480+
android:textSize="15dp"
481481
app:layout_constraintBottom_toBottomOf="parent"
482482
app:layout_constraintEnd_toEndOf="parent"
483483
app:layout_constraintHorizontal_bias="0.5"

0 commit comments

Comments
 (0)