Skip to content

Commit b6500de

Browse files
committed
Fixed dropbox configuration setup.
1 parent 198c381 commit b6500de

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

java/src/main/java/org/astonbitecode/rustkeylock/fragments/EditConfiguration.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class EditConfiguration extends Fragment implements OnClickListener, Back
4343
private transient EditText nextcloudUrlText;
4444
private transient EditText nextcloudUsernameText;
4545
private transient EditText nextcloudPasswordText;
46+
private transient TextView dbxTokenLabel;
4647

4748
public EditConfiguration(List<String> strings) {
4849
this.strings = new ArrayList<>(strings);
@@ -71,11 +72,7 @@ public void onClick(View view) {
7172
String useSelfSignedCertString = Boolean.valueOf(useSelfSignedCert.isChecked()).toString();
7273
Log.d(TAG, "Saving configuration (password not shown here): " + url + ", " + user + ", " + useSelfSignedCertString);
7374

74-
boolean errorsOccured = false;
75-
76-
if (!errorsOccured) {
77-
InterfaceWithRust.INSTANCE.set_configuration(Arrays.asList(url, user, password, useSelfSignedCertString, strings.get(5)));
78-
}
75+
InterfaceWithRust.INSTANCE.set_configuration(Arrays.asList(url, user, password, useSelfSignedCertString, strings.get(5)));
7976
} else if (view.getId() == R.id.editConfigurationCancelButton) {
8077
Log.d(TAG, "Clicked Cancel in configuration");
8178
InterfaceWithRust.INSTANCE.go_to_menu(JavaMenu.Main());
@@ -96,14 +93,14 @@ public void onClick(View view) {
9693
@Override
9794
public void onResume() {
9895
super.onResume();
99-
String token = strings.get(5);
100-
101-
if (token == null || token.isEmpty()) {
102-
String retrieved_token_from_shared_preferences = Auth.getOAuth2Token();
103-
if (retrieved_token_from_shared_preferences != null) {
104-
token = retrieved_token_from_shared_preferences;
105-
InterfaceWithRust.INSTANCE.go_to_menu(JavaMenu.SetDbToken(token));
106-
}
96+
97+
String retrieved_token_from_shared_preferences = Auth.getOAuth2Token();
98+
if (retrieved_token_from_shared_preferences != null) {
99+
strings.set(5, retrieved_token_from_shared_preferences);
100+
dbxTokenLabel.setText((strings.get(5) == null || strings.get(5).isEmpty()) ?
101+
"Press the button below to acquire a new authentication token." :
102+
"A token is acquired. Press the button below if you want to renew."
103+
);
107104
}
108105
}
109106

@@ -135,6 +132,7 @@ private void prepareUiElements(View v) {
135132
"Press the button below to acquire a new authentication token." :
136133
"A token is acquired. Press the button below if you want to renew."
137134
);
135+
this.dbxTokenLabel = dbxTokenLabel;
138136
}
139137

140138
@Override

rust/src/japi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ pub(crate) enum JavaMenu {
240240
ExportEntries,
241241
ShowConfiguration,
242242
WaitForDbxTokenCallback { s: String },
243-
SetDbxToken { s: String },
243+
SetDbxToken { token: String },
244244
Current,
245245
}
246246

0 commit comments

Comments
 (0)