Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/passman-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbinsky08 <timo@binsky.org>2022-06-24 19:55:41 +0300
committerbinsky08 <timo@binsky.org>2022-06-24 19:55:41 +0300
commitf7d12184dedec714ee5e0882cf915a41de57d5b5 (patch)
tree8fb9159386169c7d1d203376bccc39952ba2982c
parent1ff8dc05a0778f5849c1aabd5911fa715cc9a775 (diff)
fix reloading credential in the fragment view after editingfix-credential-fragment-after-edit
Signed-off-by: binsky08 <timo@binsky.org>
-rw-r--r--app/src/main/java/es/wolfi/app/passman/activities/PasswordListActivity.java13
-rw-r--r--app/src/main/java/es/wolfi/app/passman/fragments/CredentialDisplayFragment.java25
2 files changed, 28 insertions, 10 deletions
diff --git a/app/src/main/java/es/wolfi/app/passman/activities/PasswordListActivity.java b/app/src/main/java/es/wolfi/app/passman/activities/PasswordListActivity.java
index 9afb070..861ac0d 100644
--- a/app/src/main/java/es/wolfi/app/passman/activities/PasswordListActivity.java
+++ b/app/src/main/java/es/wolfi/app/passman/activities/PasswordListActivity.java
@@ -386,6 +386,7 @@ public class PasswordListActivity extends AppCompatActivity implements
Vault.updateAutofillVault(v, settings);
try {
OfflineStorage.getInstance().putObject(v.guid, Vault.asJson(v));
+ OfflineStorage.getInstance().commit();
} catch (JSONException e) {
e.printStackTrace();
}
@@ -411,19 +412,26 @@ public class PasswordListActivity extends AppCompatActivity implements
Vault.updateAutofillVault(v, settings);
try {
OfflineStorage.getInstance().putObject(v.guid, Vault.asJson(v));
+ OfflineStorage.getInstance().commit();
} catch (JSONException e) {
e.printStackTrace();
}
Fragment vaultFragment = getSupportFragmentManager().findFragmentByTag("vault");
-
if (vaultFragment != null && vaultFragment.isVisible()) {
- Log.e("refreshVault", "load credentials into content password list");
+ Log.d("refreshVault", "load credentials into content password list");
CredentialItemFragment credentialItems = (CredentialItemFragment)
getSupportFragmentManager().findFragmentById(R.id.content_password_list);
assert credentialItems != null;
credentialItems.loadCredentialList(findViewById(R.id.content_password_list));
}
+
+ CredentialDisplayFragment credentialDisplayFragment = (CredentialDisplayFragment) getSupportFragmentManager().findFragmentByTag("credential");
+ if (credentialDisplayFragment != null) {
+ Log.d("refreshCredential", "load credential into current credential display fragment");
+ credentialDisplayFragment.reloadCredentialFromActiveVaultIfPossible();
+ credentialDisplayFragment.updateViewContent();
+ }
}
public void deleteCredentialInCurrentLocalVaultList(Credential credential) {
@@ -436,6 +444,7 @@ public class PasswordListActivity extends AppCompatActivity implements
Vault.updateAutofillVault(v, settings);
try {
OfflineStorage.getInstance().putObject(v.guid, Vault.asJson(v));
+ OfflineStorage.getInstance().commit();
} catch (JSONException e) {
e.printStackTrace();
}
diff --git a/app/src/main/java/es/wolfi/app/passman/fragments/CredentialDisplayFragment.java b/app/src/main/java/es/wolfi/app/passman/fragments/CredentialDisplayFragment.java
index a63f5d9..c150c0c 100644
--- a/app/src/main/java/es/wolfi/app/passman/fragments/CredentialDisplayFragment.java
+++ b/app/src/main/java/es/wolfi/app/passman/fragments/CredentialDisplayFragment.java
@@ -97,6 +97,7 @@ public class CredentialDisplayFragment extends Fragment {
private Credential credential;
private Handler handler;
private Runnable otp_refresh = null;
+ private View fragmentView;
private OnCredentialFragmentInteraction mListener;
private OnListFragmentInteractionListener filelistListener;
@@ -122,16 +123,20 @@ public class CredentialDisplayFragment extends Fragment {
return fragment;
}
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
+ public void reloadCredentialFromActiveVaultIfPossible() {
if (getArguments() != null) {
Vault v = (Vault) SingleTon.getTon().getExtra(SettingValues.ACTIVE_VAULT.toString());
if (v != null) {
credential = v.findCredentialByGUID(getArguments().getString(CREDENTIAL));
}
}
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ reloadCredentialFromActiveVaultIfPossible();
if (credential != null) {
handler = new Handler();
@@ -212,9 +217,13 @@ public class CredentialDisplayFragment extends Fragment {
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
+ fragmentView = view;
+ updateViewContent();
+ }
+ public void updateViewContent() {
if (credential != null) {
- FloatingActionButton editCredentialButton = view.findViewById(R.id.editCredentialButton);
+ FloatingActionButton editCredentialButton = fragmentView.findViewById(R.id.editCredentialButton);
editCredentialButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -229,16 +238,16 @@ public class CredentialDisplayFragment extends Fragment {
editCredentialButton.setVisibility(View.VISIBLE);
- RecyclerView filesListRecyclerView = (RecyclerView) view.findViewById(R.id.filesList);
+ RecyclerView filesListRecyclerView = (RecyclerView) fragmentView.findViewById(R.id.filesList);
filesListRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
filesListRecyclerView.setAdapter(new FileViewAdapter(credential.getFilesList(), filelistListener));
- RecyclerView customFieldsListRecyclerView = (RecyclerView) view.findViewById(R.id.customFieldsList);
+ RecyclerView customFieldsListRecyclerView = (RecyclerView) fragmentView.findViewById(R.id.customFieldsList);
customFieldsListRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
customFieldsListRecyclerView.setAdapter(new CustomFieldViewAdapter(credential.getCustomFieldsList(), filelistListener));
if (credential.getCompromised().equals("true")) {
- TextView passwordLabel = view.findViewById(R.id.credential_password_label);
+ TextView passwordLabel = fragmentView.findViewById(R.id.credential_password_label);
passwordLabel.setBackgroundColor(getResources().getColor(R.color.compromised));
}