Java 类android.preference.PreferenceActivity.Header 实例源码

项目:android_library_libxposed    文件:LXAppSettings.java   
public static void registerSettingsAppHook(LoadPackageParam lpparam,
        final LXSettingsCallback iface) {
    if (!lpparam.packageName.equals("com.android.settings"))
        return;

    if (settingsAppHooked)
        return;

    Class<?> SettingsClazz = XposedHelpers.findClass(
            "com.android.settings.Settings", lpparam.classLoader);
    XposedBridge.hookAllMethods(SettingsClazz, "updateHeaderList",
            new XC_MethodHook() {
                @SuppressWarnings("unchecked")
                @Override
                protected void beforeHookedMethod(MethodHookParam param)
                        throws Throwable {
                    List<Header> headers = (List<Header>) param.args[0];
                    iface.updateHeaderList(headers);
                }
            });

    settingsAppHooked = true;
}
项目:AppOpsXposed    文件:ApkVariant.java   
protected void hookLoadHeadersFromResource(LoadPackageParam lpparam, String className, final int[] hookResIds, final int addAfterHeaderId) throws Throwable
{
    hookLoadHeadersFromResource(lpparam, className, new XC_MethodHook() {

            @SuppressWarnings("unchecked")
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable
            {
                final int xmlResId = (Integer) param.args[0];
                debug("loadHeadersFromResource: xmlResId=" + xmlResId);

                for(int hookResId : hookResIds)
                {
                    if(xmlResId == hookResId)
                    {
                        addAppOpsHeader((List<Header>) param.args[1], addAfterHeaderId, (Context) param.thisObject);
                        break;
                    }
                }
            }
    });
}
项目:LWPTools    文件:UniversalHeaderAdapter.java   
public View getView(int position, View convertView, ViewGroup parent) {
    Header header = getItem(position);
    int headerType = header.extras.getInt(UniversalHeader.HEADER_TYPE_KEY);
    View view = null;

    switch (headerType) {
    case UniversalHeader.TYPE_CATEGORY:
        view = mInflater.inflate(android.R.layout.preference_category, parent, false);
        ((TextView) view.findViewById(android.R.id.title)).setText(header.getTitle(getContext()
                .getResources()));
        break;

    case UniversalHeader.TYPE_NORMAL:
    case UniversalHeader.TYPE_ABOUT_DIALOG:
    case UniversalHeader.TYPE_ONE_TIME_INTENT:
        int customLayoutResource = header.extras==null? 0 : header.extras.getInt(UniversalHeader.HEADER_CUSTOM_LAYOUT_RESOURCE_KEY);

        view = mInflater.inflate(customLayoutResource==0?mHeaderLayoutResource:customLayoutResource, parent, false);
        ((ImageView) view.findViewById(android.R.id.icon)).setImageResource(header.iconRes);
        TextView titleView = ((TextView) view.findViewById(android.R.id.title));
        titleView.setText(header.getTitle(getContext().getResources()));
        TextView summaryView = ((TextView) view.findViewById(android.R.id.summary));
        if (header.summaryRes!=0){
            summaryView.setText(header.getSummary(getContext().getResources()));
        } else {
            summaryView.setVisibility(View.GONE);
        }

        break;
    }

    return view;
}
项目:AppOpsXposed    文件:ApkVariant.java   
protected Object onCreateAppOpsHeader(Context context, int addAfterHeaderId)
{
    final Header appOpsHeader = new Header();
    appOpsHeader.title = getAppOpsTitle();
    appOpsHeader.id = R.id.app_ops_settings;
    appOpsHeader.iconRes = getAppOpsHeaderIcon();
    appOpsHeader.intent = Util.createAppOpsIntent(null);

    return appOpsHeader;
}
项目:AppOpsXposed    文件:AOSP.java   
private void addAppOpsHeader(LoadPackageParam lpparam)
{
    final int settingsHeadersId = Res.getSettingsIdentifier("xml/settings_headers");
    final int personalSectionId = Res.getSettingsIdentifier("id/personal_section");

    if(settingsHeadersId != 0)
    {
        try
        {
            hookLoadHeadersFromResource(lpparam, settingsHeadersId, personalSectionId);
            return;
        }
        catch(Throwable t)
        {
            debug(t);
        }
    }

    // This is a last resort only, since we might end up with multiple occurences of
    // "App ops" within settings, which is ugly.

    log("Hooking onBuildHeaders :-(");

    XposedHelpers.findAndHookMethod("com.android.settings.Settings", lpparam.classLoader,
            "onBuildHeaders", List.class, new XC_MethodHook() {
                @SuppressWarnings("unchecked")
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable
                {
                    addAppOpsHeader((List<Header>) param.args[0], personalSectionId, (Context) param.thisObject);
                }
    });
}
项目:AppOpsXposed    文件:Oppo.java   
@Override
protected Object onCreateAppOpsHeader(Context context, int addAfterHeaderId)
{
    final Header header = (Header) super.onCreateAppOpsHeader(context, addAfterHeaderId);
    if(mForceCompatibilityMode)
    {
        header.fragment = null;
        header.intent = Util.createAppOpsIntent(null);
    }
    return header;
}
项目:ApkLauncher    文件:DeviceAdminSample.java   
/**
 * We override this method to provide PreferenceActivity with the top-level preference headers.
 */
@Override
public void onBuildHeaders(List<Header> target) {
    loadHeadersFromResource(R.xml.device_admin_headers, target);
}
项目:ApkLauncher    文件:PreferenceWithHeaders.java   
/**
 * Populate the activity with the top-level headers.
 */
@Override
public void onBuildHeaders(List<Header> target) {
    loadHeadersFromResource(R.xml.preference_headers, target);
}
项目:ApkLauncher    文件:Target_PreferenceActivity.java   
public Header onGetInitialHeader() {
//      return super.onGetInitialHeader();
        return null;
    }
项目:ApkLauncher    文件:Target_PreferenceActivity.java   
public Header onGetNewHeader() {
//do NOT edit this file, auto-generated by host_target.groovy from Target_Activity.java.template
//      return super.onGetNewHeader();
        return null;
    }
项目:ApkLauncher    文件:Target_PreferenceActivity.java   
public void loadHeadersFromResource(int resid, List<Header> target) {
    mHostActivity.loadHeadersFromResource(resid, target);
}
项目:ApkLauncher    文件:Target_PreferenceActivity.java   
public void onHeaderClick(Header header, int position) {
//      super.onHeaderClick(header, position);
    }
项目:ApkLauncher    文件:Target_PreferenceActivity.java   
public void switchToHeader(Header header) {
    mHostActivity.switchToHeader(header);
}
项目:LWPTools    文件:UniversalHeader.java   
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public Header createHeader(Context context){
    if (headerType==TYPE_ONE_TIME_INTENT){
        final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
        if (sharedPrefs.getBoolean(oneTimeIntentPrefNamePressed, false))
            return null; //it's been pressed before. don't create the header.
    }

    header = new Header();
    header.title = context.getString(titleRes);
    if (headerType==TYPE_ONE_TIME_INTENT){
        header.intent = new Intent(Intent.ACTION_VIEW);
        header.intent.setData(Uri.parse(oneTimeIntentUrl));
    } else if (intent!=null){
        header.intent = intent;
    } else if (fragment!=null){
        header.fragment = fragment;
    }
    header.iconRes = iconRes;
    header.summaryRes = summaryRes;

    Bundle extras = new Bundle();
    extras.putInt(HEADER_TYPE_KEY, headerType);

    if (customLayoutRes != 0){
        extras.putInt(HEADER_CUSTOM_LAYOUT_RESOURCE_KEY,customLayoutRes);
    }

    if (headerType==TYPE_ABOUT_DIALOG){
        extras.putInt(ABOUT_DIALOG_VERSION_RESOURCE, aboutDialogVersionRes);
        extras.putInt(ABOUT_DIALOG_HTML_MESSAGE_RESOURCE, aboutDialogHtmlMessageRes);
        extras.putInt(ABOUT_DIALOG_ICON_RESOURCE, aboutDialogIconRes);
    }

    if (headerType==TYPE_ONE_TIME_INTENT){
        extras.putString(ONE_TIME_INTENT_PREF_NAME_PRESSED, oneTimeIntentPrefNamePressed);
    }

    header.extras = extras;
    return header;
}
项目:LWPTools    文件:UniversalHeaderAdapter.java   
public UniversalHeaderAdapter(Context context, List<Header> objects, int headerLayoutResource) {
    super(context, 0, objects);
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mHeaderLayoutResource = headerLayoutResource;
}
项目:mythling    文件:HeaderListAdapter.java   
public HeaderListAdapter(Context context, List<Header> objects) {
    super(context, 0, objects);
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
项目:AppOpsXposed    文件:ApkVariant.java   
protected long getIdFromHeader(Object header) {
    return ((Header) header).id;
}
项目:learning_gradle_android    文件:UnifiedPreferenceHelper.java   
/**
 * Called when the activity needs its list of headers built. By implementing
 * this and adding at least one item to the list, you will cause the
 * activity to run in its modern fragment mode. Note that this function may
 * not always be called; for example, if the activity has been asked to
 * display a particular fragment without the header list, there is no need
 * to build the headers.
 * 
 * <p>
 * Typical implementations will use {@link #loadHeadersFromResource} to fill
 * in the list from a resource. For convenience this is done if a header
 * resource has been set with {@link #setHeaderRes(int)}.
 * 
 * @param target The list in which to place the headers.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List<Header> target) {
    // Do not build headers unless in single pane mode.
    if (!isSinglePane() && mHeaderRes > 0) {
        loadHeadersFromResource(mHeaderRes, target);
    }
}
项目:learning_gradle_android    文件:UnifiedPreferenceHelper.java   
/**
 * Called when the activity needs its list of headers built. By implementing
 * this and adding at least one item to the list, you will cause the
 * activity to run in its modern fragment mode. Note that this function may
 * not always be called; for example, if the activity has been asked to
 * display a particular fragment without the header list, there is no need
 * to build the headers.
 * 
 * <p>
 * Typical implementations will use {@link #loadHeadersFromResource} to fill
 * in the list from a resource. For convenience this is done if a header
 * resource has been set with {@link #setHeaderRes(int)}.
 * 
 * @param target The list in which to place the headers.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List<Header> target) {
    // Do not build headers unless in single pane mode.
    if (!isSinglePane() && mHeaderRes > 0) {
        loadHeadersFromResource(mHeaderRes, target);
    }
}
项目:learning_gradle_android    文件:UnifiedPreferenceHelper.java   
/**
 * Called when the activity needs its list of headers built. By implementing
 * this and adding at least one item to the list, you will cause the
 * activity to run in its modern fragment mode. Note that this function may
 * not always be called; for example, if the activity has been asked to
 * display a particular fragment without the header list, there is no need
 * to build the headers.
 * 
 * <p>
 * Typical implementations will use {@link #loadHeadersFromResource} to fill
 * in the list from a resource. For convenience this is done if a header
 * resource has been set with {@link #setHeaderRes(int)}.
 * 
 * @param target The list in which to place the headers.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List<Header> target) {
    // Do not build headers unless in single pane mode.
    if (!isSinglePane() && mHeaderRes > 0) {
        loadHeadersFromResource(mHeaderRes, target);
    }
}
项目:learning_gradle_android    文件:UnifiedPreferenceHelper.java   
/**
 * Called when the activity needs its list of headers built. By implementing
 * this and adding at least one item to the list, you will cause the
 * activity to run in its modern fragment mode. Note that this function may
 * not always be called; for example, if the activity has been asked to
 * display a particular fragment without the header list, there is no need
 * to build the headers.
 * 
 * <p>
 * Typical implementations will use {@link #loadHeadersFromResource} to fill
 * in the list from a resource. For convenience this is done if a header
 * resource has been set with {@link #setHeaderRes(int)}.
 * 
 * @param target The list in which to place the headers.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List<Header> target) {
    // Do not build headers unless in single pane mode.
    if (!isSinglePane() && mHeaderRes > 0) {
        loadHeadersFromResource(mHeaderRes, target);
    }
}
项目:learning_gradle_android    文件:UnifiedPreferenceHelper.java   
/**
 * Called when the activity needs its list of headers built. By implementing
 * this and adding at least one item to the list, you will cause the
 * activity to run in its modern fragment mode. Note that this function may
 * not always be called; for example, if the activity has been asked to
 * display a particular fragment without the header list, there is no need
 * to build the headers.
 * 
 * <p>
 * Typical implementations will use {@link #loadHeadersFromResource} to fill
 * in the list from a resource. For convenience this is done if a header
 * resource has been set with {@link #setHeaderRes(int)}.
 * 
 * @param target The list in which to place the headers.
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List<Header> target) {
    // Do not build headers unless in single pane mode.
    if (!isSinglePane() && mHeaderRes > 0) {
        loadHeadersFromResource(mHeaderRes, target);
    }
}
项目:ApkLauncher    文件:Target_PreferenceActivity.java   
public void onBuildHeaders(List<Header> target) {

}
项目:android_library_libxposed    文件:LXSettingsCallback.java   
public void updateHeaderList(List<Header> target);