Skip to content

Commit c6410c2

Browse files
committed
2 parents f8f3c92 + a927a80 commit c6410c2

File tree

7 files changed

+62
-284
lines changed

7 files changed

+62
-284
lines changed

app/src/main/java/fr/free/nrw/commons/AboutActivity.java

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.Intent;
77
import android.net.Uri;
88
import android.os.Bundle;
9+
import android.text.Html;
910
import android.text.SpannableString;
1011
import android.text.style.UnderlineSpan;
1112
import android.util.Log;
@@ -62,6 +63,18 @@ public void onCreate(Bundle savedInstanceState) {
6263
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
6364
faqText.setText(content);
6465
versionText.setText(BuildConfig.VERSION_NAME);
66+
TextView rate_us = findViewById(R.id.about_rate_us);
67+
TextView privacy_policy = findViewById(R.id.about_privacy_policy);
68+
TextView translate = findViewById(R.id.about_translate);
69+
TextView credits = findViewById(R.id.about_credits);
70+
TextView faq = findViewById(R.id.about_faq);
71+
72+
rate_us.setText(Html.fromHtml(getString(R.string.about_rate_us)));
73+
privacy_policy.setText(Html.fromHtml(getString(R.string.about_privacy_policy)));
74+
translate.setText(Html.fromHtml(getString(R.string.about_translate)));
75+
credits.setText(Html.fromHtml(getString(R.string.about_credits)));
76+
faq.setText(Html.fromHtml(getString(R.string.about_faq)));
77+
6578
initDrawer();
6679
}
6780

app/src/main/java/fr/free/nrw/commons/nearby/NearbyController.java

+38-32
Original file line numberDiff line numberDiff line change
@@ -54,41 +54,47 @@ public NearbyPlacesInfo loadAttractionsFromLocation(LatLng curLatLng) {
5454
}
5555
List<Place> places = nearbyPlaces.getFromWikidataQuery(curLatLng, Locale.getDefault().getLanguage());
5656

57-
LatLng[] boundaryCoordinates = {places.get(0).location, // south
58-
places.get(0).location, // north
59-
places.get(0).location, // west
60-
places.get(0).location};// east, init with a random location
61-
62-
if (curLatLng != null) {
63-
Timber.d("Sorting places by distance...");
64-
final Map<Place, Double> distances = new HashMap<>();
65-
for (Place place: places) {
66-
distances.put(place, computeDistanceBetween(place.location, curLatLng));
67-
// Find boundaries with basic find max approach
68-
if (place.location.getLatitude() < boundaryCoordinates[0].getLatitude()) {
69-
boundaryCoordinates[0] = place.location;
70-
}
71-
if (place.location.getLatitude() > boundaryCoordinates[1].getLatitude()) {
72-
boundaryCoordinates[1] = place.location;
73-
}
74-
if (place.location.getLongitude() < boundaryCoordinates[2].getLongitude()) {
75-
boundaryCoordinates[2] = place.location;
76-
}
77-
if (place.location.getLongitude() > boundaryCoordinates[3].getLongitude()) {
78-
boundaryCoordinates[3] = place.location;
57+
if (places.size() > 0) {
58+
LatLng[] boundaryCoordinates = {places.get(0).location, // south
59+
places.get(0).location, // north
60+
places.get(0).location, // west
61+
places.get(0).location};// east, init with a random location
62+
63+
64+
if (curLatLng != null) {
65+
Timber.d("Sorting places by distance...");
66+
final Map<Place, Double> distances = new HashMap<>();
67+
for (Place place : places) {
68+
distances.put(place, computeDistanceBetween(place.location, curLatLng));
69+
// Find boundaries with basic find max approach
70+
if (place.location.getLatitude() < boundaryCoordinates[0].getLatitude()) {
71+
boundaryCoordinates[0] = place.location;
72+
}
73+
if (place.location.getLatitude() > boundaryCoordinates[1].getLatitude()) {
74+
boundaryCoordinates[1] = place.location;
75+
}
76+
if (place.location.getLongitude() < boundaryCoordinates[2].getLongitude()) {
77+
boundaryCoordinates[2] = place.location;
78+
}
79+
if (place.location.getLongitude() > boundaryCoordinates[3].getLongitude()) {
80+
boundaryCoordinates[3] = place.location;
81+
}
7982
}
83+
Collections.sort(places,
84+
(lhs, rhs) -> {
85+
double lhsDistance = distances.get(lhs);
86+
double rhsDistance = distances.get(rhs);
87+
return (int) (lhsDistance - rhsDistance);
88+
}
89+
);
8090
}
81-
Collections.sort(places,
82-
(lhs, rhs) -> {
83-
double lhsDistance = distances.get(lhs);
84-
double rhsDistance = distances.get(rhs);
85-
return (int) (lhsDistance - rhsDistance);
86-
}
87-
);
91+
nearbyPlacesInfo.placeList = places;
92+
nearbyPlacesInfo.boundaryCoordinates = boundaryCoordinates;
93+
return nearbyPlacesInfo;
94+
}
95+
else {
96+
return null;
8897
}
89-
nearbyPlacesInfo.placeList = places;
90-
nearbyPlacesInfo.boundaryCoordinates = boundaryCoordinates;
91-
return nearbyPlacesInfo;
9298
}
9399

94100
/**

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
android:layout_marginTop="@dimen/standard_gap"
112112
android:gravity="center"
113113
android:textColor="@color/primaryColor"
114-
android:text="@string/about_rate_us" />
114+
/>
115115

116116
<TextView
117117
android:id="@+id/about_privacy_policy"
@@ -121,7 +121,7 @@
121121
android:layout_marginTop="@dimen/standard_gap"
122122
android:textColor="@color/primaryColor"
123123
android:gravity="center"
124-
android:text="@string/about_privacy_policy" />
124+
/>
125125

126126
<TextView
127127
android:id="@+id/about_translate"
@@ -131,7 +131,7 @@
131131
android:textColor="@color/primaryColor"
132132
android:layout_marginTop="@dimen/standard_gap"
133133
android:gravity="center"
134-
android:text="@string/about_translate" />
134+
/>
135135

136136
<TextView
137137
android:id="@+id/about_credits"
@@ -141,7 +141,7 @@
141141
android:textColor="@color/primaryColor"
142142
android:layout_marginTop="@dimen/standard_gap"
143143
android:gravity="center"
144-
android:text="@string/about_credits" />
144+
/>
145145

146146
<TextView
147147
android:id="@+id/about_faq"

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

+2-21
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
android:layout_width="match_parent"
66
android:layout_height="match_parent">
77

8-
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
8+
<android.support.design.widget.CoordinatorLayout
99
xmlns:app="http://schemas.android.com/apk/res-auto"
1010
android:id="@+id/coordinator_layout"
1111
android:layout_width="match_parent"
@@ -39,32 +39,13 @@
3939
android:layout_width="match_parent"
4040
android:layout_height="match_parent" />
4141
</LinearLayout>
42-
<android.support.design.widget.FloatingActionButton
43-
android:id="@+id/fab_list"
44-
android:layout_width="wrap_content"
45-
android:layout_height="wrap_content"
46-
app:fabSize="mini"
47-
android:layout_alignBottom="@id/toolbar"
48-
android:layout_alignParentRight="true"
49-
android:layout_marginRight="28dp"
50-
android:layout_marginBottom="-96dp"
51-
android:visibility="invisible"
52-
app:elevation="6dp"
53-
app:pressedTranslationZ="12dp"
54-
app:backgroundTint="@color/button_blue"
55-
android:clickable="true"
56-
app:srcCompat="@drawable/ic_list_white_24dp"
57-
android:scaleType="center"
58-
/>
5942

6043
<View
6144
android:id="@+id/transparentView"
6245
android:layout_width="match_parent"
6346
android:layout_height="match_parent"
6447
android:layout_alignParentLeft="true"
65-
android:layout_alignParentStart="true"
66-
android:layout_alignParentTop="true"
67-
android:layout_marginTop="18dp"
48+
android:layout_below="@id/toolbar"
6849
android:background="#aa969696"
6950
android:elevation="6dp">
7051

app/src/main/res/values/strings.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
<string name="about_license">The Wikimedia Commons app is an open-source app created and maintained by grantees and volunteers of the Wikimedia community. The Wikimedia Foundation is not involved in the creation, development, or maintenance of the app. </string>
8787
<string name="trademarked_name" translatable="false">Wikimedia Commons</string>
8888
<string name="about_improve">Create a new &lt;a href=\"https://github.com/commons-app/apps-android-commons/issues\"&gt;GitHub issue&lt;/a&gt; for bug reports and suggestions.</string>
89-
<string name="about_privacy_policy"><u>Privacy policy</u></string>
90-
<string name="about_credits"><u>Credits</u></string>
89+
<string name="about_privacy_policy"><![CDATA[<u>Privacy policy</u>]]></string>
90+
<string name="about_credits"><![CDATA[<u>Credits</u>]]></string>
9191
<string name="title_activity_about">About</string>
9292
<string name="menu_feedback">Send Feedback (via Email)</string>
9393
<string name="no_email_client">No email client installed</string>
@@ -253,16 +253,16 @@
253253
<string name="nearby_wikipedia">WIKIPEDIA</string>
254254
<string name="nearby_commons">COMMONS</string>
255255

256-
<string name="about_rate_us"><u>Rate us</u></string>
257-
<string name="about_faq">FAQ</string>
256+
<string name="about_rate_us"><![CDATA[<u>Rate us</u>]]></string>
257+
<string name="about_faq"><![CDATA[<u>FAQ</u>]]></string>
258258
<string name="welcome_skip_button">Skip Tutorial</string>
259259

260260
<string name="no_internet">Internet unavailable</string>
261261
<string name="internet_established">Internet available</string>
262262
<string name="error_notifications">Error fetching notifications</string>
263263
<string name="no_notifications">No notifications found</string>
264264

265-
<string name="about_translate"><u>Translate</u></string>
265+
<string name="about_translate"><![CDATA[<u>Translate</u>]]></string>
266266
<string name="about_translate_title">Languages</string>
267267
<string name="about_translate_message">Select the language that you would like to submit translations for</string>
268268
<string name="about_translate_proceed">Proceed</string>

app/src/test/java/fr/free/nrw/commons/nearby/NearbyActivityTest.java

-93
This file was deleted.

0 commit comments

Comments
 (0)