Commits

Ben Luo committed 6894a5e

it works

Comments (0)

Files changed (15)

.idea/inspectionProfiles/Project_Default.xml

+<component name="InspectionProjectProfileManager">
+  <profile version="1.0" is_locked="false">
+    <option name="myName" value="Project Default" />
+    <option name="myLocal" value="false" />
+    <inspection_tool class="AndroidLintButtonStyle" enabled="false" level="WARNING" enabled_by_default="false" />
+    <inspection_tool class="AndroidLintUselessParent" enabled="false" level="WARNING" enabled_by_default="false" />
+  </profile>
+</component>

.idea/inspectionProfiles/profiles_settings.xml

+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="PROJECT_PROFILE" value="Project Default" />
+    <option name="USE_PROJECT_PROFILE" value="true" />
+    <version value="1.0" />
+  </settings>
+</component>
 <?xml version="1.0" encoding="UTF-8"?>
 <module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="false">
-    <output url="file://$MODULE_DIR$/build/classes/main" />
-    <output-test url="file://$MODULE_DIR$/build/classes/test" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <excludeFolder url="file://$MODULE_DIR$/.gradle" />

app/src/main/AndroidManifest.xml

                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+        <activity
+            android:name="org.benluo.yimushihang.app.FileBrowserActivity"
+            android:label="@string/title_activity_file_browser" >
+        </activity>
     </application>
-
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 </manifest>

app/src/main/java/org/benluo/yimushihang/app/FileBrowserActivity.java

+package org.benluo.yimushihang.app;
+
+
+//Heavily based on code from
+//https://github.com/mburman/Android-File-Explore
+//	Version of Aug 13, 2011
+//Also contributed:
+//  Sugan Krishnan (https://github.com/rgksugan) - Jan 2013.
+//
+
+//Project type now is Android library:
+//  http://developer.android.com/guide/developing/projects/projects-eclipse.html#ReferencingLibraryProject
+
+//General Java imports
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.StatFs;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+//Android imports
+//Import of resources file for file browser
+
+public class FileBrowserActivity extends Activity {
+    // Intent Action Constants
+    public static final String INTENT_ACTION_SELECT_DIR = "SELECT_DIRECTORY_ACTION";
+    public static final String INTENT_ACTION_SELECT_FILE = "SELECT_FILE_ACTION";
+
+    // Intent parameters names constants
+    public static final String startDirectoryParameter = "directoryPath";
+    public static final String returnDirectoryParameter = "directoryPathRet";
+    public static final String returnFileParameter = "filePathRet";
+    public static final String showCannotReadParameter = "showCannotRead";
+    public static final String filterExtension = "filterExtension";
+
+    // Stores names of traversed directories
+    ArrayList<String> pathDirsList = new ArrayList<String>();
+
+    // Check if the first level of the directory structure is the one showing
+    // private Boolean firstLvl = true;
+
+    private static final String LOGTAG = "F_PATH";
+
+    private List<Item> fileList = new ArrayList<Item>();
+    private File path = null;
+    private String chosenFile;
+    // private static final int DIALOG_LOAD_FILE = 1000;
+
+    ArrayAdapter<Item> adapter;
+
+    private boolean showHiddenFilesAndDirs = true;
+
+    private boolean directoryShownIsEmpty = false;
+
+    private String filterFileExtension = null;
+
+    // Action constants
+    private static int currentAction = -1;
+    private static final int SELECT_DIRECTORY = 1;
+    private static final int SELECT_FILE = 2;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        // In case of
+        // SELECT_DIRECTORY_ACTION
+        // Expects com.mburman.fileexplore.directoryPath parameter to
+        // point to the start folder.
+        // If empty or null, will start from SDcard root.
+        setContentView(R.layout.activity_file_browser);
+
+        // Set action for this activity
+        Intent thisInt = this.getIntent();
+        currentAction = SELECT_DIRECTORY;// This would be a default action in
+        // case not set by intent
+        if (thisInt.getAction().equalsIgnoreCase(INTENT_ACTION_SELECT_FILE)) {
+            Log.d(LOGTAG, "SELECT ACTION - SELECT FILE");
+            currentAction = SELECT_FILE;
+        }
+
+        showHiddenFilesAndDirs = thisInt.getBooleanExtra(
+                showCannotReadParameter, true);
+
+        filterFileExtension = thisInt.getStringExtra(filterExtension);
+
+        setInitialDirectory();
+
+        parseDirectoryPath();
+        loadFileList();
+        this.createFileListAdapter();
+        this.initializeButtons();
+        this.initializeFileListView();
+        updateCurrentDirectoryTextView();
+        Log.d(LOGTAG, path.getAbsolutePath());
+    }
+
+    private void setInitialDirectory() {
+        Intent thisInt = this.getIntent();
+        String requestedStartDir = thisInt
+                .getStringExtra(startDirectoryParameter);
+
+        if (requestedStartDir != null && requestedStartDir.length() > 0) {// if(requestedStartDir!=null
+            File tempFile = new File(requestedStartDir);
+            if (tempFile.isDirectory())
+                this.path = tempFile;
+        }// if(requestedStartDir!=null
+
+        if (this.path == null) {// No or invalid directory supplied in intent
+            // parameter
+            if (Environment.getExternalStorageDirectory().isDirectory()
+                    && Environment.getExternalStorageDirectory().canRead())
+                path = Environment.getExternalStorageDirectory();
+            else
+                path = new File("/");
+        }// if(this.path==null) {//No or invalid directory supplied in intent
+        // parameter
+    }// private void setInitialDirectory() {
+
+    private void parseDirectoryPath() {
+        pathDirsList.clear();
+        String pathString = path.getAbsolutePath();
+        String[] parts = pathString.split("/");
+        int i = 0;
+        while (i < parts.length) {
+            pathDirsList.add(parts[i]);
+            i++;
+        }
+    }
+
+    private void initializeButtons() {
+        Button upDirButton = (Button) this.findViewById(R.id.upDirectoryButton);
+        upDirButton.setOnClickListener(new OnClickListener() {
+            public void onClick(View v) {
+                Log.d(LOGTAG, "onclick for upDirButton");
+                loadDirectoryUp();
+                loadFileList();
+                adapter.notifyDataSetChanged();
+                updateCurrentDirectoryTextView();
+            }
+        });// upDirButton.setOnClickListener(
+
+        Button selectFolderButton = (Button) this
+                .findViewById(R.id.selectCurrentDirectoryButton);
+        if (currentAction == SELECT_DIRECTORY) {
+            selectFolderButton.setOnClickListener(new OnClickListener() {
+                public void onClick(View v) {
+                    Log.d(LOGTAG, "onclick for selectFolderButton");
+                    returnDirectoryFinishActivity();
+                }
+            });
+        } else {// if(currentAction == this.SELECT_DIRECTORY) {
+            selectFolderButton.setVisibility(View.GONE);
+        }// } else {//if(currentAction == this.SELECT_DIRECTORY) {
+    }// private void initializeButtons() {
+
+    private void loadDirectoryUp() {
+        // present directory removed from list
+        String s = pathDirsList.remove(pathDirsList.size() - 1);
+        // path modified to exclude present directory
+        path = new File(path.toString().substring(0,
+                path.toString().lastIndexOf(s)));
+        fileList.clear();
+    }
+
+    private void updateCurrentDirectoryTextView() {
+        int i = 0;
+        String curDirString = "";
+        while (i < pathDirsList.size()) {
+            curDirString += pathDirsList.get(i) + "/";
+            i++;
+        }
+        if (pathDirsList.size() == 0) {
+            ((Button) this.findViewById(R.id.upDirectoryButton))
+                    .setEnabled(false);
+            curDirString = "/";
+        } else
+            ((Button) this.findViewById(R.id.upDirectoryButton))
+                    .setEnabled(true);
+        long freeSpace = getFreeSpace(curDirString);
+        String formattedSpaceString = formatBytes(freeSpace);
+        if (freeSpace == 0) {
+            Log.d(LOGTAG, "NO FREE SPACE");
+            File currentDir = new File(curDirString);
+            if (!currentDir.canWrite())
+                formattedSpaceString = "NON Writable";
+        }
+
+        ((Button) this.findViewById(R.id.selectCurrentDirectoryButton))
+                .setText("Select\n[" + formattedSpaceString
+                        + "]");
+
+        ((TextView) this.findViewById(R.id.currentDirectoryTextView))
+                .setText("Current directory: " + curDirString);
+    }// END private void updateCurrentDirectoryTextView() {
+
+    private void showToast(String message) {
+        Toast.makeText(this, message, Toast.LENGTH_LONG).show();
+    }
+
+    private void initializeFileListView() {
+        ListView lView = (ListView) this.findViewById(R.id.fileListView);
+        lView.setBackgroundColor(Color.LTGRAY);
+        LinearLayout.LayoutParams lParam = new LinearLayout.LayoutParams(
+                LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
+        lParam.setMargins(15, 5, 15, 5);
+        lView.setAdapter(this.adapter);
+        lView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            public void onItemClick(AdapterView<?> parent, View view,
+                                    int position, long id) {
+                chosenFile = fileList.get(position).file;
+                File sel = new File(path + "/" + chosenFile);
+                Log.d(LOGTAG, "Clicked:" + chosenFile);
+                if (sel.isDirectory()) {
+                    if (sel.canRead()) {
+                        // Adds chosen directory to list
+                        pathDirsList.add(chosenFile);
+                        path = new File(sel + "");
+                        Log.d(LOGTAG, "Just reloading the list");
+                        loadFileList();
+                        adapter.notifyDataSetChanged();
+                        updateCurrentDirectoryTextView();
+                        Log.d(LOGTAG, path.getAbsolutePath());
+                    } else {// if(sel.canRead()) {
+                        showToast("Path does not exist or cannot be read");
+                    }// } else {//if(sel.canRead()) {
+                }// if (sel.isDirectory()) {
+                // File picked or an empty directory message clicked
+                else {// if (sel.isDirectory()) {
+                    Log.d(LOGTAG, "item clicked");
+                    if (!directoryShownIsEmpty) {
+                        Log.d(LOGTAG, "File selected:" + chosenFile);
+                        returnFileFinishActivity(sel.getAbsolutePath());
+                    }
+                }// else {//if (sel.isDirectory()) {
+            }// public void onClick(DialogInterface dialog, int which) {
+        });// lView.setOnClickListener(
+    }// private void initializeFileListView() {
+
+    private void returnDirectoryFinishActivity() {
+        Intent retIntent = new Intent();
+        retIntent.putExtra(returnDirectoryParameter, path.getAbsolutePath());
+        this.setResult(RESULT_OK, retIntent);
+        this.finish();
+    }// END private void returnDirectoryFinishActivity() {
+
+    private void returnFileFinishActivity(String filePath) {
+        Intent retIntent = new Intent();
+        retIntent.putExtra(returnFileParameter, filePath);
+        this.setResult(RESULT_OK, retIntent);
+        this.finish();
+    }// END private void returnDirectoryFinishActivity() {
+
+    private void loadFileList() {
+        try {
+            path.mkdirs();
+        } catch (SecurityException e) {
+            Log.e(LOGTAG, "unable to write on the sd card ");
+        }
+        fileList.clear();
+
+        if (path.exists() && path.canRead()) {
+            FilenameFilter filter = new FilenameFilter() {
+                public boolean accept(File dir, String filename) {
+                    File sel = new File(dir, filename);
+                    boolean showReadableFile = showHiddenFilesAndDirs
+                            || sel.canRead();
+                    // Filters based on whether the file is hidden or not
+                    if (currentAction == SELECT_DIRECTORY) {
+                        return (sel.isDirectory() && showReadableFile);
+                    }
+                    if (currentAction == SELECT_FILE) {
+
+                        // If it is a file check the extension if provided
+                        if (sel.isFile() && filterFileExtension != null) {
+                            return (showReadableFile && sel.getName().endsWith(
+                                    filterFileExtension));
+                        }
+                        return (showReadableFile);
+                    }
+                    return true;
+                }// public boolean accept(File dir, String filename) {
+            };// FilenameFilter filter = new FilenameFilter() {
+
+            String[] fList = path.list(filter);
+            this.directoryShownIsEmpty = false;
+            for (int i = 0; i < fList.length; i++) {
+                // Convert into file path
+                File sel = new File(path, fList[i]);
+                Log.d(LOGTAG,
+                        "File:" + fList[i] + " readable:"
+                                + (Boolean.valueOf(sel.canRead())).toString()
+                );
+                int drawableID = R.drawable.file_icon;
+                boolean canRead = sel.canRead();
+                // Set drawables
+                if (sel.isDirectory()) {
+                    if (canRead) {
+                        drawableID = R.drawable.folder_icon;
+                    } else {
+                        drawableID = R.drawable.folder_icon_light;
+                    }
+                }
+                fileList.add(i, new Item(fList[i], drawableID, canRead));
+            }// for (int i = 0; i < fList.length; i++) {
+            if (fileList.size() == 0) {
+                // Log.d(LOGTAG, "This directory is empty");
+                this.directoryShownIsEmpty = true;
+                fileList.add(0, new Item("Directory is empty", -1, true));
+            } else {// sort non empty list
+                Collections.sort(fileList, new ItemFileNameComparator());
+            }
+        } else {
+            Log.e(LOGTAG, "path does not exist or cannot be read");
+        }
+        // Log.d(TAG, "loadFileList finished");
+    }// private void loadFileList() {
+
+    private void createFileListAdapter() {
+        adapter = new ArrayAdapter<Item>(this,
+                android.R.layout.select_dialog_item, android.R.id.text1,
+                fileList) {
+            @Override
+            public View getView(int position, View convertView, ViewGroup parent) {
+                // creates view
+                View view = super.getView(position, convertView, parent);
+                TextView textView = (TextView) view
+                        .findViewById(android.R.id.text1);
+                // put the image on the text view
+                int drawableID = 0;
+                if (fileList.get(position).icon != -1) {
+                    // If icon == -1, then directory is empty
+                    drawableID = fileList.get(position).icon;
+                }
+                textView.setCompoundDrawablesWithIntrinsicBounds(drawableID, 0,
+                        0, 0);
+
+                textView.setEllipsize(null);
+
+                // add margin between image and text (support various screen
+                // densities)
+                // int dp5 = (int) (5 *
+                // getResources().getDisplayMetrics().density + 0.5f);
+                int dp3 = (int) (3 * getResources().getDisplayMetrics().density + 0.5f);
+                // TODO: change next line for empty directory, so text will be
+                // centered
+                textView.setCompoundDrawablePadding(dp3);
+                textView.setBackgroundColor(Color.LTGRAY);
+                return view;
+            }// public View getView(int position, View convertView, ViewGroup
+        };// adapter = new ArrayAdapter<Item>(this,
+    }// private createFileListAdapter(){
+
+    private class Item {
+        public String file;
+        public int icon;
+        public boolean canRead;
+
+        public Item(String file, Integer icon, boolean canRead) {
+            this.file = file;
+            this.icon = icon;
+        }
+
+        @Override
+        public String toString() {
+            return file;
+        }
+    }// END private class Item {
+
+    private class ItemFileNameComparator implements Comparator<Item> {
+        public int compare(Item lhs, Item rhs) {
+            return lhs.file.toLowerCase().compareTo(rhs.file.toLowerCase());
+        }
+    }
+
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
+            Log.d(LOGTAG, "ORIENTATION_LANDSCAPE");
+        } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
+            Log.d(LOGTAG, "ORIENTATION_PORTRAIT");
+        }
+        // Layout apparently changes itself, only have to provide good onMeasure
+        // in custom components
+        // TODO: check with keyboard
+        // if(newConfig.keyboard == Configuration.KEYBOARDHIDDEN_YES)
+    }// END public void onConfigurationChanged(Configuration newConfig) {
+
+    public static long getFreeSpace(String path) {
+        StatFs stat = new StatFs(path);
+        long availSize = (long) stat.getAvailableBlocks()
+                * (long) stat.getBlockSize();
+        return availSize;
+    }// END public static long getFreeSpace(String path) {
+
+    public static String formatBytes(long bytes) {
+        // TODO: add flag to which part is needed (e.g. GB, MB, KB or bytes)
+        String retStr = "";
+        // One binary gigabyte equals 1,073,741,824 bytes.
+        if (bytes > 1073741824) {// Add GB
+            long gbs = bytes / 1073741824;
+            retStr += (new Long(gbs)).toString() + "GB ";
+            bytes = bytes - (gbs * 1073741824);
+        }
+        // One MB - 1048576 bytes
+        if (bytes > 1048576) {// Add GB
+            long mbs = bytes / 1048576;
+            retStr += (new Long(mbs)).toString() + "MB ";
+            bytes = bytes - (mbs * 1048576);
+        }
+        if (bytes > 1024) {
+            long kbs = bytes / 1024;
+            retStr += (new Long(kbs)).toString() + "KB";
+            bytes = bytes - (kbs * 1024);
+        } else
+            retStr += (new Long(bytes)).toString() + " bytes";
+        return retStr;
+    }// public static String formatBytes(long bytes){
+
+}// END public class FileBrowserActivity extends Activity {

app/src/main/java/org/benluo/yimushihang/app/MainActivity.java

 import android.app.AlertDialog;
 import android.content.Context;
 import android.content.DialogInterface;
+import android.content.Intent;
 import android.os.Bundle;
+import android.os.Handler;
 import android.view.Menu;
 import android.view.MenuItem;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+
+
+public class MainActivity extends Activity implements View.OnClickListener {
+
+//    File seletedFile;
+    private Context ctx;
+//    private int currentPosition = 0;
+    private int currentSpeed = 12; //12 charactor per second
+    private long loopTime = 1000 / currentSpeed;
+    private InputStreamReader currentDisplayContent = null ;
+    private Handler mHandler;
+    private boolean runBtnStatus;
+//    private long mStartTime;
+    private TextView content;
+    private Button bnStart;
+    private Runnable mUpdateTimeTask;
+    char[] currentDisplay = new char[3];
+//    private final int REQUEST_CODE_PICK_DIR = 1;
+    private final int REQUEST_CODE_PICK_FILE = 2;
+//    private File readingFile;
 
 
-public class MainActivity extends Activity {
-
-    File seletedFile;
-    Context ctx;
-    int currentPosition, currentSpeed;
-
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         ctx = this;
+        runBtnStatus = true;
         setContentView(R.layout.activity_main);
-
+        content = (TextView) findViewById(R.id.tvContent);
+        bnStart = (Button) findViewById(R.id.bnStart);
+        content.setText(R.string.no_content);
     }
 
     @Override
             case R.id.action_about:
                 showAbout();
                 return true;
-//            case R.id.action_select_article:
-////                seletedFile =;
-//                return true;
+            case R.id.action_select_article:
+                selectFile();
+                return true;
 //            case R.id.action_settings:
 //                settings();
 //                return true;
         }
     }
 
-    private void showAbout(){
+    private void showAbout() {
         AlertDialog.Builder aboutDialogBuilder = new AlertDialog.Builder(ctx);
-        String message = getString(R.string.about_content)+"\n"+getString(R.string.version) + getString(R.string.version_number);
+        String message = getString(R.string.about_content) + "\n" + getString(R.string.version) + getString(R.string.version_number);
         aboutDialogBuilder.setTitle(R.string.about)
                 .setIcon(android.R.drawable.ic_dialog_info)
                 .setMessage(message)
                 .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
-
                     @Override
                     public void onClick(DialogInterface dialogInterface, int i) {
                         dialogInterface.dismiss();
                     }
-
                 })
                 .show();
 
     }
 
-    private void settings(){
+    private void selectFile(){
+        Intent fileExploreIntent = new Intent(FileBrowserActivity.INTENT_ACTION_SELECT_FILE,
+                null, this, FileBrowserActivity.class);
+        fileExploreIntent.putExtra(FileBrowserActivity.showCannotReadParameter, false);
+        startActivityForResult(fileExploreIntent,REQUEST_CODE_PICK_FILE);
+    }
+
+//    private void settings() {
+//
+//    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        if (requestCode == REQUEST_CODE_PICK_FILE && resultCode == RESULT_OK) {
+            String fileNameWithWholePath = data.getStringExtra(FileBrowserActivity.returnFileParameter);
+            FileInputStream in = null;
+            try {
+                in = new FileInputStream(new File(fileNameWithWholePath));
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+            try {
+                currentDisplayContent = new InputStreamReader(in, "UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+
+            // set up handler for runnable task
+            mHandler = new Handler();
+            mUpdateTimeTask = new Runnable() {
+                public void run() {
+                    try {
+                        currentDisplayContent.read(currentDisplay, 0, 3);//  new int[]{currentPosition}, currentPosition + 3, currentDisplay, 0);
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+
+                    content.setText(String.valueOf(currentDisplay).replaceAll("(\r\n|\n\r|\r|\n)", "-"));
+//                    currentPosition++;
+
+                    mHandler.postDelayed(this, loopTime);
+                }
+            };
+        }
+
 
     }
 
-    private void run(){
+    @Override
+    public void onClick(View v) {
+//
+//        new Timer().scheduleAtFixedRate(new TimerTask() {
+//            //            private static int i=0;
+//            @Override
+//            public void run() {
+//                char[] currentDisplay = new char[3];
+//                TextView content = (TextView) findViewById(R.id.tvContent);
+//                currentDisplayContent.getChars(currentPosition, currentPosition + 3, currentDisplay, 0);
+//                content.setText("我是谁");//String.valueOf(currentDisplay));
+//                currentPosition++;
+//
+//            }
+//        }, 0, loopTime);//put here time 1000 milliseconds=1 second
+
+        if (currentDisplayContent != null) {
+            if (runBtnStatus) {
+                mHandler.removeCallbacks(mUpdateTimeTask);
+                mHandler.postDelayed(mUpdateTimeTask, loopTime);
+                bnStart.setText(R.string.stop);
+                runBtnStatus = false;
+            } else {
+                mHandler.removeCallbacks(mUpdateTimeTask);
+                bnStart.setText(R.string.start);
+                runBtnStatus = true;
+            }
+
+        }
+
+
 //        running = window.setInterval(function(){
 //            $('#display').text(((sentence.length > i)? sentence[i] : "") + ((sentence.length > i + 1)? sentence[i + 1] : "") + ((sentence.length > i + 2)? sentence[i + 2] : ""));
 //            i = i + 1;
 //        }, 1000 / parseInt($('#speed').val()));
     }
 
-    void ToDBC(String txtstring) {
+//    void ToDBC(String txtstring) {
 //        var tmp = "";
 //        for(var i=0;i<txtstring.length;i++) {
 //            if(txtstring.charCodeAt(i)==32) {
 //
 //        }
 //        return tmp;
-   }
+//    }
 }

app/src/main/res/drawable-mdpi/dir_up.png

Added
New image

app/src/main/res/drawable-mdpi/file_icon.png

Added
New image

app/src/main/res/drawable-mdpi/folder_icon.png

Added
New image

app/src/main/res/drawable-mdpi/folder_icon_light.png

Added
New image

app/src/main/res/layout/activity_file_browser.xml

+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context="org.benluo.yimushihang.app.FileBrowserActivity">
+
+
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="top"
+            android:orientation="horizontal"
+            android:padding="0dp" >
+
+
+
+                <Button
+                    android:id="@+id/upDirectoryButton"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="top"
+                    android:layout_margin="0dp"
+                    android:padding="@dimen/activity_vertical_margin"
+                    android:drawableLeft="@drawable/dir_up"
+                    android:text="@string/up"
+                    android:layout_weight="1" />
+
+
+                <Button
+                    android:id="@+id/selectCurrentDirectoryButton"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="top"
+                    android:gravity = "center|center_vertical"
+                    android:layout_margin="0dp"
+                    android:layout_weight="1"
+                    android:padding="0dp"
+                    android:text="@string/select" />
+            </LinearLayout>
+
+        <TextView
+                    android:id="@+id/currentDirectoryTextView"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/current_folder" />
+
+        <ListView
+                    android:id="@+id/fileListView"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_marginTop="5dp"
+                    android:layout_weight="1" />
+    </LinearLayout>
+
+
+</RelativeLayout>

app/src/main/res/layout/activity_main.xml

         android:layout_alignParentBottom="true"
         android:layout_alignParentLeft="true"
         android:layout_alignParentStart="true"
-        android:layout_marginBottom="73dp">
+        android:layout_marginBottom="73dp"
+        android:gravity="fill_horizontal|center_vertical">
 
         <TextView
-            android:text="@string/about"
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content" />
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:textSize="20sp"
+            android:textStyle="bold"
+            android:id="@+id/tvContent"
+            android:phoneNumber="false" />
 
         <Button
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="@string/start_or_pause"
-            android:id="@+id/button" />
+            android:text="@string/start"
+            android:id="@+id/bnStart"
+            android:layout_gravity="center"
+            android:longClickable="false"
+            android:onClick="onClick" />
     </LinearLayout>
 
 </RelativeLayout>

app/src/main/res/menu/file_browser.xml

+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:context="org.benluo.yimushihang.app.FileBrowserActivity" >
+    
+    <item android:id="@+id/action_settings"
+        android:title="@string/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never" />
+</menu>

app/src/main/res/values-en/strings.xml

     <string name="start_or_pause">New Button</string>
     <string name="version">Version: </string>
     <string name="version_number">0.1.0</string>
+    <string name="title_activity_file_browser">File browser</string>
+    <string name="select">Select</string>
+    <string name="up">Up</string>
+    <string name="current_folder">Current folder: \n</string>
+    <string name="no_content">No Content</string>
+    <string name="stop">Stop</string>
 </resources>

app/src/main/res/values/strings.xml

 <?xml version="1.0" encoding="utf-8"?>
 <resources>
+
     <string name="app_name">一目十行</string>
     <string name="action_settings">设置</string>
     <string name="about">关于</string>
     <string name="select_article">选择文章</string>
     <string name="about_content">“一目十行” 版权归 benluo@gmail.com</string>
-    <string name="start_or_pause">开始</string>
+    <string name="start">开始</string>
     <string name="version">版本:</string>
     <string name="version_number">0.1.0</string>
+    <string name="stop">停止</string>
+    <string name="title_activity_file_browser">文件浏览</string>
+    <string name="select">选择</string>
+    <string name="up">上一级</string>
+    <string name="current_folder">当前目录: \n</string>
+    <string name="no_content">无内容</string>
+
 </resources>