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;
}
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();
}
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);
}
});
}
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;
}
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
}
}
Aggregations