use of androidx.annotation.VisibleForTesting in project android by nextcloud.
the class SettingsActivity method handleMnemonicRequest.
@VisibleForTesting
public void handleMnemonicRequest(Intent data) {
if (data == null) {
DisplayUtils.showSnackMessage(this, "Error retrieving mnemonic!");
} else {
if (data.getIntExtra(RequestCredentialsActivity.KEY_CHECK_RESULT, RequestCredentialsActivity.KEY_CHECK_RESULT_FALSE) == RequestCredentialsActivity.KEY_CHECK_RESULT_TRUE) {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
String mnemonic = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.MNEMONIC);
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.FallbackTheming_Dialog);
AlertDialog alertDialog = builder.setTitle(R.string.prefs_e2e_mnemonic).setMessage(mnemonic).setPositiveButton(R.string.common_ok, (dialog, which) -> dialog.dismiss()).create();
alertDialog.show();
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
}
}
}
use of androidx.annotation.VisibleForTesting in project android by nextcloud.
the class ManageAccountsActivity method showUser.
@VisibleForTesting
public void showUser(User user, UserInfo userInfo) {
final Intent intent = new Intent(this, UserInfoActivity.class);
OwnCloudAccount oca = user.toOwnCloudAccount();
intent.putExtra(UserInfoActivity.KEY_ACCOUNT, user);
intent.putExtra(KEY_DISPLAY_NAME, oca.getDisplayName());
intent.putExtra(KEY_USER_DATA, userInfo);
startActivityForResult(intent, KEY_USER_INFO_REQUEST_CODE);
}
use of androidx.annotation.VisibleForTesting in project android by nextcloud.
the class TextDrawable method extractCharsFromDisplayName.
@VisibleForTesting
public static String extractCharsFromDisplayName(@NonNull String displayName) {
if (displayName.isEmpty()) {
return "";
}
String[] nameParts = displayName.split("\\s+");
StringBuilder firstTwoLetters = new StringBuilder();
for (int i = 0; i < Math.min(2, nameParts.length); i++) {
firstTwoLetters.append(nameParts[i].substring(0, 1).toUpperCase(Locale.getDefault()));
}
return firstTwoLetters.toString();
}
use of androidx.annotation.VisibleForTesting in project Signal-Android by signalapp.
the class AttachmentDatabase method getDataStream.
@SuppressWarnings("WeakerAccess")
@VisibleForTesting
@Nullable
protected InputStream getDataStream(AttachmentId attachmentId, String dataType, long offset) {
DataInfo dataInfo = getAttachmentDataFileInfo(attachmentId, dataType);
if (dataInfo == null) {
return null;
}
try {
if (dataInfo.random != null && dataInfo.random.length == 32) {
return ModernDecryptingPartInputStream.createFor(attachmentSecret, dataInfo.random, dataInfo.file, offset);
} else {
InputStream stream = ClassicDecryptingPartInputStream.createFor(attachmentSecret, dataInfo.file);
long skipped = stream.skip(offset);
if (skipped != offset) {
Log.w(TAG, "Skip failed: " + skipped + " vs " + offset);
return null;
}
return stream;
}
} catch (IOException e) {
Log.w(TAG, e);
return null;
}
}
use of androidx.annotation.VisibleForTesting in project Signal-Android by signalapp.
the class FeatureFlags method computeChanges.
@VisibleForTesting
@NonNull
static Map<String, Change> computeChanges(@NonNull Map<String, Object> oldMap, @NonNull Map<String, Object> newMap) {
Map<String, Change> changes = new HashMap<>();
Set<String> allKeys = new HashSet<>();
allKeys.addAll(oldMap.keySet());
allKeys.addAll(newMap.keySet());
for (String key : allKeys) {
Object oldValue = oldMap.get(key);
Object newValue = newMap.get(key);
if (oldValue == null && newValue == null) {
throw new AssertionError("Should not be possible.");
} else if (oldValue != null && newValue == null) {
changes.put(key, Change.REMOVED);
} else if (newValue != oldValue && newValue instanceof Boolean) {
changes.put(key, (boolean) newValue ? Change.ENABLED : Change.DISABLED);
} else if (!Objects.equals(oldValue, newValue)) {
changes.put(key, Change.CHANGED);
}
}
return changes;
}
Aggregations