Search in sources :

Example 56 with LayoutPreference

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);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference)

Example 57 with LayoutPreference

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();
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) RemoteException(android.os.RemoteException)

Example 58 with LayoutPreference

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);
    }
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Activity(android.app.Activity)

Example 59 with LayoutPreference

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);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Before(org.junit.Before)

Example 60 with LayoutPreference

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();
}
Also used : NotificationChannel(android.app.NotificationChannel) LayoutPreference(com.android.settingslib.widget.LayoutPreference) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceCategory(androidx.preference.PreferenceCategory) LayoutPreference(com.android.settingslib.widget.LayoutPreference) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) View(android.view.View) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Aggregations

LayoutPreference (com.android.settingslib.widget.LayoutPreference)61 Before (org.junit.Before)10 Preference (androidx.preference.Preference)8 Activity (android.app.Activity)5 View (android.view.View)5 Button (android.widget.Button)5 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)5 Test (org.junit.Test)5 ImageView (android.widget.ImageView)3 PreferenceManager (androidx.preference.PreferenceManager)3 PreferenceScreen (androidx.preference.PreferenceScreen)3 Intent (android.content.Intent)2 UserInfo (android.content.pm.UserInfo)2 Resources (android.content.res.Resources)2 Bundle (android.os.Bundle)2 RemoteException (android.os.RemoteException)2 UserManager (android.os.UserManager)2 TextView (android.widget.TextView)2 PreferenceFragmentCompat (androidx.preference.PreferenceFragmentCompat)2 WifiDataUsageSummaryPreferenceController (com.android.settings.datausage.WifiDataUsageSummaryPreferenceController)2