<commit_before>package com.garethevans.church.opensongtablet;

import android.app.Activity;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;

public class ListSongFiles extends Activity {
	
	public static void listSongFolders() {
		File songfolder = new File(FullscreenActivity.root.getAbsolutePath() + "/documents/OpenSong/Songs");
		File[] tempmyitems = null;
		if (songfolder.isDirectory() && songfolder!=null) {
				tempmyitems = songfolder.listFiles();
		}
		// Go through this list and check if the item is a directory or a file.
		int tempnumitems=0;
		if (tempmyitems != null && tempmyitems.length>0) {
			tempnumitems = tempmyitems.length;
		} else {
			tempnumitems = 0;
		}
		int numactualdirs  = 0;
		for (int x=0; x<tempnumitems; x++) {
			if (tempmyitems[x] != null && tempmyitems[x].isDirectory()){
				numactualdirs ++;
			}
		}
		
		//Now set the size of the temp arrays
		ArrayList<String> tempProperDirectories = new ArrayList<String>();

		//Now read the stuff into the temp array
		for (int x=0; x<tempnumitems; x++) {
			if (tempmyitems[x] != null && tempmyitems[x].isDirectory()) {
				tempProperDirectories.add(tempmyitems[x].getName());
			}
		}

		//Sort these arrays
		Collections.sort(tempProperDirectories, String.CASE_INSENSITIVE_ORDER);
		
		FullscreenActivity.mSongFolderNames = new String[numactualdirs+1];
		FullscreenActivity.mSongFolderNames = tempProperDirectories.toArray(FullscreenActivity.mSongFolderNames);

		// Now go through each folder and add the file names to these arrays
		FullscreenActivity.childSongs = new String[numactualdirs+1][];

		// Add the MAIN folder first
		File[] temp_mainfiles = songfolder.listFiles();
		int main_numfiles = 0;
		if (songfolder.isDirectory() && temp_mainfiles != null) {
			main_numfiles = temp_mainfiles.length;			
		}

		// Go through this list and check if the item is a directory or a file.
		if (temp_mainfiles != null && main_numfiles>0 && songfolder.isDirectory()) {
				main_numfiles = temp_mainfiles.length;
			} else {
				main_numfiles = 0;
			}
		//Now set the size of the temp arrays
		ArrayList<String> tempMainProperFiles= new ArrayList<String>();
		int temp_mainnumfilescount = 0;
		for (int x=0; x<main_numfiles; x++) {
			if (temp_mainfiles[x] != null && !temp_mainfiles[x].isDirectory() && temp_mainfiles[x].isFile()){
				tempMainProperFiles.add(temp_mainfiles[x].getName());
				temp_mainnumfilescount++;
			}
		}
			
		//Sort these arrays
		Collections.sort(tempMainProperFiles, String.CASE_INSENSITIVE_ORDER);

		FullscreenActivity.childSongs[0] = new String[temp_mainnumfilescount];
		FullscreenActivity.childSongs[0] = tempMainProperFiles.toArray(FullscreenActivity.childSongs[0]);
		
		
		for (int w=0;w<numactualdirs;w++) {
			File currsongfolder = new File(FullscreenActivity.root.getAbsolutePath() + "/documents/OpenSong/Songs/"+FullscreenActivity.mSongFolderNames[w]);
			File[] tempmyfiles = currsongfolder.listFiles();		
			// Go through this list and check if the item is a directory or a file.
			int tempnumfiles=0;
			if (tempmyfiles != null && tempmyfiles.length>0) {
				tempnumfiles = tempmyfiles.length;
			} else {
				tempnumfiles = 0;
			}
			int numactualfiles  = 0;
			for (int x=0; x<tempnumfiles; x++) {
				if (tempmyfiles[x] != null && tempmyfiles[x].isFile()){
					numactualfiles ++;
				}
			}
			
			//Now set the size of the temp arrays
			ArrayList<String> tempProperFiles= new ArrayList<String>();

			//Now read the stuff into the temp array
			for (int x=0; x<numactualfiles; x++) {
				if (tempmyfiles[x] != null && tempmyfiles[x].isFile()) {
					tempProperFiles.add(tempmyfiles[x].getName());
				}
			}

			//Sort these arrays
			Collections.sort(tempProperFiles, String.CASE_INSENSITIVE_ORDER);

			FullscreenActivity.childSongs[w+1] = new String[numactualfiles];
			FullscreenActivity.childSongs[w+1] = tempProperFiles.toArray(FullscreenActivity.childSongs[w+1]);

		}
	}
	
	public static void listSongs() {
		// A temporary array to put the file names into.  Do this, sort the array
		// In the proper array mSongFileNames make it one item larger
		// Set item 0 to be the menu showing which folder is being browsed
		// Then add all the temp array items into the new one in a position higher by 1

		// List the items in the main storage location into a temporary array.<commit_msg>Added locale sort order<commit_after>package com.garethevans.church.opensongtablet;

import android.app.Activity;

import java.io.File;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;

public class ListSongFiles extends Activity {
	
	public static void listSongFolders() {
		File songfolder = new File(FullscreenActivity.root.getAbsolutePath() + "/documents/OpenSong/Songs");
		File[] tempmyitems = null;
		if (songfolder.isDirectory() && songfolder!=null) {
				tempmyitems = songfolder.listFiles();
		}
		// Go through this list and check if the item is a directory or a file.
		int tempnumitems=0;
		if (tempmyitems != null && tempmyitems.length>0) {
			tempnumitems = tempmyitems.length;
		} else {
			tempnumitems = 0;
		}
		int numactualdirs  = 0;
		for (int x=0; x<tempnumitems; x++) {
			if (tempmyitems[x] != null && tempmyitems[x].isDirectory()){
				numactualdirs ++;
			}
		}
		
		//Now set the size of the temp arrays
		ArrayList<String> tempProperDirectories = new ArrayList<String>();

		//Now read the stuff into the temp array
		for (int x=0; x<tempnumitems; x++) {
			if (tempmyitems[x] != null && tempmyitems[x].isDirectory()) {
				tempProperDirectories.add(tempmyitems[x].getName());
			}
		}

		//Sort these arrays
		// Add locale sort
		Collator coll = Collator.getInstance(FullscreenActivity.locale);
		coll.setStrength(Collator.PRIMARY);
		Collections.sort(tempProperDirectories,coll);
		//Collections.sort(tempProperDirectories, String.CASE_INSENSITIVE_ORDER);
		
		FullscreenActivity.mSongFolderNames = new String[numactualdirs+1];
		FullscreenActivity.mSongFolderNames = tempProperDirectories.toArray(FullscreenActivity.mSongFolderNames);

		// Now go through each folder and add the file names to these arrays
		FullscreenActivity.childSongs = new String[numactualdirs+1][];

		// Add the MAIN folder first
		File[] temp_mainfiles = songfolder.listFiles();
		int main_numfiles = 0;
		if (songfolder.isDirectory() && temp_mainfiles != null) {
			main_numfiles = temp_mainfiles.length;			
		}

		// Go through this list and check if the item is a directory or a file.
		if (temp_mainfiles != null && main_numfiles>0 && songfolder.isDirectory()) {
				main_numfiles = temp_mainfiles.length;
			} else {
				main_numfiles = 0;
			}
		//Now set the size of the temp arrays
		ArrayList<String> tempMainProperFiles= new ArrayList<String>();
		int temp_mainnumfilescount = 0;
		for (int x=0; x<main_numfiles; x++) {
			if (temp_mainfiles[x] != null && !temp_mainfiles[x].isDirectory() && temp_mainfiles[x].isFile()){
				tempMainProperFiles.add(temp_mainfiles[x].getName());
				temp_mainnumfilescount++;
			}
		}
			
		//Sort these arrays
		// Add locale sort
		Collator coll = Collator.getInstance(FullscreenActivity.locale);
		coll.setStrength(Collator.PRIMARY);
		Collections.sort(tempMainProperFiles,coll);
		//Collections.sort(tempMainProperFiles, String.CASE_INSENSITIVE_ORDER);

		FullscreenActivity.childSongs[0] = new String[temp_mainnumfilescount];
		FullscreenActivity.childSongs[0] = tempMainProperFiles.toArray(FullscreenActivity.childSongs[0]);
		
		
		for (int w=0;w<numactualdirs;w++) {
			File currsongfolder = new File(FullscreenActivity.root.getAbsolutePath() + "/documents/OpenSong/Songs/"+FullscreenActivity.mSongFolderNames[w]);
			File[] tempmyfiles = currsongfolder.listFiles();		
			// Go through this list and check if the item is a directory or a file.
			int tempnumfiles=0;
			if (tempmyfiles != null && tempmyfiles.length>0) {
				tempnumfiles = tempmyfiles.length;
			} else {
				tempnumfiles = 0;
			}
			int numactualfiles  = 0;
			for (int x=0; x<tempnumfiles; x++) {
				if (tempmyfiles[x] != null && tempmyfiles[x].isFile()){
					numactualfiles ++;
				}
			}
			
			//Now set the size of the temp arrays
			ArrayList<String> tempProperFiles= new ArrayList<String>();

			//Now read the stuff into the temp array
			for (int x=0; x<numactualfiles; x++) {
				if (tempmyfiles[x] != null && tempmyfiles[x].isFile()) {
					tempProperFiles.add(tempmyfiles[x].getName());
				}
			}

			//Sort these arrays
			// Add locale sort
			Collator coll = Collator.getInstance(FullscreenActivity.locale);
			coll.setStrength(Collator.PRIMARY);
			Collections.sort(tempProperFiles,coll);
			//Collections.sort(tempProperFiles, String.CASE_INSENSITIVE_ORDER);

			FullscreenActivity.childSongs[w+1] = new String[numactualfiles];
			FullscreenActivity.childSongs[w+1] = tempProperFiles.toArray(FullscreenActivity.childSongs[w+1]);

		}
	}
	
	public static void listSongs() {
		// A temporary array to put the file names into.  Do this, sort the array
		// In the proper array mSongFileNames make it one item larger
		// Set item 0 to be the menu showing which folder is being browsed
		// Then add all the temp array items into the new one in a position higher by 1

		// List the items in the main storage location into a temporary array.
{'fraction_non_alphanumeric': 0.11410408361167977, 'fraction_numerical': 0.006033832561146428, 'mean_word_length': 4.097199341021417, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3230324', 'n_tokens_mistral': 3381, 'n_tokens_neox': 2916, 'n_words': 760}