src/main/java/de/blau/android/presets/AutoPreset.java
/**
     * Instantiate a Preset from the auto-preset files
     * 
     * @param context Android context
     * @param activePresets array of active presets
     * @param autopresetPosition the position we will add the auto preset
     * @throws ParserConfigurationException
     * @throws SAXException
     * @throws IOException
     * @throws NoSuchAlgorithmException
     */
Instantiate a Preset from the auto-preset files


Instantiate a Preset from the auto - preset files
public static void readAutoPreset(@NonNull Context context, @NonNull Preset[] activePresets, int autopresetPosition)
            throws ParserConfigurationException, SAXException, IOException, NoSuchAlgorithmException {
        String autopresetGroupName = context.getString(R.string.preset_autopreset);
        try {
            File autoPresetDir = FileUtil.getPublicDirectory(FileUtil.getPublicDirectory(), Paths.DIRECTORY_PATH_AUTOPRESET);
            File autoIcon = new File(autoPresetDir, AutoPreset.ICON);
            if (!autoIcon.exists()) {
                for (int i = 0; i < ICONS.length; i++) {
                    try {
                        FileUtil.copyFileFromAssets(context, "images/" + ICONS[i], autoPresetDir, ICONSDEST[i]);
                    } catch (IOException e) {
                        Log.e(DEBUG_TAG, "Icon not found " + ICONS[i] + " " + e.getMessage());
                    }
                }
                (new File(autoPresetDir, ".nomedia")).createNewFile(); 
            }
        } catch (IOException e) {
            Log.e(DEBUG_TAG, "Icon/file not found ", e);
        }
        activePresets[autopresetPosition] = new Preset(context, FileUtil.getPublicDirectory(FileUtil.getPublicDirectory(), Paths.DIRECTORY_PATH_AUTOPRESET),
                null, true);
        Preset autopreset = activePresets[autopresetPosition];
        PresetGroup group = autopreset.getGroupByName(autopresetGroupName);
        if (group == null) {
            new PresetGroup(autopreset, autopreset.getRootGroup(), autopresetGroupName, AutoPreset.ICON);
        }
    }
public static void readAutoPreset ( @ NonNull Context context , @ NonNull Preset [ ] activePresets , int autopresetPosition ) throws ParserConfigurationException , SAXException , IOException , NoSuchAlgorithmException { String autopresetGroupName = context . getString ( R . string . preset_autopreset ) ; try { File autoPresetDir = FileUtil . getPublicDirectory ( FileUtil . getPublicDirectory ( ) , Paths . DIRECTORY_PATH_AUTOPRESET ) ; File autoIcon = new File ( autoPresetDir , AutoPreset . ICON ) ; if ( ! autoIcon . exists ( ) ) { for ( int i = 0 ; i < ICONS . length ; i ++ ) { try { FileUtil . copyFileFromAssets ( context , "images/" + ICONS [ i ] , autoPresetDir , ICONSDEST [ i ] ) ; } catch ( IOException e ) { Log . e ( DEBUG_TAG , "Icon not found " + ICONS [ i ] + " " + e . getMessage ( ) ) ; } } ( new File ( autoPresetDir , ".nomedia" ) ) . createNewFile ( ) ; } } catch ( IOException e ) { Log . e ( DEBUG_TAG , "Icon/file not found " , e ) ; } activePresets [ autopresetPosition ] = new Preset ( context , FileUtil . getPublicDirectory ( FileUtil . getPublicDirectory ( ) , Paths . DIRECTORY_PATH_AUTOPRESET ) , null , true ) ; Preset autopreset = activePresets [ autopresetPosition ] ; PresetGroup group = autopreset . getGroupByName ( autopresetGroupName ) ; if ( group == null ) { new PresetGroup ( autopreset , autopreset . getRootGroup ( ) , autopresetGroupName , AutoPreset . ICON ) ; } }
Instantiate a Preset from the auto-preset files
Instantiate a Preset from the auto - preset files
// add .nomedia file to stop the directory being indexed // NOSONAR // don't fail because of an exception here