use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiSettings method updateAccessPointPreferences.
private void updateAccessPointPreferences() {
// in case state has changed
if (!mWifiManager.isWifiEnabled()) {
return;
}
// AccessPoints are sorted by the WifiTracker
final List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
if (isVerboseLoggingEnabled()) {
Log.i(TAG, "updateAccessPoints called for: " + accessPoints);
}
boolean hasAvailableAccessPoints = false;
mStatusMessagePreference.setVisible(false);
mConnectedAccessPointPreferenceCategory.setVisible(true);
mAccessPointsPreferenceCategory.setVisible(true);
cacheRemoveAllPrefs(mAccessPointsPreferenceCategory);
int index = configureConnectedAccessPointPreferenceCategory(accessPoints) ? 1 : 0;
int numAccessPoints = accessPoints.size();
for (; index < numAccessPoints; index++) {
AccessPoint accessPoint = accessPoints.get(index);
// Ignore access points that are out of range.
if (accessPoint.isReachable()) {
String key = accessPoint.getKey();
hasAvailableAccessPoints = true;
LongPressAccessPointPreference pref = (LongPressAccessPointPreference) getCachedPreference(key);
if (pref != null) {
pref.setOrder(index);
continue;
}
LongPressAccessPointPreference preference = createLongPressAccessPointPreference(accessPoint);
preference.setKey(key);
preference.setOrder(index);
if (mOpenSsid != null && mOpenSsid.equals(accessPoint.getSsidStr()) && (accessPoint.getSecurity() != AccessPoint.SECURITY_NONE && accessPoint.getSecurity() != AccessPoint.SECURITY_OWE)) {
if (!accessPoint.isSaved() || isDisabledByWrongPassword(accessPoint)) {
onPreferenceTreeClick(preference);
mOpenSsid = null;
}
}
mAccessPointsPreferenceCategory.addPreference(preference);
accessPoint.setListener(WifiSettings.this);
preference.refresh();
}
}
removeCachedPrefs(mAccessPointsPreferenceCategory);
mAddWifiNetworkPreference.setOrder(index);
mAccessPointsPreferenceCategory.addPreference(mAddWifiNetworkPreference);
setAdditionalSettingsSummaries();
if (!hasAvailableAccessPoints) {
setProgressBarVisible(true);
Preference pref = new Preference(getPrefContext());
pref.setSelectable(false);
pref.setSummary(R.string.wifi_empty_list_wifi_on);
pref.setOrder(index++);
pref.setKey(PREF_KEY_EMPTY_WIFI_LIST);
mAccessPointsPreferenceCategory.addPreference(pref);
} else {
// Continuing showing progress bar for an additional delay to overlap with animation
getView().postDelayed(mHideProgressBarRunnable, 1700);
}
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeveloperPreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
mViewHolder = holder;
if (donateLink != null) {
final OnClickListener openDonate = new OnClickListener() {
@Override
public void onClick(View v) {
Uri donateURL = Uri.parse(donateLink);
final Intent intent = new Intent(Intent.ACTION_VIEW, donateURL);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
getContext().startActivity(intent);
}
};
donateButton.setOnClickListener(openDonate);
} else {
donateButton.setVisibility(View.GONE);
}
final OnPreferenceClickListener opengplus = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (gplusName != null) {
Uri gplusURL = Uri.parse("https://plus.google.com/+" + gplusName);
final Intent intent = new Intent(Intent.ACTION_VIEW, gplusURL);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
getContext().startActivity(intent);
}
if (twitterName != null) {
Uri twitterURL = Uri.parse("https://twitter.com/" + twitterName);
final Intent intent = new Intent(Intent.ACTION_VIEW, twitterURL);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
getContext().startActivity(intent);
}
return true;
}
};
// changed to clicking the preference to open gplus
// it was a hit or miss to click the gplus icon
this.setOnPreferenceClickListener(opengplus);
UrlImageViewHelper.setUrlDrawable(this.photoView, getGravatarUrl(devEmail), R.drawable.ic_null, UrlImageViewHelper.CACHE_DURATION_ONE_WEEK);
if (gplusName == null)
gplusButton.setVisibility(View.INVISIBLE);
devName.setText(nameDev);
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsPreferenceFragmentTest method removePreference_nested_shouldRemove.
@Test
public void removePreference_nested_shouldRemove() {
final String key = "test_key";
final PreferenceScreen mScreen = spy(new PreferenceScreen(mContext, null));
when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
final PreferenceCategory nestedCategory = new ProgressCategory(mContext);
final Preference preference = new Preference(mContext);
preference.setKey(key);
preference.setPersistent(false);
mScreen.addPreference(nestedCategory);
nestedCategory.addPreference(preference);
assertThat(mFragment.removePreference(mScreen, key)).isTrue();
assertThat(nestedCategory.getPreferenceCount()).isEqualTo(0);
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsPreferenceFragmentTest method removePreference_flat_shouldRemove.
@Test
public void removePreference_flat_shouldRemove() {
final String key = "test_key";
final PreferenceScreen mScreen = spy(new PreferenceScreen(mContext, null));
when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
final Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(key);
mScreen.addPreference(preference);
assertThat(mFragment.removePreference(mScreen, key)).isTrue();
assertThat(mScreen.getPreferenceCount()).isEqualTo(0);
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RecentAppsPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final Context context = spy(RuntimeEnvironment.application);
when(context.getApplicationContext()).thenReturn(context);
ReflectionHelpers.setStaticField(ApplicationsState.class, "sInstance", mAppState);
doReturn(mUserManager).when(context).getSystemService(Context.USER_SERVICE);
doReturn(mPackageManager).when(context).getPackageManager();
when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {});
final View appEntitiesHeaderView = LayoutInflater.from(context).inflate(R.layout.app_entities_header, null);
final Preference dividerPreference = new Preference(context);
final LayoutPreference recentAppsPreference = spy(new LayoutPreference(context, appEntitiesHeaderView));
mController = spy(new RecentAppsPreferenceController(context, "test_key"));
mController.setFragment(mFragment);
mController.mAppEntitiesController = mock(AppEntitiesHeaderController.class);
mController.mRecentAppsPreference = recentAppsPreference;
mController.mDivider = dividerPreference;
when(mScreen.findPreference(RecentAppsPreferenceController.KEY_DIVIDER)).thenReturn(dividerPreference);
when(mScreen.findPreference("test_key")).thenReturn(recentAppsPreference);
when(recentAppsPreference.findViewById(R.id.app_entities_header)).thenReturn(appEntitiesHeaderView);
}
Aggregations