Skip to content

Commit eeaa9a9

Browse files
Merge branch 'master' into feat5
2 parents fc8b522 + 1db1715 commit eeaa9a9

19 files changed

+767
-185
lines changed

app/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ dependencies {
1818
implementation 'com.google.code.gson:gson:2.8.1'
1919
implementation 'com.jakewharton.timber:timber:4.5.1'
2020
implementation 'info.debatty:java-string-similarity:0.24'
21-
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.1@aar'){
21+
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.4.1@aar'){
2222
transitive=true
2323
}
2424

2525

2626
implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION"
2727
implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION"
2828
implementation "com.android.support:design:$SUPPORT_LIB_VERSION"
29+
implementation "com.android.support:customtabs:$SUPPORT_LIB_VERSION"
2930

3031
implementation "com.android.support:cardview-v7:$SUPPORT_LIB_VERSION"
3132

@@ -48,7 +49,7 @@ dependencies {
4849
compile 'com.facebook.stetho:stetho:1.5.0'
4950

5051
testCompile 'junit:junit:4.12'
51-
testCompile 'org.robolectric:robolectric:3.4'
52+
testCompile 'org.robolectric:robolectric:3.7.1'
5253

5354
testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
5455
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
@@ -77,7 +78,7 @@ dependencies {
7778
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
7879

7980
testImplementation 'junit:junit:4.12'
80-
testImplementation 'org.robolectric:robolectric:3.4'
81+
testImplementation 'org.robolectric:robolectric:3.7.1'
8182
testImplementation 'org.mockito:mockito-all:1.10.19'
8283

8384
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.content.Intent;
44
import android.net.Uri;
55
import android.os.Bundle;
6+
import android.support.customtabs.CustomTabsIntent;
7+
import android.support.v4.content.ContextCompat;
68
import android.view.View;
79
import android.widget.TextView;
810

@@ -47,28 +49,28 @@ public void launchFacebook(View view) {
4749
intent.setPackage("com.facebook.katana");
4850
startActivity(intent);
4951
} catch (Exception e) {
50-
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + "1921335171459985")));
52+
Utils.handleWebUrl(this,Uri.parse("https://www.facebook.com/" + "1921335171459985"));
5153
}
52-
5354
}
5455

5556
@OnClick(R.id.github_launch_icon)
5657
public void launchGithub(View view) {
57-
58-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/commons-app/apps-android-commons\\"));
59-
startActivity(browserIntent);
58+
Utils.handleWebUrl(this,Uri.parse("https://commons-app.github.io/\\"));
6059
}
6160

6261
@OnClick(R.id.website_launch_icon)
6362
public void launchWebsite(View view) {
64-
65-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://commons-app.github.io/\\"));
66-
startActivity(browserIntent);
63+
Utils.handleWebUrl(this,Uri.parse("https://commons-app.github.io/\\"));
6764
}
6865

69-
@OnClick(R.id.about_rate_us)
70-
public void rateApp(View view) {
66+
@OnClick(R.id.about_credits)
67+
public void launchCredits(View view) {
68+
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/blob/master/CREDITS/\\"));
69+
}
7170

72-
Utils.rateApp(this);
71+
@OnClick(R.id.about_privacy_policy)
72+
public void launchPrivacyPolicy(View view) {
73+
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Privacy-policy\\"));
7374
}
75+
7476
}

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import android.net.Uri;
66
import android.preference.PreferenceManager;
77
import android.support.annotation.NonNull;
8+
import android.support.customtabs.CustomTabsIntent;
9+
import android.support.v4.content.ContextCompat;
810

911
import org.apache.commons.codec.binary.Hex;
1012
import org.apache.commons.codec.digest.DigestUtils;
@@ -13,6 +15,7 @@
1315
import java.io.IOException;
1416
import java.io.InputStreamReader;
1517
import java.io.UnsupportedEncodingException;
18+
import java.net.URL;
1619
import java.net.URLEncoder;
1720
import java.util.Locale;
1821
import java.util.regex.Matcher;
@@ -172,4 +175,15 @@ public static void rateApp(Context context) {
172175
}
173176
return ;
174177
}
175-
}
178+
179+
public static void handleWebUrl(Context context,Uri url){
180+
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
181+
builder.setToolbarColor(ContextCompat.getColor(context, R.color.primaryColor));
182+
builder.setSecondaryToolbarColor(ContextCompat.getColor(context, R.color.primaryDarkColor));
183+
builder.setExitAnimations(context, android.R.anim.slide_in_left, android.R.anim.slide_out_right);
184+
CustomTabsIntent customTabsIntent = builder.build();
185+
customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
186+
customTabsIntent.launchUrl(context, url);
187+
}
188+
189+
}

app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
7272
@BindView(R.id.loginTwoFactor) EditText twoFactorEdit;
7373
@BindView(R.id.error_message_container) ViewGroup errorMessageContainer;
7474
@BindView(R.id.error_message) TextView errorMessage;
75+
@BindView(R.id.login_credentials) TextView loginCredentials;
7576
@BindView(R.id.two_factor_container)TextInputLayout twoFactorContainer;
7677
ProgressDialog progressDialog;
7778
private AppCompatDelegate delegate;
@@ -112,6 +113,12 @@ public void onCreate(Bundle savedInstanceState) {
112113

113114
loginButton.setOnClickListener(view -> performLogin());
114115
signupButton.setOnClickListener(view -> signUp());
116+
117+
if(BuildConfig.FLAVOR == "beta"){
118+
loginCredentials.setText(getString(R.string.login_credential));
119+
} else {
120+
loginCredentials.setVisibility(View.GONE);
121+
}
115122
}
116123

117124

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import android.content.Intent;
44
import android.net.Uri;
55
import android.os.Bundle;
6+
import android.support.customtabs.CustomTabsIntent;
67
import android.support.v4.app.FragmentActivity;
8+
import android.support.v4.content.ContextCompat;
79
import android.support.v7.widget.PopupMenu;
810
import android.view.LayoutInflater;
911
import android.view.MenuItem;
@@ -17,6 +19,7 @@
1719
import butterknife.OnClick;
1820
import butterknife.Unbinder;
1921
import fr.free.nrw.commons.R;
22+
import fr.free.nrw.commons.Utils;
2023
import fr.free.nrw.commons.location.LatLng;
2124
import fr.free.nrw.commons.ui.widget.OverlayDialog;
2225
import fr.free.nrw.commons.utils.DialogUtil;
@@ -141,8 +144,7 @@ void onReadArticleClick() {
141144
}
142145

143146
private void openWebView(Uri link) {
144-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, link);
145-
startActivity(browserIntent);
147+
Utils.handleWebUrl(getContext(),link);
146148
}
147149

148150
@OnClick(R.id.emptyLayout)

app/src/main/java/fr/free/nrw/commons/notification/NotificationActivity.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
import android.content.Intent;
66
import android.net.Uri;
77
import android.os.Bundle;
8+
import android.support.v7.widget.DividerItemDecoration;
89
import android.support.v7.widget.LinearLayoutManager;
910
import android.support.v7.widget.RecyclerView;
1011

1112
import com.pedrogomez.renderers.RVRendererAdapter;
1213

14+
import java.util.Collections;
1315
import java.util.List;
1416

1517
import javax.inject.Inject;
@@ -45,8 +47,9 @@ protected void onCreate(Bundle savedInstanceState) {
4547
}
4648

4749
private void initListView() {
48-
recyclerView = findViewById(R.id.listView);
4950
recyclerView.setLayoutManager(new LinearLayoutManager(this));
51+
DividerItemDecoration itemDecor = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL);
52+
recyclerView.addItemDecoration(itemDecor);
5053
addNotifications();
5154
}
5255

@@ -58,6 +61,7 @@ private void addNotifications() {
5861
.subscribeOn(Schedulers.io())
5962
.observeOn(AndroidSchedulers.mainThread())
6063
.subscribe(notificationList -> {
64+
Collections.reverse(notificationList);
6165
Timber.d("Number of notifications is %d", notificationList.size());
6266
setAdapter(notificationList);
6367
}, throwable -> Timber.e(throwable, "Error occurred while loading notifications"));

app/src/main/java/fr/free/nrw/commons/theme/NavigationBaseActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
121121
return true;
122122
case R.id.action_feedback:
123123
drawerLayout.closeDrawer(navigationView);
124-
Intent feedbackIntent = new Intent(Intent.ACTION_SEND);
124+
Intent feedbackIntent = new Intent(Intent.ACTION_SENDTO);
125125
feedbackIntent.setType("message/rfc822");
126+
feedbackIntent.setData(Uri.parse("mailto:"));
126127
feedbackIntent.putExtra(Intent.EXTRA_EMAIL,
127128
new String[]{CommonsApplication.FEEDBACK_EMAIL});
128129
feedbackIntent.putExtra(Intent.EXTRA_SUBJECT,

app/src/main/res/layout-land/activity_login.xml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
<android.support.v7.widget.CardView
1414
android:layout_width="match_parent"
1515
android:layout_height="wrap_content"
16-
android:layout_marginTop="@dimen/large_gap"
1716
android:layout_marginBottom="@dimen/standard_gap"
1817
android:layout_marginEnd="@dimen/standard_gap"
1918
android:layout_marginLeft="@dimen/standard_gap"
2019
android:layout_marginRight="@dimen/standard_gap"
2120
android:layout_marginStart="@dimen/standard_gap"
21+
android:layout_marginTop="@dimen/large_gap"
2222
app:cardCornerRadius="4dp"
2323
app:cardElevation="4dp">
2424

@@ -40,11 +40,26 @@
4040
android:textColor="@android:color/white"
4141
android:textSize="@dimen/heading_text_size" />
4242

43+
<TextView
44+
android:id="@+id/login_credentials"
45+
android:layout_width="match_parent"
46+
android:layout_height="wrap_content"
47+
android:layout_below="@id/title"
48+
android:layout_marginEnd="@dimen/standard_gap"
49+
android:layout_marginLeft="@dimen/standard_gap"
50+
android:layout_marginRight="@dimen/standard_gap"
51+
android:layout_marginStart="@dimen/standard_gap"
52+
android:paddingBottom="@dimen/standard_gap"
53+
android:paddingTop="@dimen/small_gap"
54+
android:textAlignment="center"
55+
android:textColor="@color/secondaryDarkColor"
56+
tools:text="@string/login_credential" />
57+
4358
<FrameLayout
4459
android:id="@+id/error_message_container"
4560
android:layout_width="match_parent"
4661
android:layout_height="wrap_content"
47-
android:layout_below="@id/title"
62+
android:layout_below="@id/login_credentials"
4863
android:visibility="gone"
4964
tools:visibility="visible">
5065

@@ -56,6 +71,7 @@
5671
android:layout_marginLeft="@dimen/standard_gap"
5772
android:layout_marginRight="@dimen/standard_gap"
5873
android:layout_marginStart="@dimen/standard_gap"
74+
android:gravity="center"
5975
android:paddingBottom="@dimen/small_gap"
6076
android:paddingTop="@dimen/small_gap"
6177
android:textColor="@color/secondaryDarkColor"
@@ -149,8 +165,8 @@
149165

150166
<Button
151167
android:id="@+id/signupButton"
152-
android:layout_width="0dp"
153168
style="@style/Widget.AppCompat.Button.Borderless.Colored"
169+
android:layout_width="0dp"
154170
android:layout_height="wrap_content"
155171
android:layout_gravity="center_horizontal"
156172
android:layout_marginEnd="@dimen/small_gap"
@@ -160,8 +176,8 @@
160176

161177
<Button
162178
android:id="@+id/loginButton"
163-
android:layout_width="0dp"
164179
style="@style/Widget.AppCompat.Button.Colored"
180+
android:layout_width="0dp"
165181
android:layout_height="wrap_content"
166182
android:layout_marginLeft="@dimen/small_gap"
167183
android:layout_marginStart="@dimen/small_gap"
@@ -174,33 +190,33 @@
174190
<fr.free.nrw.commons.ui.widget.HtmlTextView
175191
android:id="@+id/about_privacy_policy"
176192
style="?android:textAppearanceSmall"
177-
android:layout_below="@id/buttonFrame"
178193
android:layout_width="wrap_content"
179194
android:layout_height="wrap_content"
180-
android:layout_marginBottom="@dimen/standard_gap"
195+
android:layout_below="@id/buttonFrame"
196+
android:layout_centerHorizontal="true"
181197
android:layout_gravity="center_horizontal"
182-
android:text="@string/about_privacy_policy"
183-
android:layout_centerHorizontal="true"/>
198+
android:layout_marginBottom="@dimen/standard_gap"
199+
android:text="@string/about_privacy_policy" />
184200

185201
</RelativeLayout>
186202
</android.support.v7.widget.CardView>
187203

188204
<android.support.v7.widget.AppCompatImageView
189205
android:layout_width="64dp"
190206
android:layout_height="64dp"
191-
android:elevation="8dp"
192-
tools:ignore="UnusedAttribute"
193207
android:layout_gravity="center_horizontal"
194-
app:srcCompat="@drawable/blue_rinse_circle" />
208+
android:elevation="8dp"
209+
app:srcCompat="@drawable/blue_rinse_circle"
210+
tools:ignore="UnusedAttribute" />
195211

196212
<android.support.v7.widget.AppCompatImageView
197213
android:layout_width="42dp"
198-
tools:ignore="UnusedAttribute"
199214
android:layout_height="42dp"
200215
android:layout_gravity="center_horizontal"
201216
android:layout_marginTop="8dp"
202217
android:elevation="8dp"
203-
app:srcCompat="@drawable/commons_logo_large" />
218+
app:srcCompat="@drawable/commons_logo_large"
219+
tools:ignore="UnusedAttribute" />
204220

205221
</FrameLayout>
206222

0 commit comments

Comments
 (0)