<commit_before>/**
 * 
 */
package org.readium.sdklauncher_android;

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

import org.readium.sdk.android.EPub3;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

/**
 * @author chtian
 * 
 */
public class ContainerList extends Activity {
    private Context context;
    private final String testPath = "epubtest";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.container_list);
        context = this;
        final ListView view = (ListView) findViewById(R.id.containerList);

        final ArrayList<String> list = getInnerBooks();

        BookListAdapter bookListAdapter = new BookListAdapter(this, list);
        view.setAdapter(bookListAdapter);

        if (0 == list.size()) {
            Toast.makeText(
                    context,
                    Environment.getExternalStorageDirectory().getAbsolutePath()
                            + "/" + testPath
                            + "/ is empty, copy epub3 test file first please.",
                    Toast.LENGTH_LONG).show();
        }

        view.setOnItemClickListener(new ListView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {

                Toast.makeText(context, "Select " + list.get(arg2),
                        Toast.LENGTH_SHORT).show();

                // TODO: Get book content object.....
                EPub3 epub = new EPub3();
                int handle = epub.openBook(Environment
                        .getExternalStorageDirectory().getAbsolutePath()
                        + "/"
                        + testPath + "/" + list.get(arg2));
                // ---------------------------

                Intent intent = new Intent(getApplicationContext(),
                        BookDataActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.putExtra("bookname", list.get(arg2));
                startActivity(intent);
            }
        });
    }

    // get books in /sdcard/epubtest path
    private ArrayList<String> getInnerBooks() {
        ArrayList<String> list = new ArrayList<String>();
        File sdcard = Environment.getExternalStorageDirectory();
        File epubpath = new File(sdcard, "epubtest");
        for (File f : epubpath.listFiles()) {
            if (f.isFile()) {
                String name = f.getName();
                if (name.length() > 5
                        && name.substring(name.length() - 5).equals(".epub")) {

                    list.add(name);
                    Log.i("books", name);
                }
            }
        }

        return list;
    }

}
<commit_msg>Minor change to Launcher to interface with new ePub3-Library<commit_after>/**
 * 
 */
package org.readium.sdklauncher_android;

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

import org.readium.sdk.android.Container;
import org.readium.sdk.android.EPub3;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

/**
 * @author chtian
 * 
 */
public class ContainerList extends Activity {
    private Context context;
    private final String testPath = "epubtest";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.container_list);
        context = this;
        final ListView view = (ListView) findViewById(R.id.containerList);

        final ArrayList<String> list = getInnerBooks();

        BookListAdapter bookListAdapter = new BookListAdapter(this, list);
        view.setAdapter(bookListAdapter);

        if (0 == list.size()) {
            Toast.makeText(
                    context,
                    Environment.getExternalStorageDirectory().getAbsolutePath()
                            + "/" + testPath
                            + "/ is empty, copy epub3 test file first please.",
                    Toast.LENGTH_LONG).show();
        }

        view.setOnItemClickListener(new ListView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {

                Toast.makeText(context, "Select " + list.get(arg2),
                        Toast.LENGTH_SHORT).show();

                // TODO: Get book content object.....
                Container container = EPub3.openBook(Environment
                        .getExternalStorageDirectory().getAbsolutePath()
                        + "/"
                        + testPath + "/" + list.get(arg2));
                // ---------------------------

                Intent intent = new Intent(getApplicationContext(),
                        BookDataActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.putExtra("bookname", list.get(arg2));
                startActivity(intent);
            }
        });
    }

    // get books in /sdcard/epubtest path
    private ArrayList<String> getInnerBooks() {
        ArrayList<String> list = new ArrayList<String>();
        File sdcard = Environment.getExternalStorageDirectory();
        File epubpath = new File(sdcard, "epubtest");
        for (File f : epubpath.listFiles()) {
            if (f.isFile()) {
                String name = f.getName();
                if (name.length() > 5
                        && name.substring(name.length() - 5).equals(".epub")) {

                    list.add(name);
                    Log.i("books", name);
                }
            }
        }

        return list;
    }

}

{'fraction_non_alphanumeric': 0.11478316943414477, 'fraction_numerical': 0.004513944865387715, 'mean_word_length': 1.7858105074090704, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3022533', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1549, 'n_words': 334}