diff --git a/app-pro/build.gradle b/app-pro/build.gradle
index 0a81e4c..3689ac2 100644
--- a/app-pro/build.gradle
+++ b/app-pro/build.gradle
@@ -27,8 +27,8 @@ android {
applicationId "com.maskyn.fileeditorpro"
minSdkVersion 11
targetSdkVersion 22
- versionCode 39
- versionName "1.15.1"
+ versionCode 41
+ versionName "1.16"
}
compileOptions {
diff --git a/app/build.gradle b/app/build.gradle
index c4331c6..25c84fd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -46,8 +46,8 @@ android {
applicationId "com.maskyn.fileeditor"
minSdkVersion 11
targetSdkVersion 22
- versionCode 39
- versionName "1.15.1"
+ versionCode 41
+ versionName "1.16"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 43f4755..dff57c8 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,6 @@
-
+ -
+
+
-
- -
-
-
-
+
+
+ -
-
+ sha1="5365d91f442ac54c37a5ae3ebbcd82d9f43835e9">
+
-
-
+ revision="22.0.0"
+ sha1="1014d409d1af641616ca7a2b3fda549cf559d605">
+
-
-
+ sha1="591d72211acc0b909b79c840e0b3ed9a0982d807">
+
-
+
+
+ -
-
+ sha1="66cee5a65742fef58c1dcdc0b892042f7bb1530b">
+
+
+ -
+
+
+ -
+
+
+ -
+
-
- -
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- -
-
+ sha1="905075e6c80f206bbe6cf1e809d2caa69f420c76">
+
-
+ -
+
+
+ -
+
+
-
-
+ sha1="b5b92f469d515a13d778900f6d50c03d12f35504">
+
+
+ -
+
+
+ -
+
-
+ -
+
+
+ -
+
+
+ -
+
+
-
+
+
+ -
-
+ sha1="74a89f0f8b56d9f11d70b8d8134cf4109f4797dc">
+
-
-
+ sha1="4e86306289ace4aa0cfec44a05ed2b410d36989d">
+
-
-
+ sha1="0a4af6a85230b990eb8690b696d2db9247338611">
+
-
-
-
- -
-
+ sha1="d84409890828e07d344a3b9b1da545dba9897b51">
+
-
+ -
+
+
diff --git a/build/intermediates/model_data.bin b/build/intermediates/model_data.bin
index 6036517..6d8559d 100644
Binary files a/build/intermediates/model_data.bin and b/build/intermediates/model_data.bin differ
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/MainActivity.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/MainActivity.java
index aed4331..2861669 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/MainActivity.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/activity/MainActivity.java
@@ -99,6 +99,7 @@ import sharedcode.turboeditor.texteditor.PageSystemButtons;
import sharedcode.turboeditor.texteditor.Patterns;
import sharedcode.turboeditor.texteditor.SearchResult;
import sharedcode.turboeditor.util.AccessStorageApi;
+import sharedcode.turboeditor.util.AccessoryView;
import sharedcode.turboeditor.util.AnimationUtils;
import sharedcode.turboeditor.util.AppInfoHelper;
import sharedcode.turboeditor.util.IHomeActivity;
@@ -112,7 +113,7 @@ import sharedcode.turboeditor.views.GoodScrollView;
public abstract class MainActivity extends ActionBarActivity implements IHomeActivity, FindTextDialog
.SearchDialogInterface, GoodScrollView.ScrollInterface, PageSystem.PageSystemInterface,
PageSystemButtons.PageButtonsInterface, NumberPickerDialog.INumberPickerDialog, SaveFileDialog.ISaveDialog,
- AdapterView.OnItemClickListener, AdapterDrawer.Callbacks{
+ AdapterView.OnItemClickListener, AdapterDrawer.Callbacks, AccessoryView.IAccessoryView{
//region VARIABLES
private static final int READ_REQUEST_CODE = 42;
@@ -132,14 +133,14 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
new Runnable() {
@Override
public void run() {
- mEditor.replaceTextKeepCursor(null, true);
+ mEditor.replaceTextKeepCursor(null);
}
};
private static final Runnable colorRunnable_duringScroll =
new Runnable() {
@Override
public void run() {
- mEditor.replaceTextKeepCursor(null, false);
+ mEditor.replaceTextKeepCursor(null);
}
};
private static boolean fileOpened = false;
@@ -630,6 +631,8 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
horizontalScroll = (HorizontalScrollView) findViewById(R.id.horizontal_scroll);
mEditor = (Editor) findViewById(R.id.editor);
+ AccessoryView accessoryView = (AccessoryView) findViewById(R.id.accessoryView);
+ accessoryView.setInterface(this);
//mEditor.setLayerType(View.LAYER_TYPE_NONE, null);
if (PreferenceHelper.getWrapContent(this)) {
@@ -660,7 +663,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
invalidateOptionsMenu();
mEditor.disableTextChangedListener();
- mEditor.replaceTextKeepCursor(pageSystem.getCurrentPageText(), false);
+ mEditor.replaceTextKeepCursor(pageSystem.getCurrentPageText());
mEditor.enableTextChangedListener();
}
@@ -673,7 +676,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
findViewById(R.id.no_file_opened_messagge).setVisibility(View.VISIBLE);
mEditor.disableTextChangedListener();
- mEditor.replaceTextKeepCursor("", false);
+ mEditor.replaceTextKeepCursor("");
mEditor.enableTextChangedListener();
} catch (Exception e) {
// lol
@@ -786,7 +789,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
//region EVENTBUS
public void newFileToOpen(final File newFile, final String newFileText) {
- if (fileOpened && mEditor.canSaveFile()) {
+ if (fileOpened && mEditor != null && mEditor.canSaveFile()) {
SaveFileDialog.newInstance(sFilePath, pageSystem.getAllText(mEditor
.getText().toString()), currentEncoding, true, newFile.getAbsolutePath()).show(getFragmentManager(),
"dialog");
@@ -953,6 +956,8 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
if (types.contains(PreferenceChangeType.THEME_CHANGE)) {
ThemeUtils.setWindowsBackground(this);
+ AccessoryView accessoryView = (AccessoryView) findViewById(R.id.accessoryView);
+ accessoryView.updateTextColors();
}
if (types.contains(PreferenceChangeType.WRAP_CONTENT)) {
@@ -967,7 +972,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
}
} else if (types.contains(PreferenceChangeType.LINE_NUMERS)) {
mEditor.disableTextChangedListener();
- mEditor.replaceTextKeepCursor(null, true);
+ mEditor.replaceTextKeepCursor(null);
mEditor.enableTextChangedListener();
if (PreferenceHelper.getLineNumbers(this)) {
mEditor.setPadding(
@@ -984,7 +989,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
}
} else if (types.contains(PreferenceChangeType.SYNTAX)) {
mEditor.disableTextChangedListener();
- mEditor.replaceTextKeepCursor(null, true);
+ mEditor.replaceTextKeepCursor(null);
mEditor.enableTextChangedListener();
} else if (types.contains(PreferenceChangeType.MONOSPACE)) {
if (PreferenceHelper.getUseMonospace(this))
@@ -1039,14 +1044,14 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
try {
final byte[] oldText = mEditor.getText().toString().getBytes(oldEncoding);
mEditor.disableTextChangedListener();
- mEditor.replaceTextKeepCursor(new String(oldText, newEncoding), true);
+ mEditor.replaceTextKeepCursor(new String(oldText, newEncoding));
mEditor.enableTextChangedListener();
currentEncoding = newEncoding;
} catch (UnsupportedEncodingException ignored) {
try {
final byte[] oldText = mEditor.getText().toString().getBytes(oldEncoding);
mEditor.disableTextChangedListener();
- mEditor.replaceTextKeepCursor(new String(oldText, "UTF-16"), true);
+ mEditor.replaceTextKeepCursor(new String(oldText, "UTF-16"));
mEditor.enableTextChangedListener();
} catch (UnsupportedEncodingException ignored2) {
}
@@ -1109,7 +1114,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
pageSystem.savePage(mEditor.getText().toString());
pageSystem.nextPage();
mEditor.disableTextChangedListener();
- mEditor.replaceTextKeepCursor(pageSystem.getCurrentPageText(), false);
+ mEditor.replaceTextKeepCursor(pageSystem.getCurrentPageText());
mEditor.enableTextChangedListener();
verticalScroll.postDelayed(new Runnable() {
@@ -1131,7 +1136,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
pageSystem.savePage(mEditor.getText().toString());
pageSystem.prevPage();
mEditor.disableTextChangedListener();
- mEditor.replaceTextKeepCursor(pageSystem.getCurrentPageText(), false);
+ mEditor.replaceTextKeepCursor(pageSystem.getCurrentPageText());
mEditor.enableTextChangedListener();
verticalScroll.postDelayed(new Runnable() {
@@ -1220,7 +1225,7 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
pageSystem.savePage(mEditor.getText().toString());
pageSystem.goToPage(value);
mEditor.disableTextChangedListener();
- mEditor.replaceTextKeepCursor(pageSystem.getCurrentPageText(), true);
+ mEditor.replaceTextKeepCursor(pageSystem.getCurrentPageText());
mEditor.enableTextChangedListener();
verticalScroll.postDelayed(new Runnable() {
@@ -1261,6 +1266,12 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
if (andCloseOpenedFile)
cannotOpenFile();
}
+
+ @Override
+ public void onButtonAccessoryViewClicked(String text) {
+ mEditor.getText().insert(mEditor.getSelectionStart(), text);
+ }
+
//endregion
public static class Editor extends EditText {
@@ -1658,10 +1669,11 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
canSaveFile = false;
}
- public void replaceTextKeepCursor(String textToUpdate, boolean mantainCursorPos) {
+ public void replaceTextKeepCursor(String textToUpdate) {
int cursorPos;
int cursorPosEnd;
+
if (textToUpdate != null) {
cursorPos = 0;
cursorPosEnd = 0;
@@ -1682,6 +1694,8 @@ public abstract class MainActivity extends ActionBarActivity implements IHomeAct
enableTextChangedListener();
+ boolean mantainCursorPos = cursorPos >= firstVisibleIndex && cursorPos <= lastVisibleIndex;
+
if (mantainCursorPos)
firstVisibleIndex = cursorPos;
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/EncodingDialog.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/EncodingDialog.java
index ee7d769..31e20cb 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/EncodingDialog.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/EncodingDialog.java
@@ -49,6 +49,7 @@ public class EncodingDialog extends DialogFragment implements AdapterView.OnItem
Constants.CHARSET_ISO_2022_CN,
Constants.CHARSET_ISO_2022_JP,
Constants.CHARSET_ISO_2022_KR,
+ "ISO-8859-2",
Constants.CHARSET_ISO_8859_5,
Constants.CHARSET_ISO_8859_7,
Constants.CHARSET_ISO_8859_8,
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/ThemeDialog.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/ThemeDialog.java
new file mode 100644
index 0000000..9434c5a
--- /dev/null
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/dialogfragment/ThemeDialog.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2014 Vlad Mihalachi
+ *
+ * This file is part of Turbo Editor.
+ *
+ * Turbo Editor is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Turbo Editor is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package sharedcode.turboeditor.dialogfragment;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+import sharedcode.turboeditor.R;
+import sharedcode.turboeditor.preferences.PreferenceHelper;
+
+public class ThemeDialog extends DialogFragment implements AdapterView.OnItemClickListener {
+
+ private ListView list;
+
+ public static ThemeDialog newInstance() {
+ final ThemeDialog f = new ThemeDialog();
+ return f;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+
+ final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_theme_list, null);
+ list = (ListView) view.findViewById(android.R.id.list);
+
+ String[] themes = {
+ getString(R.string.theme_dark), getString(R.string.light_theme), getString(R.string.theme_black)
+ };
+
+ list.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.item_single_choice, themes));
+ list.setOnItemClickListener(this);
+
+ int currentTheme = PreferenceHelper.getTheme(getActivity());
+
+ for (int i = 0; i < themes.length; i++) {
+ if (i == currentTheme)
+ list.setItemChecked(i, true);
+ }
+
+ return new AlertDialog.Builder(getActivity())
+ .setView(view)
+ .create();
+ }
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ DialogListener target = (DialogListener) getTargetFragment();
+ if (target == null) {
+ target = (DialogListener) getActivity();
+ }
+ target.onThemeSelected(position);
+ this.dismiss();
+ }
+
+ public interface DialogListener {
+ void onThemeSelected(int result);
+ }
+}
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 ca0aaa7..529a11b 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/PreferenceHelper.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/PreferenceHelper.java
@@ -57,8 +57,20 @@ public final class PreferenceHelper {
return getPrefs(context).getBoolean("editor_wrap_content", true);
}
+ public static int getTheme(Context context) {
+ return getPrefs(context).getInt("theme", 0);
+ }
+
+ public static boolean getDarkTheme(Context context) {
+ return getPrefs(context).getInt("theme", 0) == 0;
+ }
+
public static boolean getLightTheme(Context context) {
- return getPrefs(context).getBoolean("light_theme", false);
+ return getPrefs(context).getInt("theme", 0) == 1;
+ }
+
+ public static boolean getBlackTheme(Context context) {
+ return getPrefs(context).getInt("theme", 0) == 2;
}
public static boolean getSuggestionActive(Context context) {
@@ -158,8 +170,8 @@ public final class PreferenceHelper {
getEditor(context).putBoolean("has_donated", value).commit();
}
- public static void setLightTheme(Context context, boolean value) {
- getEditor(context).putBoolean("light_theme", value).commit();
+ public static void setTheme(Context context, int value) {
+ getEditor(context).putInt("theme", value).commit();
}
public static void setSuggestionsActive(Context context, boolean value) {
@@ -179,7 +191,7 @@ public final class PreferenceHelper {
}
public static void setSendErrorReport(Context context, boolean value) {
- getEditor(context).putBoolean("ignore_back_button", value).commit();
+ getEditor(context).putBoolean("send_error_reports", value).commit();
}
public static void setEncoding(Context context, String value) {
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 e17666f..15bfd09 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/SettingsFragment.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/preferences/SettingsFragment.java
@@ -20,6 +20,8 @@
package sharedcode.turboeditor.preferences;
import android.app.Fragment;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
@@ -32,9 +34,11 @@ import sharedcode.turboeditor.R;
import sharedcode.turboeditor.activity.MainActivity;
import sharedcode.turboeditor.dialogfragment.EncodingDialog;
import sharedcode.turboeditor.dialogfragment.NumberPickerDialog;
+import sharedcode.turboeditor.dialogfragment.ThemeDialog;
+import sharedcode.turboeditor.util.ProCheckUtils;
import sharedcode.turboeditor.util.ViewUtils;
-public class SettingsFragment extends Fragment implements NumberPickerDialog.INumberPickerDialog, EncodingDialog.DialogListener {
+public class SettingsFragment extends Fragment implements NumberPickerDialog.INumberPickerDialog, EncodingDialog.DialogListener, ThemeDialog.DialogListener {
// Editor Variables
private boolean sLineNumbers;
@@ -43,7 +47,6 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
private boolean sUseMonospace;
private boolean sReadOnly;
- private boolean sLightTheme;
private boolean sSuggestions;
private boolean sAutoSave;
private boolean sIgnoreBackButton;
@@ -59,7 +62,6 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
sLineNumbers = PreferenceHelper.getLineNumbers(getActivity());
sReadOnly = PreferenceHelper.getReadOnly(getActivity());
- sLightTheme = PreferenceHelper.getLightTheme(getActivity());
sSuggestions = PreferenceHelper.getSuggestionActive(getActivity());
sAutoSave = PreferenceHelper.getAutoSave(getActivity());
sIgnoreBackButton = PreferenceHelper.getIgnoreBackButton(getActivity());
@@ -73,7 +75,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 swLightTheme, swSuggestions, swAutoSave, swIgnoreBackButton, swSplitText, swErrorReports;
+ final SwitchCompat swSuggestions, swAutoSave, swIgnoreBackButton, swSplitText, swErrorReports;
swLineNumbers = (SwitchCompat) rootView.findViewById(R.id.switch_line_numbers);
swSyntax = (SwitchCompat) rootView.findViewById(R.id.switch_syntax);
@@ -81,7 +83,6 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
swMonospace = (SwitchCompat) rootView.findViewById(R.id.switch_monospace);
swReadOnly = (SwitchCompat) rootView.findViewById(R.id.switch_read_only);
- swLightTheme = (SwitchCompat) rootView.findViewById(R.id.switch_light_theme);
swSuggestions = (SwitchCompat) rootView.findViewById(R.id.switch_suggestions_active);
swAutoSave = (SwitchCompat) rootView.findViewById(R.id.switch_auto_save);
swIgnoreBackButton = (SwitchCompat) rootView.findViewById(R.id.switch_ignore_backbutton);
@@ -94,17 +95,31 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
swMonospace.setChecked(sUseMonospace);
swReadOnly.setChecked(sReadOnly);
- swLightTheme.setChecked(sLightTheme);
swSuggestions.setChecked(sSuggestions);
swAutoSave.setChecked(sAutoSave);
swIgnoreBackButton.setChecked(sIgnoreBackButton);
swSplitText.setChecked(sSplitText);
swErrorReports.setChecked(sErrorReports);
- TextView fontSizeView, encodingView, donateView, extraOptionsView;
+ TextView fontSizeView, encodingView, extraOptionsView, themeView, goPro;
+ goPro = (TextView) rootView.findViewById(R.id.drawer_button_go_pro);
fontSizeView = (TextView) rootView.findViewById(R.id.drawer_button_font_size);
encodingView = (TextView) rootView.findViewById(R.id.drawer_button_encoding);
extraOptionsView = (TextView) rootView.findViewById(R.id.drawer_button_extra_options);
+ themeView = (TextView) rootView.findViewById(R.id.drawer_button_theme);
+
+ ViewUtils.setVisible(goPro, !ProCheckUtils.isPro(getActivity()));
+ goPro.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final String appPackageName = "com.maskyn.fileeditorpro";
+ try {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
+ } catch (android.content.ActivityNotFoundException anfe) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
+ }
+ }
+ });
swLineNumbers.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@@ -183,11 +198,12 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
}
});
- swLightTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ themeView.setOnClickListener(new View.OnClickListener() {
@Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- PreferenceHelper.setLightTheme(getActivity(), isChecked);
- ((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.THEME_CHANGE);
+ public void onClick(View v) {
+ ThemeDialog dialogFrag = ThemeDialog.newInstance();
+ dialogFrag.setTargetFragment(SettingsFragment.this, 0);
+ dialogFrag.show(getFragmentManager().beginTransaction(), "dialog");
}
});
@@ -242,4 +258,10 @@ public class SettingsFragment extends Fragment implements NumberPickerDialog.INu
PreferenceHelper.setEncoding(getActivity(), result);
((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.ENCODING);
}
+
+ @Override
+ public void onThemeSelected(int result) {
+ PreferenceHelper.setTheme(getActivity(), result);
+ ((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.THEME_CHANGE);
+ }
}
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/texteditor/Patterns.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/texteditor/Patterns.java
index cca92e6..71ffed3 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/texteditor/Patterns.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/texteditor/Patterns.java
@@ -55,17 +55,20 @@ public class Patterns {
"(!|,|\\(|\\)|\\+|\\-|\\*|<|>|=|\\.|\\?|;|\\{|\\}|\\[|\\]|\\|)");
public static final Pattern NUMBERS_OR_SYMBOLS = Pattern.compile(NUMBERS.pattern()+"|"+SYMBOLS.pattern());
public static final Pattern GENERAL_KEYWORDS = Pattern.compile(
- "\\b(alignas|alignof|and|and_eq|asm|auto|bitand|bitorbool|break|case|catch|char|"
- + "char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype"
- + "|default|delete|do|double|dynamic_cast|echo|else|enum|explicit|export|extern|"
- + "false|float|for|friend|function|goto|if|inline|int|mutable|namespace|new|noexcept|"
- + "not|not_eq|null|nullptr|operator|or|or_eq|private|protected|public|register|"
- + "reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast"
- + "|struct|switch|template|this|thread_local|throw|true|try|typedef|typeid|typename|undefined"
- + "|union|unsigned|using|var|virtual|void|volatile|wchar_t|while|xor|xor_eq|)\\b", Pattern.CASE_INSENSITIVE);
+ "(?<=\\b)((alignas)|(alignof)|(and)|(and_eq)|(asm)|(auto)|(bitand)|(bitorbool)|(break)|(case)|(catch)|(char)|("
+ + "char16_t)|(char32_t)|(class)|(compl)|(const)|(constexpr)|(const_cast)|(continue)|(decltype"
+ + ")|(default)|(delete)|(do)|(double)|(dynamic_cast)|(echo)|(else)|(enum)|(explicit)|(export)|(extern)|("
+ + "false)|(float)|(for)|(friend)|(function)|(goto)|(if)|(inline)|(int)|(mutable)|(namespace)|(new)|(noexcept)|("
+ + "not)|(not_eq)|(null)|(nullptr)|(operator)|(or)|(or_eq)|(private)|(protected)|(public)|(register)|("
+ + "reinterpret_cast)|(return)|(short)|(signed)|(sizeof)|(static)|(static_assert)|(static_cast"
+ + ")|(struct)|(switch)|(template)|(this)|(thread_local)|(throw)|(true)|(try)|(typedef)|(typeid)|(typename)|(undefined"
+ + ")|(union)|(unsigned)|(using)|(var)|(virtual)|(void)|(volatile)|(wchar_t)|(while)|(xor)|(xor_eq))(?=\\b)", Pattern.CASE_INSENSITIVE);
public static final Pattern PY_KEYWORDS = Pattern.compile(
- "\\b(int|float|long|complex|str|unicode|list|tuple|bytearray|buffer|xrange|set|frozenset|dict|bool)|(True|False|None|self|NotImplemented|Ellipsis|__debug__|__file__)|(and|del|from|not|while|as|elif|global|or|with|assert|else|if|pass|yield|break|except|import|print|class|exec|in|raise|continue|finally|is|return|def|for|lambda|try)|(ArithmeticError|AssertionError|AttributeError|BaseException|DeprecationWarning|EnvironmentError|EOFError|Exception|FloatingPointError|FutureWarning|GeneratorExit|IOError|ImportError|ImportWarning|IndexError|KeyError|KeyboardInterrupt|LookupError|MemoryError|NameError|NotImplementedError|OSError|OverflowError|PendingDeprecationWarning|ReferenceError|RuntimeError|RuntimeWarning|StandardError|StopIteration|SyntaxError|SyntaxWarning|SystemError|SystemExit|TypeError|UnboundLocalError|UserWarning|UnicodeError|UnicodeWarning|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ValueError|Warning|WindowsError|ZeroDivisionError)\\b", Pattern.CASE_INSENSITIVE);
+ "(?<=\\b)((int)|(float)|(long)|(complex)|(str)|(unicode)|(list)|(tuple)|(bytearray)|(buffer)|(xrange)|(set)|(frozenset)|(dict)|(bool)" +
+ "|(True)|(False)|(None)|(self)|(NotImplemented)|(Ellipsis)|(__debug__)|(__file__)" +
+ "|(and)|(del)|(from)|(not)|(while)|(as)|(elif)|(global)|(or)|(with)|(assert)|(else)|(if)|(pass)|(yield)|(break)|(except)|(import)|(print)|(class)|(exec)|(in)|(raise)|(continue)|(finally)|(is)|(return)|(def)|(for)|(lambda)|(try)" +
+ "|(ArithmeticError)|(AssertionError)|(AttributeError)|(BaseException)|(DeprecationWarning)|(EnvironmentError)|(EOFError)|(Exception)|(FloatingPointError)|(FutureWarning)|(GeneratorExit)|(IOError)|(ImportError)|(ImportWarning)|(IndexError)|(KeyError)|(KeyboardInterrupt)|(LookupError)|(MemoryError)|(NameError)|(NotImplementedError)|(OSError)|(OverflowError)|(PendingDeprecationWarning)|(ReferenceError)|(RuntimeError)|(RuntimeWarning)|(StandardError)|(StopIteration)|(SyntaxError)|(SyntaxWarning)|(SystemError)|(SystemExit)|(TypeError)|(UnboundLocalError)|(UserWarning)|(UnicodeError)|(UnicodeWarning)|(UnicodeEncodeError)|(UnicodeDecodeError)|(UnicodeTranslateError)|(ValueError)|(Warning)|(WindowsError)|(ZeroDivisionError))(?=\\b)", Pattern.CASE_INSENSITIVE);
public static final Pattern LUA_KEYWORDS = Pattern.compile(
"@[A-Za-z0-9_\\.]*|\\b(local|global|boolean|number|userdata)\\b|\\b(true|false|nil)\\b|\\b(return|then|while|and|break|do|else|elseif|end|for|function|if|in|not|or|repeat|until|thread|table)\\b" +
@@ -82,7 +85,7 @@ public class Patterns {
public static final Pattern GENERAL_COMMENTS_NO_SLASH = Pattern.compile(
"/\\*(?:.|[\\n\\r])*?\\*/|#.*");
public static final Pattern SQL_KEYWORDS = Pattern.compile(
- "\\b(ADD|EXCEPT|PERCENT|ALL|EXEC|PLAN|ALTER|EXECUTE|PRECISION|AND|EXISTS|PRIMARY|ANY|EXIT|PRINT|AS|FETCH|PROC|ASC|FILE|PROCEDURE|AUTHORIZATION|FILLFACTOR|PUBLIC|BACKUP|FOR|RAISERROR|BEGIN|FOREIGN|READ|BETWEEN|FREETEXT|READTEXT|BREAK|FREETEXTTABLE|RECONFIGURE|BROWSE|FROM|REFERENCES|BULK|FULL|REPLICATION|BY|FUNCTION|RESTORE|CASCADE|GOTO|RESTRICT|CASE|GRANT|RETURN|CHECK|GROUP|REVOKE|CHECKPOINT|HAVING|RIGHT|CLOSE|HOLDLOCK|ROLLBACK|CLUSTERED|IDENTITY|ROWCOUNT|COALESCE|IDENTITY_INSERT|ROWGUIDCOL|COLLATE|IDENTITYCOL|RULE|COLUMN|IF|SAVE|COMMIT|IN|SCHEMA|COMPUTE|INDEX|SELECT|CONSTRAINT|INNER|SESSION_USER|CONTAINS|INSERT|SET|CONTAINSTABLE|INTERSECT|SETUSER|CONTINUE|INTO|SHUTDOWN|CONVERT|IS|SOME|CREATE|JOIN|STATISTICS|CROSS|KEY|SYSTEM_USER|CURRENT|KILL|TABLE|CURRENT_DATE|LEFT|TEXTSIZE|CURRENT_TIME|LIKE|THEN|CURRENT_TIMESTAMP|LINENO|TO|CURRENT_USER|LOAD|TOP|CURSOR|NATIONAL|TRAN|DATABASE|NOCHECK|TRANSACTION|DBCC|NONCLUSTERED|TRIGGER|DEALLOCATE|NOT|TRUNCATE|DECLARE|NULL|TSEQUAL|DEFAULT|NULLIF|UNION|DELETE|OF|UNIQUE|DENY|OFF|UPDATE|DESC|OFFSETS|UPDATETEXT|DISK|ON|USE|DISTINCT|OPEN|USER|DISTRIBUTED|OPENDATASOURCE|VALUES|DOUBLE|OPENQUERY|VARYING|DROP|OPENROWSET|VIEW|DUMMY|OPENXML|WAITFOR|DUMP|OPTION|WHEN|ELSE|OR|WHERE|END|ORDER|WHILE|ERRLVL|OUTER|WITH|ESCAPE|OVER|WRITETEXT)\\b", Pattern.CASE_INSENSITIVE);
+ "(?<=\\b)((ADD)|(EXCEPT)|(PERCENT)|(ALL)|(EXEC)|(PLAN)|(ALTER)|(EXECUTE)|(PRECISION)|(AND)|(EXISTS)|(PRIMARY)|(ANY)|(EXIT)|(PRINT)|(AS)|(FETCH)|(PROC)|(ASC)|(FILE)|(PROCEDURE)|(AUTHORIZATION)|(FILLFACTOR)|(PUBLIC)|(BACKUP)|(FOR)|(RAISERROR)|(BEGIN)|(FOREIGN)|(READ)|(BETWEEN)|(FREETEXT)|(READTEXT)|(BREAK)|(FREETEXTTABLE)|(RECONFIGURE)|(BROWSE)|(FROM)|(REFERENCES)|(BULK)|(FULL)|(REPLICATION)|(BY)|(FUNCTION)|(RESTORE)|(CASCADE)|(GOTO)|(RESTRICT)|(CASE)|(GRANT)|(RETURN)|(CHECK)|(GROUP)|(REVOKE)|(CHECKPOINT)|(HAVING)|(RIGHT)|(CLOSE)|(HOLDLOCK)|(ROLLBACK)|(CLUSTERED)|(IDENTITY)|(ROWCOUNT)|(COALESCE)|(IDENTITY_INSERT)|(ROWGUIDCOL)|(COLLATE)|(IDENTITYCOL)|(RULE)|(COLUMN)|(IF)|(SAVE)|(COMMIT)|(IN)|(SCHEMA)|(COMPUTE)|(INDEX)|(SELECT)|(CONSTRAINT)|(INNER)|(SESSION_USER)|(CONTAINS)|(INSERT)|(SET)|(CONTAINSTABLE)|(INTERSECT)|(SETUSER)|(CONTINUE)|(INTO)|(SHUTDOWN)|(CONVERT)|(IS)|(SOME)|(CREATE)|(JOIN)|(STATISTICS)|(CROSS)|(KEY)|(SYSTEM_USER)|(CURRENT)|(KILL)|(TABLE)|(CURRENT_DATE)|(LEFT)|(TEXTSIZE)|(CURRENT_TIME)|(LIKE)|(THEN)|(CURRENT_TIMESTAMP)|(LINENO)|(TO)|(CURRENT_USER)|(LOAD)|(TOP)|(CURSOR)|(NATIONAL)|(TRAN)|(DATABASE)|(NOCHECK)|(TRANSACTION)|(DBCC)|(NONCLUSTERED)|(TRIGGER)|(DEALLOCATE)|(NOT)|(TRUNCATE)|(DECLARE)|(NULL)|(TSEQUAL)|(DEFAULT)|(NULLIF)|(UNION)|(DELETE)|(OF)|(UNIQUE)|(DENY)|(OFF)|(UPDATE)|(DESC)|(OFFSETS)|(UPDATETEXT)|(DISK)|(ON)|(USE)|(DISTINCT)|(OPEN)|(USER)|(DISTRIBUTED)|(OPENDATASOURCE)|(VALUES)|(DOUBLE)|(OPENQUERY)|(VARYING)|(DROP)|(OPENROWSET)|(VIEW)|(DUMMY)|(OPENXML)|(WAITFOR)|(DUMP)|(OPTION)|(WHEN)|(ELSE)|(OR)|(WHERE)|(END)|(ORDER)|(WHILE)|(ERRLVL)|(OUTER)|(WITH)|(ESCAPE)|(OVER)|(WRITETEXT))(?=\\b)", Pattern.CASE_INSENSITIVE);
public static final Pattern LINK = android.util.Patterns.WEB_URL;
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/AccessoryView.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/AccessoryView.java
new file mode 100644
index 0000000..05e8f54
--- /dev/null
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/AccessoryView.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2014 Vlad Mihalachi
+ *
+ * This file is part of Turbo Editor.
+ *
+ * Turbo Editor is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Turbo Editor is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package sharedcode.turboeditor.util;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+
+import sharedcode.turboeditor.R;
+import sharedcode.turboeditor.preferences.PreferenceHelper;
+
+/**
+ * Created by mac on 15/02/15.
+ */
+public class AccessoryView extends LinearLayout {
+
+ public IAccessoryView iAccessoryView;
+ private TypedValue outValue;
+
+ public AccessoryView(Context context) {
+ super(context);
+ init();
+ }
+
+ public AccessoryView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public AccessoryView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init();
+ }
+
+ private void init() {
+ setOrientation(HORIZONTAL);
+ createView();
+ }
+
+ public void setInterface(IAccessoryView iBreadcrumb) {
+ this.iAccessoryView = iBreadcrumb;
+ }
+
+
+ public void createView() {
+ removeAllViews();
+
+ // If we're running on Honeycomb or newer, then we can use the Theme's
+ // selectableItemBackground to ensure that the View has a pressed state
+ outValue = new TypedValue();
+ getContext().getTheme().resolveAttribute(R.attr.selectableItemBackgroundBorderless, outValue, true);
+
+ String[] characters = {
+ "<", ">", "!", "/", ".", ";", "=", "\"", "{", "}", "[", "]", "(", ")", "&", "|", "#", "*", "+", "-", ":", "%", ",", "_", "@", "?", "^", "'",
+ };
+
+ for (int i = 0; i < characters.length; i++)
+ addAButton(characters[i]);
+
+ updateTextColors();
+ }
+
+ private void addAButton(final String text) {
+ int dimension = (int) PixelDipConverter.convertDpToPixel(50, getContext());
+ //int padding = (int) PixelDipConverter.convertDpToPixel(10, getContext());
+ final Button name = new Button(getContext());
+
+ name.setLayoutParams(new LinearLayout.LayoutParams(dimension, dimension));
+
+
+ name.setGravity(Gravity.CENTER);
+
+ name.setText(text);
+ name.setTextSize(15);
+ name.setAllCaps(true);
+
+ //name.setPadding(padding, padding, padding, padding);
+
+ name.setClickable(true);
+
+ name.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ iAccessoryView.onButtonAccessoryViewClicked(text);
+ }
+ });
+
+ name.setBackgroundResource(outValue.resourceId);
+ addView(name);
+ }
+
+ public void updateTextColors() {
+ boolean isLightTheme = PreferenceHelper.getLightTheme(getContext());
+ for (int i = 0; i < getChildCount(); i++) {
+ ((Button) getChildAt(i)).setTextColor(isLightTheme ? getResources().getColor(android.R.color.background_dark) : getResources().getColor(android.R.color.white));
+ }
+ }
+
+ public interface IAccessoryView {
+ public void onButtonAccessoryViewClicked(String text);
+ }
+}
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/ProCheckUtils.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/ProCheckUtils.java
index a7a1268..593ad23 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/ProCheckUtils.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/ProCheckUtils.java
@@ -25,11 +25,11 @@ public class ProCheckUtils {
public static boolean isPro(Context context, boolean includeDonations) {
// happy new year
- return true;
+ return context.getPackageName().equals("com.maskyn.fileeditorpro");
/*
if (Build.FOR_AMAZON)
return true;
- else if (context.getPackageName().equals("com.maskyn.fileeditorpro"))
+ else if ()
return true;
else if (includeDonations && PreferenceHelper.hasDonated(context))
return true;
diff --git a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/ThemeUtils.java b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/ThemeUtils.java
index d36899d..adb7771 100644
--- a/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/ThemeUtils.java
+++ b/libraries/sharedCode/src/main/java/sharedcode/turboeditor/util/ThemeUtils.java
@@ -35,21 +35,16 @@ public class ThemeUtils {
}
}
- public static void setPreferenceTheme(Activity activity){
- boolean light = PreferenceHelper.getLightTheme(activity);
- if (light) {
- activity.setTheme(R.style.PreferenceLight);
- } else {
- activity.setTheme(R.style.PreferenceDark);
- }
- }
-
public static void setWindowsBackground(Activity activity) {
boolean whiteTheme = PreferenceHelper.getLightTheme(activity);
+ boolean darkTheme = PreferenceHelper.getDarkTheme(activity);
+ boolean blackTheme = PreferenceHelper.getBlackTheme(activity);
if (whiteTheme) {
activity.getWindow().setBackgroundDrawableResource(R.color.window_background_light);
- } else {
+ } else if (darkTheme) {
activity.getWindow().setBackgroundDrawableResource(R.color.window_background);
+ } else {
+ activity.getWindow().setBackgroundDrawableResource(android.R.color.black);
}
}
}
diff --git a/libraries/sharedCode/src/main/res/layout/activity_home.xml b/libraries/sharedCode/src/main/res/layout/activity_home.xml
index d2a6573..6d71c6b 100644
--- a/libraries/sharedCode/src/main/res/layout/activity_home.xml
+++ b/libraries/sharedCode/src/main/res/layout/activity_home.xml
@@ -58,7 +58,8 @@
android:scrollbars="vertical"
android:fillViewport="true"
android:id="@id/vertical_scroll"
- android:background="@null">
+ android:background="@null"
+ android:layout_marginBottom="50dp">
-
+
@@ -99,11 +100,23 @@
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_gravity="bottom|right"
- android:layout_marginBottom="16dp"
+ android:layout_marginBottom="66dp"
android:layout_marginRight="100dp"
android:layout_marginEnd="90dp"
android:visibility="invisible"/>
+
+
+
+
diff --git a/libraries/sharedCode/src/main/res/layout/dialog_theme_list.xml b/libraries/sharedCode/src/main/res/layout/dialog_theme_list.xml
new file mode 100644
index 0000000..d6b6733
--- /dev/null
+++ b/libraries/sharedCode/src/main/res/layout/dialog_theme_list.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
diff --git a/libraries/sharedCode/src/main/res/layout/fragment_settings.xml b/libraries/sharedCode/src/main/res/layout/fragment_settings.xml
index a152708..103c76b 100644
--- a/libraries/sharedCode/src/main/res/layout/fragment_settings.xml
+++ b/libraries/sharedCode/src/main/res/layout/fragment_settings.xml
@@ -32,6 +32,21 @@
android:orientation="vertical"
>
+
+
@@ -147,18 +161,19 @@
android:visibility="gone"
android:orientation="vertical">
-
-
+
+ Happy PI day!
+ Added the Accessory View (now you can input more easily special symbols!)
+ Added a Black theme!
+ Added ISO-8859-2 encoding
+ Bug fixes
+
+
+
It is a "beta" release, feel free to send you feedback on github.com!
Added Save As! (and rename option)
Added Replace All!
diff --git a/libraries/sharedCode/src/main/res/values/ids.xml b/libraries/sharedCode/src/main/res/values/ids.xml
index de50092..f1f7281 100644
--- a/libraries/sharedCode/src/main/res/values/ids.xml
+++ b/libraries/sharedCode/src/main/res/values/ids.xml
@@ -76,7 +76,6 @@
-
@@ -86,6 +85,7 @@
+
diff --git a/libraries/sharedCode/src/main/res/values/strings.xml b/libraries/sharedCode/src/main/res/values/strings.xml
index 11ca75a..b3f91c2 100644
--- a/libraries/sharedCode/src/main/res/values/strings.xml
+++ b/libraries/sharedCode/src/main/res/values/strings.xml
@@ -75,4 +75,7 @@
New file
Delete current file
Replace all
+ Theme
+ Dark theme
+ Black theme