Example usage for android.preference PreferenceFragment getActivity

List of usage examples for android.preference PreferenceFragment getActivity

Introduction

In this page you can find the example usage for android.preference PreferenceFragment getActivity.

Prototype

final public Activity getActivity() 

Source Link

Document

Return the Activity this fragment is currently associated with.

Usage

From source file:com.almalence.opencam.PluginManager.java

@Override
public void loadHeaderContent(String settings, PreferenceFragment pf) {
    List<Plugin> activePlugins = new ArrayList<Plugin>();
    List<Plugin> inactivePlugins = new ArrayList<Plugin>();

    boolean hasInactive = false;

    loadStandardSettingsBefore(pf, settings);
    if ("general_more".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_general_more);
        ApplicationScreen.instance.onAdvancePreferenceCreate(pf);
    } else if ("general_image_size".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_general_image_size);
        if (CameraController.isUseCamera2()) {
            Preference pref;/*  www. java  2  s  .co m*/
            if (null != (pref = pf.findPreference(ApplicationScreen.sImageSizeMultishotBackPref))
                    || null != (pref = pf.findPreference(ApplicationScreen.sImageSizeMultishotFrontPref))) {
                pref.setTitle(ApplicationScreen.getAppResources()
                        .getString(R.string.Pref_Comon_SmartMultishot_And_Super_ImageSize_Title));
            }
        }
        ApplicationScreen.instance.onPreferenceCreate(pf);
    } else if ("vf_settings".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_vf_common);
    } else if ("vf_more".equals(settings)) {
        for (int i = 0; i < listVF.size(); i++) {
            Plugin pg = listVF.get(i);
            if (activeVF.contains(pg.getID()))
                activePlugins.add(pg);
            else
                inactivePlugins.add(pg);
        }
        addHeadersContent(pf, activePlugins, false);

        pf.addPreferencesFromResource(R.xml.preferences_vf_more);

        if (activePlugins.size() != listVF.size() && isPreferenecesAvailable(inactivePlugins, false))
            pf.addPreferencesFromResource(R.xml.preferences_vf_inactive);

        ApplicationScreen.instance.onAdvancePreferenceCreate(pf); //Some vf advance preferences may be related to entire application instead of some special vf plugin
    } else if ("vf_inactive_settings".equals(settings)) {
        for (int i = 0; i < listVF.size(); i++) {
            Plugin pg = listVF.get(i);
            if (!activeVF.contains(pg.getID()))
                inactivePlugins.add(pg);
        }
        addHeadersContent(pf, inactivePlugins, false);
    } else if ("save_configuration".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_general_saveconfiguration);
    } else if ("export_more".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_export_common);
    } else if ("export_timestamp".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_export_timestamp);
    } else if ("shooting_settings".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_modes);
    } else if ("capture_expobracketing_more".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_capture_expobracketing_more);
    } else if ("processing_expobracketing_more".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_processing_hdr_more);
    } else if ("capture_night_more".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_capture_night_more);
    } else if ("processing_night_more".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_processing_night_more);
        if (CameraController.isUseCamera2()) {
            PreferenceScreen prefScr;
            if (null != (prefScr = (PreferenceScreen) pf.findPreference("nightProcessingMoreScreen"))) {
                Preference pref;
                if (null != (pref = pf.findPreference("keepcolorsPref"))) {
                    prefScr.removePreference(pref);
                }
            }
        }
    } else if ("capture_preshot_more".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_capture_preshot_more);
    } else if ("capture_panorama_more".equals(settings)) {
        pf.addPreferencesFromResource(R.xml.preferences_capture_panoramaaugmented_more);
        Plugin panoramaPlugin = pluginList.get(activeCapture);
        panoramaPlugin.onPreferenceCreate(pf);
    } else if ("dro".equals(settings)) {
        AddModeSettings("single", pf);
    } else if ("burst".equals(settings)) {
        AddModeSettings("burstmode", pf);
    } else if ("expobracketing".equals(settings)) {
        AddModeSettings("expobracketing", pf);
    } else if ("hdr".equals(settings)) {
        AddModeSettings("hdrmode", pf);
    } else if ("night".equals(settings)) {
        AddModeSettings("nightmode", pf);
    } else if ("super".equals(settings)) {
        AddModeSettings("super", pf);
    } else if ("video".equals(settings)) {
        AddModeSettings("video", pf);
    } else if ("preshot".equals(settings)) {
        AddModeSettings("pixfix", pf);
    } else if ("multishot".equals(settings)) {
        AddModeSettings("multishot", pf);
    } else if ("panorama_augmented".equals(settings)) {
        AddModeSettings("panorama_augmented", pf);
    } else if ("bestshotmode".equals(settings)) {
        AddModeSettings("bestshotmode", pf);
    } else if ("saving_settings".equals(settings)) {
        // for (int i = 0; i < listFilter.size(); i++)
        // {
        // Plugin pg = listFilter.get(i);
        // if (activeFilter.contains(pg.getID()))
        // activePlugins.add(pg);
        // else
        // inactivePlugins.add(pg);
        // }
        // if (activePlugins.size() != listFilter.size() &&
        // isPreferenecesAvailable(inactivePlugins, false))
        // hasInactive = true;
        addHeadersContent(pf, activePlugins, false);

        activePlugins.clear();
        inactivePlugins.clear();
        for (int i = 0; i < listExport.size(); i++) {
            Plugin pg = listExport.get(i);
            if (activeExport.contains(pg.getID()))
                activePlugins.add(pg);
            else
                inactivePlugins.add(pg);
        }
        if (activePlugins.size() != listExport.size() && isPreferenecesAvailable(inactivePlugins, false))
            hasInactive = true;
        addHeadersContent(pf, activePlugins, false);

        if (hasInactive)
            pf.addPreferencesFromResource(R.xml.preferences_saving_inactive);
    } else if ("saving_inactive_settings".equals(settings)) {
        // for (int i = 0; i < listFilter.size(); i++)
        // {
        // Plugin pg = listFilter.get(i);
        // if (!activeFilter.contains(pg.getID()))
        // inactivePlugins.add(pg);
        // }
        addHeadersContent(pf, inactivePlugins, false);

        activePlugins.clear();
        for (int i = 0; i < listExport.size(); i++) {
            Plugin pg = listExport.get(i);
            if (!activeExport.contains(pg.getID()))
                inactivePlugins.add(pg);
        }
        addHeadersContent(pf, inactivePlugins, false);
    } else if ("advanced".equals(settings)) {
        loadCommonAdvancedSettings(pf);

        for (int i = 0; i < listVF.size(); i++) {
            Plugin pg = listVF.get(i);
            if (activeVF.contains(pg.getID()))
                activePlugins.add(pg);
            else
                inactivePlugins.add(pg);
        }
        if (isPreferenecesAvailable(inactivePlugins, true))
            hasInactive = true;
        addHeadersContent(pf, activePlugins, true);

        activePlugins.clear();
        inactivePlugins.clear();
        for (int i = 0; i < listCapture.size(); i++) {
            Plugin pg = listCapture.get(i);
            if (activeCapture.equals(pg.getID()))
                activePlugins.add(pg);
            else
                inactivePlugins.add(pg);
        }
        if (isPreferenecesAvailable(inactivePlugins, true))
            hasInactive = true;
        addHeadersContent(pf, activePlugins, true);

        activePlugins.clear();
        inactivePlugins.clear();
        for (int i = 0; i < listProcessing.size(); i++) {
            Plugin pg = listProcessing.get(i);
            if (activeProcessing.equals(pg.getID()))
                activePlugins.add(pg);
            else
                inactivePlugins.add(pg);
        }
        if (isPreferenecesAvailable(inactivePlugins, true))
            hasInactive = true;
        addHeadersContent(pf, activePlugins, true);

        activePlugins.clear();
        inactivePlugins.clear();
        // for (int i = 0; i < listFilter.size(); i++)
        // {
        // Plugin pg = listFilter.get(i);
        // if (activeFilter.contains(pg.getID()))
        // activePlugins.add(pg);
        // else
        // inactivePlugins.add(pg);
        // }
        if (isPreferenecesAvailable(inactivePlugins, true))
            hasInactive = true;
        addHeadersContent(pf, activePlugins, true);

        activePlugins.clear();
        inactivePlugins.clear();
        for (int i = 0; i < listExport.size(); i++) {
            Plugin pg = listExport.get(i);
            if (activeExport.equals(pg.getID()))
                activePlugins.add(pg);
            else
                inactivePlugins.add(pg);
        }
        if (isPreferenecesAvailable(inactivePlugins, true))
            hasInactive = true;
        addHeadersContent(pf, activePlugins, true);

        if (hasInactive)
            pf.addPreferencesFromResource(R.xml.preferences_advance_inactive);
    } else if ("advanced_inactive".equals(settings)) {
        for (int i = 0; i < listVF.size(); i++) {
            Plugin pg = listVF.get(i);
            if (!activeVF.contains(pg.getID()))
                inactivePlugins.add(pg);
        }
        addHeadersContent(pf, inactivePlugins, true);

        inactivePlugins.clear();
        for (int i = 0; i < listCapture.size(); i++) {
            Plugin pg = listCapture.get(i);
            if (!activeCapture.equals(pg.getID()))
                inactivePlugins.add(pg);
        }
        addHeadersContent(pf, inactivePlugins, true);

        inactivePlugins.clear();
        for (int i = 0; i < listProcessing.size(); i++) {
            Plugin pg = listProcessing.get(i);
            if (!activeProcessing.equals(pg.getID()))
                inactivePlugins.add(pg);
        }
        addHeadersContent(pf, inactivePlugins, true);

        inactivePlugins.clear();
        // for (int i = 0; i < listFilter.size(); i++)
        // {
        // Plugin pg = listFilter.get(i);
        // if (!activeFilter.contains(pg.getID()))
        // inactivePlugins.add(pg);
        // }
        addHeadersContent(pf, inactivePlugins, true);

        inactivePlugins.clear();
        for (int i = 0; i < listExport.size(); i++) {
            Plugin pg = listExport.get(i);
            if (!activeExport.equals(pg.getID()))
                inactivePlugins.add(pg);
        }
        addHeadersContent(pf, inactivePlugins, true);
    } else if ("plugins_settings".equals(settings)) {
        pf.getActivity().finish();
        Preferences.closePrefs();
        MainScreen.setShowStore(true);
    }
}