diff --git a/app-pro/src/main/AndroidManifest.xml b/app-pro/src/main/AndroidManifest.xml
index 1312ba9..82081cd 100644
--- a/app-pro/src/main/AndroidManifest.xml
+++ b/app-pro/src/main/AndroidManifest.xml
@@ -39,6 +39,7 @@
android:hardwareAccelerated="false"
android:largeHeap="true"
android:supportsRtl="true"
+ android:name="sharedcode.turboeditor.activity.MyApp"
>
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a6f245a..8bb69d6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -42,6 +42,7 @@
android:hardwareAccelerated="false"
android:largeHeap="true"
android:supportsRtl="true"
+ android:name="sharedcode.turboeditor.activity.MyApp"
>
diff --git a/build/intermediates/dex-cache/cache.xml b/build/intermediates/dex-cache/cache.xml
index 66f500b..85a85b9 100644
--- a/build/intermediates/dex-cache/cache.xml
+++ b/build/intermediates/dex-cache/cache.xml
@@ -7,6 +7,12 @@
jumboMode="false"
revision="20.0.0"
sha1="a18ff12a9ab5ae52fd30d42f134517997568231e"/>
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
.
+ */
+
+package sharedcode.turboeditor.activity;
+
+import android.app.Application;
+import android.view.ViewConfiguration;
+
+import java.lang.reflect.Field;
+
+public class MyApp extends Application {
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ // force to sow the overflow menu icon
+ try {
+ ViewConfiguration config = ViewConfiguration.get(this);
+ Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
+ if(menuKeyField != null) {
+ menuKeyField.setAccessible(true);
+ menuKeyField.setBoolean(config, false);
+ }
+ } catch (Exception ex) {
+ // Ignore
+ }
+ }
+}
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/SelectFileActivity.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/SelectFileActivity.java
index 316082b..9dfd338 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/SelectFileActivity.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/SelectFileActivity.java
@@ -59,9 +59,9 @@ import sharedcode.turboeditor.util.Constants;
import sharedcode.turboeditor.util.RootUtils;
public class SelectFileActivity extends Activity implements SearchView.OnQueryTextListener, AdapterView.OnItemClickListener, EditDialogFragment.EditDialogListener {
- private String currentFolder;
+ private String currentFolder = PreferenceHelper.SD_CARD_ROOT;
private ListView listView;
- private boolean wantAFile;
+ private boolean wantAFile = true;
private MenuItem mSearchViewMenuItem;
private SearchView mSearchView;
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/adapter/AdapterDrawer.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/adapter/AdapterDrawer.java
index ca7fd91..957b966 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/adapter/AdapterDrawer.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/adapter/AdapterDrawer.java
@@ -95,10 +95,12 @@ public class AdapterDrawer extends
selectedPath = "";
}
});
- if (TextUtils.equals(selectedPath, files.get(position).getAbsolutePath()))
+ if (TextUtils.equals(selectedPath, files.get(position).getAbsolutePath())) {
hold.nameLabel.setTypeface(hold.nameLabel.getTypeface(), Typeface.BOLD);
- else
+ }
+ else {
hold.nameLabel.setTypeface(hold.nameLabel.getTypeface(), Typeface.NORMAL);
+ }
}
return convertView;
}
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/fragment/EditorFragment.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/fragment/EditorFragment.java
index b92bcc9..f60e3c7 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/fragment/EditorFragment.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/fragment/EditorFragment.java
@@ -151,11 +151,15 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ String fileText = getArguments().getString("fileText");
+ if(fileText == null)
+ fileText = "";
+
setHasOptionsMenu(true);
+
sFilePath = getArguments().getString("filePath");
- pageSystem = new PageSystem(getActivity(), this, getArguments().getString("fileText"));
+ pageSystem = new PageSystem(getActivity(), this, fileText);
currentEncoding = getArguments().getString("encoding");
- getArguments().remove("fileText");
}
@@ -290,8 +294,18 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
if (searchingText) {
MenuItem imReplace = menu.findItem(R.id.im_replace);
+ MenuItem imPrev = menu.findItem(R.id.im_previous_item);
+ MenuItem imNext = menu.findItem(R.id.im_next_item);
+
if (imReplace != null)
- imReplace.setVisible(searchResult.isReplace);
+ imReplace.setVisible(searchResult.canReplaceSomething());
+
+ if (imPrev != null)
+ imPrev.setVisible(searchResult.hasPrevious());
+
+ if (imNext != null)
+ imNext.setVisible(searchResult.hasNext());
+
} else {
MenuItem imSave = menu.findItem(R.id.im_save);
@@ -344,8 +358,9 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
}
else if(i == R.id.im_goto_line){
+ int min = mEditor.getLineUtils().firstReadLine();
int max = mEditor.getLineUtils().lastReadLine();
- SeekbarDialogFragment dialogFrag = SeekbarDialogFragment.newInstance(SeekbarDialogFragment.Actions.GoToLine, 0, 0, max);
+ SeekbarDialogFragment dialogFrag = SeekbarDialogFragment.newInstance(SeekbarDialogFragment.Actions.GoToLine, min, min, max);
dialogFrag.setTargetFragment(EditorFragment.this, 0);
dialogFrag.show(getFragmentManager().beginTransaction(), "dialog");
}
@@ -368,6 +383,9 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
+ }
+ else {
+
}
return super.onOptionsItemSelected(item);
}
@@ -562,6 +580,8 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
mEditor.setSelection(searchResult.foundIndex.get(searchResult.index), searchResult.foundIndex.get(searchResult.index) + searchResult.textLength);
}
+
+ getActivity().invalidateOptionsMenu();
}
public void previousResult() {
@@ -584,12 +604,20 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
mEditor.setSelection(searchResult.foundIndex.get(searchResult.index), searchResult.foundIndex.get(searchResult.index) + searchResult.textLength);
}
+
+ getActivity().invalidateOptionsMenu();
}
public void replaceText() {
mEditor.setText(mEditor.getText().replace(searchResult.foundIndex.get(searchResult.index), searchResult.foundIndex.get(searchResult.index) + searchResult.textLength, searchResult.textToReplace));
searchResult.doneReplace();
- nextResult();
+
+ getActivity().invalidateOptionsMenu();
+
+ if(searchResult.hasNext())
+ nextResult();
+ else if(searchResult.hasPrevious())
+ previousResult();
}
//endregion
@@ -712,7 +740,7 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
*/
private final EditTextChangeListener
mChangeListener;
- int lineCount, realLine;
+ private int lineCount, realLine;
private LineUtils lineUtils;
private boolean modified = true;
/**
@@ -787,7 +815,27 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
- return true;
+ if (event.isCtrlPressed()) {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_A:
+ case KeyEvent.KEYCODE_X:
+ case KeyEvent.KEYCODE_C:
+ case KeyEvent.KEYCODE_V:
+ case KeyEvent.KEYCODE_Z:
+ case KeyEvent.KEYCODE_Y:
+ case KeyEvent.KEYCODE_S:
+ return true;
+ default:
+ return false;
+ }
+ } else {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_TAB:
+ return true;
+ default:
+ return false;
+ }
+ }
}
@Override
@@ -1030,67 +1078,70 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
return editable;
}
- firstVisibleIndex = 0;
- int end = CHARS_TO_COLOR;
+ int end;
int height = getHeight();
if(height > 0) {
firstVisibleIndex = getLayout().getLineStart(getLineUtils().getFirstVisibleLine(editorInterface.getVerticalScrollView(), height, getLineCount()));
- end = getLayout().getLineStart(getLineUtils().getLastVisibleLine(editorInterface.getVerticalScrollView(), height, lineCount, deviceHeight));
- //int end = firstColoredIndex + CHARS_TO_COLOR;
+ end = getLayout().getLineStart(getLineUtils().getLastVisibleLine(editorInterface.getVerticalScrollView(), height, getLineCount(), deviceHeight));
+ } else {
+ firstVisibleIndex = 0;
+ end = CHARS_TO_COLOR;
}
firstColoredIndex = firstVisibleIndex - (CHARS_TO_COLOR / 5);
+
+ // normalize
if (firstColoredIndex < 0)
firstColoredIndex = 0;
if (end > editable.length())
end = editable.length();
- CharSequence textToHiglight = editable.subSequence(firstColoredIndex, end);
+ CharSequence textToHighlight = editable.subSequence(firstColoredIndex, end);
if (fileExtension.contains("htm")
|| fileExtension.contains("xml")) {
- color(Patterns.HTML_OPEN_TAGS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.HTML_CLOSE_TAGS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.HTML_ATTRS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.GENERAL_STRINGS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.XML_COMMENTS, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.HTML_OPEN_TAGS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.HTML_CLOSE_TAGS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.HTML_ATTRS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.GENERAL_STRINGS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.XML_COMMENTS, editable, textToHighlight, firstColoredIndex);
} else if (fileExtension.equals("css")) {
//color(CSS_STYLE_NAME, editable);
- color(Patterns.CSS_ATTRS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.CSS_ATTR_VALUE, editable, textToHiglight, firstColoredIndex);
- color(Patterns.SYMBOLS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.GENERAL_COMMENTS, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.CSS_ATTRS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.CSS_ATTR_VALUE, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.SYMBOLS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.GENERAL_COMMENTS, editable, textToHighlight, firstColoredIndex);
} else if (Arrays.asList(MimeTypes.MIME_CODE).contains(fileExtension)) {
if(fileExtension.equals("lua"))
- color(Patterns.LUA_KEYWORDS, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.LUA_KEYWORDS, editable, textToHighlight, firstColoredIndex);
else if(fileExtension.equals("py"))
- color(Patterns.PY_KEYWORDS, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.PY_KEYWORDS, editable, textToHighlight, firstColoredIndex);
else
- color(Patterns.GENERAL_KEYWORDS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.NUMBERS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.SYMBOLS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.GENERAL_STRINGS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.GENERAL_COMMENTS, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.GENERAL_KEYWORDS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.NUMBERS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.SYMBOLS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.GENERAL_STRINGS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.GENERAL_COMMENTS, editable, textToHighlight, firstColoredIndex);
if (fileExtension.equals("php"))
- color(Patterns.PHP_VARIABLES, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.PHP_VARIABLES, editable, textToHighlight, firstColoredIndex);
} else if (Arrays.asList(MimeTypes.MIME_SQL).contains(fileExtension)) {
- color(Patterns.SYMBOLS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.GENERAL_STRINGS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.SQL_KEYWORDS, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.SYMBOLS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.GENERAL_STRINGS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.SQL_KEYWORDS, editable, textToHighlight, firstColoredIndex);
} else {
if(!fileExtension.contains("md"))
- color(Patterns.GENERAL_KEYWORDS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.NUMBERS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.SYMBOLS, editable, textToHiglight, firstColoredIndex);
- color(Patterns.GENERAL_STRINGS, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.GENERAL_KEYWORDS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.NUMBERS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.SYMBOLS, editable, textToHighlight, firstColoredIndex);
+ color(Patterns.GENERAL_STRINGS, editable, textToHighlight, firstColoredIndex);
if (fileExtension.equals("prop") || fileExtension.contains("conf") || fileExtension.contains("md"))
- color(Patterns.GENERAL_COMMENTS_NO_SLASH, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.GENERAL_COMMENTS_NO_SLASH, editable, textToHighlight, firstColoredIndex);
else
- color(Patterns.GENERAL_COMMENTS, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.GENERAL_COMMENTS, editable, textToHighlight, firstColoredIndex);
if(fileExtension.contains("md"))
- color(Patterns.LINK, editable, textToHiglight, firstColoredIndex);
+ color(Patterns.LINK, editable, textToHighlight, firstColoredIndex);
}
return editable;
@@ -1098,7 +1149,7 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
private void color(Pattern pattern,
Editable allText,
- CharSequence textToHiglight,
+ CharSequence textToHighlight,
int start) {
int color = 0;
if (pattern.equals(Patterns.HTML_OPEN_TAGS)
@@ -1128,7 +1179,7 @@ public class EditorFragment extends Fragment implements FindTextDialogFragment.S
color = getResources().getColor(R.color.syntax_variable);
}
- m = pattern.matcher(textToHiglight);
+ m = pattern.matcher(textToHighlight);
while (m.find()) {
allText.setSpan(
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/LineUtils.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/LineUtils.java
index 20a6e13..4472f96 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/LineUtils.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/LineUtils.java
@@ -38,10 +38,6 @@ public class LineUtils {
return scrollView.getChildAt(0).getHeight() / lineCount * line;
}
- public int getFirstVisibleLine(ScrollView scrollView, int lineCount){
- return getFirstVisibleLine(scrollView, scrollView.getChildAt(0).getHeight(), lineCount);
- }
-
public int getFirstVisibleLine(ScrollView scrollView, int childHeight, int lineCount) throws ArithmeticException{
int line = (scrollView.getScrollY() * lineCount) / childHeight;
if (line < 0) line = 0;
@@ -108,6 +104,10 @@ public class LineUtils {
return line;
}
+ public int firstReadLine() {
+ return realLines[0];
+ }
+
public int lastReadLine() {
return realLines[realLines.length-1];
}
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/SearchResult.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/SearchResult.java
index eb9ab22..634c805 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/SearchResult.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/SearchResult.java
@@ -22,6 +22,7 @@ package sharedcode.turboeditor.util;
import java.util.LinkedList;
public class SearchResult {
+ // list of index
public LinkedList foundIndex;
public int textLength;
public boolean isReplace;
@@ -47,4 +48,16 @@ public class SearchResult {
public int numberOfResults() {
return foundIndex.size();
}
+
+ public boolean hasNext() {
+ return index < foundIndex.size() - 1;
+ }
+
+ public boolean hasPrevious() {
+ return index > 0;
+ }
+
+ public boolean canReplaceSomething() {
+ return isReplace && foundIndex.size() > 0;
+ }
}
diff --git a/libraries/sharedCode/src/main/res/layout/fragment_navigation_drawer.xml b/libraries/sharedCode/src/main/res/layout/fragment_navigation_drawer.xml
index 8436c90..2bf553a 100644
--- a/libraries/sharedCode/src/main/res/layout/fragment_navigation_drawer.xml
+++ b/libraries/sharedCode/src/main/res/layout/fragment_navigation_drawer.xml
@@ -50,7 +50,7 @@
@@ -62,7 +62,7 @@
@@ -97,12 +97,20 @@
android:textColor="@color/navigation_drawer_button_text_color_inverted"/>
+
+
-
-
-
-
-
+ android:layout_height="52dp"
+ android:orientation="horizontal"
+ >
+
+
-
+
+
-
-
+
-
-
+
+
+
diff --git a/libraries/sharedCode/src/main/res/layout/item_drawer_list.xml b/libraries/sharedCode/src/main/res/layout/item_drawer_list.xml
index 2f09282..6d87335 100644
--- a/libraries/sharedCode/src/main/res/layout/item_drawer_list.xml
+++ b/libraries/sharedCode/src/main/res/layout/item_drawer_list.xml
@@ -29,7 +29,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
- android:textSize="20sp"
+ android:textSize="18sp"
android:paddingStart="@dimen/item_drawer_list_padding"
android:paddingEnd="@dimen/item_drawer_list_padding"
android:paddingLeft="@dimen/item_drawer_list_padding"