Search in sources :

Example 76 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsPreferenceFragment method removePreference.

@VisibleForTesting
boolean removePreference(PreferenceGroup group, String key) {
    final int preferenceCount = group.getPreferenceCount();
    for (int i = 0; i < preferenceCount; i++) {
        final Preference preference = group.getPreference(i);
        final String curKey = preference.getKey();
        if (TextUtils.equals(curKey, key)) {
            return group.removePreference(preference);
        }
        if (preference instanceof PreferenceGroup) {
            if (removePreference((PreferenceGroup) preference, key)) {
                return true;
            }
        }
    }
    return false;
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Preference(androidx.preference.Preference) PreferenceGroup(androidx.preference.PreferenceGroup) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 77 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ResetNetwork method showFinalConfirmation.

@VisibleForTesting
void showFinalConfirmation() {
    Bundle args = new Bundle();
    if (mSubscriptions != null && mSubscriptions.size() > 0) {
        int selectedIndex = mSubscriptionSpinner.getSelectedItemPosition();
        SubscriptionInfo subscription = mSubscriptions.get(selectedIndex);
        args.putInt(PhoneConstants.SUBSCRIPTION_KEY, subscription.getSubscriptionId());
    }
    args.putBoolean(MasterClear.ERASE_ESIMS_EXTRA, mEsimContainer.getVisibility() == View.VISIBLE && mEsimCheckbox.isChecked());
    new SubSettingLauncher(getContext()).setDestination(ResetNetworkConfirm.class.getName()).setArguments(args).setTitleRes(R.string.reset_network_confirm_title).setSourceMetricsCategory(getMetricsCategory()).launch();
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle) SubscriptionInfo(android.telephony.SubscriptionInfo) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 78 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AdvancedBluetoothDetailsHeaderController method updateIcon.

/**
 * Update icon by {@code iconUri}. If icon exists in cache, use it; otherwise extract it
 * from uri in background thread and update it in main thread.
 */
@VisibleForTesting
void updateIcon(ImageView imageView, String iconUri) {
    if (mIconCache.containsKey(iconUri)) {
        imageView.setImageBitmap(mIconCache.get(iconUri));
        return;
    }
    ThreadUtils.postOnBackgroundThread(() -> {
        try {
            final Bitmap bitmap = MediaStore.Images.Media.getBitmap(mContext.getContentResolver(), Uri.parse(iconUri));
            ThreadUtils.postOnMainThread(() -> {
                mIconCache.put(iconUri, bitmap);
                imageView.setImageBitmap(bitmap);
            });
        } catch (IOException e) {
            Log.e(TAG, "Failed to get bitmap for: " + iconUri);
        }
    });
}
Also used : Bitmap(android.graphics.Bitmap) IOException(java.io.IOException) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 79 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AdvancedBluetoothDetailsHeaderController method createBtBatteryIcon.

@VisibleForTesting
Drawable createBtBatteryIcon(Context context, int level, boolean charging) {
    final BatteryMeterView.BatteryMeterDrawable drawable = new BatteryMeterView.BatteryMeterDrawable(context, context.getColor(R.color.meter_background_color), context.getResources().getDimensionPixelSize(R.dimen.advanced_bluetooth_battery_meter_width), context.getResources().getDimensionPixelSize(R.dimen.advanced_bluetooth_battery_meter_height));
    drawable.setBatteryLevel(level);
    final int attr = level > LOW_BATTERY_LEVEL || charging ? android.R.attr.colorControlNormal : android.R.attr.colorError;
    drawable.setColorFilter(new PorterDuffColorFilter(com.android.settings.Utils.getColorAttrDefaultColor(context, attr), PorterDuff.Mode.SRC));
    drawable.setCharging(charging);
    return drawable;
}
Also used : BatteryMeterView(com.android.settings.fuelgauge.BatteryMeterView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 80 with VisibleForTesting

use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ShowSurfaceUpdatesPreferenceController method updateShowUpdatesSetting.

@VisibleForTesting
void updateShowUpdatesSetting() {
    // magic communication with surface flinger.
    try {
        if (mSurfaceFlinger != null) {
            final Parcel data = Parcel.obtain();
            final Parcel reply = Parcel.obtain();
            data.writeInterfaceToken(SURFACE_COMPOSER_INTERFACE_KEY);
            mSurfaceFlinger.transact(SURFACE_FLINGER_READ_CODE, data, reply, 0);
            @SuppressWarnings("unused") final int showCpu = reply.readInt();
            @SuppressWarnings("unused") final int enableGL = reply.readInt();
            final int showUpdates = reply.readInt();
            ((SwitchPreference) mPreference).setChecked(showUpdates != SETTING_VALUE_OFF);
            reply.recycle();
            data.recycle();
        }
    } catch (RemoteException ex) {
    // intentional no-op
    }
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Parcel(android.os.Parcel) RemoteException(android.os.RemoteException) VisibleForTesting(androidx.annotation.VisibleForTesting)

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