added enc key delete

This commit is contained in:
gdlbo
2023-03-19 12:05:32 +03:00
parent 207a63117e
commit 2cf60aedac
6 changed files with 12 additions and 7 deletions
@@ -5,7 +5,6 @@ import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.Preferences;
public abstract class IMProcessor {
@@ -84,4 +83,8 @@ public abstract class IMProcessor {
public String getEncryptionKeyFor(int id) {
return Preferences.getPreferences().getString("VT_IMEncodeKey_" + getPrefKey() + "_" + id, null);
}
public void removeEncryptionKeyFor(int id) {
Preferences.getPreferences().edit().remove("VT_IMEncodeKey_" + getPrefKey() + "_" + id).apply();
}
}
@@ -100,7 +100,7 @@ public class CryptImHook {
key = enabled.getEncryptionKeyFor(peerId);
}
if (key.equals("VTAesDefault")) {
if (Objects.equals(key, "VTAesDefault")) {
key = null;
}
@@ -128,6 +128,9 @@ public class CryptImHook {
Editable edit = editText.getText();
finalEnabled.setEncryptionKeyFor(peerId, edit == null ? null : edit.toString());
}).setNegativeButton(android.R.string.cancel, null)
.setNeutralButton("Удалить ключ", (dialog, which) -> {
finalEnabled.removeEncryptionKeyFor(peerId);
})
.show();
}
}