use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.
the class ZenAutomaticRuleHeaderPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
if (mRule == null || mFragment == null) {
return;
}
if (mController == null) {
final LayoutPreference pref = (LayoutPreference) preference;
mController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment, pref.findViewById(R.id.entity_header));
}
mController.setIcon(getIcon()).setLabel(mRule.getName()).done(mFragment.getActivity(), false);
}
use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.
the class NoConversationsPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
LayoutPreference pref = (LayoutPreference) preference;
// Load conversations
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... unused) {
mConversationCount = mBackend.getConversations(false).getList().size();
try {
mConversationCount += mPs.getRecentConversations().getList().size();
} catch (RemoteException e) {
Log.w(TAG, "Error calling PS", e);
}
return null;
}
@Override
protected void onPostExecute(Void unused) {
if (mContext == null) {
return;
}
pref.findViewById(R.id.onboarding).setVisibility(mConversationCount == 0 ? View.VISIBLE : View.GONE);
preference.setVisible(mConversationCount == 0);
}
}.execute();
}
use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.
the class ConversationHeaderPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
if (mAppRow != null && mFragment != null) {
Activity activity = null;
if (mStarted) {
// don't call done on an activity if it hasn't started yet
activity = mFragment.getActivity();
}
if (activity == null) {
return;
}
LayoutPreference pref = (LayoutPreference) preference;
mHeaderController = EntityHeaderController.newInstance(activity, mFragment, pref.findViewById(R.id.entity_header));
pref = mHeaderController.setIcon(mConversationDrawable).setLabel(getLabel()).setSummary(getSummary()).setPackageName(mAppRow.pkg).setUid(mAppRow.uid).setButtonActions(EntityHeaderController.ActionType.ACTION_NOTIF_PREFERENCE, EntityHeaderController.ActionType.ACTION_NONE).setHasAppInfoLink(true).setRecyclerView(mFragment.getListView(), mFragment.getSettingsLifecycle()).done(activity, mContext);
pref.findViewById(R.id.entity_header).setVisibility(View.VISIBLE);
pref.findViewById(R.id.entity_header).setBackground(null);
}
}
use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.
the class AdvancedBluetoothDetailsHeaderControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = new AdvancedBluetoothDetailsHeaderController(mContext, "pref_Key");
when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
mController.init(mCachedDevice);
mLayoutPreference = new LayoutPreference(mContext, LayoutInflater.from(mContext).inflate(R.layout.advanced_bt_entity_header, null));
mController.mLayoutPreference = mLayoutPreference;
mController.mBluetoothAdapter = mBluetoothAdapter;
when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
when(mCachedDevice.getAddress()).thenReturn(MAC_ADDRESS);
}
use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.
the class RecentConversationsPreferenceControllerTest method testRemoveConversations.
@Test
public void testRemoveConversations() throws Exception {
ShortcutInfo si = mock(ShortcutInfo.class);
when(si.getId()).thenReturn("person");
when(si.getPackage()).thenReturn("pkg");
ConversationChannel ccw = new ConversationChannel(si, 6, new NotificationChannel("hi", "hi", 4), new NotificationChannelGroup("hi", "group"), 7, false);
ConversationChannel ccw2 = new ConversationChannel(si, 6, new NotificationChannel("bye", "bye", 4), new NotificationChannelGroup("hi", "group"), 7, true);
PreferenceCategory group = new PreferenceCategory(mContext);
PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext);
screen.addPreference(group);
RecentConversationPreference pref = mController.createConversationPref(new PreferenceCategory(mContext), ccw, 100);
final View view = View.inflate(mContext, pref.getLayoutResource(), null);
PreferenceViewHolder holder = spy(PreferenceViewHolder.createInstanceForTests(view));
View delete = View.inflate(mContext, pref.getSecondTargetResId(), null);
when(holder.findViewById(pref.getClearId())).thenReturn(delete);
group.addPreference(pref);
RecentConversationPreference pref2 = mController.createConversationPref(new PreferenceCategory(mContext), ccw2, 100);
final View view2 = View.inflate(mContext, pref2.getLayoutResource(), null);
PreferenceViewHolder holder2 = spy(PreferenceViewHolder.createInstanceForTests(view2));
View delete2 = View.inflate(mContext, pref2.getSecondTargetResId(), null);
when(holder2.findViewById(pref.getClearId())).thenReturn(delete2);
group.addPreference(pref2);
LayoutPreference clearAll = mController.getClearAll(group);
group.addPreference(clearAll);
clearAll.findViewById(R.id.conversation_settings_clear_recents).performClick();
verify(mPs).removeAllRecentConversations();
assertThat((Preference) group.findPreference("hi:person")).isNull();
assertThat((Preference) group.findPreference("bye:person")).isNotNull();
}
Aggregations