Add option to set default root directory

This commit is contained in:
William Brawner 2018-03-04 19:48:49 -06:00 committed by William Brawner
parent d6a03832d6
commit 80ec8e9b17
12 changed files with 198 additions and 70 deletions

View file

@ -0,0 +1,25 @@
package com.wbrawner.simplemarkdown.utility;
@SuppressWarnings("WeakerAccess")
public class Constants {
// Request codes
public static final int REQUEST_OPEN_FILE = 1;
public static final int REQUEST_SAVE_FILE = 2;
public static final int REQUEST_ROOT_DIR = 1000;
// Extras
public static final String EXTRA_FILE = "EXTRA_FILE";
public static final String EXTRA_FILE_PATH = "EXTRA_FILE_PATH";
public static final String EXTRA_REQUEST_CODE = "EXTRA_REQUEST_CODE";
public static final String EXTRA_EXPLORER = "EXTRA_EXPLORER";
// Settings keys
public static final String KEY_AUTOSAVE = "autosave";
public static final String KEY_DOCS_PATH = "defaultRootDir";
// Settings values
public static final String VALUE_EDIT_VIEW = "0";
public static final String VALUE_FILE_VIEW = "1";
}

View file

@ -5,10 +5,12 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Environment; import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import com.wbrawner.simplemarkdown.view.activity.SettingsActivity; import com.crashlytics.android.Crashlytics;
import java.io.Closeable; import java.io.Closeable;
import java.io.File; import java.io.File;
@ -22,7 +24,7 @@ public class Utils {
public static String getDocsPath(Context context) { public static String getDocsPath(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getString( return prefs.getString(
SettingsActivity.KEY_DOCS_PATH, Constants.KEY_DOCS_PATH,
Environment.getExternalStorageDirectory() + "/" + Environment.getExternalStorageDirectory() + "/" +
Environment.DIRECTORY_DOCUMENTS + "/" Environment.DIRECTORY_DOCUMENTS + "/"
); );
@ -74,7 +76,7 @@ public class Utils {
public static boolean isAutosaveEnabled(Context context) { public static boolean isAutosaveEnabled(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getBoolean( return prefs.getBoolean(
SettingsActivity.KEY_AUTOSAVE, Constants.KEY_AUTOSAVE,
true true
); );
} }
@ -95,4 +97,16 @@ public class Utils {
Manifest.permission.WRITE_EXTERNAL_STORAGE Manifest.permission.WRITE_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED; ) == PackageManager.PERMISSION_GRANTED;
} }
@SuppressWarnings("SameParameterValue")
public static Handler createSafeHandler(String name) {
HandlerThread handlerThread = new HandlerThread(name);
handlerThread.start();
handlerThread.setUncaughtExceptionHandler((t, e) -> {
Crashlytics.logException(e);
t.interrupt();
});
return new Handler(handlerThread.getLooper());
}
} }

View file

@ -16,6 +16,7 @@ import android.widget.ListView;
import android.widget.SimpleAdapter; import android.widget.SimpleAdapter;
import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.R;
import com.wbrawner.simplemarkdown.utility.Constants;
import com.wbrawner.simplemarkdown.utility.Utils; import com.wbrawner.simplemarkdown.utility.Utils;
import java.io.File; import java.io.File;
@ -24,14 +25,16 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicReference;
public class ExplorerActivity extends AppCompatActivity { public class ExplorerActivity extends AppCompatActivity {
private Handler fileHandler = new Handler(); private Handler fileHandler = Utils.createSafeHandler("ExplorerThread");
private ListView listView; private ListView listView;
private File[] mounts; private File[] mounts;
private String docsDirPath; private String docsDirPath;
private String filePath; private AtomicReference<String> filePath = new AtomicReference<>("");
private boolean isSave = false; private volatile boolean isSave = false;
private volatile boolean showFiles = true;
private EditText fileName; private EditText fileName;
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
@ -43,23 +46,26 @@ public class ExplorerActivity extends AppCompatActivity {
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
Intent intent = getIntent(); Intent intent = getIntent();
if (intent == null || !intent.hasExtra(MainActivity.EXTRA_REQUEST_CODE)) { if (intent == null || !intent.hasExtra(Constants.EXTRA_REQUEST_CODE)) {
finish(); finish();
return; return;
} }
docsDirPath = Utils.getDocsPath(this); docsDirPath = Utils.getDocsPath(this);
int requestCode = intent.getIntExtra(MainActivity.EXTRA_REQUEST_CODE, -1); int requestCode = intent.getIntExtra(Constants.EXTRA_REQUEST_CODE, -1);
switch (requestCode) { switch (requestCode) {
case MainActivity.OPEN_FILE_REQUEST: case Constants.REQUEST_OPEN_FILE:
break; break;
case MainActivity.SAVE_FILE_REQUEST: case Constants.REQUEST_ROOT_DIR:
showFiles = false;
break;
case Constants.REQUEST_SAVE_FILE:
isSave = true; isSave = true;
fileName = findViewById(R.id.file_name); fileName = findViewById(R.id.file_name);
fileName.setVisibility(View.VISIBLE); fileName.setVisibility(View.VISIBLE);
if (intent.hasExtra(MainActivity.EXTRA_FILE)) { if (intent.hasExtra(Constants.EXTRA_FILE)) {
File file = (File) intent.getSerializableExtra(MainActivity.EXTRA_FILE); File file = (File) intent.getSerializableExtra(Constants.EXTRA_FILE);
if (file.exists() && file.canWrite()) { if (file.exists() && file.canWrite()) {
docsDirPath = file.getParentFile().getAbsolutePath(); docsDirPath = file.getParentFile().getAbsolutePath();
fileName.setText(file.getName()); fileName.setText(file.getName());
@ -74,10 +80,10 @@ public class ExplorerActivity extends AppCompatActivity {
String absolutePath = String.format( String absolutePath = String.format(
Locale.ENGLISH, Locale.ENGLISH,
"%s/%s", "%s/%s",
filePath, filePath.get(),
fileName.getText().toString() fileName.getText().toString()
); );
fileIntent.putExtra(MainActivity.EXTRA_FILE_PATH, absolutePath); fileIntent.putExtra(Constants.EXTRA_FILE_PATH, absolutePath);
setResult(RESULT_OK, fileIntent); setResult(RESULT_OK, fileIntent);
finish(); finish();
}); });
@ -103,14 +109,20 @@ public class ExplorerActivity extends AppCompatActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_explorer, menu);
if (!showFiles) {
menu.findItem(R.id.action_select).setVisible(true);
}
if (hasRemovableStorage()) { if (hasRemovableStorage()) {
getMenuInflater().inflate(R.menu.menu_explorer, menu); menu.findItem(R.id.action_use_sdcard).setVisible(true);
if (filePath.contains(mounts[1].getAbsolutePath())) { if (filePath.get().contains(mounts[1].getAbsolutePath())) {
menu.findItem(R.id.action_use_sdcard).setChecked(true); menu.findItem(R.id.action_use_sdcard).setChecked(true);
} }
return true;
} }
return false;
return true;
} }
@Override @Override
@ -127,6 +139,10 @@ public class ExplorerActivity extends AppCompatActivity {
} else { } else {
updateListView(new File(docsDirPath)); updateListView(new File(docsDirPath));
} }
break;
case R.id.action_select:
replyWithFile(new File(filePath.get()));
break;
} }
return true; return true;
} }
@ -161,9 +177,10 @@ public class ExplorerActivity extends AppCompatActivity {
dirs.add(fileHashMap); dirs.add(fileHashMap);
continue; continue;
} }
if (!file.getName().endsWith("md") if (!showFiles ||
&& !file.getName().endsWith("markdown") (!file.getName().endsWith("md")
&& !file.getName().endsWith("text")) { && !file.getName().endsWith("markdown")
&& !file.getName().endsWith("text"))) {
continue; continue;
} }
HashMap<String, Object> fileHashMap = new HashMap<>(); HashMap<String, Object> fileHashMap = new HashMap<>();
@ -181,7 +198,7 @@ public class ExplorerActivity extends AppCompatActivity {
private void updateListView(File filesDir) { private void updateListView(File filesDir) {
setTitle(filesDir.getName()); setTitle(filesDir.getName());
filePath = filesDir.getAbsolutePath(); filePath.set(filesDir.getAbsolutePath());
fileHandler.post(() -> { fileHandler.post(() -> {
List<HashMap<String, Object>> files = loadFiles(filesDir); List<HashMap<String, Object>> files = loadFiles(filesDir);
@ -210,10 +227,14 @@ public class ExplorerActivity extends AppCompatActivity {
fileName.setText(file.getName()); fileName.setText(file.getName());
} }
} else { } else {
Intent fileIntent = new Intent(); replyWithFile(file);
fileIntent.putExtra(MainActivity.EXTRA_FILE, file);
setResult(RESULT_OK, fileIntent);
finish();
} }
} }
private void replyWithFile(File file) {
Intent fileIntent = new Intent();
fileIntent.putExtra(Constants.EXTRA_FILE, file);
setResult(RESULT_OK, fileIntent);
finish();
}
} }

View file

@ -10,7 +10,6 @@ import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -20,6 +19,7 @@ import android.widget.Toast;
import com.wbrawner.simplemarkdown.MarkdownApplication; import com.wbrawner.simplemarkdown.MarkdownApplication;
import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.R;
import com.wbrawner.simplemarkdown.presentation.MarkdownPresenter; import com.wbrawner.simplemarkdown.presentation.MarkdownPresenter;
import com.wbrawner.simplemarkdown.utility.Constants;
import com.wbrawner.simplemarkdown.utility.Utils; import com.wbrawner.simplemarkdown.utility.Utils;
import com.wbrawner.simplemarkdown.view.DisableableViewPager; import com.wbrawner.simplemarkdown.view.DisableableViewPager;
import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter; import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter;
@ -35,14 +35,6 @@ import butterknife.ButterKnife;
public class MainActivity extends AppCompatActivity public class MainActivity extends AppCompatActivity
implements ActivityCompat.OnRequestPermissionsResultCallback { implements ActivityCompat.OnRequestPermissionsResultCallback {
static final int WRITE_PERMISSION_REQUEST = 0;
static final int OPEN_FILE_REQUEST = 1;
static final int SAVE_FILE_REQUEST = 2;
static final String EXTRA_FILE = "EXTRA_FILE";
static final String EXTRA_FILE_PATH = "EXTRA_FILE_PATH";
static final String EXTRA_REQUEST_CODE = "EXTRA_REQUEST_CODE";
static final String EXTRA_EXPLORER = "EXTRA_EXPLORER";
@Inject @Inject
MarkdownPresenter presenter; MarkdownPresenter presenter;
@ -60,7 +52,6 @@ public class MainActivity extends AppCompatActivity
((MarkdownApplication) getApplication()).getComponent().inject(this); ((MarkdownApplication) getApplication()).getComponent().inject(this);
ButterKnife.bind(this); ButterKnife.bind(this);
presenter.setRootDir(Utils.getDocsPath(this));
pager.setAdapter( pager.setAdapter(
new EditPagerAdapter(getSupportFragmentManager(), MainActivity.this) new EditPagerAdapter(getSupportFragmentManager(), MainActivity.this)
); );
@ -71,8 +62,8 @@ public class MainActivity extends AppCompatActivity
tabLayout.setVisibility(View.GONE); tabLayout.setVisibility(View.GONE);
} }
newFileHandler = new NewFileHandler(); newFileHandler = new NewFileHandler();
if (getIntent().getBooleanExtra(EXTRA_EXPLORER, false)) { if (getIntent().getBooleanExtra(Constants.EXTRA_EXPLORER, false)) {
requestFileOp(OPEN_FILE_REQUEST); requestFileOp(Constants.REQUEST_OPEN_FILE);
} }
} }
@ -103,7 +94,7 @@ public class MainActivity extends AppCompatActivity
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_save: case R.id.action_save:
requestFileOp(SAVE_FILE_REQUEST); requestFileOp(Constants.REQUEST_SAVE_FILE);
break; break;
case R.id.action_share: case R.id.action_share:
Intent shareIntent = new Intent(Intent.ACTION_SEND); Intent shareIntent = new Intent(Intent.ACTION_SEND);
@ -115,7 +106,7 @@ public class MainActivity extends AppCompatActivity
)); ));
break; break;
case R.id.action_load: case R.id.action_load:
requestFileOp(OPEN_FILE_REQUEST); requestFileOp(Constants.REQUEST_OPEN_FILE);
break; break;
case R.id.action_new: case R.id.action_new:
presenter.saveMarkdown(newFileHandler, null); presenter.saveMarkdown(newFileHandler, null);
@ -184,8 +175,8 @@ public class MainActivity extends AppCompatActivity
@NonNull int[] grantResults @NonNull int[] grantResults
) { ) {
switch (requestCode) { switch (requestCode) {
case SAVE_FILE_REQUEST: case Constants.REQUEST_SAVE_FILE:
case OPEN_FILE_REQUEST: { case Constants.REQUEST_OPEN_FILE: {
// If request is cancelled, the result arrays are empty. // If request is cancelled, the result arrays are empty.
if (grantResults.length > 0 if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) { && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
@ -212,22 +203,22 @@ public class MainActivity extends AppCompatActivity
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) { switch (requestCode) {
case OPEN_FILE_REQUEST: case Constants.REQUEST_OPEN_FILE:
if (resultCode != RESULT_OK || data == null || !data.hasExtra(EXTRA_FILE)) { if (resultCode != RESULT_OK || data == null || !data.hasExtra(Constants.EXTRA_FILE)) {
break; break;
} }
File markdownFile = (File) data.getSerializableExtra(EXTRA_FILE); File markdownFile = (File) data.getSerializableExtra(Constants.EXTRA_FILE);
presenter.loadMarkdown(markdownFile); presenter.loadMarkdown(markdownFile);
break; break;
case SAVE_FILE_REQUEST: case Constants.REQUEST_SAVE_FILE:
if (resultCode != RESULT_OK if (resultCode != RESULT_OK
|| data == null || data == null
|| !data.hasExtra(EXTRA_FILE_PATH) || !data.hasExtra(Constants.EXTRA_FILE_PATH)
|| data.getStringExtra(EXTRA_FILE_PATH).isEmpty()) { || data.getStringExtra(Constants.EXTRA_FILE_PATH).isEmpty()) {
break; break;
} }
String path = data.getStringExtra(EXTRA_FILE_PATH); String path = data.getStringExtra(Constants.EXTRA_FILE_PATH);
presenter.saveMarkdown(null, path); presenter.saveMarkdown(null, path);
break; break;
} }
@ -237,8 +228,8 @@ public class MainActivity extends AppCompatActivity
private void requestFileOp(int requestType) { private void requestFileOp(int requestType) {
if (Utils.canAccessFiles(MainActivity.this)) { if (Utils.canAccessFiles(MainActivity.this)) {
Intent intent = new Intent(MainActivity.this, ExplorerActivity.class); Intent intent = new Intent(MainActivity.this, ExplorerActivity.class);
intent.putExtra(EXTRA_REQUEST_CODE, requestType); intent.putExtra(Constants.EXTRA_REQUEST_CODE, requestType);
intent.putExtra(EXTRA_FILE, presenter.getFile()); intent.putExtra(Constants.EXTRA_FILE, presenter.getFile());
startActivityForResult( startActivityForResult(
intent, intent,
requestType requestType

View file

@ -9,11 +9,6 @@ import com.wbrawner.simplemarkdown.R;
public class SettingsActivity extends AppCompatActivity { public class SettingsActivity extends AppCompatActivity {
public static final String KEY_AUTOSAVE = "autosave";
public static final String KEY_DOCS_PATH = "defaultRootDir";
public static final String EDIT_VIEW = "0";
public static final String FILE_VIEW = "1";
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View file

@ -1,6 +1,7 @@
package com.wbrawner.simplemarkdown.view.activity; package com.wbrawner.simplemarkdown.view.activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -9,6 +10,7 @@ import android.support.v7.app.AppCompatActivity;
import com.wbrawner.simplemarkdown.MarkdownApplication; import com.wbrawner.simplemarkdown.MarkdownApplication;
import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.R;
import com.wbrawner.simplemarkdown.presentation.MarkdownPresenter; import com.wbrawner.simplemarkdown.presentation.MarkdownPresenter;
import com.wbrawner.simplemarkdown.utility.Constants;
import com.wbrawner.simplemarkdown.utility.Utils; import com.wbrawner.simplemarkdown.utility.Utils;
import javax.inject.Inject; import javax.inject.Inject;
@ -32,15 +34,20 @@ public class SplashActivity extends AppCompatActivity {
presenter.setFileName(defaultName); presenter.setFileName(defaultName);
} }
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String defaultRootDir =
sharedPreferences.getString(Constants.KEY_DOCS_PATH, Utils.getDocsPath(this));
presenter.setRootDir(defaultRootDir);
Intent startIntent = new Intent(this, MainActivity.class); Intent startIntent = new Intent(this, MainActivity.class);
String startScreen = PreferenceManager.getDefaultSharedPreferences(this) String startScreen = PreferenceManager.getDefaultSharedPreferences(this)
.getString( .getString(
getString(R.string.key_default_view), getString(R.string.key_default_view),
SettingsActivity.EDIT_VIEW Constants.VALUE_EDIT_VIEW
); );
switch (startScreen) { switch (startScreen) {
case SettingsActivity.FILE_VIEW: case Constants.VALUE_FILE_VIEW:
startIntent.putExtra(MainActivity.EXTRA_EXPLORER, true); startIntent.putExtra(Constants.EXTRA_EXPLORER, true);
break; break;
} }
startActivity(startIntent); startActivity(startIntent);

View file

@ -61,18 +61,24 @@ public class PreviewFragment extends Fragment implements MarkdownPreviewView {
} }
@Override @Override
public void updatePreview(String html) { public void updatePreview(String html) {
if (markdownPreview != null) { if (markdownPreview == null) {
markdownPreview.post(() -> markdownPreview.loadDataWithBaseURL( return;
}
markdownPreview.post(() -> {
if (markdownPreview == null) {
return;
}
markdownPreview.loadDataWithBaseURL(
null, null,
style + html, style + html,
"text/html", "text/html",
"UTF-8", "UTF-8",
null null
)); );
} });
} }
@Override @Override

View file

@ -1,5 +1,6 @@
package com.wbrawner.simplemarkdown.view.fragment; package com.wbrawner.simplemarkdown.view.fragment;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference; import android.preference.ListPreference;
@ -7,8 +8,17 @@ import android.preference.Preference;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.Log;
import com.crashlytics.android.Crashlytics;
import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.R;
import com.wbrawner.simplemarkdown.utility.Constants;
import com.wbrawner.simplemarkdown.utility.Utils;
import com.wbrawner.simplemarkdown.view.activity.ExplorerActivity;
import java.io.File;
import static android.app.Activity.RESULT_OK;
public class SettingsFragment extends PreferenceFragment public class SettingsFragment extends PreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener { implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -23,6 +33,14 @@ public class SettingsFragment extends PreferenceFragment
sharedPreferences, sharedPreferences,
findPreference(getString(R.string.key_default_view)) findPreference(getString(R.string.key_default_view))
); );
Preference defaultRoot = findPreference(Constants.KEY_DOCS_PATH);
defaultRoot.setSummary(Utils.getDocsPath(getActivity()));
defaultRoot.setOnPreferenceClickListener((preference) -> {
Intent intent = new Intent(getActivity(), ExplorerActivity.class);
intent.putExtra(Constants.EXTRA_REQUEST_CODE, Constants.REQUEST_ROOT_DIR);
startActivityForResult(intent, Constants.REQUEST_ROOT_DIR);
return true;
});
} }
@Override @Override
@ -40,8 +58,38 @@ public class SettingsFragment extends PreferenceFragment
if (storedValue.isEmpty()) { if (storedValue.isEmpty()) {
return; return;
} }
int index = Integer.valueOf(storedValue); int index = 0;
try {
index = Integer.valueOf(storedValue);
} catch (NumberFormatException e) {
Log.e("SimpleMarkdown", "Unable to parse " + storedValue + " to integer");
Crashlytics.logException(e);
}
String summary = listPreference.getEntries()[index].toString(); String summary = listPreference.getEntries()[index].toString();
preference.setSummary(summary); preference.setSummary(summary);
} }
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK || data == null) {
// If the user cancelled the request, then we don't care about the response
return;
}
switch (requestCode) {
case Constants.REQUEST_ROOT_DIR:
File root = (File) data.getSerializableExtra(Constants.EXTRA_FILE);
if (root == null) {
Crashlytics.logException(new RuntimeException("Got null/empty response from setting default root dir"));
return;
}
Preference defaultRoot = findPreference(Constants.KEY_DOCS_PATH);
defaultRoot.setSummary(root.getAbsolutePath());
PreferenceManager.getDefaultSharedPreferences(getActivity())
.edit()
.putString(Constants.KEY_DOCS_PATH, root.getAbsolutePath())
.apply();
break;
}
}
} }

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z" />
</vector>

View file

@ -2,8 +2,15 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:title="@string/action_use_sdcard" android:id="@+id/action_select"
android:icon="@drawable/ic_action_select"
android:title="@string/action_select"
android:visible="false"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_use_sdcard" android:id="@+id/action_use_sdcard"
app:showAsAction="never" android:checkable="true"
android:checkable="true" /> android:title="@string/action_use_sdcard"
android:visible="false"
app:showAsAction="never" />
</menu> </menu>

View file

@ -38,6 +38,8 @@
<string name="pref_title_default_view">Default View</string> <string name="pref_title_default_view">Default View</string>
<string name="value_edit_view">Edit View</string> <string name="value_edit_view">Edit View</string>
<string name="value_explorer_view">File Explorer View</string> <string name="value_explorer_view">File Explorer View</string>
<string name="pref_description_default_root">Default Root Directory</string>
<string name="action_select">Select</string>
<string-array name="pref_entries_default_view"> <string-array name="pref_entries_default_view">
<item>@string/value_edit_view</item> <item>@string/value_edit_view</item>
<item>@string/value_explorer_view</item> <item>@string/value_explorer_view</item>

View file

@ -6,10 +6,13 @@
android:summary="@string/pref_description_autosave" android:summary="@string/pref_description_autosave"
android:title="@string/pref_title_autosave" /> android:title="@string/pref_title_autosave" />
<ListPreference <ListPreference
android:key="@string/key_default_view" android:defaultValue="@string/value_edit_view"
android:entries="@array/pref_entries_default_view" android:entries="@array/pref_entries_default_view"
android:entryValues="@array/pref_values_default_view" android:entryValues="@array/pref_values_default_view"
android:defaultValue="@string/value_edit_view" android:key="@string/key_default_view"
android:title="@string/pref_title_default_view" /> android:title="@string/pref_title_default_view" />
<Preference
android:key="defaultRootDir"
android:title="@string/pref_description_default_root" />
</PreferenceScreen> </PreferenceScreen>