Skip to content

Commit 2280995

Browse files
author
maskara
committed
Fix keyboard state for license screen
1 parent 9b958d9 commit 2280995

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

app/src/main/java/fr/free/nrw/commons/upload/DescriptionsAdapter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@
3535

3636
class DescriptionsAdapter extends RecyclerView.Adapter<DescriptionsAdapter.ViewHolder> {
3737

38-
Title title;
39-
List<Description> descriptions;
38+
private Title title;
39+
private List<Description> descriptions;
4040
private Context context;
4141
private Callback callback;
4242
private Subject<String> titleChangedSubject;
4343

4444
private BiMap<AdapterView, String> selectedLanguages;
4545
private UploadView uploadView;
4646

47-
public DescriptionsAdapter(UploadView uploadView) {
47+
DescriptionsAdapter(UploadView uploadView) {
4848
title = new Title();
4949
descriptions = new ArrayList<>();
5050
descriptions.add(new Description());
@@ -53,11 +53,11 @@ public DescriptionsAdapter(UploadView uploadView) {
5353
this.uploadView = uploadView;
5454
}
5555

56-
public void setCallback(Callback callback) {
56+
void setCallback(Callback callback) {
5757
this.callback = callback;
5858
}
5959

60-
public void setItems(Title title, List<Description> descriptions) {
60+
void setItems(Title title, List<Description> descriptions) {
6161
this.descriptions = descriptions;
6262
this.title = title;
6363
selectedLanguages = new BiMap<>();
@@ -95,11 +95,11 @@ public int getItemCount() {
9595
return descriptions.size() + 1;
9696
}
9797

98-
public List<Description> getDescriptions() {
98+
List<Description> getDescriptions() {
9999
return descriptions;
100100
}
101101

102-
public void addDescription(Description description) {
102+
void addDescription(Description description) {
103103
this.descriptions.add(description);
104104
notifyItemInserted(descriptions.size() + 1);
105105
}

app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
import android.Manifest;
44
import android.animation.LayoutTransition;
55
import android.annotation.SuppressLint;
6-
import android.content.Context;
76
import android.content.Intent;
87
import android.content.SharedPreferences;
9-
import android.database.Cursor;
108
import android.net.Uri;
119
import android.os.Build;
1210
import android.os.Bundle;
@@ -19,7 +17,6 @@
1917
import android.text.Html;
2018
import android.text.TextUtils;
2119
import android.text.method.LinkMovementMethod;
22-
import android.util.AttributeSet;
2320
import android.view.View;
2421
import android.view.inputmethod.InputMethodManager;
2522
import android.widget.AdapterView;
@@ -307,6 +304,7 @@ public void setBottomCardVisibility(@UploadPage int page) {
307304
viewFlipper.setDisplayedChild(1);
308305
} else if (page == LICENSE) {
309306
viewFlipper.setDisplayedChild(2);
307+
dismissKeyboard();
310308
} else if (page == PLEASE_WAIT) {
311309
viewFlipper.setDisplayedChild(3);
312310
}
@@ -332,7 +330,12 @@ public void setBackground(Uri mediaUri) {
332330

333331
@Override
334332
public void dismissKeyboard() {
333+
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
335334

335+
// verify if the soft keyboard is open
336+
if (imm != null && imm.isAcceptingText() && getCurrentFocus() != null) {
337+
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
338+
}
336339
}
337340

338341
@Override

app/src/main/java/fr/free/nrw/commons/upload/UploadModel.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ public class UploadModel {
3838

3939
private MediaWikiApi mwApi;
4040
private static UploadItem DUMMY = new UploadItem(Uri.EMPTY, "", "", GPSExtractor.DUMMY, "", null,-1l) {
41-
@Override
42-
public boolean isDummy() {
43-
return true;
44-
}
4541
};
4642
private final SharedPreferences prefs;
4743
private final List<String> licenses;
@@ -374,19 +370,13 @@ static class UploadItem {
374370
descriptions = new ArrayList<>();
375371
descriptions.add(new Description());
376372
this.wikidataEntityId = wikidataEntityId;
377-
378373
this.mediaUri = mediaUri;
379374
this.mimeType = mimeType;
380375
this.source = source;
381376
this.gpsCoords = gpsCoords;
382377
this.fileExt = fileExt;
383378
imageQuality = BehaviorSubject.createDefault(ImageUtils.IMAGE_WAIT);
384379
this.createdTimestamp=createdTimestamp;
385-
// imageQuality.subscribe(iq->Timber.i("New value of imageQuality:"+ImageUtils.IMAGE_OK));
386-
}
387-
388-
public boolean isDummy() {
389-
return false;
390380
}
391381
}
392382

0 commit comments

Comments
 (0)