Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions app/src/main/java/fr/free/nrw/commons/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,14 @@ public void launchTranslate(View view) {
builder.setView(spinner);
builder.setTitle(R.string.about_translate_title)
.setMessage(R.string.about_translate_message)
.setPositiveButton(R.string.about_translate_proceed, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String languageSelected = spinner.getSelectedItem().toString();
TokensTranslations tokensTranslations = new TokensTranslations();
tokensTranslations.initailize();
String token = tokensTranslations.getTranslationToken(languageSelected);
Utils.handleWebUrl(AboutActivity.this,Uri.parse("https://translatewiki.net/w/i.php?title=Special:Translate&language="+token+"&group=commons-android-strings&filter=%21translated&action=translate ?"));
}
.setPositiveButton(R.string.about_translate_proceed, (dialog, which) -> {
String languageSelected = spinner.getSelectedItem().toString();
TokensTranslations tokensTranslations = new TokensTranslations();
tokensTranslations.initailize();
String token = tokensTranslations.getTranslationToken(languageSelected);
Utils.handleWebUrl(AboutActivity.this,Uri.parse("https://translatewiki.net/w/i.php?title=Special:Translate&language="+token+"&group=commons-android-strings&filter=%21translated&action=translate ?"));
});
builder.setNegativeButton(R.string.about_translate_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
builder.setNegativeButton(R.string.about_translate_cancel, (dialog, which) -> finish());
builder.create().show();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ protected void showBlockStatus()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.filter(result -> result)
.subscribe(result -> {
ViewUtil.showSnackbar(findViewById(android.R.id.content), R.string.block_notification);
}
.subscribe(result -> ViewUtil.showSnackbar(findViewById(android.R.id.content), R.string.block_notification)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,20 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
View rootView = inflater.inflate(R.layout.fragment_search_history, container, false);
ButterKnife.bind(this, rootView);
recentSearches = recentSearchesDao.recentSearches(10);
recent_searches_delete_button.setOnClickListener(v -> {
new AlertDialog.Builder(getContext())
.setMessage(getString(R.string.delete_recent_searches_dialog))
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
recentSearchesDao.deleteAll(recentSearches);
Toast.makeText(getContext(),getString(R.string.search_history_deleted),Toast.LENGTH_SHORT).show();
recentSearches = recentSearchesDao.recentSearches(10);
adapter = new ArrayAdapter<String>(getContext(),R.layout.item_recent_searches, recentSearches);
recentSearchesList.setAdapter(adapter);
adapter.notifyDataSetChanged();
dialog.dismiss();
})
.setNegativeButton(android.R.string.no, null)
.create()
.show();
});
recent_searches_delete_button.setOnClickListener(v -> new AlertDialog.Builder(getContext())
.setMessage(getString(R.string.delete_recent_searches_dialog))
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
recentSearchesDao.deleteAll(recentSearches);
Toast.makeText(getContext(),getString(R.string.search_history_deleted),Toast.LENGTH_SHORT).show();
recentSearches = recentSearchesDao.recentSearches(10);
adapter = new ArrayAdapter<String>(getContext(),R.layout.item_recent_searches, recentSearches);
recentSearchesList.setAdapter(adapter);
adapter.notifyDataSetChanged();
dialog.dismiss();
})
.setNegativeButton(android.R.string.no, null)
.create()
.show());
adapter = new ArrayAdapter<String>(getContext(),R.layout.item_recent_searches, recentSearches);
recentSearchesList.setAdapter(adapter);
recentSearchesList.setOnItemClickListener((parent, view, position, id) -> (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,17 +377,13 @@ public void onDeleteButtonClicked(){
final EditText input = new EditText(getActivity());
alert.setView(input);
input.requestFocus();
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String reason = input.getText().toString();
DeleteTask deleteTask = new DeleteTask(getActivity(), media, reason);
deleteTask.execute();
enableDeleteButton(false);
}
alert.setPositiveButton(R.string.ok, (dialog, whichButton) -> {
String reason = input.getText().toString();
DeleteTask deleteTask = new DeleteTask(getActivity(), media, reason);
deleteTask.execute();
enableDeleteButton(false);
});
alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
alert.setNegativeButton(R.string.cancel, (dialog, whichButton) -> {
});
AlertDialog d = alert.create();
input.addTextChangedListener(new TextWatcher() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,10 @@ private void setupMapView(Bundle savedInstanceState) {
// create map
mapView = new MapView(getActivity(), options);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
((NearbyActivity)getActivity()).setMapViewTutorialShowCase();
NearbyMapFragment.this.mapboxMap = mapboxMap;
updateMapSignificantly();
}
mapView.getMapAsync(mapboxMap -> {
((NearbyActivity)getActivity()).setMapViewTutorialShowCase();
NearbyMapFragment.this.mapboxMap = mapboxMap;
updateMapSignificantly();
});
mapView.setStyleUrl("asset://mapstyle.json");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ private void refresh() {
if (!NetworkUtils.isInternetConnectionEstablished(this)) {
progressBar.setVisibility(View.GONE);
Snackbar.make(relativeLayout , R.string.no_internet, Snackbar.LENGTH_INDEFINITE)
.setAction(R.string.retry, view -> {
refresh();
}).show();
.setAction(R.string.retry, view -> refresh()).show();
}else {
progressBar.setVisibility(View.VISIBLE);
addNotifications();
Expand Down
48 changes: 16 additions & 32 deletions app/src/main/java/fr/free/nrw/commons/quiz/QuizActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ public void setNextQuestion(){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(getResources().getString(R.string.warning));
alert.setMessage(getResources().getString(R.string.warning_for_no_answer));
alert.setPositiveButton(R.string.continue_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alert.setPositiveButton(R.string.continue_message, (dialog, which) -> dialog.dismiss());
AlertDialog dialog = alert.create();
dialog.show();
}
Expand All @@ -82,21 +77,13 @@ public void onBackPressed() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(getResources().getString(R.string.warning));
alert.setMessage(getResources().getString(R.string.quiz_back_button));
alert.setPositiveButton(R.string.continue_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent i = new Intent(QuizActivity.this, QuizResultActivity.class);
dialog.dismiss();
i.putExtra("QuizResult",score);
startActivity(i);
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
alert.setPositiveButton(R.string.continue_message, (dialog, which) -> {
Intent i = new Intent(QuizActivity.this, QuizResultActivity.class);
dialog.dismiss();
i.putExtra("QuizResult",score);
startActivity(i);
});
alert.setNegativeButton("Cancel", (dialogInterface, i) -> dialogInterface.dismiss());
AlertDialog dialog = alert.create();
dialog.show();
}
Expand Down Expand Up @@ -143,18 +130,15 @@ public void customAlert(String title, String Message) {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(title);
alert.setMessage(Message);
alert.setPositiveButton(R.string.continue_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
questionIndex++;
if(questionIndex == quiz.size()){
Intent i = new Intent(QuizActivity.this, QuizResultActivity.class);
dialog.dismiss();
i.putExtra("QuizResult",score);
startActivity(i);
}else {
displayQuestion();
}
alert.setPositiveButton(R.string.continue_message, (dialog, which) -> {
questionIndex++;
if(questionIndex == quiz.size()){
Intent i = new Intent(QuizActivity.this, QuizResultActivity.class);
dialog.dismiss();
i.putExtra("QuizResult",score);
startActivity(i);
}else {
displayQuestion();
}
});
AlertDialog dialog = alert.create();
Expand Down
13 changes: 2 additions & 11 deletions app/src/main/java/fr/free/nrw/commons/quiz/QuizResultActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,8 @@ public void showAlert(Bitmap screenshot) {
TextView shareMessage = (TextView) view.findViewById(R.id.alert_text);
shareMessage.setText(R.string.quiz_result_share_message);
alertadd.setView(view);
alertadd.setPositiveButton(R.string.about_translate_proceed, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
shareScreen(screenshot);
}
});
alertadd.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
alertadd.setPositiveButton(R.string.about_translate_proceed, (dialog, which) -> shareScreen(screenshot));
alertadd.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.cancel());
alertadd.show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,9 @@ private void setUserName() {
username.setText(allAccounts[0].name);
}
ImageView userIcon = navHeaderView.findViewById(R.id.user_icon);
userIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawerLayout.closeDrawer(navigationView);
AchievementsActivity.startYourself(NavigationBaseActivity.this);
}
userIcon.setOnClickListener(v -> {
drawerLayout.closeDrawer(navigationView);
AchievementsActivity.startYourself(NavigationBaseActivity.this);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

private void initRecyclerView() {
descriptionsAdapter = new DescriptionsAdapter();
descriptionsAdapter.setCallback((mediaDetailDescription, descriptionInfo) -> showInfoAlert(mediaDetailDescription,descriptionInfo));
descriptionsAdapter.setCallback(this::showInfoAlert);
descriptionsAdapter.setLanguages(getLocaleSupportedByDevice());
rvDescriptions.setLayoutManager(new LinearLayoutManager(getContext()));
rvDescriptions.setAdapter(descriptionsAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ private void loadPictureOfTheDay(Context context,
loadImageFromUrl(response.getImageUrl(), context, views, appWidgetManager, appWidgetId);
}
},
t -> {
Timber.e(t, "Fetching picture of the day failed");
}
t -> Timber.e(t, "Fetching picture of the day failed")
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ private void logEdit(String revisionId) {
} else {
Timber.d("Wikidata edit couldn't be tagged");
}
}, throwable -> {
Timber.e(throwable, "Error occurred while adding tag to the edit");
});
}, throwable -> Timber.e(throwable, "Error occurred while adding tag to the edit"));
}

/**
Expand Down