Search in sources :

Example 26 with EntityHeaderController

use of com.android.settings.widget.EntityHeaderController in project packages_apps_Settings by Spark-Rom.

the class TopLevelSettings method onUserCard.

private void onUserCard() {
    final LayoutPreference headerPreference = (LayoutPreference) getPreferenceScreen().findPreference(KEY_USER_CARD);
    final Activity context = getActivity();
    final boolean DisableUserCard = Settings.System.getIntForUser(context.getContentResolver(), Settings.System.DISABLE_USERCARD, 0, UserHandle.USER_CURRENT) != 0;
    if (DisableUserCard && headerPreference != null) {
        getPreferenceScreen().removePreference(headerPreference);
    } else {
        if (headerPreference != null) {
            final View userCard = headerPreference.findViewById(R.id.entity_header);
            final TextView textview = headerPreference.findViewById(R.id.summary);
            final Bundle bundle = getArguments();
            final EntityHeaderController controller = EntityHeaderController.newInstance(context, this, userCard).setRecyclerView(getListView(), getSettingsLifecycle()).setButtonActions(EntityHeaderController.ActionType.ACTION_NONE, EntityHeaderController.ActionType.ACTION_NONE);
            userCard.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(Intent.ACTION_MAIN);
                    intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$UserSettingsActivity"));
                    startActivity(intent);
                }
            });
            final int iconId = bundle.getInt("icon_id", 0);
            if (iconId == 0) {
                final UserManager userManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
                final UserInfo info = Utils.getExistingUser(userManager, android.os.Process.myUserHandle());
                controller.setLabel(info.name);
                controller.setIcon(com.android.settingslib.Utils.getUserIcon(getActivity(), userManager, info));
            }
            controller.done(context, true);
        }
    }
}
Also used : EntityHeaderController(com.android.settings.widget.EntityHeaderController) Bundle(android.os.Bundle) Activity(android.app.Activity) Intent(android.content.Intent) UserInfo(android.content.pm.UserInfo) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) LayoutPreference(com.android.settingslib.widget.LayoutPreference) UserManager(android.os.UserManager) TextView(android.widget.TextView) ComponentName(android.content.ComponentName)

Example 27 with EntityHeaderController

use of com.android.settings.widget.EntityHeaderController in project packages_apps_Settings by Spark-Rom.

the class AdvancedPowerUsageDetail method initHeader.

@VisibleForTesting
void initHeader() {
    final View appSnippet = mHeaderPreference.findViewById(R.id.entity_header);
    final Activity context = getActivity();
    final Bundle bundle = getArguments();
    EntityHeaderController controller = EntityHeaderController.newInstance(context, this, appSnippet).setRecyclerView(getListView(), getSettingsLifecycle()).setButtonActions(EntityHeaderController.ActionType.ACTION_NONE, EntityHeaderController.ActionType.ACTION_NONE);
    if (mAppEntry == null) {
        controller.setLabel(bundle.getString(EXTRA_LABEL));
        final int iconId = bundle.getInt(EXTRA_ICON_ID, 0);
        if (iconId == 0) {
            controller.setIcon(context.getPackageManager().getDefaultActivityIcon());
        } else {
            controller.setIcon(context.getDrawable(bundle.getInt(EXTRA_ICON_ID)));
        }
    } else {
        mState.ensureIcon(mAppEntry);
        controller.setLabel(mAppEntry);
        controller.setIcon(mAppEntry);
        controller.setIsInstantApp(AppUtils.isInstant(mAppEntry.info));
    }
    if (mEnableTriState) {
        controller.setSummary(getAppActiveTime(bundle));
    }
    controller.done(context, true);
}
Also used : EntityHeaderController(com.android.settings.widget.EntityHeaderController) Bundle(android.os.Bundle) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) View(android.view.View) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 28 with EntityHeaderController

use of com.android.settings.widget.EntityHeaderController in project android_packages_apps_Settings by ArrowOS.

the class AdvancedPowerUsageDetail method initHeader.

@VisibleForTesting
void initHeader() {
    final View appSnippet = mHeaderPreference.findViewById(R.id.entity_header);
    final Activity context = getActivity();
    final Bundle bundle = getArguments();
    EntityHeaderController controller = EntityHeaderController.newInstance(context, this, appSnippet).setRecyclerView(getListView(), getSettingsLifecycle()).setButtonActions(EntityHeaderController.ActionType.ACTION_NONE, EntityHeaderController.ActionType.ACTION_NONE);
    if (mAppEntry == null) {
        controller.setLabel(bundle.getString(EXTRA_LABEL));
        final int iconId = bundle.getInt(EXTRA_ICON_ID, 0);
        if (iconId == 0) {
            controller.setIcon(context.getPackageManager().getDefaultActivityIcon());
        } else {
            controller.setIcon(context.getDrawable(bundle.getInt(EXTRA_ICON_ID)));
        }
    } else {
        mState.ensureIcon(mAppEntry);
        controller.setLabel(mAppEntry);
        controller.setIcon(mAppEntry);
        controller.setIsInstantApp(AppUtils.isInstant(mAppEntry.info));
    }
    if (mEnableTriState) {
        controller.setSummary(getAppActiveTime(bundle));
    }
    controller.done(context, true);
}
Also used : EntityHeaderController(com.android.settings.widget.EntityHeaderController) Bundle(android.os.Bundle) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) View(android.view.View) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 29 with EntityHeaderController

use of com.android.settings.widget.EntityHeaderController in project android_packages_apps_Settings by ArrowOS.

the class MyDeviceInfoFragment method initHeader.

private void initHeader() {
    // TODO: Migrate into its own controller.
    final LayoutPreference headerPreference = getPreferenceScreen().findPreference(KEY_MY_DEVICE_INFO_HEADER);
    final boolean shouldDisplayHeader = getContext().getResources().getBoolean(R.bool.config_show_device_header_in_device_info);
    headerPreference.setVisible(shouldDisplayHeader);
    if (!shouldDisplayHeader) {
        return;
    }
    final View headerView = headerPreference.findViewById(R.id.entity_header);
    final Activity context = getActivity();
    final Bundle bundle = getArguments();
    final EntityHeaderController controller = EntityHeaderController.newInstance(context, this, headerView).setRecyclerView(getListView(), getSettingsLifecycle()).setButtonActions(EntityHeaderController.ActionType.ACTION_NONE, EntityHeaderController.ActionType.ACTION_NONE);
    // TODO: There may be an avatar setting action we can use here.
    final int iconId = bundle.getInt("icon_id", 0);
    if (iconId == 0) {
        final UserManager userManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
        final UserInfo info = Utils.getExistingUser(userManager, android.os.Process.myUserHandle());
        controller.setLabel(info.name);
        controller.setIcon(com.android.settingslib.Utils.getUserIcon(getActivity(), userManager, info));
    }
    controller.done(context, true);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) EntityHeaderController(com.android.settings.widget.EntityHeaderController) Bundle(android.os.Bundle) UserManager(android.os.UserManager) Activity(android.app.Activity) UserInfo(android.content.pm.UserInfo) View(android.view.View)

Example 30 with EntityHeaderController

use of com.android.settings.widget.EntityHeaderController in project packages_apps_Settings by AICP.

the class MyDeviceInfoFragment method initHeader.

private void initHeader() {
    // TODO: Migrate into its own controller.
    final LayoutPreference headerPreference = getPreferenceScreen().findPreference(KEY_MY_DEVICE_INFO_HEADER);
    final boolean shouldDisplayHeader = getContext().getResources().getBoolean(R.bool.config_show_device_header_in_device_info);
    headerPreference.setVisible(shouldDisplayHeader);
    if (!shouldDisplayHeader) {
        return;
    }
    final View headerView = headerPreference.findViewById(R.id.entity_header);
    final Activity context = getActivity();
    final Bundle bundle = getArguments();
    final EntityHeaderController controller = EntityHeaderController.newInstance(context, this, headerView).setRecyclerView(getListView(), getSettingsLifecycle()).setButtonActions(EntityHeaderController.ActionType.ACTION_NONE, EntityHeaderController.ActionType.ACTION_NONE);
    // TODO: There may be an avatar setting action we can use here.
    final int iconId = bundle.getInt("icon_id", 0);
    if (iconId == 0) {
        final UserManager userManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
        final UserInfo info = Utils.getExistingUser(userManager, android.os.Process.myUserHandle());
        controller.setLabel(info.name);
        controller.setIcon(com.android.settingslib.Utils.getUserIcon(getActivity(), userManager, info));
    }
    controller.done(context, true);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) EntityHeaderController(com.android.settings.widget.EntityHeaderController) Bundle(android.os.Bundle) UserManager(android.os.UserManager) Activity(android.app.Activity) UserInfo(android.content.pm.UserInfo) View(android.view.View)

Aggregations

Activity (android.app.Activity)31 Bundle (android.os.Bundle)31 View (android.view.View)31 EntityHeaderController (com.android.settings.widget.EntityHeaderController)31 SettingsActivity (com.android.settings.SettingsActivity)16 UserInfo (android.content.pm.UserInfo)15 UserManager (android.os.UserManager)15 LayoutPreference (com.android.settingslib.widget.LayoutPreference)15 VisibleForTesting (androidx.annotation.VisibleForTesting)14 VisibleForTesting (android.support.annotation.VisibleForTesting)2 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 TextView (android.widget.TextView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1