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 569167a..1b80b77 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/SelectFileActivity.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/SelectFileActivity.java
@@ -181,7 +181,7 @@ public class SelectFileActivity extends ActionBarActivity implements SearchView.
private void finishWithResult(File file) {
if (file != null) {
Uri uri = Uri.fromFile(file);
- Toast.makeText(this, uri.toString(), Toast.LENGTH_SHORT).show();
+ //Toast.makeText(this, uri.toString(), Toast.LENGTH_SHORT).show();
setResult(RESULT_OK, new Intent().setData(uri));
finish();
} else {
@@ -242,6 +242,11 @@ public class SelectFileActivity extends ActionBarActivity implements SearchView.
}
} else if (selectedFile.isDirectory()) {
//Toast.makeText(this, "its folder", Toast.LENGTH_SHORT).show();
+ if (mfabOkMode) {
+ prevposition = 0;
+ mfabOkMode = false;
+ mFab.setDrawable(getResources().getDrawable(R.drawable.ic_fab_add));
+ }
new UpdateList().execute(selectedFile.getAbsolutePath());
}
} else if (folderOpenMode) {
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/PreferenceHelper.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/PreferenceHelper.java
index ed59459..7cef2fb 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/PreferenceHelper.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/PreferenceHelper.java
@@ -147,6 +147,10 @@ public final class PreferenceHelper {
return getPrefs(context).getBoolean("page_system_active", true);
}
+ public static boolean getSplitByLine(Context context){
+ return getPrefs(context).getBoolean("split_by_line", true);
+ }
+
public static boolean hasDonated(Context context) {
return getPrefs(context).getBoolean("has_donated", false);
}
@@ -224,6 +228,10 @@ public final class PreferenceHelper {
getEditor(context).putBoolean("page_system_active", value).commit();
}
+ public static void setSplitByLine(Context context, boolean value){
+ getEditor(context).putBoolean("split_by_line",value).commit();
+ }
+
public static void setSendErrorReport(Context context, boolean value) {
getEditor(context).putBoolean("send_error_reports", value).commit();
}
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/SettingsFragment.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/SettingsFragment.java
index a4745f8..5c79494 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/SettingsFragment.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/SettingsFragment.java
@@ -54,6 +54,7 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
private boolean sAutoSave;
private boolean sIgnoreBackButton;
private boolean sSplitText;
+ private boolean sSplitByLine;
private boolean sErrorReports;
@Override
@@ -71,6 +72,7 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
sAutoSave = PreferenceHelper.getAutoSave(context);
sIgnoreBackButton = PreferenceHelper.getIgnoreBackButton(context);
sSplitText = PreferenceHelper.getSplitText(context);
+ sSplitByLine = PreferenceHelper.getSplitByLine(context);
sErrorReports = PreferenceHelper.getSendErrorReports(context);
}
@@ -80,7 +82,7 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
// Our custom layout
final View rootView = inflater.inflate(R.layout.fragment_settings, container, false);
final SwitchCompat swLineNumbers, swSyntax, swWrapContent, swMonospace, swReadOnly;
- final SwitchCompat swSuggestions, swAccessoryView, swStorageAccessFramework, swAutoSave, swIgnoreBackButton, swSplitText, swErrorReports;
+ final SwitchCompat swSuggestions, swAccessoryView, swStorageAccessFramework, swAutoSave, swIgnoreBackButton, swSplitText, swSplitByLine, swErrorReports;
swLineNumbers = (SwitchCompat) rootView.findViewById(R.id.switch_line_numbers);
swSyntax = (SwitchCompat) rootView.findViewById(R.id.switch_syntax);
@@ -94,6 +96,8 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
swAutoSave = (SwitchCompat) rootView.findViewById(R.id.switch_auto_save);
swIgnoreBackButton = (SwitchCompat) rootView.findViewById(R.id.switch_ignore_backbutton);
swSplitText = (SwitchCompat) rootView.findViewById(R.id.switch_page_system);
+ swSplitByLine = (SwitchCompat) rootView.findViewById(R.id.split_by_line);
+
swErrorReports = (SwitchCompat) rootView.findViewById(R.id.switch_send_error_reports);
swLineNumbers.setChecked(sLineNumbers);
@@ -108,6 +112,7 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
swAutoSave.setChecked(sAutoSave);
swIgnoreBackButton.setChecked(sIgnoreBackButton);
swSplitText.setChecked(sSplitText);
+ swSplitByLine.setChecked(sSplitByLine);
swErrorReports.setChecked(sErrorReports);
TextView fontSizeView, encodingView, extraOptionsView, themeView, goPro;
@@ -259,6 +264,14 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
PreferenceHelper.setSplitText(getActivity(), isChecked);
+ swSplitByLine.setEnabled(isChecked);
+ }
+ });
+
+ swSplitByLine.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ PreferenceHelper.setSplitByLine(getActivity(), isChecked);
}
});
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/texteditor/PageSystem.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/texteditor/PageSystem.java
index 8b11de4..b2939f0 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/texteditor/PageSystem.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/texteditor/PageSystem.java
@@ -37,6 +37,8 @@ public class PageSystem {
final int charForPage = 20000;
final int firstPageChars = 50000;
+ final int lineForPage = 250;
+
this.pageSystemInterface = pageSystemInterface;
pages = new LinkedList<>();
@@ -46,8 +48,9 @@ public class PageSystem {
int nextIndexOfReturn;
final int textLength = text.length();
boolean pageSystemEnabled = PreferenceHelper.getSplitText(context);
+ boolean splitByLineEnablec = PreferenceHelper.getSplitByLine(context);
- if (pageSystemEnabled) {
+ if (pageSystemEnabled && !splitByLineEnablec) {
while (i < textLength) {
// first page is longer
to = i + (i == 0 ? firstPageChars : charForPage);
@@ -57,14 +60,38 @@ public class PageSystem {
pages.add(text.substring(i, to));
i = to + 1;
}
+ if (i == 0)
+ pages.add("");
+ } else if(pageSystemEnabled && splitByLineEnablec){
+ int linecount = 0;
+ to = 0;
+ while (i < textLength) {
+ // first page is longer
+ nextIndexOfReturn = text.indexOf("\n", to);
+ if (nextIndexOfReturn > to) {
+ to = nextIndexOfReturn;
+ linecount++;
+ }
+ if (to > text.length()) {
+ to = text.length();
+ pages.add(text.substring(i, to));
+ i = to;
+ }
+ if (linecount >= lineForPage) {
+ pages.add(text.substring(i, to));
+ i = to;
+ linecount = 0;
+ }
-
+ to++;
+ }
if (i == 0)
pages.add("");
} else {
pages.add(text);
}
+
startingLines = new int[pages.size()];
setStartingLines();
}
diff --git a/libraries/sharedCode/src/main/res/layout/fragment_settings.xml b/libraries/sharedCode/src/main/res/layout/fragment_settings.xml
index 3018caa..89329e2 100644
--- a/libraries/sharedCode/src/main/res/layout/fragment_settings.xml
+++ b/libraries/sharedCode/src/main/res/layout/fragment_settings.xml
@@ -275,6 +275,20 @@
android:paddingRight="16dp"
android:textColor="@color/navigation_drawer_button_text_color_inverted"/>
+
+
+
diff --git a/libraries/sharedCode/src/main/res/values/strings.xml b/libraries/sharedCode/src/main/res/values/strings.xml
index f52b403..9aaa215 100644
--- a/libraries/sharedCode/src/main/res/values/strings.xml
+++ b/libraries/sharedCode/src/main/res/values/strings.xml
@@ -84,4 +84,6 @@
The file cannot be renamed
Use the "Storage Access Framework"
+ Split By Line
+
diff --git a/libraries/sharedCode/src/main/res/xml/extra_options.xml b/libraries/sharedCode/src/main/res/xml/extra_options.xml
index 4b0c733..2f996f3 100644
--- a/libraries/sharedCode/src/main/res/xml/extra_options.xml
+++ b/libraries/sharedCode/src/main/res/xml/extra_options.xml
@@ -61,6 +61,11 @@
android:title="@string/split_text_if_too_long"
android:defaultValue="true"/>
+
+