Search in sources :

Example 96 with VisibleForTesting

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));
        }
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) User(com.nextcloud.client.account.User) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) ColorDrawable(android.graphics.drawable.ColorDrawable) PreferenceScreen(android.preference.PreferenceScreen) UserAccountManager(com.nextcloud.client.account.UserAccountManager) DarkMode(com.nextcloud.client.preferences.DarkMode) ActionBar(androidx.appcompat.app.ActionBar) EncryptionUtils(com.owncloud.android.utils.EncryptionUtils) View(android.view.View) PreferenceManager(android.preference.PreferenceManager) DisplayUtils(com.owncloud.android.utils.DisplayUtils) ThemeUtils(com.owncloud.android.utils.theme.ThemeUtils) BuildConfig(com.owncloud.android.BuildConfig) ThemeToolbarUtils(com.owncloud.android.utils.theme.ThemeToolbarUtils) EtmActivity(com.nextcloud.client.etm.EtmActivity) DocumentsStorageProvider(com.owncloud.android.providers.DocumentsStorageProvider) AppPreferences(com.nextcloud.client.preferences.AppPreferences) ExternalLinksProvider(com.owncloud.android.datamodel.ExternalLinksProvider) ViewGroup(android.view.ViewGroup) Log_OC(com.owncloud.android.lib.common.utils.Log_OC) DataStorageProvider(com.owncloud.android.datastorage.DataStorageProvider) ListPreference(android.preference.ListPreference) List(java.util.List) ThemeColorUtils(com.owncloud.android.utils.theme.ThemeColorUtils) MainApp(com.owncloud.android.MainApp) ThemeTextUtils(com.owncloud.android.utils.theme.ThemeTextUtils) MimeTypeUtil(com.owncloud.android.utils.MimeTypeUtil) LogsActivity(com.nextcloud.client.logger.ui.LogsActivity) R(com.owncloud.android.R) ThemeButtonUtils(com.owncloud.android.utils.theme.ThemeButtonUtils) StoragePoint(com.owncloud.android.datastorage.StoragePoint) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) AlertDialog(androidx.appcompat.app.AlertDialog) PreferenceCategory(android.preference.PreferenceCategory) AppPreferencesImpl(com.nextcloud.client.preferences.AppPreferencesImpl) ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) Intent(android.content.Intent) PackageInfo(android.content.pm.PackageInfo) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) ExternalLink(com.owncloud.android.lib.common.ExternalLink) Inject(javax.inject.Inject) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) AuthenticatorActivity(com.owncloud.android.authentication.AuthenticatorActivity) LayoutRes(androidx.annotation.LayoutRes) URLUtil(android.webkit.URLUtil) AppCompatDelegate(androidx.appcompat.app.AppCompatDelegate) TextUtils(android.text.TextUtils) DeviceCredentialUtils(com.owncloud.android.utils.DeviceCredentialUtils) ClientFactory(com.nextcloud.client.network.ClientFactory) LoadingVersionNumberTask(com.owncloud.android.ui.asynctasks.LoadingVersionNumberTask) ExternalLinkType(com.owncloud.android.lib.common.ExternalLinkType) SharedPreferences(android.content.SharedPreferences) Preference(android.preference.Preference) Configuration(android.content.res.Configuration) Injectable(com.nextcloud.client.di.Injectable) Activity(android.app.Activity) VisibleForTesting(androidx.annotation.VisibleForTesting) SwitchPreference(android.preference.SwitchPreference) ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 97 with VisibleForTesting

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);
}
Also used : Intent(android.content.Intent) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 98 with VisibleForTesting

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();
}
Also used : Paint(android.graphics.Paint) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 99 with VisibleForTesting

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;
    }
}
Also used : ModernDecryptingPartInputStream(org.thoughtcrime.securesms.crypto.ModernDecryptingPartInputStream) ClassicDecryptingPartInputStream(org.thoughtcrime.securesms.crypto.ClassicDecryptingPartInputStream) DigestInputStream(java.security.DigestInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) VisibleForTesting(androidx.annotation.VisibleForTesting) Nullable(androidx.annotation.Nullable)

Example 100 with VisibleForTesting

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;
}
Also used : HashMap(java.util.HashMap) JSONObject(org.json.JSONObject) HashSet(java.util.HashSet) VisibleForTesting(androidx.annotation.VisibleForTesting) NonNull(androidx.annotation.NonNull)

Aggregations

VisibleForTesting (androidx.annotation.VisibleForTesting)385 Intent (android.content.Intent)36 ArrayList (java.util.ArrayList)36 Context (android.content.Context)34 Bundle (android.os.Bundle)30 Uri (android.net.Uri)18 View (android.view.View)18 Preference (androidx.preference.Preference)18 TextView (android.widget.TextView)16 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)16 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)16 SuppressLint (android.annotation.SuppressLint)15 Activity (android.app.Activity)14 RemoteException (android.os.RemoteException)14 SubscriptionInfo (android.telephony.SubscriptionInfo)12 ImageView (android.widget.ImageView)12 BluetoothDevice (android.bluetooth.BluetoothDevice)11 ComponentName (android.content.ComponentName)11 Drawable (android.graphics.drawable.Drawable)11 SharedPreferences (android.content.SharedPreferences)10