// Path: src/com/hughes/android/dictionary/DictionaryInfo.java
// public static final class IndexInfo implements Serializable {
//     private static final long serialVersionUID = 6524751236198309438L;
// 
//     static final int NUM_CSV_FIELDS = 3;
// 
//     public final String shortName; // Often LangISO.
//     final int allTokenCount;
//     public final int mainTokenCount;
// 
//     public IndexInfo(String shortName, int allTokenCount, int mainTokenCount) {
//         this.shortName = shortName;
//         this.allTokenCount = allTokenCount;
//         this.mainTokenCount = mainTokenCount;
//     }
// 
//     void append(StringBuilder result) {
//         result.append(shortName);
//         result.append("\t").append(allTokenCount);
//         result.append("\t").append(mainTokenCount);
//     }
// 
//     public IndexInfo(final String[] fields, int i) {
//         shortName = fields[i++];
//         allTokenCount = Integer.parseInt(fields[i++]);
//         mainTokenCount = Integer.parseInt(fields[i++]);
//     }
// }
// 
// Path: src/com/hughes/android/util/IntentLauncher.java
// public class IntentLauncher implements OnClickListener {
// 
//     private final Context context;
//     private final Intent intent;
// 
//     public IntentLauncher(final Context context, final Intent intent) {
//         this.context = context;
//         this.intent = intent;
//     }
// 
//     protected void onGo() {
//     }
// 
//     private void go() {
//         onGo();
//         context.startActivity(intent);
//     }
// 
//     @Override
//     public void onClick(View v) {
//         go();
//     }
// 
// }


import android.Manifest;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.DownloadManager.Request;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.support.v4.provider.DocumentFile;
import android.support.v7.preference.PreferenceManager;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.SearchView.OnQueryTextListener;
import android.support.v7.widget.Toolbar;
import android.text.InputType;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.hughes.android.dictionary.DictionaryInfo.IndexInfo;
import com.hughes.android.util.IntentLauncher;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
        final boolean updateAvailable = application.updateAvailable(dictionaryInfo);
        final Button downloadButton = row.findViewById(R.id.downloadButton);
        final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename);
        boolean broken = false;
        if (!dictionaryInfo.isValid()) {
            broken = true;
            canLaunch = false;
        }
        if (downloadable != null && (!canLaunch || updateAvailable)) {
            downloadButton
            .setText(getString(
                         R.string.downloadButton,
                         downloadable.zipBytes / 1024.0 / 1024.0));
            downloadButton.setMinWidth(application.languageButtonPixels * 3 / 2);
            downloadButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    downloadDictionary(downloadable.downloadUrl, downloadable.zipBytes, downloadButton);
                }
            });
            downloadButton.setVisibility(View.VISIBLE);

            if (isDownloadActive(downloadable.downloadUrl, false))
                downloadButton.setText("X");
        } else {
            downloadButton.setVisibility(View.GONE);
        }

        LinearLayout buttons = row.findViewById(R.id.dictionaryLauncherButtons);

// Path: src/com/hughes/android/dictionary/DictionaryInfo.java
// public static final class IndexInfo implements Serializable {
//     private static final long serialVersionUID = 6524751236198309438L;
// 
//     static final int NUM_CSV_FIELDS = 3;
// 
//     public final String shortName; // Often LangISO.
//     final int allTokenCount;
//     public final int mainTokenCount;
// 
//     public IndexInfo(String shortName, int allTokenCount, int mainTokenCount) {
//         this.shortName = shortName;
//         this.allTokenCount = allTokenCount;
//         this.mainTokenCount = mainTokenCount;
//     }
// 
//     void append(StringBuilder result) {
//         result.append(shortName);
//         result.append("\t").append(allTokenCount);
//         result.append("\t").append(mainTokenCount);
//     }
// 
//     public IndexInfo(final String[] fields, int i) {
//         shortName = fields[i++];
//         allTokenCount = Integer.parseInt(fields[i++]);
//         mainTokenCount = Integer.parseInt(fields[i++]);
//     }
// }
// 
// Path: src/com/hughes/android/util/IntentLauncher.java
// public class IntentLauncher implements OnClickListener {
// 
//     private final Context context;
//     private final Intent intent;
// 
//     public IntentLauncher(final Context context, final Intent intent) {
//         this.context = context;
//         this.intent = intent;
//     }
// 
//     protected void onGo() {
//     }
// 
//     private void go() {
//         onGo();
//         context.startActivity(intent);
//     }
// 
//     @Override
//     public void onClick(View v) {
//         go();
//     }
// 
// }


// Path: src/com/hughes/android/dictionary/DictionaryManagerActivity.java
import android.Manifest;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.DownloadManager.Request;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.support.v4.provider.DocumentFile;
import android.support.v7.preference.PreferenceManager;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.SearchView.OnQueryTextListener;
import android.support.v7.widget.Toolbar;
import android.text.InputType;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.hughes.android.dictionary.DictionaryInfo.IndexInfo;
import com.hughes.android.util.IntentLauncher;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

        final boolean updateAvailable = application.updateAvailable(dictionaryInfo);
        final Button downloadButton = row.findViewById(R.id.downloadButton);
        final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename);
        boolean broken = false;
        if (!dictionaryInfo.isValid()) {
            broken = true;
            canLaunch = false;
        }
        if (downloadable != null && (!canLaunch || updateAvailable)) {
            downloadButton
            .setText(getString(
                         R.string.downloadButton,
                         downloadable.zipBytes / 1024.0 / 1024.0));
            downloadButton.setMinWidth(application.languageButtonPixels * 3 / 2);
            downloadButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    downloadDictionary(downloadable.downloadUrl, downloadable.zipBytes, downloadButton);
                }
            });
            downloadButton.setVisibility(View.VISIBLE);

            if (isDownloadActive(downloadable.downloadUrl, false))
                downloadButton.setText("X");
        } else {
            downloadButton.setVisibility(View.GONE);
        }

        LinearLayout buttons = row.findViewById(R.id.dictionaryLauncherButtons);

        final List<IndexInfo> sortedIndexInfos = application