Compare commits
66 Commits
v1.13
...
replace-ro
Author | SHA1 | Date | |
---|---|---|---|
d9f35737de | |||
f7a95be11b | |||
f08edb736d | |||
05e3600504 | |||
0b24c89307 | |||
f8491fefdb | |||
4885aa9df6 | |||
0dd894a777 | |||
01e7a2674c | |||
8838fbd5a9 | |||
ddd99e48e5 | |||
b4da74dea1 | |||
24e7fc5904 | |||
6ef85c45b5 | |||
2c55929f9f | |||
e45665ece1 | |||
97f1be558b | |||
2ee5a8e904 | |||
c56b0f8054 | |||
7a6d0d3eba | |||
ef533e6e44 | |||
23d09e05c9 | |||
a35d95b799 | |||
39c7dd956c | |||
12c539738a | |||
68e8c4235a | |||
b7f84409db | |||
79d6cb6172 | |||
c1d658ffb1 | |||
a3624e6b2e | |||
cd20b586f1 | |||
02492c8d83 | |||
871b2cfc11 | |||
401814cb22 | |||
0269d9c210 | |||
46ad99aa46 | |||
9408fba5dd | |||
ebce0bd69b | |||
ce2c2d8b0f | |||
0de5a82cdf | |||
69f8f2b0c7 | |||
245b9f4230 | |||
3db0519ec6 | |||
9b7de55f55 | |||
66a86dc513 | |||
38123fd510 | |||
481fe94eb9 | |||
6a965ca560 | |||
a1e82b65d4 | |||
e399a217e5 | |||
68ad318388 | |||
1f3ad1ab12 | |||
2414192638 | |||
1cd94a5310 | |||
ce4d1756fb | |||
3234597537 | |||
5f77e6d7b5 | |||
60395106e5 | |||
3ee11e0bfb | |||
b71d27aeaa | |||
05e4157bed | |||
89673216e8 | |||
7a86540c60 | |||
b359950e34 | |||
614274c7d6 | |||
78407c292a |
25
.fdroid.yml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
Categories:
|
||||||
|
- Writing
|
||||||
|
License: GPL-3.0-or-later
|
||||||
|
WebSite: https://github.com/adrianmalacoda/text-editor-8000
|
||||||
|
SourceCode: https://github.com/adrianmalacoda/text-editor-8000
|
||||||
|
IssueTracker: https://github.com/adrianmalacoda/text-editor-8000/issues
|
||||||
|
|
||||||
|
AutoName: Text Editor 8000
|
||||||
|
Summary: Simple text editor
|
||||||
|
Description: Simple, yet powerful editor for text files.
|
||||||
|
|
||||||
|
RepoType: git
|
||||||
|
Repo: .
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- versionName: "1.20"
|
||||||
|
versionCode: 48
|
||||||
|
commit: HEAD
|
||||||
|
subdir: app
|
||||||
|
gradle: yes
|
||||||
|
|
||||||
|
AutoUpdateMode: None
|
||||||
|
UpdateCheckMode: RepoManifest
|
||||||
|
CurrentVersion: 1.20
|
||||||
|
CurrentVersion Code: 48
|
123
.gitignore
vendored
@ -1,62 +1,63 @@
|
|||||||
# Built application files
|
# Built application files
|
||||||
*.apk
|
*.apk
|
||||||
*.ap_
|
*.ap_
|
||||||
|
|
||||||
# Files for the Dalvik VM
|
# Files for the Dalvik VM
|
||||||
*.dex
|
*.dex
|
||||||
|
|
||||||
# Java class files
|
# Java class files
|
||||||
*.class
|
*.class
|
||||||
|
|
||||||
# Generated files
|
# Generated files
|
||||||
bin/
|
bin/
|
||||||
gen/
|
gen/
|
||||||
doc/
|
doc/
|
||||||
|
/build
|
||||||
# Proguard folder generated by Eclipse
|
|
||||||
proguard/
|
# Proguard folder generated by Eclipse
|
||||||
|
proguard/
|
||||||
# Log Files
|
|
||||||
*.log
|
# Log Files
|
||||||
|
*.log
|
||||||
# Built application files
|
|
||||||
/*/build/
|
# Built application files
|
||||||
|
/*/build/
|
||||||
# Crashlytics configuations
|
|
||||||
com_crashlytics_export_strings.xml
|
# Crashlytics configuations
|
||||||
crashlytics-build.properties
|
com_crashlytics_export_strings.xml
|
||||||
crashlytics.properties
|
crashlytics-build.properties
|
||||||
|
crashlytics.properties
|
||||||
# Local configuration file (sdk path, etc)
|
|
||||||
local.properties
|
# Local configuration file (sdk path, etc)
|
||||||
|
local.properties
|
||||||
# Gradle generated files
|
|
||||||
.gradle/
|
# Gradle generated files
|
||||||
|
.gradle/
|
||||||
# Signing files
|
|
||||||
.signing/
|
# Signing files
|
||||||
|
.signing/
|
||||||
# User-specific configurations
|
|
||||||
.idea/libraries/
|
# User-specific configurations
|
||||||
.idea/workspace.xml
|
.idea/libraries/
|
||||||
.idea/tasks.xml
|
.idea/workspace.xml
|
||||||
.idea/.name
|
.idea/tasks.xml
|
||||||
.idea/compiler.xml
|
.idea/.name
|
||||||
.idea/copyright/profiles_settings.xml
|
.idea/compiler.xml
|
||||||
.idea/encodings.xml
|
.idea/copyright/profiles_settings.xml
|
||||||
.idea/misc.xml
|
.idea/encodings.xml
|
||||||
.idea/modules.xml
|
.idea/misc.xml
|
||||||
.idea/scopes/scope_settings.xml
|
.idea/modules.xml
|
||||||
.idea/vcs.xml
|
.idea/scopes/scope_settings.xml
|
||||||
*.iml
|
.idea/vcs.xml
|
||||||
|
*.iml
|
||||||
# OS-specific files
|
|
||||||
.DS_Store
|
# OS-specific files
|
||||||
.DS_Store?
|
.DS_Store
|
||||||
._*
|
.DS_Store?
|
||||||
.Spotlight-V100
|
._*
|
||||||
.Trashes
|
.Spotlight-V100
|
||||||
ehthumbs.db
|
.Trashes
|
||||||
Thumbs.db
|
ehthumbs.db
|
||||||
*~
|
Thumbs.db
|
||||||
|
*~
|
||||||
#*#
|
#*#
|
9
.gitlab-ci.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
image: fdroidbuild:latest
|
||||||
|
|
||||||
|
build-apk:
|
||||||
|
script:
|
||||||
|
- fdroid build
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- unsigned/*.apk
|
||||||
|
- unsigned/*.tar.gz
|
174
.idea/codeStyleSettings.xml
generated
@ -1,174 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectCodeStyleSettingsManager">
|
|
||||||
<option name="PER_PROJECT_SETTINGS">
|
|
||||||
<value>
|
|
||||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
|
|
||||||
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
|
|
||||||
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
|
|
||||||
<value />
|
|
||||||
</option>
|
|
||||||
<option name="IMPORT_LAYOUT_TABLE">
|
|
||||||
<value>
|
|
||||||
<package name="android" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="com" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="junit" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="net" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="org" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="java" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="javax" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="" withSubpackages="true" static="true" />
|
|
||||||
<emptyLine />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="RIGHT_MARGIN" value="100" />
|
|
||||||
<AndroidXmlCodeStyleSettings>
|
|
||||||
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
|
||||||
</AndroidXmlCodeStyleSettings>
|
|
||||||
<XML>
|
|
||||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
|
||||||
</XML>
|
|
||||||
<codeStyleSettings language="XML">
|
|
||||||
<option name="FORCE_REARRANGE_MODE" value="1" />
|
|
||||||
<indentOptions>
|
|
||||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
|
||||||
</indentOptions>
|
|
||||||
<arrangement>
|
|
||||||
<rules>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>xmlns:android</NAME>
|
|
||||||
<XML_NAMESPACE>Namespace:</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>xmlns:.*</NAME>
|
|
||||||
<XML_NAMESPACE>Namespace:</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:id</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:name</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>name</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>style</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:layout_width</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:layout_height</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:layout_.*</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:width</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:height</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</rules>
|
|
||||||
</arrangement>
|
|
||||||
</codeStyleSettings>
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
|
|
9
.idea/copyright/Copyright_Vlad_Mihalachi.xml
generated
@ -1,9 +0,0 @@
|
|||||||
<component name="CopyrightManager">
|
|
||||||
<copyright>
|
|
||||||
<option name="notice" value="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 <http://www.gnu.org/licenses/>." />
|
|
||||||
<option name="keyword" value="Copyright" />
|
|
||||||
<option name="allowReplaceKeyword" value="Copyright" />
|
|
||||||
<option name="myName" value="Copyright Vlad Mihalachi" />
|
|
||||||
<option name="myLocal" value="true" />
|
|
||||||
</copyright>
|
|
||||||
</component>
|
|
8
.idea/gradle.xml
generated
@ -3,8 +3,9 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="LOCAL" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleHome" value="C:\Android\android-studio\gradle\gradle-2.10" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
@ -12,12 +13,11 @@
|
|||||||
<option value="$PROJECT_DIR$/app-pro" />
|
<option value="$PROJECT_DIR$/app-pro" />
|
||||||
<option value="$PROJECT_DIR$/libraries" />
|
<option value="$PROJECT_DIR$/libraries" />
|
||||||
<option value="$PROJECT_DIR$/libraries/FloatingActionButton" />
|
<option value="$PROJECT_DIR$/libraries/FloatingActionButton" />
|
||||||
<option value="$PROJECT_DIR$/libraries/RootCommands" />
|
|
||||||
<option value="$PROJECT_DIR$/libraries/sharedCode" />
|
<option value="$PROJECT_DIR$/libraries/sharedCode" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
14
.idea/inspectionProfiles/Project_Default.xml
generated
@ -1,14 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<profile version="1.0" is_locked="false">
|
|
||||||
<option name="myName" value="Project Default" />
|
|
||||||
<option name="myLocal" value="false" />
|
|
||||||
<inspection_tool class="AndroidLintMissingQuantity" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="AndroidLintMissingTranslation" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="AndroidLintNewApi" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="AndroidLintUnusedQuantity" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
|
|
||||||
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
|
|
||||||
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
|
|
||||||
</inspection_tool>
|
|
||||||
</profile>
|
|
||||||
</component>
|
|
7
.idea/inspectionProfiles/profiles_settings.xml
generated
@ -1,7 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<settings>
|
|
||||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
|
||||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
|
||||||
<version value="1.0" />
|
|
||||||
</settings>
|
|
||||||
</component>
|
|
74
README.md
@ -1,60 +1,14 @@
|
|||||||
# Turbo Editor
|
# Text Editor 8000
|
||||||
[](https://crowdin.com/project/turbo-client)
|
Text editor for Android. Forked from [Turbo Editor](https://github.com/vmihalachi/turbo-editor) by Vlad Mihalachi.
|
||||||
|
|
||||||
Simple, powerful and Open Source text editor for Android licensed under the GPLv3 license.
|
Currently this fork includes a fix for hardware keyboards, as well as an updated [CommonMark](http://commonmark.org/) Markdown renderer.
|
||||||
|
|
||||||
### Download
|
## Notice
|
||||||
[](http://play.google.com/store/apps/details?id=com.maskyn.fileeditorpro)
|
This project undergoes sporadic bursts of activity. There's no timeframe for a release, and stuff gets worked on when it gets worked on.
|
||||||
|
|
||||||
[](https://f-droid.org/repository/browse/?fdid=com.maskyn.fileeditorpro)
|
The general policy is that master is always buildable and should run fine, but there's no guarantees.
|
||||||
|
|
||||||
### Contribute
|
Also, [build artifacts](https://gitlab.monarch-pass.net/malacoda/text-editor-8000/-/jobs/artifacts/master/download?job=build-apk) from master are available on the Monarch Pass GitLab. Note that as of now these builds are not signed so you'll need to sign them yourself before installing them. Use at your own risk!
|
||||||
You can contribute to this project in many ways:
|
|
||||||
* Browse our issues, comment on proposals, report bugs.
|
## License
|
||||||
* Help to translate the application on [Crowdin][crowdin]
|
GNU General Public License version 3, see [LICENSE](./license).
|
||||||
* Be a part of the Google Plus [Community][community googleplus]
|
|
||||||
* Discuss with us on [XDA thread][xda thread]
|
|
||||||
* Help to maintain this project active and [Donate][donate]
|
|
||||||
|
|
||||||
------
|
|
||||||
|
|
||||||
###Donate
|
|
||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=26VWS2TSAMUJA)
|
|
||||||
|
|
||||||
[](https://flattr.com/submit/auto?user_id=vmihalachi&url=https://github.com/vmihalachi/turbo-editor&title=Turbo Editor&language=java&tags=github&category=software)
|
|
||||||
|
|
||||||
------
|
|
||||||
|
|
||||||
###Images
|
|
||||||

|
|
||||||
------
|
|
||||||
|
|
||||||
### Developer
|
|
||||||
[Vlad Mihalachi][developer site]
|
|
||||||
|
|
||||||
------
|
|
||||||
|
|
||||||
### A special thanks to..
|
|
||||||
* [Dumitru Grubii][contributor dumitru grubii] for the icon
|
|
||||||
* All the translators
|
|
||||||
* You?
|
|
||||||
|
|
||||||
------
|
|
||||||
|
|
||||||
### License
|
|
||||||
Turbo Client is made available under the terms of the [GPLv3][gplv3].
|
|
||||||
|
|
||||||
See the [LICENSE][license] file that accompanies this distribution for the full text of the license.
|
|
||||||
|
|
||||||
[gplv3]: http://www.gnu.org/licenses/gpl.html
|
|
||||||
[license]: https://github.com/vmihalachi/turbo-editor/LICENSE
|
|
||||||
[donate]: https://github.com/vmihalachi/turbo-editor#donate
|
|
||||||
[donate paypal]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PUQXSX6MTXHZ2
|
|
||||||
[xda thread]: http://forum.xda-developers.com/android/apps-games/app-turbo-editor-text-editor-t2832016
|
|
||||||
[community googleplus]: https://plus.google.com/u/0/communities/111974095419108178946
|
|
||||||
[crowdin]: https://crowdin.net/project/turbo-client
|
|
||||||
[developer site]: http://vmihalachi.com/
|
|
||||||
[crowdin]: https://crowdin.net/project/turbo-client
|
|
||||||
[contributor dumitru grubii]: https://twitter.com/DumitruGrubii
|
|
||||||
[project issues]: https://github.com/vmihalachi/turbo-editor/issues
|
|
||||||
[project wiki]: https://github.com/vmihalachi/turbo-editor/wiki
|
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 20
|
|
||||||
buildToolsVersion '20.0.0'
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "com.maskyn.fileeditorpro"
|
|
||||||
minSdkVersion 11
|
|
||||||
targetSdkVersion 19
|
|
||||||
versionCode 29
|
|
||||||
versionName "1.12"
|
|
||||||
}
|
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
|
||||||
}
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
runProguard false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lintOptions {
|
|
||||||
abortOnError false
|
|
||||||
}
|
|
||||||
packagingOptions {
|
|
||||||
exclude 'META-INF/LICENSE.txt'
|
|
||||||
exclude 'META-INF/NOTICE.txt'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
|
||||||
compile project(':libraries:sharedCode')
|
|
||||||
}
|
|
17
app-pro/proguard-rules.pro
vendored
@ -1,17 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# By default, the flags in this file are appended to flags specified
|
|
||||||
# in C:/Users/Vlad/AppData/Local/Android/android-sdk/tools/proguard/proguard-android.txt
|
|
||||||
# You can edit the include path and order by changing the proguardFiles
|
|
||||||
# directive in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
@ -1,120 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ 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 <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="com.maskyn.fileeditorpro"
|
|
||||||
android:installLocation="auto">
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
|
|
||||||
|
|
||||||
<supports-screens
|
|
||||||
android:anyDensity="true"
|
|
||||||
android:largeScreens="true"
|
|
||||||
android:normalScreens="true"
|
|
||||||
android:resizeable="true"
|
|
||||||
android:smallScreens="true"
|
|
||||||
android:xlargeScreens="true" />
|
|
||||||
|
|
||||||
<application
|
|
||||||
android:allowBackup="true"
|
|
||||||
android:icon="@drawable/ic_launcher"
|
|
||||||
android:label="@string/nome_app_turbo_editor"
|
|
||||||
android:hardwareAccelerated="true"
|
|
||||||
android:largeHeap="true"
|
|
||||||
android:supportsRtl="true"
|
|
||||||
android:name="sharedcode.turboeditor.activity.MyApp"
|
|
||||||
>
|
|
||||||
|
|
||||||
<!-- android:alwaysRetainTaskState="true" -->
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".HomeActivity"
|
|
||||||
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
|
|
||||||
android:launchMode="singleTop"
|
|
||||||
android:windowSoftInputMode="stateUnspecified|adjustResize"
|
|
||||||
android:theme="@style/AppThemeEditorDark">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
<action android:name="android.intent.action.EDIT" />
|
|
||||||
<action android:name="android.intent.action.PICK" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
|
|
||||||
<data android:scheme="file" />
|
|
||||||
<data android:mimeType="text/*" />
|
|
||||||
<data android:pathPattern="*.txt" />
|
|
||||||
<data android:pathPattern="*.html" />
|
|
||||||
<data android:pathPattern="*.css" />
|
|
||||||
<data android:pathPattern="*.js" />
|
|
||||||
<data android:pathPattern="*.md"/>
|
|
||||||
<data android:pathPattern="*.php" />
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SEND" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="text/plain" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:name="sharedcode.turboeditor.activity.SelectFileActivity"
|
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
|
||||||
android:label="@string/open_a_file"
|
|
||||||
android:parentActivityName=".HomeActivity"
|
|
||||||
android:theme="@style/AppThemeBaseLight">
|
|
||||||
<meta-data
|
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
|
||||||
android:value=".HomeActivity" />
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name="sharedcode.turboeditor.preferences.ExtraSettingsActivity"
|
|
||||||
android:label="@string/extra_options"
|
|
||||||
android:parentActivityName=".HomeActivity">
|
|
||||||
<meta-data
|
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
|
||||||
android:value=".HomeActivity" />
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<meta-data
|
|
||||||
android:name="com.sec.android.support.multiwindow"
|
|
||||||
android:value="true" />
|
|
||||||
<meta-data
|
|
||||||
android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W"
|
|
||||||
android:value="632.0dip" />
|
|
||||||
<meta-data
|
|
||||||
android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H"
|
|
||||||
android:value="598.0dip" />
|
|
||||||
<meta-data
|
|
||||||
android:name="com.sec.android.multiwindow.MINIMUM_SIZE_W"
|
|
||||||
android:value="632.0dip" />
|
|
||||||
<meta-data
|
|
||||||
android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H"
|
|
||||||
android:value="598.0dip" />
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
|
3
app/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
/build
|
/build
|
||||||
|
manifest-merger-release-report.txt
|
||||||
|
162
app/build.gradle
@ -1,74 +1,88 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2016 Adrian Malacoda
|
||||||
*
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
* This file is part of Turbo Editor.
|
*
|
||||||
*
|
* This file is part of Text Editor 8000.
|
||||||
* 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
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* it under the terms of the GNU General Public License as published by
|
||||||
* (at your option) any later version.
|
* 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
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* GNU General Public License for more details.
|
* 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 <http://www.gnu.org/licenses/>.
|
* You should have received a copy of the GNU General Public License
|
||||||
*/
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
buildscript {
|
|
||||||
repositories {
|
import java.util.regex.Pattern
|
||||||
maven { url 'http://download.crashlytics.com/maven' }
|
|
||||||
}
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
dependencies {
|
android {
|
||||||
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
|
lintOptions {
|
||||||
}
|
disable 'MissingTranslation', 'ExtraTranslation'
|
||||||
|
}
|
||||||
}
|
|
||||||
|
compileSdkVersion 22
|
||||||
apply plugin: 'com.android.application'
|
buildToolsVersion '22.0.1'
|
||||||
apply plugin: 'crashlytics'
|
|
||||||
|
defaultConfig {
|
||||||
repositories {
|
applicationId "net.monarchpass.android.texteditor8000"
|
||||||
maven { url 'http://download.crashlytics.com/maven' }
|
minSdkVersion 15
|
||||||
}
|
targetSdkVersion 22
|
||||||
|
versionCode 48
|
||||||
|
versionName "1.20"
|
||||||
|
}
|
||||||
android {
|
|
||||||
compileSdkVersion 20
|
compileOptions {
|
||||||
buildToolsVersion '20.0.0'
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
defaultConfig {
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
applicationId "com.maskyn.fileeditor"
|
}
|
||||||
minSdkVersion 11
|
buildTypes {
|
||||||
targetSdkVersion 19
|
release {
|
||||||
versionCode 30
|
minifyEnabled false
|
||||||
versionName "1.13"
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
compileOptions {
|
}
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
lintOptions {
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
abortOnError false
|
||||||
}
|
}
|
||||||
buildTypes {
|
packagingOptions {
|
||||||
release {
|
exclude 'META-INF/LICENSE.txt'
|
||||||
runProguard false
|
exclude 'META-INF/NOTICE.txt'
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
lintOptions {
|
dependencies {
|
||||||
abortOnError false
|
compile 'com.github.topjohnwu:libsu:1.2.0'
|
||||||
}
|
compile project(':libraries:FloatingActionButton')
|
||||||
packagingOptions {
|
compile 'org.apache.commons:commons-lang3:+'
|
||||||
exclude 'META-INF/LICENSE.txt'
|
compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3'
|
||||||
exclude 'META-INF/NOTICE.txt'
|
compile('com.android.support:appcompat-v7:22.+') {
|
||||||
}
|
exclude group: 'com.android.support', module: 'support-v4'
|
||||||
}
|
}
|
||||||
|
compile 'com.android.support:support-v4:22.+'
|
||||||
dependencies {
|
compile 'com.github.gabrielemariotti.changeloglib:library:+'
|
||||||
compile fileTree(dir: 'libs', include: '*.jar')
|
compile 'commons-io:commons-io:2.4'
|
||||||
compile project(':libraries:sharedCode')
|
compile 'com.android.support:support-annotations:+'
|
||||||
compile 'com.google.android.gms:play-services:5.0.89'
|
compile 'com.atlassian.commonmark:commonmark:0.11.0'
|
||||||
compile 'com.crashlytics.android:crashlytics:1.+'
|
}
|
||||||
}
|
|
||||||
|
task incrementVersionCode << {
|
||||||
|
println(":incrementVersionCode - Incrementing Version Code...")
|
||||||
|
def buildGradleFile = file("build.gradle")
|
||||||
|
def patternVersionCode = Pattern.compile("versionCode (\\d+)")
|
||||||
|
def buildGradleFileText = buildGradleFile.getText()
|
||||||
|
def matcherVersionCode = patternVersionCode.matcher(buildGradleFileText)
|
||||||
|
matcherVersionCode.find()
|
||||||
|
def mVersionCode = Integer.parseInt(matcherVersionCode.group(1))
|
||||||
|
def mNextVersionCode = mVersionCode + 1
|
||||||
|
def manifestContent = matcherVersionCode.replaceAll("versionCode " + mNextVersionCode)
|
||||||
|
println(":incrementVersionCode - current versionCode=" + mVersionCode);
|
||||||
|
println(":incrementVersionCode - next versionCode=" + mNextVersionCode);
|
||||||
|
buildGradleFile.write(manifestContent)
|
||||||
|
}
|
||||||
|
0
app/private/cache/retriever/catalog.xml
vendored
Normal file
34
app/proguard-rules.pro
vendored
@ -1,17 +1,17 @@
|
|||||||
# Add project specific ProGuard rules here.
|
# Add project specific ProGuard rules here.
|
||||||
# By default, the flags in this file are appended to flags specified
|
# By default, the flags in this file are appended to flags specified
|
||||||
# in C:\Users\Vlad\AppData\Local\Android\android-sdk/tools/proguard/proguard-android.txt
|
# in C:/Users/Vlad/AppData/Local/Android/android-sdk/tools/proguard/proguard-android.txt
|
||||||
# You can edit the include path and order by changing the proguardFiles
|
# You can edit the include path and order by changing the proguardFiles
|
||||||
# directive in build.gradle.
|
# directive in build.gradle.
|
||||||
#
|
#
|
||||||
# For more details, see
|
# For more details, see
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
# Add any project specific keep options here:
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
# If your project uses WebView with JS, uncomment the following
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
# class:
|
# class:
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
# public *;
|
# public *;
|
||||||
#}
|
#}
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.maskyn.fileeditorpro;
|
package com.maskyn.fileeditorpro;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.test.ApplicationTestCase;
|
import android.test.ApplicationTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||||
*/
|
*/
|
||||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||||
public ApplicationTest() {
|
public ApplicationTest() {
|
||||||
super(Application.class);
|
super(Application.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,129 +1,162 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<!--
|
||||||
<!--
|
~ Copyright (C) 2014 Vlad Mihalachi
|
||||||
~ Copyright (C) 2014 Vlad Mihalachi
|
~
|
||||||
~
|
~ This file is part of Text Editor 8000.
|
||||||
~ This file is part of Turbo Editor.
|
~
|
||||||
~
|
~ Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
~ 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
|
||||||
~ it under the terms of the GNU General Public License as published by
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
~ the Free Software Foundation, either version 3 of the License, or
|
~ (at your option) any later version.
|
||||||
~ (at your option) any later version.
|
~
|
||||||
~
|
~ Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
~ Turbo Editor is distributed in the hope that it will be useful,
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
~ GNU General Public License for more details.
|
||||||
~ GNU General Public License for more details.
|
~
|
||||||
~
|
~ You should have received a copy of the GNU General Public License
|
||||||
~ You should have received a copy of the GNU General Public License
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-->
|
||||||
-->
|
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
package="com.maskyn.fileeditorpro"
|
||||||
package="com.maskyn.fileeditor"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:installLocation="auto">
|
android:installLocation="auto">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<supports-screens
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
android:anyDensity="true"
|
||||||
<uses-permission android:name="com.android.vending.BILLING" />
|
android:largeScreens="true"
|
||||||
|
android:normalScreens="true"
|
||||||
<supports-screens
|
android:resizeable="true"
|
||||||
android:anyDensity="true"
|
android:smallScreens="true"
|
||||||
android:largeScreens="true"
|
android:xlargeScreens="true" />
|
||||||
android:normalScreens="true"
|
|
||||||
android:resizeable="true"
|
<application
|
||||||
android:smallScreens="true"
|
android:allowBackup="true"
|
||||||
android:xlargeScreens="true" />
|
android:icon="@drawable/ic_launcher"
|
||||||
|
android:label="@string/nome_app_turbo_editor"
|
||||||
<application
|
android:hardwareAccelerated="true"
|
||||||
android:allowBackup="true"
|
android:largeHeap="true"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:supportsRtl="true"
|
||||||
android:label="@string/nome_app_turbo_editor"
|
android:name="com.maskyn.fileeditorpro.application.MyApp"
|
||||||
android:hardwareAccelerated="true"
|
tools:replace="android:label"
|
||||||
android:largeHeap="true"
|
>
|
||||||
android:supportsRtl="true"
|
|
||||||
android:name="sharedcode.turboeditor.activity.MyApp"
|
<!-- android:alwaysRetainTaskState="true" -->
|
||||||
>
|
|
||||||
|
<activity
|
||||||
<!-- android:alwaysRetainTaskState="true" -->
|
android:name=".HomeActivity"
|
||||||
|
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
|
||||||
<meta-data android:name="com.google.android.gms.version"
|
android:launchMode="singleTop"
|
||||||
android:value="@integer/google_play_services_version"/>
|
android:windowSoftInputMode="stateUnspecified|adjustResize"
|
||||||
<activity
|
android:theme="@style/AppThemeEditorDark">
|
||||||
android:name=".HomeActivity"
|
<intent-filter>
|
||||||
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
|
<action android:name="android.intent.action.MAIN" />
|
||||||
android:launchMode="singleTop"
|
|
||||||
android:windowSoftInputMode="stateUnspecified|adjustResize"
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
android:theme="@style/AppThemeEditorDark">
|
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
|
||||||
<intent-filter>
|
</intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<data android:scheme="file" />
|
||||||
<action android:name="android.intent.action.EDIT" />
|
<data android:mimeType="*/*" />
|
||||||
<action android:name="android.intent.action.PICK" />
|
<data android:host="*" />
|
||||||
|
<data android:pathPattern=".*\\.txt" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<data android:pathPattern=".*\\.html" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<data android:pathPattern=".*\\.xml" />
|
||||||
|
<data android:pathPattern=".*\\.css" />
|
||||||
<data android:scheme="file" />
|
<data android:pathPattern=".*\\.js" />
|
||||||
<data android:mimeType="text/*" />
|
<data android:pathPattern=".*\\.md"/>
|
||||||
<data android:pathPattern="*.txt" />
|
<data android:pathPattern=".*\\.markdown"/>
|
||||||
<data android:pathPattern="*.html" />
|
<data android:pathPattern=".*\\.php" />
|
||||||
<data android:pathPattern="*.css" />
|
<data android:pathPattern=".*\\.py" />
|
||||||
<data android:pathPattern="*.js" />
|
<data android:pathPattern=".*\\.script" />
|
||||||
<data android:pathPattern="*.md"/>
|
<data android:pathPattern=".*\\.cs" />
|
||||||
<data android:pathPattern="*.php" />
|
<data android:pathPattern=".*\\.java" />
|
||||||
</intent-filter>
|
<data android:pathPattern=".*\\.rb" />
|
||||||
<intent-filter>
|
<data android:pathPattern=".*\\.aspx" />
|
||||||
<action android:name="android.intent.action.SEND" />
|
<data android:pathPattern=".*\\.cshtml" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<data android:pathPattern=".*\\.vbhtml" />
|
||||||
<data android:mimeType="text/plain" />
|
<data android:pathPattern=".*\\.go" />
|
||||||
</intent-filter>
|
<data android:pathPattern=".*\\.c" />
|
||||||
</activity>
|
<data android:pathPattern=".*\\.h" />
|
||||||
<activity
|
<data android:pathPattern=".*\\.cc" />
|
||||||
android:name="sharedcode.turboeditor.activity.SelectFileActivity"
|
<data android:pathPattern=".*\\.cpp" />
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
<data android:pathPattern=".*\\.hh" />
|
||||||
android:label="@string/open_a_file"
|
<data android:pathPattern=".*\\.hpp" />
|
||||||
android:parentActivityName=".HomeActivity"
|
<data android:pathPattern=".*\\.pl" />
|
||||||
android:theme="@style/AppThemeBaseLight">
|
<data android:pathPattern=".*\\.pm" />
|
||||||
<meta-data
|
<data android:pathPattern=".*\\.t" />
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
<data android:pathPattern=".*\\.pod" />
|
||||||
android:value=".HomeActivity" />
|
<data android:pathPattern=".*\\.m" />
|
||||||
</activity>
|
<data android:pathPattern=".*\\.f" />
|
||||||
|
<data android:pathPattern=".*\\.for" />
|
||||||
<activity
|
<data android:pathPattern=".*\\.f90" />
|
||||||
android:name="sharedcode.turboeditor.preferences.ExtraSettingsActivity"
|
<data android:pathPattern=".*\\.f95" />
|
||||||
android:label="@string/extra_options"
|
<data android:pathPattern=".*\\.asp" />
|
||||||
android:parentActivityName=".HomeActivity">
|
<data android:pathPattern=".*\\.json" />
|
||||||
<meta-data
|
<data android:pathPattern=".*\\.wiki" />
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
<data android:pathPattern=".*\\.lua" />
|
||||||
android:value=".HomeActivity" />
|
<data android:pathPattern=".*\\.r" />
|
||||||
</activity>
|
<data android:pathPattern=".*\\.key" />
|
||||||
|
<data android:pathPattern=".*\\.log" />
|
||||||
<meta-data
|
</intent-filter>
|
||||||
android:name="com.sec.android.support.multiwindow"
|
<intent-filter >
|
||||||
android:value="true" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<meta-data
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W"
|
<data android:scheme="file" />
|
||||||
android:value="632.0dip" />
|
<data android:mimeType="text/*" />
|
||||||
<meta-data
|
</intent-filter>
|
||||||
android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H"
|
<intent-filter>
|
||||||
android:value="598.0dip" />
|
<action android:name="android.intent.action.SEND" />
|
||||||
<meta-data
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
android:name="com.sec.android.multiwindow.MINIMUM_SIZE_W"
|
<data android:mimeType="text/plain" />
|
||||||
android:value="632.0dip" />
|
</intent-filter>
|
||||||
<meta-data
|
</activity>
|
||||||
android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H"
|
<activity
|
||||||
android:value="598.0dip" />
|
android:name="com.maskyn.fileeditorpro.activity.SelectFileActivity"
|
||||||
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
<activity android:name="com.google.android.gms.ads.AdActivity"
|
android:label="@string/open_a_file"
|
||||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
android:exported="true"
|
||||||
<meta-data android:name="com.crashlytics.ApiKey" android:value="672ab7531ce1e2e83c2ec6d84e8e94f2fa692c2a"/>
|
android:parentActivityName=".HomeActivity"
|
||||||
</application>
|
android:theme="@style/AppThemeBaseLight">
|
||||||
|
<meta-data
|
||||||
</manifest>
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".HomeActivity" />
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.GET_CONTENT" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.OPENABLE" />
|
||||||
|
|
||||||
|
<data android:mimeType="*/*" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="com.sec.android.support.multiwindow"
|
||||||
|
android:value="true" />
|
||||||
|
<meta-data
|
||||||
|
android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W"
|
||||||
|
android:value="632.0dip" />
|
||||||
|
<meta-data
|
||||||
|
android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H"
|
||||||
|
android:value="598.0dip" />
|
||||||
|
<meta-data
|
||||||
|
android:name="com.sec.android.multiwindow.MINIMUM_SIZE_W"
|
||||||
|
android:value="632.0dip" />
|
||||||
|
<meta-data
|
||||||
|
android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H"
|
||||||
|
android:value="598.0dip" />
|
||||||
|
|
||||||
|
<activity android:name="com.maskyn.fileeditorpro.activity.MarkdownActivity" />
|
||||||
|
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
|
112
app/src/main/assets/classic_theme_markdown.css
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
@charset "utf-8";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* markdown.css
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||||
|
* later version.
|
||||||
|
*
|
||||||
|
* This program 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 Lesser General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see http://gnu.org/licenses/lgpl.txt.
|
||||||
|
*
|
||||||
|
* @project Weblog and Open Source Projects of Florian Wolters
|
||||||
|
* @version GIT: $Id$
|
||||||
|
* @package xhtml-css
|
||||||
|
* @author Florian Wolters <florian.wolters.85@googlemail.com>
|
||||||
|
* @copyright 2012 Florian Wolters
|
||||||
|
* @cssdoc version 1.0-pre
|
||||||
|
* @license http://gnu.org/licenses/lgpl.txt GNU Lesser General Public License
|
||||||
|
* @link http://github.com/FlorianWolters/jekyll-bootstrap-theme
|
||||||
|
* @media all
|
||||||
|
* @valid true
|
||||||
|
*/
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: Helvetica, Arial, Freesans, clean, sans-serif;
|
||||||
|
padding:1em;
|
||||||
|
margin:auto;
|
||||||
|
max-width:42em;
|
||||||
|
background:#fefefe;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #000000;
|
||||||
|
font-size: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
border-bottom: 1px solid #CCCCCC;
|
||||||
|
color: #000000;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4 {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h5 {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h6 {
|
||||||
|
color: #777777;
|
||||||
|
background-color: inherit;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
height: 0.2em;
|
||||||
|
border: 0;
|
||||||
|
color: #CCCCCC;
|
||||||
|
background-color: #CCCCCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
p, blockquote, ul, ol, dl, li, table, pre {
|
||||||
|
margin: 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
code, pre {
|
||||||
|
border-radius: 3px;
|
||||||
|
background-color: #F8F8F8;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
border: 1px solid #EAEAEA;
|
||||||
|
margin: 0 2px;
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
border: 1px solid #CCCCCC;
|
||||||
|
line-height: 1.25em;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 6px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre > code {
|
||||||
|
border: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a, a:visited {
|
||||||
|
color: #4183C4;
|
||||||
|
background-color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.maskyn.fileeditor;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import com.google.android.gms.ads.AdRequest;
|
|
||||||
import com.google.android.gms.ads.InterstitialAd;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
import sharedcode.turboeditor.preferences.PreferenceHelper;
|
|
||||||
|
|
||||||
public class AdsHelper {
|
|
||||||
private InterstitialAd interstitial;
|
|
||||||
|
|
||||||
public AdsHelper(Activity activity) {
|
|
||||||
|
|
||||||
interstitial = new InterstitialAd(activity);
|
|
||||||
interstitial.setAdUnitId("ca-app-pub-5679083452234719/7178038180");
|
|
||||||
|
|
||||||
// Create ad request.
|
|
||||||
AdRequest adRequest = new AdRequest.Builder().build();
|
|
||||||
|
|
||||||
// Begin loading your interstitial.
|
|
||||||
interstitial.loadAd(adRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void displayInterstitial() {
|
|
||||||
interstitial.show();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.maskyn.fileeditor;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import com.crashlytics.android.Crashlytics;
|
|
||||||
|
|
||||||
import sharedcode.turboeditor.activity.BaseHomeActivity;
|
|
||||||
import sharedcode.turboeditor.preferences.PreferenceHelper;
|
|
||||||
import sharedcode.turboeditor.util.ProCheckUtils;
|
|
||||||
|
|
||||||
public class HomeActivity extends BaseHomeActivity {
|
|
||||||
|
|
||||||
private AdsHelper adsHelper;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
if(PreferenceHelper.getSendErrorReports(this))
|
|
||||||
Crashlytics.start(this);
|
|
||||||
// setup the ads
|
|
||||||
if(!ProCheckUtils.isPro(this))
|
|
||||||
adsHelper = new AdsHelper(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void displayInterstitial() {
|
|
||||||
if(adsHelper != null && !ProCheckUtils.isPro(this))
|
|
||||||
adsHelper.displayInterstitial();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +1,31 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.maskyn.fileeditorpro;
|
package com.maskyn.fileeditorpro;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import com.maskyn.fileeditorpro.activity.MainActivity;
|
||||||
|
|
||||||
import sharedcode.turboeditor.activity.BaseHomeActivity;
|
public class HomeActivity extends MainActivity {
|
||||||
|
|
||||||
public class HomeActivity extends BaseHomeActivity {
|
@Override
|
||||||
|
public boolean showInterstitial() {
|
||||||
@Override
|
// nothing to do here
|
||||||
public void displayInterstitial() {
|
return false;
|
||||||
// nothing to do here
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
* Copyright (C) 2018 Adrian Malacoda
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.activity;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
|
||||||
|
import org.commonmark.node.Node;
|
||||||
|
import org.commonmark.parser.Parser;
|
||||||
|
import org.commonmark.renderer.html.HtmlRenderer;
|
||||||
|
|
||||||
|
public class MarkdownActivity extends Activity {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
MarkdownView webView = new MarkdownView(this);
|
||||||
|
setContentView(webView);
|
||||||
|
webView.loadMarkdown(getIntent().getStringExtra("text"), "file:///android_asset/classic_theme_markdown.css");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class MarkdownView extends WebView {
|
||||||
|
private static final String CSS_LINK = "<link rel='stylesheet' type='text/css' href='%s'>";
|
||||||
|
private final Parser parser;
|
||||||
|
private final HtmlRenderer renderer;
|
||||||
|
|
||||||
|
MarkdownView (Context context) {
|
||||||
|
super(context);
|
||||||
|
parser = Parser.builder().build();
|
||||||
|
renderer = HtmlRenderer.builder().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadMarkdown(String content, String cssUri) {
|
||||||
|
String html = String.format(CSS_LINK, cssUri);
|
||||||
|
html = html += renderer.render(parser.parse(content));
|
||||||
|
loadDataWithBaseURL(null, html, "text/html", null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,468 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.activity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.view.MenuItemCompat;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.support.v7.widget.SearchView;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.Filter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.PopupMenu;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.faizmalkani.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.topjohnwu.superuser.io.SuFile;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import com.maskyn.fileeditorpro.R;
|
||||||
|
import com.maskyn.fileeditorpro.adapter.AdapterDetailedList;
|
||||||
|
import com.maskyn.fileeditorpro.dialogfragment.EditTextDialog;
|
||||||
|
import com.maskyn.fileeditorpro.preferences.PreferenceHelper;
|
||||||
|
import com.maskyn.fileeditorpro.util.AlphanumComparator;
|
||||||
|
import com.maskyn.fileeditorpro.util.Build;
|
||||||
|
import com.maskyn.fileeditorpro.util.ThemeUtils;
|
||||||
|
|
||||||
|
public class SelectFileActivity extends ActionBarActivity implements SearchView.OnQueryTextListener, AdapterView.OnItemClickListener, EditTextDialog.EditDialogListener {
|
||||||
|
private String currentFolder;
|
||||||
|
private ListView listView;
|
||||||
|
private boolean wantAFile = true;
|
||||||
|
private MenuItem mSearchViewMenuItem;
|
||||||
|
private SearchView mSearchView;
|
||||||
|
private Filter filter;
|
||||||
|
private int prevposition = 0;
|
||||||
|
private FloatingActionButton mFab;
|
||||||
|
private boolean mfabOkMode = false;
|
||||||
|
private File selectedFile;
|
||||||
|
private boolean folderOpenMode = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
currentFolder = PreferenceHelper.defaultFolder(this);
|
||||||
|
|
||||||
|
ThemeUtils.setTheme(this);
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_select_file);
|
||||||
|
|
||||||
|
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
//final Actions action = (Actions) getIntent().getExtras().getSerializable("action");
|
||||||
|
wantAFile = true; //action == Actions.SelectFile;
|
||||||
|
mfabOkMode = false;
|
||||||
|
folderOpenMode = getIntent().getBooleanExtra("foldermode", false);
|
||||||
|
if(folderOpenMode)
|
||||||
|
setTitle("Open Folder");
|
||||||
|
|
||||||
|
listView = (ListView) findViewById(android.R.id.list);
|
||||||
|
listView.setOnItemClickListener(this);
|
||||||
|
listView.setTextFilterEnabled(true);
|
||||||
|
|
||||||
|
mFab = (FloatingActionButton) findViewById(R.id.fabbutton);
|
||||||
|
mFab.setColor(getResources().getColor(R.color.fab_light));
|
||||||
|
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_fab_add));
|
||||||
|
|
||||||
|
mFab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (!mfabOkMode) {
|
||||||
|
PopupMenu popup = new PopupMenu(SelectFileActivity.this, v);
|
||||||
|
|
||||||
|
popup.getMenuInflater().inflate(R.menu.popup_new_file, popup.getMenu());
|
||||||
|
|
||||||
|
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
int i = item.getItemId();
|
||||||
|
if (i == R.id.im_new_file) {
|
||||||
|
EditTextDialog.newInstance(EditTextDialog.Actions.NewFile).show(getFragmentManager().beginTransaction(), "dialog");
|
||||||
|
return true;
|
||||||
|
} else if (i == R.id.im_new_folder) {
|
||||||
|
EditTextDialog.newInstance(EditTextDialog.Actions.NewFolder).show(getFragmentManager().beginTransaction(), "dialog");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
popup.show();
|
||||||
|
}
|
||||||
|
if (mfabOkMode) {
|
||||||
|
finishWithResult(selectedFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mFab.listenTo(listView);
|
||||||
|
|
||||||
|
String lastNavigatedPath = PreferenceHelper.getWorkingFolder(this);
|
||||||
|
|
||||||
|
File file = new File(lastNavigatedPath);
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
PreferenceHelper.setWorkingFolder(this, PreferenceHelper.defaultFolder(this));
|
||||||
|
file = new File(PreferenceHelper.defaultFolder(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
new UpdateList().execute(file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (currentFolder.isEmpty() || currentFolder.equals("/")) {
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
File file = new File(currentFolder);
|
||||||
|
String parentFolder = file.getParent();
|
||||||
|
new UpdateList().execute(parentFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onQueryTextChange(String newText) {
|
||||||
|
if (filter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(newText)) {
|
||||||
|
filter.filter(null);
|
||||||
|
} else {
|
||||||
|
filter.filter(newText);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onQueryTextSubmit(String query) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finish this Activity with a result code and URI of the selected file.
|
||||||
|
*
|
||||||
|
* @param file The file selected.
|
||||||
|
*/
|
||||||
|
private void finishWithResult(File file) {
|
||||||
|
if (file != null) {
|
||||||
|
Uri uri = Uri.fromFile(file);
|
||||||
|
//Toast.makeText(this, uri.toString(), Toast.LENGTH_SHORT).show();
|
||||||
|
setResult(RESULT_OK, new Intent().setData(uri));
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent,
|
||||||
|
View view, int position, long id) {
|
||||||
|
|
||||||
|
final String name = ((TextView) view.findViewById(android.R.id.text1)).getText().toString();
|
||||||
|
if (name.equals("..")) {
|
||||||
|
if (currentFolder.equals("/")) {
|
||||||
|
new UpdateList().execute(PreferenceHelper.getWorkingFolder(this));
|
||||||
|
} else {
|
||||||
|
File tempFile = new File(currentFolder);
|
||||||
|
if (tempFile.isFile()) {
|
||||||
|
tempFile = tempFile.getParentFile()
|
||||||
|
.getParentFile();
|
||||||
|
} else {
|
||||||
|
tempFile = tempFile.getParentFile();
|
||||||
|
|
||||||
|
}
|
||||||
|
new UpdateList().execute(tempFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
if (mfabOkMode) {
|
||||||
|
prevposition = 0;
|
||||||
|
mfabOkMode = false;
|
||||||
|
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_fab_add));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else if (name.equals(getString(R.string.home))) {
|
||||||
|
new UpdateList().execute(PreferenceHelper.getWorkingFolder(this));
|
||||||
|
Toast.makeText(this, "test", Toast.LENGTH_SHORT).show();
|
||||||
|
if (mfabOkMode) {
|
||||||
|
prevposition = 0;
|
||||||
|
mfabOkMode = false;
|
||||||
|
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_fab_add));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//final File selectedFile = new File(currentFolder, name);
|
||||||
|
selectedFile = new File(currentFolder, name);
|
||||||
|
|
||||||
|
if (!folderOpenMode) {
|
||||||
|
if (selectedFile.isFile() && wantAFile) {
|
||||||
|
if (prevposition == position)
|
||||||
|
finishWithResult(selectedFile);
|
||||||
|
else {
|
||||||
|
prevposition = position;
|
||||||
|
mfabOkMode = true;
|
||||||
|
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_fab_ok));
|
||||||
|
view.setSelected(true);
|
||||||
|
}
|
||||||
|
} 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) {
|
||||||
|
if (selectedFile.isDirectory()) {
|
||||||
|
if (prevposition == position) {
|
||||||
|
new UpdateList().execute(selectedFile.getAbsolutePath());
|
||||||
|
if (mfabOkMode) {
|
||||||
|
prevposition = 0;
|
||||||
|
mfabOkMode = false;
|
||||||
|
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_fab_add));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prevposition = position;
|
||||||
|
mfabOkMode = true;
|
||||||
|
mFab.setDrawable(getResources().getDrawable(R.drawable.ic_fab_ok));
|
||||||
|
view.setSelected(true);
|
||||||
|
}
|
||||||
|
} else if (selectedFile.isFile()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.activity_select_file, menu);
|
||||||
|
mSearchViewMenuItem = menu.findItem(R.id.im_search);
|
||||||
|
mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchViewMenuItem);
|
||||||
|
mSearchView.setIconifiedByDefault(true);
|
||||||
|
mSearchView.setOnQueryTextListener(this);
|
||||||
|
mSearchView.setSubmitButtonEnabled(false);
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
|
// menu items
|
||||||
|
MenuItem imSetAsWorkingFolder = menu.findItem(R.id.im_set_as_working_folder);
|
||||||
|
MenuItem imIsWorkingFolder = menu.findItem(R.id.im_is_working_folder);
|
||||||
|
MenuItem imSelectFolder = menu.findItem(R.id.im_select_folder);
|
||||||
|
if (imSetAsWorkingFolder != null) {
|
||||||
|
// set the imSetAsWorkingFolder visible only if the two folder dont concide
|
||||||
|
imSetAsWorkingFolder.setVisible(!currentFolder.equals(PreferenceHelper.getWorkingFolder(SelectFileActivity.this)));
|
||||||
|
}
|
||||||
|
if (imIsWorkingFolder != null) {
|
||||||
|
// set visible is the other is invisible
|
||||||
|
imIsWorkingFolder.setVisible(!imSetAsWorkingFolder.isVisible());
|
||||||
|
}
|
||||||
|
if (imSelectFolder != null) {
|
||||||
|
imSelectFolder.setVisible(!wantAFile);
|
||||||
|
}
|
||||||
|
return super.onPrepareOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
int i = item.getItemId();
|
||||||
|
if (i == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
} else if (i == R.id.im_set_as_working_folder) {
|
||||||
|
PreferenceHelper.setWorkingFolder(SelectFileActivity.this, currentFolder);
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
return true;
|
||||||
|
} else if (i == R.id.im_is_working_folder) {
|
||||||
|
Toast.makeText(getBaseContext(), R.string.is_the_working_folder, Toast.LENGTH_SHORT).show();
|
||||||
|
return true;
|
||||||
|
} else if (i == R.id.im_select_folder) {
|
||||||
|
finishWithResult(new File(currentFolder));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEdittextDialogEnded(final String inputText, final String hint, final EditTextDialog.Actions actions) {
|
||||||
|
if (actions == EditTextDialog.Actions.NewFile && !TextUtils.isEmpty(inputText)) {
|
||||||
|
File file = new File(currentFolder, inputText);
|
||||||
|
try {
|
||||||
|
file.createNewFile();
|
||||||
|
finishWithResult(file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Toast.makeText(SelectFileActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else if (actions == EditTextDialog.Actions.NewFolder && !TextUtils.isEmpty(inputText)) {
|
||||||
|
File file = new File(currentFolder, inputText);
|
||||||
|
file.mkdirs();
|
||||||
|
new UpdateList().execute(currentFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Actions {
|
||||||
|
SelectFile, SelectFolder
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UpdateList extends AsyncTask<String, Void, LinkedList<AdapterDetailedList.FileDetail>> {
|
||||||
|
|
||||||
|
String exceptionMessage;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
super.onPreExecute();
|
||||||
|
if (mSearchView != null) {
|
||||||
|
mSearchView.setIconified(true);
|
||||||
|
MenuItemCompat.collapseActionView(mSearchViewMenuItem);
|
||||||
|
mSearchView.setQuery("", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected LinkedList<AdapterDetailedList.FileDetail> doInBackground(final String... params) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
final String path = params[0];
|
||||||
|
if (TextUtils.isEmpty(path)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
File tempFolder = new File(path);
|
||||||
|
if (tempFolder.isFile()) {
|
||||||
|
tempFolder = tempFolder.getParentFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] unopenableExtensions = {"apk", "mp3", "mp4", "png", "jpg", "jpeg"};
|
||||||
|
|
||||||
|
final LinkedList<AdapterDetailedList.FileDetail> fileDetails = new LinkedList<>();
|
||||||
|
final LinkedList<AdapterDetailedList.FileDetail> folderDetails = new LinkedList<>();
|
||||||
|
currentFolder = tempFolder.getAbsolutePath();
|
||||||
|
|
||||||
|
if (!tempFolder.canRead()) {
|
||||||
|
SuFile folder = new SuFile(currentFolder);
|
||||||
|
SuFile[] files = folder.listFiles();
|
||||||
|
|
||||||
|
if (files != null) {
|
||||||
|
for (SuFile file : files) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
folderDetails.add(new AdapterDetailedList.FileDetail(file.getName(),
|
||||||
|
getString(R.string.folder),
|
||||||
|
""));
|
||||||
|
} else if (!FilenameUtils.isExtension(file.getName().toLowerCase(), unopenableExtensions)
|
||||||
|
&& file.length() <= Build.MAX_FILE_SIZE * FileUtils.ONE_KB) {
|
||||||
|
final long fileSize = file.length();
|
||||||
|
//SimpleDateFormat format = new SimpleDateFormat("MMM dd, yyyy hh:mm a");
|
||||||
|
//String date = format.format("");
|
||||||
|
fileDetails.add(new AdapterDetailedList.FileDetail(file.getName(),
|
||||||
|
FileUtils.byteCountToDisplaySize(fileSize), ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
File[] files = tempFolder.listFiles();
|
||||||
|
|
||||||
|
Arrays.sort(files, getFileNameComparator());
|
||||||
|
|
||||||
|
if (files != null) {
|
||||||
|
for (final File f : files) {
|
||||||
|
if (f.isDirectory()) {
|
||||||
|
folderDetails.add(new AdapterDetailedList.FileDetail(f.getName(),
|
||||||
|
getString(R.string.folder),
|
||||||
|
""));
|
||||||
|
} else if (f.isFile()
|
||||||
|
&& !FilenameUtils.isExtension(f.getName().toLowerCase(), unopenableExtensions)
|
||||||
|
&& FileUtils.sizeOf(f) <= Build.MAX_FILE_SIZE * FileUtils.ONE_KB) {
|
||||||
|
final long fileSize = f.length();
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("MMM dd, yyyy hh:mm a");
|
||||||
|
String date = format.format(f.lastModified());
|
||||||
|
fileDetails.add(new AdapterDetailedList.FileDetail(f.getName(),
|
||||||
|
FileUtils.byteCountToDisplaySize(fileSize), date));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
folderDetails.addAll(fileDetails);
|
||||||
|
return folderDetails;
|
||||||
|
} catch (Exception e) {
|
||||||
|
exceptionMessage = e.getMessage();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(final LinkedList<AdapterDetailedList.FileDetail> names) {
|
||||||
|
if (names != null) {
|
||||||
|
boolean isRoot = currentFolder.equals("/");
|
||||||
|
AdapterDetailedList mAdapter = new AdapterDetailedList(getBaseContext(), names, isRoot);
|
||||||
|
listView.setAdapter(mAdapter);
|
||||||
|
filter = mAdapter.getFilter();
|
||||||
|
}
|
||||||
|
if (exceptionMessage != null) {
|
||||||
|
Toast.makeText(SelectFileActivity.this, exceptionMessage, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
super.onPostExecute(names);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Comparator<File> getFileNameComparator() {
|
||||||
|
return new AlphanumComparator() {
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getTheString(Object obj) {
|
||||||
|
return ((File) obj).getName()
|
||||||
|
.toLowerCase();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,204 +1,204 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.adapter;
|
package com.maskyn.fileeditorpro.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.R;
|
||||||
import sharedcode.turboeditor.util.MimeTypes;
|
import com.maskyn.fileeditorpro.util.MimeTypes;
|
||||||
|
|
||||||
public class AdapterDetailedList extends
|
public class AdapterDetailedList extends
|
||||||
ArrayAdapter<AdapterDetailedList.FileDetail> {
|
ArrayAdapter<AdapterDetailedList.FileDetail> {
|
||||||
|
|
||||||
// Layout Inflater
|
// Layout Inflater
|
||||||
private final LayoutInflater inflater;
|
private final LayoutInflater inflater;
|
||||||
private final LinkedList<FileDetail> orig;
|
private final LinkedList<FileDetail> orig;
|
||||||
private CustomFilter customFilter;
|
private CustomFilter customFilter;
|
||||||
// List of file details
|
// List of file details
|
||||||
private LinkedList<FileDetail> fileDetails;
|
private LinkedList<FileDetail> fileDetails;
|
||||||
|
|
||||||
public AdapterDetailedList(final Context context,
|
public AdapterDetailedList(final Context context,
|
||||||
final LinkedList<FileDetail> fileDetails,
|
final LinkedList<FileDetail> fileDetails,
|
||||||
final boolean isRoot) {
|
final boolean isRoot) {
|
||||||
super(context, R.layout.item_file_list, fileDetails);
|
super(context, R.layout.item_file_list, fileDetails);
|
||||||
this.fileDetails = fileDetails;
|
this.fileDetails = fileDetails;
|
||||||
this.orig = fileDetails;
|
this.orig = fileDetails;
|
||||||
this.inflater = LayoutInflater.from(context);
|
this.inflater = LayoutInflater.from(context);
|
||||||
if (!isRoot) {
|
if (!isRoot) {
|
||||||
this.fileDetails.addFirst(new FileDetail("..", context.getString(R.string.folder), ""));
|
this.fileDetails.addFirst(new FileDetail("..", context.getString(R.string.folder), ""));
|
||||||
} else {
|
} else {
|
||||||
this.fileDetails.addFirst(new FileDetail(context.getString(R.string.home), context.getString(R.string.folder), ""));
|
this.fileDetails.addFirst(new FileDetail(context.getString(R.string.home), context.getString(R.string.folder), ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(final int position,
|
public View getView(final int position,
|
||||||
View convertView, final ViewGroup parent) {
|
View convertView, final ViewGroup parent) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = this.inflater
|
convertView = this.inflater
|
||||||
.inflate(R.layout.item_file_list,
|
.inflate(R.layout.item_file_list,
|
||||||
null);
|
null);
|
||||||
final ViewHolder hold = new ViewHolder();
|
final ViewHolder hold = new ViewHolder();
|
||||||
hold.nameLabel = (TextView) convertView.findViewById(android.R.id.text1);
|
hold.nameLabel = (TextView) convertView.findViewById(android.R.id.text1);
|
||||||
hold.detailLabel = (TextView) convertView.findViewById(android.R.id.text2);
|
hold.detailLabel = (TextView) convertView.findViewById(android.R.id.text2);
|
||||||
hold.icon = (ImageView) convertView.findViewById(android.R.id.icon);
|
hold.icon = (ImageView) convertView.findViewById(android.R.id.icon);
|
||||||
convertView.setTag(hold);
|
convertView.setTag(hold);
|
||||||
final FileDetail fileDetail = fileDetails.get(position);
|
final FileDetail fileDetail = fileDetails.get(position);
|
||||||
final String fileName = fileDetail.getName();
|
final String fileName = fileDetail.getName();
|
||||||
setIcon(hold, fileDetail);
|
setIcon(hold, fileDetail);
|
||||||
hold.nameLabel.setText(fileName);
|
hold.nameLabel.setText(fileName);
|
||||||
hold.detailLabel.setText(fileDetail.getSize() + "\t\t" + fileDetail.getDateModified());
|
hold.detailLabel.setText(fileDetail.getSize() + "\t\t" + fileDetail.getDateModified());
|
||||||
} else {
|
} else {
|
||||||
final ViewHolder hold = ((ViewHolder) convertView.getTag());
|
final ViewHolder hold = ((ViewHolder) convertView.getTag());
|
||||||
final FileDetail fileDetail = fileDetails.get(position);
|
final FileDetail fileDetail = fileDetails.get(position);
|
||||||
final String fileName = fileDetail.getName();
|
final String fileName = fileDetail.getName();
|
||||||
setIcon(hold, fileDetail);
|
setIcon(hold, fileDetail);
|
||||||
hold.nameLabel.setText(fileName);
|
hold.nameLabel.setText(fileName);
|
||||||
hold.detailLabel.setText(fileDetail.getSize() + "\t\t" + fileDetail.getDateModified());
|
hold.detailLabel.setText(fileDetail.getSize() + "\t\t" + fileDetail.getDateModified());
|
||||||
}
|
}
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return fileDetails.size();
|
return fileDetails.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setIcon(final ViewHolder viewHolder, final FileDetail fileDetail) {
|
private void setIcon(final ViewHolder viewHolder, final FileDetail fileDetail) {
|
||||||
final String fileName = fileDetail.getName();
|
final String fileName = fileDetail.getName();
|
||||||
final String ext = FilenameUtils.getExtension(fileName);
|
final String ext = FilenameUtils.getExtension(fileName);
|
||||||
if (fileDetail.isFolder()) {
|
if (fileDetail.isFolder()) {
|
||||||
viewHolder.icon.setImageResource(R.color.file_folder);
|
viewHolder.icon.setImageResource(R.color.file_folder);
|
||||||
} else if (Arrays.asList(MimeTypes.MIME_HTML).contains(ext) || ext.endsWith("html")) {
|
} else if (Arrays.asList(MimeTypes.MIME_HTML).contains(ext) || ext.endsWith("html")) {
|
||||||
viewHolder.icon.setImageResource(R.color.file_html);
|
viewHolder.icon.setImageResource(R.color.file_html);
|
||||||
} else if (Arrays.asList(MimeTypes.MIME_CODE).contains(ext)
|
} else if (Arrays.asList(MimeTypes.MIME_CODE).contains(ext)
|
||||||
|| fileName.endsWith("css")
|
|| fileName.endsWith("css")
|
||||||
|| fileName.endsWith("js")) {
|
|| fileName.endsWith("js")) {
|
||||||
viewHolder.icon.setImageResource(R.color.file_code);
|
viewHolder.icon.setImageResource(R.color.file_code);
|
||||||
} else if (Arrays.asList(MimeTypes.MIME_ARCHIVE).contains(ext)) {
|
} else if (Arrays.asList(MimeTypes.MIME_ARCHIVE).contains(ext)) {
|
||||||
viewHolder.icon.setImageResource(R.color.file_archive);
|
viewHolder.icon.setImageResource(R.color.file_archive);
|
||||||
} else if (Arrays.asList(MimeTypes.MIME_MUSIC)
|
} else if (Arrays.asList(MimeTypes.MIME_MUSIC)
|
||||||
.contains(ext)) {
|
.contains(ext)) {
|
||||||
viewHolder.icon.setImageResource(R.color.file_media_music);
|
viewHolder.icon.setImageResource(R.color.file_media_music);
|
||||||
} else if (Arrays.asList(MimeTypes.MIME_PICTURE).contains(ext)) {
|
} else if (Arrays.asList(MimeTypes.MIME_PICTURE).contains(ext)) {
|
||||||
viewHolder.icon.setImageResource(R.color.file_media_picture);
|
viewHolder.icon.setImageResource(R.color.file_media_picture);
|
||||||
} else if (Arrays.asList(MimeTypes.MIME_VIDEO).contains(ext)) {
|
} else if (Arrays.asList(MimeTypes.MIME_VIDEO).contains(ext)) {
|
||||||
viewHolder.icon.setImageResource(R.color.file_media_video);
|
viewHolder.icon.setImageResource(R.color.file_media_video);
|
||||||
} else {
|
} else {
|
||||||
viewHolder.icon.setImageResource(R.color.file_text);
|
viewHolder.icon.setImageResource(R.color.file_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Filter getFilter() {
|
public Filter getFilter() {
|
||||||
if (customFilter == null) {
|
if (customFilter == null) {
|
||||||
customFilter = new CustomFilter();
|
customFilter = new CustomFilter();
|
||||||
}
|
}
|
||||||
return customFilter;
|
return customFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ViewHolder {
|
public static class ViewHolder {
|
||||||
|
|
||||||
// Name of the file
|
// Name of the file
|
||||||
public TextView nameLabel;
|
public TextView nameLabel;
|
||||||
|
|
||||||
// Size of the file
|
// Size of the file
|
||||||
public TextView detailLabel;
|
public TextView detailLabel;
|
||||||
|
|
||||||
// Icon of the file
|
// Icon of the file
|
||||||
public ImageView icon;
|
public ImageView icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FileDetail {
|
public static class FileDetail {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String size;
|
private final String size;
|
||||||
private final String dateModified;
|
private final String dateModified;
|
||||||
private final boolean isFolder;
|
private final boolean isFolder;
|
||||||
|
|
||||||
public FileDetail(String name, String size,
|
public FileDetail(String name, String size,
|
||||||
String dateModified) {
|
String dateModified) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.dateModified = dateModified;
|
this.dateModified = dateModified;
|
||||||
isFolder = TextUtils.isEmpty(dateModified);
|
isFolder = TextUtils.isEmpty(dateModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDateModified() {
|
public String getDateModified() {
|
||||||
return dateModified;
|
return dateModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSize() {
|
public String getSize() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFolder() {
|
public boolean isFolder() {
|
||||||
return isFolder;
|
return isFolder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CustomFilter extends Filter {
|
private class CustomFilter extends Filter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
FilterResults results = new FilterResults();
|
FilterResults results = new FilterResults();
|
||||||
if (constraint == null || constraint.length() == 0) {
|
if (constraint == null || constraint.length() == 0) {
|
||||||
results.values = orig;
|
results.values = orig;
|
||||||
results.count = orig.size();
|
results.count = orig.size();
|
||||||
} else {
|
} else {
|
||||||
LinkedList<FileDetail> nHolderList = new LinkedList<>();
|
LinkedList<FileDetail> nHolderList = new LinkedList<>();
|
||||||
for (FileDetail h : orig) {
|
for (FileDetail h : orig) {
|
||||||
if (h.getName().toLowerCase().contains(constraint.toString().toLowerCase()))
|
if (h.getName().toLowerCase().contains(constraint.toString().toLowerCase()))
|
||||||
nHolderList.add(h);
|
nHolderList.add(h);
|
||||||
}
|
}
|
||||||
results.values = nHolderList;
|
results.values = nHolderList;
|
||||||
results.count = nHolderList.size();
|
results.count = nHolderList.size();
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void publishResults(CharSequence constraint,
|
protected void publishResults(CharSequence constraint,
|
||||||
FilterResults results) {
|
FilterResults results) {
|
||||||
|
|
||||||
|
|
||||||
fileDetails = (LinkedList<FileDetail>) results.values;
|
fileDetails = (LinkedList<FileDetail>) results.values;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,138 +1,134 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.adapter;
|
package com.maskyn.fileeditorpro.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.text.TextUtils;
|
import android.net.Uri;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.LinkedList;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
import com.maskyn.fileeditorpro.R;
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.util.GreatUri;
|
||||||
|
|
||||||
public class AdapterDrawer extends
|
public class AdapterDrawer extends
|
||||||
ArrayAdapter<File> {
|
ArrayAdapter<GreatUri> {
|
||||||
|
|
||||||
private final Callbacks callbacks;
|
private final Callbacks callbacks;
|
||||||
// Layout Inflater
|
// Layout Inflater
|
||||||
private final LayoutInflater inflater;
|
private final LayoutInflater inflater;
|
||||||
// List of file details
|
// List of file details
|
||||||
private final ArrayList<File> files;
|
private final LinkedList<GreatUri> greatUris;
|
||||||
private String selectedPath = "";
|
private GreatUri selectedGreatUri = new GreatUri(Uri.EMPTY, "", "");
|
||||||
|
|
||||||
public AdapterDrawer(Context context,
|
public AdapterDrawer(Context context,
|
||||||
ArrayList<File> files,
|
LinkedList<GreatUri> greatUris,
|
||||||
Callbacks callbacks) {
|
Callbacks callbacks) {
|
||||||
super(context, R.layout.item_file_list, files);
|
super(context, R.layout.item_file_list, greatUris);
|
||||||
this.files = files;
|
this.greatUris = greatUris;
|
||||||
this.inflater = LayoutInflater.from(context);
|
this.inflater = LayoutInflater.from(context);
|
||||||
this.callbacks = callbacks;
|
this.callbacks = callbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(final int position,
|
public View getView(final int position,
|
||||||
View convertView, final ViewGroup parent) {
|
View convertView, final ViewGroup parent) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = this.inflater
|
convertView = this.inflater
|
||||||
.inflate(R.layout.item_drawer_list,
|
.inflate(R.layout.item_drawer_list,
|
||||||
parent, false);
|
parent, false);
|
||||||
final ViewHolder hold = new ViewHolder();
|
final ViewHolder hold = new ViewHolder();
|
||||||
hold.nameLabel = (TextView) convertView.findViewById(android.R.id.text1);
|
hold.nameLabel = (TextView) convertView.findViewById(android.R.id.text1);
|
||||||
hold.cancelButton = (ImageView) convertView.findViewById(R.id.button_remove_from_list);
|
hold.cancelButton = (ImageView) convertView.findViewById(R.id.button_remove_from_list);
|
||||||
convertView.setTag(hold);
|
convertView.setTag(hold);
|
||||||
|
|
||||||
final String fileName = files.get(position).getName();
|
final GreatUri greatUri = greatUris.get(position);
|
||||||
hold.nameLabel.setText(fileName);
|
final String fileName = greatUri.getFileName();
|
||||||
hold.cancelButton.setOnClickListener(new View.OnClickListener() {
|
hold.nameLabel.setText(fileName);
|
||||||
@Override
|
hold.cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
@Override
|
||||||
boolean closeOpenedFile = TextUtils.equals(selectedPath, files.get(position).getAbsolutePath());
|
public void onClick(View v) {
|
||||||
callbacks.CancelItem(position, closeOpenedFile);
|
boolean closeOpenedFile = selectedGreatUri.getUri().equals(greatUri.getUri());
|
||||||
if (closeOpenedFile)
|
callbacks.CancelItem(position, closeOpenedFile);
|
||||||
selectedPath = "";
|
if (closeOpenedFile)
|
||||||
|
selectPosition(new GreatUri(Uri.EMPTY, "", ""));
|
||||||
}
|
|
||||||
});
|
}
|
||||||
|
});
|
||||||
if (TextUtils.equals(selectedPath, files.get(position).getAbsolutePath())) {
|
|
||||||
hold.nameLabel.setTypeface(hold.nameLabel.getTypeface(), Typeface.BOLD);
|
if (selectedGreatUri.getUri().equals(greatUri.getUri())) {
|
||||||
convertView.setBackgroundColor((convertView.getResources()
|
hold.nameLabel.setTypeface(null, Typeface.BOLD);
|
||||||
.getColor(R.color.item_selected)));
|
} else {
|
||||||
} else {
|
hold.nameLabel.setTypeface(null, Typeface.NORMAL);
|
||||||
hold.nameLabel.setTypeface(hold.nameLabel.getTypeface(), Typeface.NORMAL);
|
}
|
||||||
convertView.setBackgroundColor((convertView.getResources()
|
|
||||||
.getColor(android.R.color.transparent)));
|
} else {
|
||||||
}
|
final ViewHolder hold = ((ViewHolder) convertView.getTag());
|
||||||
|
final GreatUri greatUri = greatUris.get(position);
|
||||||
} else {
|
final String fileName = greatUri.getFileName();
|
||||||
final ViewHolder hold = ((ViewHolder) convertView.getTag());
|
hold.nameLabel.setText(fileName);
|
||||||
final String fileName = files.get(position).getName();
|
hold.cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
hold.nameLabel.setText(fileName);
|
@Override
|
||||||
hold.cancelButton.setOnClickListener(new View.OnClickListener() {
|
public void onClick(View v) {
|
||||||
@Override
|
boolean closeOpenedFile = selectedGreatUri.getUri().equals(greatUri.getUri());
|
||||||
public void onClick(View v) {
|
callbacks.CancelItem(position, closeOpenedFile);
|
||||||
boolean closeOpenedFile = TextUtils.equals(selectedPath, files.get(position).getAbsolutePath());
|
if (closeOpenedFile)
|
||||||
callbacks.CancelItem(position, closeOpenedFile);
|
selectPosition(new GreatUri(Uri.EMPTY, "", ""));
|
||||||
if (closeOpenedFile)
|
|
||||||
selectedPath = "";
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
if (selectedGreatUri.getUri().equals(greatUri.getUri())) {
|
||||||
if (TextUtils.equals(selectedPath, files.get(position).getAbsolutePath())) {
|
hold.nameLabel.setTypeface(null, Typeface.BOLD);
|
||||||
hold.nameLabel.setTypeface(null, Typeface.BOLD);
|
} else {
|
||||||
convertView.setBackgroundColor((convertView.getResources()
|
hold.nameLabel.setTypeface(null, Typeface.NORMAL);
|
||||||
.getColor(R.color.item_selected)));
|
}
|
||||||
} else {
|
|
||||||
hold.nameLabel.setTypeface(null, Typeface.NORMAL);
|
}
|
||||||
convertView.setBackgroundColor((convertView.getResources()
|
return convertView;
|
||||||
.getColor(android.R.color.transparent)));
|
}
|
||||||
}
|
|
||||||
}
|
public void selectPosition(GreatUri greatUri) {
|
||||||
return convertView;
|
//callbacks.ItemSelected(selectedPath);
|
||||||
}
|
this.selectedGreatUri = greatUri;
|
||||||
|
notifyDataSetChanged();
|
||||||
public void selectView(String selectedPath) {
|
}
|
||||||
//callbacks.ItemSelected(selectedPath);
|
|
||||||
this.selectedPath = selectedPath;
|
public interface Callbacks {
|
||||||
notifyDataSetChanged();
|
void CancelItem(int position, boolean andCloseOpenedFile);
|
||||||
}
|
|
||||||
|
//void ItemSelected(String path);
|
||||||
public interface Callbacks {
|
}
|
||||||
void CancelItem(int position, boolean andCloseOpenedFile);
|
|
||||||
|
public static class ViewHolder {
|
||||||
//void ItemSelected(String path);
|
|
||||||
}
|
// Name of the file
|
||||||
|
public TextView nameLabel;
|
||||||
public static class ViewHolder {
|
|
||||||
|
public ImageView cancelButton;
|
||||||
// Name of the file
|
}
|
||||||
public TextView nameLabel;
|
}
|
||||||
|
|
||||||
public ImageView cancelButton;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +1,75 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.adapter;
|
package com.maskyn.fileeditorpro.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.R;
|
||||||
|
|
||||||
public class AdapterTwoItem extends
|
public class AdapterTwoItem extends
|
||||||
ArrayAdapter<String> {
|
ArrayAdapter<String> {
|
||||||
|
|
||||||
private final LayoutInflater inflater;
|
private final LayoutInflater inflater;
|
||||||
private final String[] lines1;
|
private final String[] lines1;
|
||||||
private final String[] lines2;
|
private final String[] lines2;
|
||||||
|
|
||||||
public AdapterTwoItem(Context context,
|
public AdapterTwoItem(Context context,
|
||||||
String[] lines1,
|
String[] lines1,
|
||||||
String[] lines2) {
|
String[] lines2) {
|
||||||
super(context, R.layout.item_two_lines, lines1);
|
super(context, R.layout.item_two_lines, lines1);
|
||||||
this.lines1 = lines1;
|
this.lines1 = lines1;
|
||||||
this.lines2 = lines2;
|
this.lines2 = lines2;
|
||||||
this.inflater = LayoutInflater.from(context);
|
this.inflater = LayoutInflater.from(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(final int position,
|
public View getView(final int position,
|
||||||
View convertView, final ViewGroup parent) {
|
View convertView, final ViewGroup parent) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = this.inflater
|
convertView = this.inflater
|
||||||
.inflate(R.layout.item_two_lines,
|
.inflate(R.layout.item_two_lines,
|
||||||
parent, false);
|
parent, false);
|
||||||
final ViewHolder hold = new ViewHolder();
|
final ViewHolder hold = new ViewHolder();
|
||||||
hold.line1 = (TextView) convertView.findViewById(android.R.id.text1);
|
hold.line1 = (TextView) convertView.findViewById(android.R.id.text1);
|
||||||
hold.line2 = (TextView) convertView.findViewById(android.R.id.text2);
|
hold.line2 = (TextView) convertView.findViewById(android.R.id.text2);
|
||||||
convertView.setTag(hold);
|
convertView.setTag(hold);
|
||||||
|
|
||||||
hold.line1.setText(lines1[position]);
|
hold.line1.setText(lines1[position]);
|
||||||
hold.line2.setText(lines2[position]);
|
hold.line2.setText(lines2[position]);
|
||||||
} else {
|
} else {
|
||||||
final ViewHolder hold = ((ViewHolder) convertView.getTag());
|
final ViewHolder hold = ((ViewHolder) convertView.getTag());
|
||||||
hold.line1.setText(lines1[position]);
|
hold.line1.setText(lines1[position]);
|
||||||
hold.line2.setText(lines2[position]);
|
hold.line2.setText(lines2[position]);
|
||||||
}
|
}
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ViewHolder {
|
public static class ViewHolder {
|
||||||
|
|
||||||
public TextView line1;
|
public TextView line1;
|
||||||
public TextView line2;
|
public TextView line2;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,44 +1,51 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.activity;
|
package com.maskyn.fileeditorpro.application;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class MyApp extends Application {
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
@Override
|
public class MyApp extends Shell.ContainerApp {
|
||||||
public void onCreate() {
|
|
||||||
super.onCreate();
|
@Override
|
||||||
// force to sow the overflow menu icon
|
public void onCreate() {
|
||||||
try {
|
super.onCreate();
|
||||||
ViewConfiguration config = ViewConfiguration.get(this);
|
|
||||||
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
|
// Shell initialization
|
||||||
if (menuKeyField != null) {
|
Shell.setFlags(Shell.FLAG_REDIRECT_STDERR);
|
||||||
menuKeyField.setAccessible(true);
|
Shell.verboseLogging(true);
|
||||||
menuKeyField.setBoolean(config, false);
|
|
||||||
}
|
// force to sow the overflow menu icon
|
||||||
} catch (Exception ex) {
|
try {
|
||||||
// Ignore
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
@ -16,7 +16,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package sharedcode.turboeditor.fragment;
|
|
||||||
|
package com.maskyn.fileeditorpro.dialogfragment;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@ -28,10 +29,9 @@ import android.content.res.Resources;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.R;
|
||||||
import sharedcode.turboeditor.views.DialogHelper;
|
import com.maskyn.fileeditorpro.views.DialogHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog fragment that shows some info about this application.
|
* Dialog fragment that shows some info about this application.
|
@ -1,90 +1,69 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package sharedcode.turboeditor.fragment;
|
|
||||||
|
package com.maskyn.fileeditorpro.dialogfragment;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.DialogFragment;
|
import android.app.Dialog;
|
||||||
import android.app.Fragment;
|
import android.app.DialogFragment;
|
||||||
import android.app.FragmentManager;
|
import android.app.Fragment;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentManager;
|
||||||
import android.content.Context;
|
import android.app.FragmentTransaction;
|
||||||
import android.content.DialogInterface;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.DialogInterface;
|
||||||
import android.net.Uri;
|
import android.os.Bundle;
|
||||||
import android.os.Bundle;
|
import android.view.LayoutInflater;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
|
import it.gmariotti.changelibs.library.view.ChangeLogListView;
|
||||||
import it.gmariotti.changelibs.library.view.ChangeLogListView;
|
import com.maskyn.fileeditorpro.R;
|
||||||
import sharedcode.turboeditor.R;
|
|
||||||
import sharedcode.turboeditor.util.Build;
|
public class ChangelogDialog extends DialogFragment {
|
||||||
|
|
||||||
public class ChangelogDialog extends DialogFragment {
|
public static void showChangeLogDialog(FragmentManager fragmentManager) {
|
||||||
|
ChangelogDialog changelogDialog = new ChangelogDialog();
|
||||||
public static void showChangeLogDialog(FragmentManager fragmentManager) {
|
FragmentTransaction ft = fragmentManager.beginTransaction();
|
||||||
ChangelogDialog changelogDialog = new ChangelogDialog();
|
Fragment prev = fragmentManager.findFragmentByTag("changelogdemo_dialog");
|
||||||
FragmentTransaction ft = fragmentManager.beginTransaction();
|
if (prev != null) {
|
||||||
Fragment prev = fragmentManager.findFragmentByTag("changelogdemo_dialog");
|
ft.remove(prev);
|
||||||
if (prev != null) {
|
}
|
||||||
ft.remove(prev);
|
ft.addToBackStack(null);
|
||||||
}
|
changelogDialog.show(ft, "changelogdemo_dialog");
|
||||||
ft.addToBackStack(null);
|
}
|
||||||
changelogDialog.show(ft, "changelogdemo_dialog");
|
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
LayoutInflater layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
ChangeLogListView chgList = (ChangeLogListView) layoutInflater.inflate(R.layout.demo_changelog_fragment_dialogstandard, null);
|
||||||
LayoutInflater layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
ChangeLogListView chgList = (ChangeLogListView) layoutInflater.inflate(R.layout.demo_changelog_fragment_dialogstandard, null);
|
return new AlertDialog.Builder(getActivity())
|
||||||
|
.setTitle(R.string.changelog)
|
||||||
return new AlertDialog.Builder(getActivity())
|
.setView(chgList)
|
||||||
.setTitle(R.string.changelog)
|
.setNegativeButton(android.R.string.cancel,
|
||||||
.setView(chgList)
|
new DialogInterface.OnClickListener() {
|
||||||
.setNegativeButton(android.R.string.cancel,
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
new DialogInterface.OnClickListener() {
|
dialog.dismiss();
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
}
|
||||||
dialog.dismiss();
|
}
|
||||||
}
|
)
|
||||||
}
|
.create();
|
||||||
)
|
|
||||||
.setPositiveButton(R.string.vota, new DialogInterface.OnClickListener() {
|
}
|
||||||
/**
|
}
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onClick(final DialogInterface dialog, final int which) {
|
|
||||||
try {
|
|
||||||
if (Build.FOR_AMAZON) {
|
|
||||||
String url = "amzn://apps/android?p=com.maskyn.fileeditor";
|
|
||||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
|
||||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
|
||||||
} else {
|
|
||||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.maskyn.fileeditor"))
|
|
||||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,128 +1,135 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.fragment;
|
package com.maskyn.fileeditorpro.dialogfragment;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.R;
|
||||||
|
import com.maskyn.fileeditorpro.views.DialogHelper;
|
||||||
// ...
|
|
||||||
public class EditTextDialog extends DialogFragment implements TextView.OnEditorActionListener {
|
// ...
|
||||||
|
public class EditTextDialog extends DialogFragment implements TextView.OnEditorActionListener {
|
||||||
private EditText mEditText;
|
|
||||||
|
private EditText mEditText;
|
||||||
public static EditTextDialog newInstance(final Actions action) {
|
|
||||||
return EditTextDialog.newInstance(action, "");
|
public static EditTextDialog newInstance(final Actions action) {
|
||||||
}
|
return EditTextDialog.newInstance(action, "");
|
||||||
|
}
|
||||||
public static EditTextDialog newInstance(final Actions action, final String hint) {
|
|
||||||
final EditTextDialog f = new EditTextDialog();
|
public static EditTextDialog newInstance(final Actions action, final String hint) {
|
||||||
final Bundle args = new Bundle();
|
final EditTextDialog f = new EditTextDialog();
|
||||||
args.putSerializable("action", action);
|
final Bundle args = new Bundle();
|
||||||
args.putString("hint", hint);
|
args.putSerializable("action", action);
|
||||||
f.setArguments(args);
|
args.putString("hint", hint);
|
||||||
return f;
|
f.setArguments(args);
|
||||||
}
|
return f;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
final Actions action = (Actions) getArguments().getSerializable("action");
|
|
||||||
final String hint;
|
final Actions action = (Actions) getArguments().getSerializable("action");
|
||||||
switch (action) {
|
final String title;
|
||||||
case NewFile:
|
switch (action) {
|
||||||
hint = getString(R.string.file);
|
case NewFile:
|
||||||
break;
|
title = getString(R.string.file);
|
||||||
case NewFolder:
|
break;
|
||||||
hint = getString(R.string.folder);
|
case NewFolder:
|
||||||
break;
|
title = getString(R.string.folder);
|
||||||
default:
|
break;
|
||||||
hint = null;
|
case Rename:
|
||||||
break;
|
title = getString(R.string.rinomina);
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_fragment_edittext, null);
|
title = null;
|
||||||
this.mEditText = (EditText) view.findViewById(android.R.id.edit);
|
break;
|
||||||
this.mEditText.setHint(hint);
|
}
|
||||||
|
|
||||||
// Show soft keyboard automatically
|
View view = new DialogHelper.Builder(getActivity())
|
||||||
this.mEditText.setText(getArguments().getString("hint"));
|
.setTitle(title)
|
||||||
this.mEditText.requestFocus();
|
.setView(R.layout.dialog_fragment_edittext)
|
||||||
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
.createSkeletonView();
|
||||||
this.mEditText.setOnEditorActionListener(this);
|
this.mEditText = (EditText) view.findViewById(android.R.id.edit);
|
||||||
|
this.mEditText.setHint(R.string.name);
|
||||||
return new AlertDialog.Builder(getActivity())
|
|
||||||
.setView(view)
|
// Show soft keyboard automatically
|
||||||
.setPositiveButton(android.R.string.ok,
|
this.mEditText.setText(getArguments().getString("hint"));
|
||||||
new DialogInterface.OnClickListener() {
|
this.mEditText.requestFocus();
|
||||||
@Override
|
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
this.mEditText.setOnEditorActionListener(this);
|
||||||
returnData();
|
|
||||||
}
|
return new AlertDialog.Builder(getActivity())
|
||||||
}
|
.setView(view)
|
||||||
)
|
.setPositiveButton(android.R.string.ok,
|
||||||
.setNegativeButton(android.R.string.cancel,
|
new DialogInterface.OnClickListener() {
|
||||||
new DialogInterface.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
returnData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
)
|
.setNegativeButton(android.R.string.cancel,
|
||||||
.create();
|
new DialogInterface.OnClickListener() {
|
||||||
}
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
void returnData() {
|
|
||||||
EditDialogListener target = (EditDialogListener) getTargetFragment();
|
}
|
||||||
if (target == null) {
|
}
|
||||||
target = (EditDialogListener) getActivity();
|
)
|
||||||
}
|
.create();
|
||||||
target.onFinishEditDialog(this.mEditText.getText().toString(), getArguments().getString("hint"),
|
}
|
||||||
(Actions) getArguments().getSerializable("action"));
|
|
||||||
this.dismiss();
|
void returnData() {
|
||||||
}
|
EditDialogListener target = (EditDialogListener) getTargetFragment();
|
||||||
|
if (target == null) {
|
||||||
@Override
|
target = (EditDialogListener) getActivity();
|
||||||
public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
|
}
|
||||||
if (EditorInfo.IME_ACTION_DONE == actionId) {
|
target.onEdittextDialogEnded(this.mEditText.getText().toString(), getArguments().getString("hint"),
|
||||||
returnData();
|
(Actions) getArguments().getSerializable("action"));
|
||||||
return true;
|
this.dismiss();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
@Override
|
||||||
|
public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
|
||||||
public enum Actions {
|
if (EditorInfo.IME_ACTION_DONE == actionId) {
|
||||||
NewFile, NewFolder
|
returnData();
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
public interface EditDialogListener {
|
return false;
|
||||||
void onFinishEditDialog(String result, String hint, Actions action);
|
}
|
||||||
}
|
|
||||||
|
public enum Actions {
|
||||||
|
NewFile, NewFolder, Rename
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface EditDialogListener {
|
||||||
|
void onEdittextDialogEnded(String result, String hint, Actions action);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,120 +1,122 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.fragment;
|
package com.maskyn.fileeditorpro.dialogfragment;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.support.v7.widget.SwitchCompat;
|
||||||
import android.widget.AdapterView;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.AdapterView;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.Switch;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import org.mozilla.universalchardet.Constants;
|
import org.mozilla.universalchardet.Constants;
|
||||||
|
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.R;
|
||||||
import sharedcode.turboeditor.preferences.PreferenceHelper;
|
import com.maskyn.fileeditorpro.preferences.PreferenceHelper;
|
||||||
|
|
||||||
public class EncodingDialog extends DialogFragment implements AdapterView.OnItemClickListener {
|
public class EncodingDialog extends DialogFragment implements AdapterView.OnItemClickListener {
|
||||||
|
|
||||||
private final String[] encodings = new String[]{
|
private final String[] encodings = new String[]{
|
||||||
Constants.CHARSET_BIG5,
|
Constants.CHARSET_BIG5,
|
||||||
Constants.CHARSET_EUC_JP,
|
Constants.CHARSET_EUC_JP,
|
||||||
Constants.CHARSET_EUC_KR,
|
Constants.CHARSET_EUC_KR,
|
||||||
Constants.CHARSET_EUC_TW,
|
Constants.CHARSET_EUC_TW,
|
||||||
Constants.CHARSET_GB18030,
|
Constants.CHARSET_GB18030,
|
||||||
"GB2312",
|
"GB2312",
|
||||||
Constants.CHARSET_IBM855,
|
Constants.CHARSET_IBM855,
|
||||||
Constants.CHARSET_IBM866,
|
Constants.CHARSET_IBM866,
|
||||||
Constants.CHARSET_ISO_2022_CN,
|
Constants.CHARSET_ISO_2022_CN,
|
||||||
Constants.CHARSET_ISO_2022_JP,
|
Constants.CHARSET_ISO_2022_JP,
|
||||||
Constants.CHARSET_ISO_2022_KR,
|
Constants.CHARSET_ISO_2022_KR,
|
||||||
Constants.CHARSET_ISO_8859_5,
|
"ISO-8859-2",
|
||||||
Constants.CHARSET_ISO_8859_7,
|
Constants.CHARSET_ISO_8859_5,
|
||||||
Constants.CHARSET_ISO_8859_8,
|
Constants.CHARSET_ISO_8859_7,
|
||||||
Constants.CHARSET_KOI8_R,
|
Constants.CHARSET_ISO_8859_8,
|
||||||
Constants.CHARSET_MACCYRILLIC,
|
Constants.CHARSET_KOI8_R,
|
||||||
Constants.CHARSET_SHIFT_JIS,
|
Constants.CHARSET_MACCYRILLIC,
|
||||||
Constants.CHARSET_UTF_16BE,
|
Constants.CHARSET_SHIFT_JIS,
|
||||||
Constants.CHARSET_UTF_16LE,
|
Constants.CHARSET_UTF_16BE,
|
||||||
Constants.CHARSET_UTF_32BE,
|
Constants.CHARSET_UTF_16LE,
|
||||||
Constants.CHARSET_UTF_32LE,
|
Constants.CHARSET_UTF_32BE,
|
||||||
Constants.CHARSET_UTF_8,
|
Constants.CHARSET_UTF_32LE,
|
||||||
Constants.CHARSET_WINDOWS_1251,
|
Constants.CHARSET_UTF_8,
|
||||||
Constants.CHARSET_WINDOWS_1252,
|
"UTF-16",
|
||||||
Constants.CHARSET_WINDOWS_1253,
|
Constants.CHARSET_WINDOWS_1251,
|
||||||
Constants.CHARSET_WINDOWS_1255
|
Constants.CHARSET_WINDOWS_1252,
|
||||||
};
|
Constants.CHARSET_WINDOWS_1253,
|
||||||
private ListView list;
|
Constants.CHARSET_WINDOWS_1255
|
||||||
|
};
|
||||||
public static EncodingDialog newInstance() {
|
private ListView list;
|
||||||
final EncodingDialog f = new EncodingDialog();
|
|
||||||
return f;
|
public static EncodingDialog newInstance() {
|
||||||
}
|
final EncodingDialog f = new EncodingDialog();
|
||||||
|
return f;
|
||||||
@Override
|
}
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
|
@Override
|
||||||
final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_encoding_list, null);
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
list = (ListView) view.findViewById(android.R.id.list);
|
|
||||||
Switch autoencoding = (Switch) view.findViewById(android.R.id.checkbox);
|
final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_encoding_list, null);
|
||||||
autoencoding.setChecked(PreferenceHelper.getAutoEncoding(getActivity()));
|
list = (ListView) view.findViewById(android.R.id.list);
|
||||||
|
SwitchCompat autoencoding = (SwitchCompat) view.findViewById(android.R.id.checkbox);
|
||||||
autoencoding.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
autoencoding.setChecked(PreferenceHelper.getAutoEncoding(getActivity()));
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
autoencoding.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
PreferenceHelper.setAutoencoding(getActivity(), isChecked);
|
@Override
|
||||||
}
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
});
|
PreferenceHelper.setAutoencoding(getActivity(), isChecked);
|
||||||
|
}
|
||||||
list.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.item_single_choice, encodings));
|
});
|
||||||
list.setOnItemClickListener(this);
|
|
||||||
|
list.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.item_single_choice, encodings));
|
||||||
String currentEncoding = PreferenceHelper.getEncoding(getActivity());
|
list.setOnItemClickListener(this);
|
||||||
|
|
||||||
for (int i = 0; i < encodings.length; i++) {
|
String currentEncoding = PreferenceHelper.getEncoding(getActivity());
|
||||||
if (currentEncoding.equals(encodings[i])) {
|
|
||||||
list.setItemChecked(i, true);
|
for (int i = 0; i < encodings.length; i++) {
|
||||||
}
|
if (currentEncoding.equals(encodings[i])) {
|
||||||
|
list.setItemChecked(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AlertDialog.Builder(getActivity())
|
}
|
||||||
.setView(view)
|
|
||||||
.create();
|
return new AlertDialog.Builder(getActivity())
|
||||||
}
|
.setView(view)
|
||||||
|
.create();
|
||||||
@Override
|
}
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
DialogListener target = (DialogListener) getTargetFragment();
|
@Override
|
||||||
if (target == null) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
target = (DialogListener) getActivity();
|
DialogListener target = (DialogListener) getTargetFragment();
|
||||||
}
|
if (target == null) {
|
||||||
target.onEncodingSelected(encodings[position]);
|
target = (DialogListener) getActivity();
|
||||||
this.dismiss();
|
}
|
||||||
}
|
target.onEncodingSelected(encodings[position]);
|
||||||
|
this.dismiss();
|
||||||
public interface DialogListener {
|
}
|
||||||
void onEncodingSelected(String result);
|
|
||||||
}
|
public interface DialogListener {
|
||||||
}
|
void onEncodingSelected(String result);
|
||||||
|
}
|
||||||
|
}
|
@ -1,91 +1,105 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.fragment;
|
package com.maskyn.fileeditorpro.dialogfragment;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.net.Uri;
|
||||||
import android.view.View;
|
import android.os.Bundle;
|
||||||
import android.widget.ListView;
|
import android.support.v4.provider.DocumentFile;
|
||||||
|
import android.view.View;
|
||||||
import org.apache.commons.io.FileUtils;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import java.io.File;
|
import org.apache.commons.io.FileUtils;
|
||||||
import java.util.Date;
|
|
||||||
|
import java.io.File;
|
||||||
import sharedcode.turboeditor.R;
|
import java.util.Date;
|
||||||
import sharedcode.turboeditor.adapter.AdapterTwoItem;
|
|
||||||
|
import com.maskyn.fileeditorpro.R;
|
||||||
// ...
|
import com.maskyn.fileeditorpro.adapter.AdapterTwoItem;
|
||||||
public class FileInfoDialog extends DialogFragment {
|
import com.maskyn.fileeditorpro.util.AccessStorageApi;
|
||||||
|
import com.maskyn.fileeditorpro.util.Device;
|
||||||
public static FileInfoDialog newInstance(String filePath) {
|
import com.maskyn.fileeditorpro.views.DialogHelper;
|
||||||
final FileInfoDialog f = new FileInfoDialog();
|
|
||||||
final Bundle args = new Bundle();
|
// ...
|
||||||
args.putString("filePath", filePath);
|
public class FileInfoDialog extends DialogFragment {
|
||||||
f.setArguments(args);
|
|
||||||
return f;
|
public static FileInfoDialog newInstance(Uri uri) {
|
||||||
}
|
final FileInfoDialog f = new FileInfoDialog();
|
||||||
|
final Bundle args = new Bundle();
|
||||||
@Override
|
args.putParcelable("uri", uri);
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
f.setArguments(args);
|
||||||
|
return f;
|
||||||
final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_fragment_file_info, null);
|
}
|
||||||
ListView list = (ListView) view.findViewById(android.R.id.list);
|
|
||||||
|
@Override
|
||||||
File file = new File(getArguments().getString("filePath"));
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
|
||||||
// Get the last modification information.
|
View view = new DialogHelper.Builder(getActivity())
|
||||||
Long lastModified = file.lastModified();
|
.setTitle(R.string.info)
|
||||||
|
.setView(R.layout.dialog_fragment_file_info)
|
||||||
// Create a new date object and pass last modified information
|
.createSkeletonView();
|
||||||
// to the date object.
|
//final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_fragment_file_info, null);
|
||||||
Date date = new Date(lastModified);
|
|
||||||
|
ListView list = (ListView) view.findViewById(android.R.id.list);
|
||||||
String[] lines1 = {
|
|
||||||
getString(R.string.name),
|
DocumentFile file = DocumentFile.fromFile(new File(AccessStorageApi.getPath(getActivity(), (Uri) getArguments().getParcelable("uri"))));
|
||||||
getString(R.string.folder),
|
|
||||||
getString(R.string.size),
|
if (file == null && Device.hasKitKatApi()) {
|
||||||
getString(R.string.modification_date)
|
file = DocumentFile.fromSingleUri(getActivity(), (Uri) getArguments().getParcelable("uri"));
|
||||||
};
|
}
|
||||||
String[] lines2 = {
|
|
||||||
file.getName(),
|
// Get the last modification information.
|
||||||
file.getParent(),
|
Long lastModified = file.lastModified();
|
||||||
FileUtils.byteCountToDisplaySize(file.length()),
|
|
||||||
date.toString()
|
// Create a new date object and pass last modified information
|
||||||
};
|
// to the date object.
|
||||||
|
Date date = new Date(lastModified);
|
||||||
list.setAdapter(new AdapterTwoItem(getActivity(), lines1, lines2));
|
|
||||||
|
String[] lines1 = {
|
||||||
return new AlertDialog.Builder(getActivity())
|
getString(R.string.name),
|
||||||
//.setTitle(title)
|
//getString(R.string.folder),
|
||||||
.setView(view)
|
getString(R.string.size),
|
||||||
.setPositiveButton(android.R.string.ok,
|
getString(R.string.modification_date)
|
||||||
new DialogInterface.OnClickListener() {
|
};
|
||||||
@Override
|
String[] lines2 = {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
file.getName(),
|
||||||
}
|
//file.getParent(),
|
||||||
}
|
FileUtils.byteCountToDisplaySize(file.length()),
|
||||||
)
|
date.toString()
|
||||||
.create();
|
};
|
||||||
}
|
|
||||||
|
list.setAdapter(new AdapterTwoItem(getActivity(), lines1, lines2));
|
||||||
|
|
||||||
|
|
||||||
|
return new AlertDialog.Builder(getActivity())
|
||||||
|
.setView(view)
|
||||||
|
.setPositiveButton(android.R.string.ok,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,207 +1,207 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.fragment;
|
package com.maskyn.fileeditorpro.dialogfragment;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.R;
|
||||||
import sharedcode.turboeditor.texteditor.SearchResult;
|
import com.maskyn.fileeditorpro.texteditor.SearchResult;
|
||||||
import sharedcode.turboeditor.views.DialogHelper;
|
import com.maskyn.fileeditorpro.views.DialogHelper;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
public class FindTextDialog extends DialogFragment {
|
public class FindTextDialog extends DialogFragment {
|
||||||
|
|
||||||
private EditText textToFind, textToReplace;
|
private EditText textToFind, textToReplace;
|
||||||
private CheckBox regexCheck, replaceCheck, matchCaseCheck;
|
private CheckBox regexCheck, replaceCheck, matchCaseCheck;
|
||||||
|
|
||||||
public static FindTextDialog newInstance(String allText) {
|
public static FindTextDialog newInstance(String allText) {
|
||||||
final FindTextDialog f = new FindTextDialog();
|
final FindTextDialog f = new FindTextDialog();
|
||||||
final Bundle args = new Bundle();
|
final Bundle args = new Bundle();
|
||||||
args.putString("allText", allText);
|
args.putString("allText", allText);
|
||||||
f.setArguments(args);
|
f.setArguments(args);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
|
||||||
//final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_fragment_find_text, null);
|
//final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_fragment_find_text, null);
|
||||||
|
|
||||||
View view = new DialogHelper.Builder(getActivity())
|
View view = new DialogHelper.Builder(getActivity())
|
||||||
.setTitle(R.string.find)
|
.setTitle(R.string.find)
|
||||||
.setView(R.layout.dialog_fragment_find_text)
|
.setView(R.layout.dialog_fragment_find_text)
|
||||||
.createSkeletonView();
|
.createSkeletonView();
|
||||||
|
|
||||||
this.textToFind = (EditText) view.findViewById(R.id.text_to_find);
|
this.textToFind = (EditText) view.findViewById(R.id.text_to_find);
|
||||||
this.textToReplace = (EditText) view.findViewById(R.id.text_to_replace);
|
this.textToReplace = (EditText) view.findViewById(R.id.text_to_replace);
|
||||||
this.regexCheck = (CheckBox) view.findViewById(R.id.regex_check);
|
this.regexCheck = (CheckBox) view.findViewById(R.id.regex_check);
|
||||||
this.replaceCheck = (CheckBox) view.findViewById(R.id.replace_check);
|
this.replaceCheck = (CheckBox) view.findViewById(R.id.replace_check);
|
||||||
this.matchCaseCheck = (CheckBox) view.findViewById(R.id.match_case_check);
|
this.matchCaseCheck = (CheckBox) view.findViewById(R.id.match_case_check);
|
||||||
|
|
||||||
replaceCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
replaceCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
textToReplace.setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
textToReplace.setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return new AlertDialog.Builder(getActivity())
|
return new AlertDialog.Builder(getActivity())
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setPositiveButton(R.string.find,
|
.setPositiveButton(R.string.find,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart(); //super.onStart() is where dialog.show() is actually called on the underlying dialog, so we have to do it after this point
|
super.onStart(); //super.onStart() is where dialog.show() is actually called on the underlying dialog, so we have to do it after this point
|
||||||
AlertDialog d = (AlertDialog) getDialog();
|
AlertDialog d = (AlertDialog) getDialog();
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
Button positiveButton = (Button) d.getButton(Dialog.BUTTON_POSITIVE);
|
Button positiveButton = (Button) d.getButton(Dialog.BUTTON_POSITIVE);
|
||||||
positiveButton.setText(getString(R.string.find));
|
positiveButton.setText(getString(R.string.find));
|
||||||
positiveButton.setOnClickListener(new View.OnClickListener() {
|
positiveButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
returnData();
|
returnData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Button negativeButton = (Button) d.getButton(Dialog.BUTTON_NEGATIVE);
|
Button negativeButton = (Button) d.getButton(Dialog.BUTTON_NEGATIVE);
|
||||||
negativeButton.setText(getString(android.R.string.cancel));
|
negativeButton.setText(getString(android.R.string.cancel));
|
||||||
negativeButton.setOnClickListener(new View.OnClickListener() {
|
negativeButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void returnData() {
|
void returnData() {
|
||||||
if (textToFind.getText().toString().isEmpty()) {
|
if (textToFind.getText().toString().isEmpty()) {
|
||||||
this.dismiss();
|
this.dismiss();
|
||||||
} else {
|
} else {
|
||||||
// we disable the okButton while we search
|
// we disable the okButton while we search
|
||||||
new SearchTask().execute();
|
new SearchTask().execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface SearchDialogInterface {
|
public interface SearchDialogInterface {
|
||||||
void onSearchDone(SearchResult searchResult);
|
void onSearchDone(SearchResult searchResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SearchTask extends AsyncTask<Void, Void, Void> {
|
private class SearchTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
LinkedList<Integer> foundIndex;
|
LinkedList<Integer> foundIndex;
|
||||||
boolean foundSomething;
|
boolean foundSomething;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
String allText = getArguments().getString("allText");
|
String allText = getArguments().getString("allText");
|
||||||
String whatToSearch = textToFind.getText().toString();
|
String whatToSearch = textToFind.getText().toString();
|
||||||
boolean caseSensitive = matchCaseCheck.isChecked();
|
boolean caseSensitive = matchCaseCheck.isChecked();
|
||||||
boolean isRegex = regexCheck.isChecked();
|
boolean isRegex = regexCheck.isChecked();
|
||||||
foundIndex = new LinkedList<>();
|
foundIndex = new LinkedList<>();
|
||||||
Matcher matcher = null;
|
Matcher matcher = null;
|
||||||
foundSomething = false;
|
foundSomething = false;
|
||||||
|
|
||||||
if (isRegex) {
|
if (isRegex) {
|
||||||
try {
|
try {
|
||||||
if (caseSensitive)
|
if (caseSensitive)
|
||||||
matcher = Pattern.compile(whatToSearch, Pattern.MULTILINE).matcher(allText);
|
matcher = Pattern.compile(whatToSearch, Pattern.MULTILINE).matcher(allText);
|
||||||
else
|
else
|
||||||
matcher = Pattern.compile(whatToSearch, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE).matcher(allText);
|
matcher = Pattern.compile(whatToSearch, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE).matcher(allText);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
isRegex = false;
|
isRegex = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRegex) {
|
if (isRegex) {
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
|
|
||||||
foundIndex.add(matcher.start());
|
foundIndex.add(matcher.start());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (caseSensitive == false) { // by default is case sensitive
|
if (caseSensitive == false) { // by default is case sensitive
|
||||||
whatToSearch = whatToSearch.toLowerCase();
|
whatToSearch = whatToSearch.toLowerCase();
|
||||||
allText = allText.toLowerCase();
|
allText = allText.toLowerCase();
|
||||||
}
|
}
|
||||||
int index = allText.indexOf(whatToSearch);
|
int index = allText.indexOf(whatToSearch);
|
||||||
while (index >= 0) {
|
while (index >= 0) {
|
||||||
foundSomething = true;
|
foundSomething = true;
|
||||||
|
|
||||||
foundIndex.add(index);
|
foundIndex.add(index);
|
||||||
|
|
||||||
index = allText.indexOf(whatToSearch, index + 1);
|
index = allText.indexOf(whatToSearch, index + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(Void aVoid) {
|
||||||
super.onPostExecute(aVoid);
|
super.onPostExecute(aVoid);
|
||||||
if (foundSomething) {
|
if (foundSomething) {
|
||||||
// the class that called this Dialog should implement the SearchDialogIterface
|
// the class that called this Dialog should implement the SearchDialogIterface
|
||||||
SearchDialogInterface searchDialogInterface;
|
SearchDialogInterface searchDialogInterface;
|
||||||
searchDialogInterface = ((SearchDialogInterface) getTargetFragment());
|
searchDialogInterface = ((SearchDialogInterface) getTargetFragment());
|
||||||
if (searchDialogInterface == null)
|
if (searchDialogInterface == null)
|
||||||
searchDialogInterface = ((SearchDialogInterface) getActivity());
|
searchDialogInterface = ((SearchDialogInterface) getActivity());
|
||||||
|
|
||||||
// if who called this has not implemented the interface we return nothing
|
// if who called this has not implemented the interface we return nothing
|
||||||
if (searchDialogInterface == null)
|
if (searchDialogInterface == null)
|
||||||
return;
|
return;
|
||||||
// else we return positions and other things
|
// else we return positions and other things
|
||||||
else {
|
else {
|
||||||
SearchResult searchResult = new SearchResult(foundIndex, textToFind.length(), replaceCheck.isChecked(), textToReplace.getText().toString());
|
SearchResult searchResult = new SearchResult(foundIndex, textToFind.length(), replaceCheck.isChecked(), textToFind.getText().toString(), textToReplace.getText().toString(), regexCheck.isChecked());
|
||||||
searchDialogInterface.onSearchDone(searchResult);
|
searchDialogInterface.onSearchDone(searchResult);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
Toast.makeText(getActivity(), String.format(getString(R.string.occurrences_found), foundIndex.size()), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), String.format(getString(R.string.occurrences_found), foundIndex.size()), Toast.LENGTH_SHORT).show();
|
||||||
// dismiss the dialog
|
// dismiss the dialog
|
||||||
FindTextDialog.this.dismiss();
|
FindTextDialog.this.dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.dialogfragment;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.app.DialogFragment;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.maskyn.fileeditorpro.R;
|
||||||
|
import com.maskyn.fileeditorpro.activity.MainActivity;
|
||||||
|
import com.maskyn.fileeditorpro.preferences.PreferenceHelper;
|
||||||
|
import com.maskyn.fileeditorpro.task.SaveFileTask;
|
||||||
|
import com.maskyn.fileeditorpro.util.GreatUri;
|
||||||
|
import com.maskyn.fileeditorpro.views.DialogHelper;
|
||||||
|
|
||||||
|
// ...
|
||||||
|
@SuppressLint("ValidFragment")
|
||||||
|
public class NewFileDetailsDialog extends DialogFragment {
|
||||||
|
|
||||||
|
private EditText mName;
|
||||||
|
private EditText mFolder;
|
||||||
|
|
||||||
|
GreatUri currentUri;
|
||||||
|
String fileText;
|
||||||
|
String fileEncoding;
|
||||||
|
|
||||||
|
public NewFileDetailsDialog(GreatUri currentUri, String fileText, String fileEncoding) {
|
||||||
|
this.currentUri = currentUri;
|
||||||
|
this.fileText = fileText;
|
||||||
|
this.fileEncoding = fileEncoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
View view = new DialogHelper.Builder(getActivity())
|
||||||
|
.setTitle(R.string.save_as)
|
||||||
|
.setView(R.layout.dialog_fragment_new_file_details)
|
||||||
|
.createSkeletonView();
|
||||||
|
|
||||||
|
this.mName = (EditText) view.findViewById(android.R.id.text1);
|
||||||
|
this.mFolder = (EditText) view.findViewById(android.R.id.text2);
|
||||||
|
|
||||||
|
boolean noName = TextUtils.isEmpty(currentUri.getFileName());
|
||||||
|
boolean noPath = TextUtils.isEmpty(currentUri.getFilePath());
|
||||||
|
|
||||||
|
if (noName) {
|
||||||
|
this.mName.setText(".txt");
|
||||||
|
} else {
|
||||||
|
this.mName.setText(currentUri.getFileName());
|
||||||
|
}
|
||||||
|
if (noPath) {
|
||||||
|
this.mFolder.setText(PreferenceHelper.getWorkingFolder(getActivity()));
|
||||||
|
} else {
|
||||||
|
this.mFolder.setText(currentUri.getParentFolder());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show soft keyboard automatically
|
||||||
|
this.mName.requestFocus();
|
||||||
|
this.mName.setSelection(0);
|
||||||
|
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||||
|
|
||||||
|
return new AlertDialog.Builder(getActivity())
|
||||||
|
.setView(view)
|
||||||
|
.setPositiveButton(android.R.string.ok,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
|
if (!mName.getText().toString().isEmpty() && !mFolder.getText().toString().isEmpty()) {
|
||||||
|
|
||||||
|
File file = new File(mFolder.getText().toString(), mName.getText().toString());
|
||||||
|
try {
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
file.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
final GreatUri newUri = new GreatUri(Uri.fromFile(file), file.getAbsolutePath(), file.getName());
|
||||||
|
|
||||||
|
new SaveFileTask((MainActivity) getActivity(), newUri, fileText, fileEncoding, new SaveFileTask.SaveFileInterface() {
|
||||||
|
@Override
|
||||||
|
public void fileSaved(Boolean success) {
|
||||||
|
if (getActivity() != null) {
|
||||||
|
((MainActivity) getActivity()).savedAFile(newUri, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.setNegativeButton(android.R.string.cancel,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,123 +1,123 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.fragment;
|
package com.maskyn.fileeditorpro.dialogfragment;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.NumberPicker;
|
import android.widget.NumberPicker;
|
||||||
|
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.R;
|
||||||
import sharedcode.turboeditor.views.DialogHelper;
|
import com.maskyn.fileeditorpro.views.DialogHelper;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
public class SeekbarDialog extends DialogFragment {
|
public class NumberPickerDialog extends DialogFragment {
|
||||||
|
|
||||||
private NumberPicker mSeekBar;
|
private NumberPicker mSeekBar;
|
||||||
|
|
||||||
public static SeekbarDialog newInstance(final Actions action) {
|
public static NumberPickerDialog newInstance(final Actions action) {
|
||||||
return SeekbarDialog.newInstance(action, 0, 50, 100);
|
return NumberPickerDialog.newInstance(action, 0, 50, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SeekbarDialog newInstance(final Actions action, final int min, final int current, final int max) {
|
public static NumberPickerDialog newInstance(final Actions action, final int min, final int current, final int max) {
|
||||||
final SeekbarDialog f = new SeekbarDialog();
|
final NumberPickerDialog f = new NumberPickerDialog();
|
||||||
final Bundle args = new Bundle();
|
final Bundle args = new Bundle();
|
||||||
args.putSerializable("action", action);
|
args.putSerializable("action", action);
|
||||||
args.putInt("min", min);
|
args.putInt("min", min);
|
||||||
args.putInt("current", current);
|
args.putInt("current", current);
|
||||||
args.putInt("max", max);
|
args.putInt("max", max);
|
||||||
f.setArguments(args);
|
f.setArguments(args);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
|
||||||
Actions action = (Actions) getArguments().getSerializable("action");
|
Actions action = (Actions) getArguments().getSerializable("action");
|
||||||
int title;
|
int title;
|
||||||
switch (action){
|
switch (action){
|
||||||
case FontSize:
|
case FontSize:
|
||||||
title = R.string.font_size;
|
title = R.string.font_size;
|
||||||
break;
|
break;
|
||||||
case SelectPage:
|
case SelectPage:
|
||||||
title = R.string.goto_page;
|
title = R.string.goto_page;
|
||||||
break;
|
break;
|
||||||
case GoToLine:
|
case GoToLine:
|
||||||
title = R.string.goto_line;
|
title = R.string.goto_line;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
title = R.string.nome_app_turbo_editor;
|
title = R.string.nome_app_turbo_editor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
View view = new DialogHelper.Builder(getActivity())
|
View view = new DialogHelper.Builder(getActivity())
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setView(R.layout.dialog_fragment_seekbar)
|
.setView(R.layout.dialog_fragment_seekbar)
|
||||||
.createSkeletonView();
|
.createSkeletonView();
|
||||||
|
|
||||||
this.mSeekBar = (NumberPicker) view.findViewById(android.R.id.input);
|
this.mSeekBar = (NumberPicker) view.findViewById(android.R.id.input);
|
||||||
this.mSeekBar.setMaxValue(getArguments().getInt("max"));
|
this.mSeekBar.setMaxValue(getArguments().getInt("max"));
|
||||||
this.mSeekBar.setMinValue(getArguments().getInt("min"));
|
this.mSeekBar.setMinValue(getArguments().getInt("min"));
|
||||||
this.mSeekBar.setValue(getArguments().getInt("current"));
|
this.mSeekBar.setValue(getArguments().getInt("current"));
|
||||||
return new AlertDialog.Builder(getActivity())
|
return new AlertDialog.Builder(getActivity())
|
||||||
//.setTitle(title)
|
//.setTitle(title)
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setPositiveButton(android.R.string.ok,
|
.setPositiveButton(android.R.string.ok,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
returnData();
|
returnData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.setNegativeButton(android.R.string.cancel,
|
.setNegativeButton(android.R.string.cancel,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
void returnData() {
|
void returnData() {
|
||||||
ISeekbarDialog target = (ISeekbarDialog) getTargetFragment();
|
INumberPickerDialog target = (INumberPickerDialog) getTargetFragment();
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
target = (ISeekbarDialog) getActivity();
|
target = (INumberPickerDialog) getActivity();
|
||||||
}
|
}
|
||||||
target.onSeekbarDialogDismissed(
|
target.onNumberPickerDialogDismissed(
|
||||||
(Actions) getArguments().getSerializable("action"),
|
(Actions) getArguments().getSerializable("action"),
|
||||||
mSeekBar.getValue()
|
mSeekBar.getValue()
|
||||||
);
|
);
|
||||||
this.dismiss();
|
this.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Actions {
|
public enum Actions {
|
||||||
FontSize, SelectPage, GoToLine
|
FontSize, SelectPage, GoToLine
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ISeekbarDialog {
|
public interface INumberPickerDialog {
|
||||||
void onSeekbarDialogDismissed(Actions action, int value);
|
void onNumberPickerDialogDismissed(Actions action, int value);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,112 +1,120 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.fragment;
|
package com.maskyn.fileeditorpro.dialogfragment;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Dialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.DialogFragment;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.app.DialogFragment;
|
||||||
import android.os.Bundle;
|
import android.content.DialogInterface;
|
||||||
import android.view.View;
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import android.view.View;
|
||||||
|
|
||||||
import java.io.File;
|
import com.maskyn.fileeditorpro.R;
|
||||||
|
import com.maskyn.fileeditorpro.activity.MainActivity;
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.task.SaveFileTask;
|
||||||
import sharedcode.turboeditor.task.SaveFileTask;
|
import com.maskyn.fileeditorpro.util.GreatUri;
|
||||||
import sharedcode.turboeditor.views.DialogHelper;
|
import com.maskyn.fileeditorpro.views.DialogHelper;
|
||||||
|
|
||||||
public class SaveFileDialog extends DialogFragment {
|
@SuppressLint("ValidFragment")
|
||||||
|
public class SaveFileDialog extends DialogFragment {
|
||||||
public static SaveFileDialog newInstance(String filePath, String text, String encoding) {
|
|
||||||
return newInstance(filePath, text, encoding, false, "");
|
GreatUri uri;
|
||||||
}
|
String text;
|
||||||
|
String encoding;
|
||||||
public static SaveFileDialog newInstance(String filePath, String text, String encoding, boolean openNewFileAfter, String pathOfNewFile) {
|
boolean openNewFileAfter;
|
||||||
SaveFileDialog frag = new SaveFileDialog();
|
GreatUri newUri;
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString("filePath", filePath);
|
@SuppressLint("ValidFragment")
|
||||||
args.putString("text", text);
|
public SaveFileDialog(GreatUri uri, String text, String encoding) {
|
||||||
args.putString("encoding", encoding);
|
this.uri = uri;
|
||||||
args.putBoolean("openNewFileAfter", openNewFileAfter);
|
this.text = text;
|
||||||
args.putString("pathOfNewFile", pathOfNewFile);
|
this.encoding = encoding;
|
||||||
frag.setArguments(args);
|
this.openNewFileAfter = false;
|
||||||
return frag;
|
this.newUri = new GreatUri(Uri.EMPTY, "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ValidFragment")
|
||||||
|
public SaveFileDialog(GreatUri uri, String text, String encoding, boolean openNewFileAfter, GreatUri newUri) {
|
||||||
@Override
|
this.uri = uri;
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
this.text = text;
|
||||||
final String filePath = getArguments().getString("filePath");
|
this.encoding = encoding;
|
||||||
final String text = getArguments().getString("text");
|
this.openNewFileAfter = openNewFileAfter;
|
||||||
final String encoding = getArguments().getString("encoding");
|
this.newUri = newUri;
|
||||||
final String fileName = FilenameUtils.getName(filePath);
|
}
|
||||||
final File file = new File(filePath);
|
|
||||||
|
@Override
|
||||||
View view = new DialogHelper.Builder(getActivity())
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
.setIcon(getResources().getDrawable(R.drawable.ic_action_save))
|
|
||||||
.setTitle(R.string.salva)
|
View view = new DialogHelper.Builder(getActivity())
|
||||||
.setMessage(String.format(getString(R.string.save_changes), fileName))
|
.setIcon(getResources().getDrawable(R.drawable.ic_action_save))
|
||||||
.createCommonView();
|
.setTitle(R.string.salva)
|
||||||
|
.setMessage(String.format(getString(R.string.save_changes), uri.getFileName()))
|
||||||
return new AlertDialog.Builder(getActivity())
|
.createCommonView();
|
||||||
.setView(view)
|
|
||||||
.setPositiveButton(R.string.salva,
|
return new AlertDialog.Builder(getActivity())
|
||||||
new DialogInterface.OnClickListener() {
|
.setView(view)
|
||||||
@Override
|
.setPositiveButton(R.string.salva,
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
new DialogInterface.OnClickListener() {
|
||||||
if (!fileName.isEmpty())
|
@Override
|
||||||
new SaveFileTask(getActivity(), filePath, text,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
encoding).execute();
|
if (uri.getFileName().isEmpty()) {
|
||||||
else {
|
NewFileDetailsDialog dialogFrag =
|
||||||
NewFileDetailsDialog dialogFrag =
|
new NewFileDetailsDialog(uri,text,
|
||||||
NewFileDetailsDialog.newInstance(text,
|
encoding);
|
||||||
encoding);
|
dialogFrag.show(getFragmentManager().beginTransaction(),
|
||||||
dialogFrag.show(getFragmentManager().beginTransaction(),
|
"dialog");
|
||||||
"dialog");
|
} else {
|
||||||
}
|
new SaveFileTask((MainActivity) getActivity(), uri, text,
|
||||||
}
|
encoding, new SaveFileTask.SaveFileInterface() {
|
||||||
}
|
@Override
|
||||||
)
|
public void fileSaved(Boolean success) {
|
||||||
.setNeutralButton(android.R.string.cancel, null)
|
if (getActivity() != null) {
|
||||||
.setNegativeButton(R.string.no,
|
((MainActivity) getActivity()).savedAFile(uri, true);
|
||||||
new DialogInterface.OnClickListener() {
|
}
|
||||||
@Override
|
}
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
}).execute();
|
||||||
ISaveDialog target = (ISaveDialog) getTargetFragment();
|
}
|
||||||
if (target == null) {
|
}
|
||||||
target = (ISaveDialog) getActivity();
|
}
|
||||||
}
|
)
|
||||||
target.userDoesntWantToSave(
|
.setNeutralButton(android.R.string.cancel, null)
|
||||||
getArguments().getBoolean("openNewFileAfter"),
|
.setNegativeButton(R.string.no,
|
||||||
getArguments().getString("pathOfNewFile")
|
new DialogInterface.OnClickListener() {
|
||||||
);
|
@Override
|
||||||
}
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
}
|
ISaveDialog target = (ISaveDialog) getTargetFragment();
|
||||||
)
|
if (target == null) {
|
||||||
.create();
|
target = (ISaveDialog) getActivity();
|
||||||
}
|
}
|
||||||
|
target.userDoesntWantToSave(
|
||||||
public interface ISaveDialog {
|
openNewFileAfter, newUri
|
||||||
void userDoesntWantToSave(boolean openNewFile, String pathOfNewFile);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ISaveDialog {
|
||||||
|
void userDoesntWantToSave(boolean openNewFile, GreatUri newUri);
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.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 com.maskyn.fileeditorpro.R;
|
||||||
|
import com.maskyn.fileeditorpro.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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
@ -17,16 +17,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.maskyn.fileeditor;
|
package com.maskyn.fileeditorpro.preferences;
|
||||||
|
|
||||||
import android.app.Application;
|
public enum PreferenceChangeType {
|
||||||
import android.test.ApplicationTestCase;
|
FONT_SIZE, ENCODING, SYNTAX, WRAP_CONTENT, MONOSPACE, LINE_NUMERS, THEME_CHANGE, TEXT_SUGGESTIONS, READ_ONLY, ACCESSORY_VIEW
|
||||||
|
}
|
||||||
/**
|
|
||||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
|
||||||
*/
|
|
||||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
|
||||||
public ApplicationTest() {
|
|
||||||
super(Application.class);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,161 +1,242 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.preferences;
|
package com.maskyn.fileeditorpro.preferences;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
public final class PreferenceHelper {
|
import java.io.File;
|
||||||
|
|
||||||
public static final String SD_CARD_ROOT = Environment.getExternalStorageDirectory().getAbsolutePath();
|
import com.maskyn.fileeditorpro.util.Device;
|
||||||
|
|
||||||
private PreferenceHelper() {
|
public final class PreferenceHelper {
|
||||||
}
|
|
||||||
|
//public static final String SD_CARD_ROOT = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||||
// Getter Methods
|
|
||||||
|
private PreferenceHelper() {
|
||||||
private static SharedPreferences getPrefs(Context context) {
|
}
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
}
|
// Getter Methods
|
||||||
|
|
||||||
private static SharedPreferences.Editor getEditor(Context context) {
|
private static SharedPreferences getPrefs(Context context) {
|
||||||
return getPrefs(context).edit();
|
return PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getUseMonospace(Context context) {
|
private static SharedPreferences.Editor getEditor(Context context) {
|
||||||
return getPrefs(context).getBoolean("use_monospace", false);
|
return getPrefs(context).edit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getLineNumbers(Context context) {
|
public static boolean getUseMonospace(Context context) {
|
||||||
return getPrefs(context).getBoolean("editor_line_numbers", true);
|
return getPrefs(context).getBoolean("use_monospace", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getSyntaxHiglight(Context context) {
|
public static boolean getUseAccessoryView(Context context) {
|
||||||
return getPrefs(context).getBoolean("editor_syntax_highlight", false);
|
return getPrefs(context).getBoolean("accessory_view", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getWrapContent(Context context) {
|
public static boolean getUseStorageAccessFramework(Context context) {
|
||||||
return getPrefs(context).getBoolean("editor_wrap_content", true);
|
return getPrefs(context).getBoolean("storage_access_framework", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getLightTheme(Context context) {
|
public static boolean getLineNumbers(Context context) {
|
||||||
return getPrefs(context).getBoolean("light_theme", false);
|
return getPrefs(context).getBoolean("editor_line_numbers", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getSuggestionActive(Context context) {
|
public static boolean getSyntaxHighlight(Context context) {
|
||||||
return getPrefs(context).getBoolean("suggestion_active", false);
|
return getPrefs(context).getBoolean("editor_syntax_highlight", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getAutoEncoding(Context context) {
|
public static boolean getWrapContent(Context context) {
|
||||||
return getPrefs(context).getBoolean("autoencoding", true);
|
return getPrefs(context).getBoolean("editor_wrap_content", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getSendErrorReports(Context context) {
|
public static int getTheme(Context context) {
|
||||||
return getPrefs(context).getBoolean("send_error_reports", true);
|
return getPrefs(context).getInt("theme", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getEncoding(Context context) {
|
public static boolean getDarkTheme(Context context) {
|
||||||
return getPrefs(context).getString("editor_encoding", "UTF-8");
|
return getPrefs(context).getInt("theme", 0) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getFontSize(Context context) {
|
public static boolean getLightTheme(Context context) {
|
||||||
return getPrefs(context).getInt("font_size", 16);
|
return getPrefs(context).getInt("theme", 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getWorkingFolder(Context context) {
|
public static boolean getBlackTheme(Context context) {
|
||||||
return getPrefs(context).getString("working_folder", SD_CARD_ROOT);
|
return getPrefs(context).getInt("theme", 0) == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getSavedPaths(Context context) {
|
public static boolean getSuggestionActive(Context context) {
|
||||||
return getPrefs(context).getString("savedPaths", "").split(",");
|
return getPrefs(context).getBoolean("suggestion_active", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getPageSystemButtonsPopupShown(Context context) {
|
public static boolean getAutoEncoding(Context context) {
|
||||||
return getPrefs(context).getBoolean("page_system_button_popup_shown", false);
|
return getPrefs(context).getBoolean("autoencoding", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getAutoSave(Context context) {
|
public static boolean getSendErrorReports(Context context) {
|
||||||
return getPrefs(context).getBoolean("auto_save", false);
|
return getPrefs(context).getBoolean("send_error_reports", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getReadOnly(Context context) {
|
public static String getEncoding(Context context) {
|
||||||
return getPrefs(context).getBoolean("read_only", false);
|
return getPrefs(context).getString("editor_encoding", "UTF-16");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getIgnoreBackButton(Context context) {
|
public static int getFontSize(Context context) {
|
||||||
return getPrefs(context).getBoolean("ignore_back_button", false);
|
return getPrefs(context).getInt("font_size", 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getPageSystemEnabled(Context context) {
|
public static String defaultFolder(Context context) {
|
||||||
return getPrefs(context).getBoolean("page_system_active", true);
|
String folder;
|
||||||
}
|
File externalFolder = context.getExternalFilesDir(null);
|
||||||
|
|
||||||
public static boolean hasDonated(Context context) {
|
if (externalFolder != null && Device.isKitKatApi()) {
|
||||||
return getPrefs(context).getBoolean("has_donated", false);
|
folder = externalFolder.getAbsolutePath();
|
||||||
}
|
} else {
|
||||||
// Setter methods
|
folder = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||||
|
}
|
||||||
public static void setUseMonospace(Context context, boolean value) {
|
//folder = context.getExternalFilesDir(null).getAbsolutePath();
|
||||||
getEditor(context).putBoolean("use_monospace", value).commit();
|
//folder = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||||
}
|
return folder;
|
||||||
|
}
|
||||||
public static void setLineNumbers(Context context, boolean value) {
|
|
||||||
getEditor(context).putBoolean("editor_line_numbers", value).commit();
|
public static String getWorkingFolder(Context context) {
|
||||||
}
|
return getPrefs(context).getString("working_folder2", defaultFolder(context));
|
||||||
|
}
|
||||||
public static void setSyntaxHiglight(Context context, boolean value) {
|
|
||||||
getEditor(context).putBoolean("editor_syntax_highlight", value).commit();
|
public static String[] getSavedPaths(Context context) {
|
||||||
}
|
return getPrefs(context).getString("savedPaths2", "").split(",");
|
||||||
|
}
|
||||||
public static void setWrapContent(Context context, boolean value) {
|
|
||||||
getEditor(context).putBoolean("editor_wrap_content", value).commit();
|
public static boolean getPageSystemButtonsPopupShown(Context context) {
|
||||||
}
|
return getPrefs(context).getBoolean("page_system_button_popup_shown", false);
|
||||||
|
}
|
||||||
public static void setAutoencoding(Context context, boolean value) {
|
|
||||||
getEditor(context).putBoolean("autoencoding", value).commit();
|
public static boolean getAutoSave(Context context) {
|
||||||
}
|
return getPrefs(context).getBoolean("auto_save", false);
|
||||||
|
}
|
||||||
public static void setFontSize(Context context, int value) {
|
|
||||||
getEditor(context).putInt("font_size", value).commit();
|
public static boolean getReadOnly(Context context) {
|
||||||
}
|
return getPrefs(context).getBoolean("read_only", false);
|
||||||
|
}
|
||||||
public static void setWorkingFolder(Context context, String value) {
|
|
||||||
getEditor(context).putString("working_folder", value).commit();
|
public static boolean getIgnoreBackButton(Context context) {
|
||||||
}
|
return getPrefs(context).getBoolean("ignore_back_button", false);
|
||||||
|
}
|
||||||
public static void setSavedPaths(Context context, StringBuilder stringBuilder) {
|
|
||||||
getEditor(context).putString("savedPaths", stringBuilder.toString()).commit();
|
public static boolean getSplitText(Context context) {
|
||||||
}
|
return getPrefs(context).getBoolean("page_system_active", true);
|
||||||
|
}
|
||||||
public static void setPageSystemButtonsPopupShown(Context context, boolean value) {
|
|
||||||
getEditor(context).putBoolean("page_system_button_popup_shown", value).commit();
|
public static boolean getSplitByLine(Context context){
|
||||||
}
|
return getPrefs(context).getBoolean("split_by_line", true);
|
||||||
|
}
|
||||||
public static void setReadOnly(Context context, boolean value) {
|
|
||||||
getEditor(context).putBoolean("read_only", value).commit();
|
public static boolean hasDonated(Context context) {
|
||||||
}
|
return getPrefs(context).getBoolean("has_donated", false);
|
||||||
|
}
|
||||||
public static void setHasDonated(Context context, boolean value) {
|
// Setter methods
|
||||||
getEditor(context).putBoolean("has_donated", value);
|
|
||||||
}
|
public static void setUseMonospace(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("use_monospace", value).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setUseAccessoryView(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("accessory_view", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setUseStorageAccessFramework(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("storage_access_framework", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLineNumbers(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("editor_line_numbers", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSyntaxHighlight(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("editor_syntax_highlight", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWrapContent(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("editor_wrap_content", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAutoencoding(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("autoencoding", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFontSize(Context context, int value) {
|
||||||
|
getEditor(context).putInt("font_size", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWorkingFolder(Context context, String value) {
|
||||||
|
getEditor(context).putString("working_folder2", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSavedPaths(Context context, StringBuilder stringBuilder) {
|
||||||
|
getEditor(context).putString("savedPaths2", stringBuilder.toString()).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPageSystemButtonsPopupShown(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("page_system_button_popup_shown", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setReadOnly(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("read_only", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setHasDonated(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("has_donated", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setTheme(Context context, int value) {
|
||||||
|
getEditor(context).putInt("theme", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSuggestionsActive(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("suggestion_active", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAutoSave(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("auto_save", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setIgnoreBackButton(Context context, boolean value) {
|
||||||
|
getEditor(context).putBoolean("ignore_back_button", value).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSplitText(Context context, boolean value) {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setEncoding(Context context, String value) {
|
||||||
|
getEditor(context).putString("editor_encoding", value).commit();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,291 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.preferences;
|
||||||
|
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.SwitchCompat;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.maskyn.fileeditorpro.R;
|
||||||
|
import com.maskyn.fileeditorpro.activity.MainActivity;
|
||||||
|
import com.maskyn.fileeditorpro.dialogfragment.EncodingDialog;
|
||||||
|
import com.maskyn.fileeditorpro.dialogfragment.NumberPickerDialog;
|
||||||
|
import com.maskyn.fileeditorpro.dialogfragment.ThemeDialog;
|
||||||
|
import com.maskyn.fileeditorpro.util.Device;
|
||||||
|
import com.maskyn.fileeditorpro.util.ViewUtils;
|
||||||
|
|
||||||
|
public class SettingsFragment extends Fragment implements NumberPickerDialog.INumberPickerDialog, EncodingDialog.DialogListener, ThemeDialog.DialogListener {
|
||||||
|
|
||||||
|
// Editor Variables
|
||||||
|
private boolean sLineNumbers;
|
||||||
|
private boolean sColorSyntax;
|
||||||
|
private boolean sWrapContent;
|
||||||
|
private boolean sUseMonospace;
|
||||||
|
private boolean sReadOnly;
|
||||||
|
private boolean sAccessoryView;
|
||||||
|
private boolean sStorageAccessFramework;
|
||||||
|
private boolean sSuggestions;
|
||||||
|
private boolean sAutoSave;
|
||||||
|
private boolean sIgnoreBackButton;
|
||||||
|
private boolean sSplitText;
|
||||||
|
private boolean sSplitByLine;
|
||||||
|
private boolean sErrorReports;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
Context context = getActivity();
|
||||||
|
sUseMonospace = PreferenceHelper.getUseMonospace(context);
|
||||||
|
sColorSyntax = PreferenceHelper.getSyntaxHighlight(context);
|
||||||
|
sWrapContent = PreferenceHelper.getWrapContent(context);
|
||||||
|
sLineNumbers = PreferenceHelper.getLineNumbers(context);
|
||||||
|
sReadOnly = PreferenceHelper.getReadOnly(context);
|
||||||
|
sAccessoryView = PreferenceHelper.getUseAccessoryView(context);
|
||||||
|
sStorageAccessFramework = PreferenceHelper.getUseStorageAccessFramework(context);
|
||||||
|
sSuggestions = PreferenceHelper.getSuggestionActive(context);
|
||||||
|
sAutoSave = PreferenceHelper.getAutoSave(context);
|
||||||
|
sIgnoreBackButton = PreferenceHelper.getIgnoreBackButton(context);
|
||||||
|
sSplitText = PreferenceHelper.getSplitText(context);
|
||||||
|
sSplitByLine = PreferenceHelper.getSplitByLine(context);
|
||||||
|
sErrorReports = PreferenceHelper.getSendErrorReports(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// 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, swSplitByLine, swErrorReports;
|
||||||
|
|
||||||
|
swLineNumbers = (SwitchCompat) rootView.findViewById(R.id.switch_line_numbers);
|
||||||
|
swSyntax = (SwitchCompat) rootView.findViewById(R.id.switch_syntax);
|
||||||
|
swWrapContent = (SwitchCompat) rootView.findViewById(R.id.switch_wrap_content);
|
||||||
|
swMonospace = (SwitchCompat) rootView.findViewById(R.id.switch_monospace);
|
||||||
|
swReadOnly = (SwitchCompat) rootView.findViewById(R.id.switch_read_only);
|
||||||
|
|
||||||
|
swSuggestions = (SwitchCompat) rootView.findViewById(R.id.switch_suggestions_active);
|
||||||
|
swAccessoryView = (SwitchCompat) rootView.findViewById(R.id.switch_accessory_view);
|
||||||
|
swStorageAccessFramework = (SwitchCompat) rootView.findViewById(R.id.switch_storage_access_framework);
|
||||||
|
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);
|
||||||
|
swSyntax.setChecked(sColorSyntax);
|
||||||
|
swWrapContent.setChecked(sWrapContent);
|
||||||
|
swMonospace.setChecked(sUseMonospace);
|
||||||
|
swReadOnly.setChecked(sReadOnly);
|
||||||
|
|
||||||
|
swSuggestions.setChecked(sSuggestions);
|
||||||
|
swAccessoryView.setChecked(sAccessoryView);
|
||||||
|
swStorageAccessFramework.setChecked(sStorageAccessFramework);
|
||||||
|
swAutoSave.setChecked(sAutoSave);
|
||||||
|
swIgnoreBackButton.setChecked(sIgnoreBackButton);
|
||||||
|
swSplitText.setChecked(sSplitText);
|
||||||
|
swSplitByLine.setChecked(sSplitByLine);
|
||||||
|
swErrorReports.setChecked(sErrorReports);
|
||||||
|
|
||||||
|
TextView fontSizeView, encodingView, extraOptionsView, themeView;
|
||||||
|
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(swStorageAccessFramework, Device.hasKitKatApi());
|
||||||
|
|
||||||
|
swLineNumbers.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
PreferenceHelper.setLineNumbers(getActivity(), isChecked);
|
||||||
|
((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.LINE_NUMERS);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swSyntax.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
sColorSyntax = isChecked;
|
||||||
|
PreferenceHelper.setSyntaxHighlight(getActivity(), isChecked);
|
||||||
|
((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.SYNTAX);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swWrapContent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
PreferenceHelper.setWrapContent(getActivity(), isChecked);
|
||||||
|
((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.WRAP_CONTENT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swMonospace.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
sUseMonospace = isChecked;
|
||||||
|
PreferenceHelper.setUseMonospace(getActivity(), isChecked);
|
||||||
|
((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.MONOSPACE);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swReadOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
PreferenceHelper.setReadOnly(getActivity(), isChecked);
|
||||||
|
((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.READ_ONLY);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fontSizeView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int fontMax = 36;
|
||||||
|
int fontCurrent = //(int) (mEditor.getTextSize() / scaledDensity);
|
||||||
|
//fontMax / 2;
|
||||||
|
PreferenceHelper.getFontSize(getActivity());
|
||||||
|
NumberPickerDialog dialogFrag = NumberPickerDialog.newInstance(NumberPickerDialog
|
||||||
|
.Actions
|
||||||
|
.FontSize, 1, fontCurrent, fontMax);
|
||||||
|
dialogFrag.setTargetFragment(SettingsFragment.this, 0);
|
||||||
|
dialogFrag.show(getFragmentManager().beginTransaction(), "dialog");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
encodingView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
EncodingDialog dialogFrag = EncodingDialog.newInstance();
|
||||||
|
dialogFrag.setTargetFragment(SettingsFragment.this, 0);
|
||||||
|
dialogFrag.show(getFragmentManager().beginTransaction(), "dialog");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
extraOptionsView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
View otherOptions = rootView.findViewById(R.id.other_options);
|
||||||
|
boolean isVisible = otherOptions.getVisibility() == View.VISIBLE;
|
||||||
|
ViewUtils.setVisible(otherOptions, !isVisible);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
themeView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
ThemeDialog dialogFrag = ThemeDialog.newInstance();
|
||||||
|
dialogFrag.setTargetFragment(SettingsFragment.this, 0);
|
||||||
|
dialogFrag.show(getFragmentManager().beginTransaction(), "dialog");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swSuggestions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
PreferenceHelper.setSuggestionsActive(getActivity(), isChecked);
|
||||||
|
((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.TEXT_SUGGESTIONS);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swAccessoryView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
PreferenceHelper.setUseAccessoryView(getActivity(), isChecked);
|
||||||
|
((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.ACCESSORY_VIEW);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swStorageAccessFramework.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
PreferenceHelper.setUseStorageAccessFramework(getActivity(), isChecked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swAutoSave.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
PreferenceHelper.setAutoSave(getActivity(), isChecked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swIgnoreBackButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
PreferenceHelper.setIgnoreBackButton(getActivity(), isChecked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swSplitText.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
swErrorReports.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
PreferenceHelper.setSendErrorReport(getActivity(), isChecked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNumberPickerDialogDismissed(NumberPickerDialog.Actions action, int value) {
|
||||||
|
PreferenceHelper.setFontSize(getActivity(), value);
|
||||||
|
((MainActivity) getActivity()).aPreferenceValueWasChanged(PreferenceChangeType.FONT_SIZE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEncodingSelected(String result) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.task;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.ParcelFileDescriptor;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.topjohnwu.superuser.io.SuFileOutputStream;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
import com.maskyn.fileeditorpro.R;
|
||||||
|
import com.maskyn.fileeditorpro.activity.MainActivity;
|
||||||
|
import com.maskyn.fileeditorpro.util.Device;
|
||||||
|
import com.maskyn.fileeditorpro.util.GreatUri;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class SaveFileTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
private final MainActivity activity;
|
||||||
|
private final GreatUri uri;
|
||||||
|
private final String newContent;
|
||||||
|
private final String encoding;
|
||||||
|
private String message;
|
||||||
|
private String positiveMessage, negativeMessage;
|
||||||
|
private SaveFileInterface mCompletionHandler;
|
||||||
|
|
||||||
|
public SaveFileTask(MainActivity activity, GreatUri uri, String newContent, String encoding, SaveFileInterface mCompletionHandler) {
|
||||||
|
this.activity = activity;
|
||||||
|
this.uri = uri;
|
||||||
|
this.newContent = newContent;
|
||||||
|
this.encoding = encoding;
|
||||||
|
this.mCompletionHandler = mCompletionHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
super.onPreExecute();
|
||||||
|
positiveMessage = String.format(activity.getString(R.string.file_saved_with_success), uri.getFileName());
|
||||||
|
negativeMessage = activity.getString(R.string.err_occured);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(final Void... voids) {
|
||||||
|
|
||||||
|
boolean isRootNeeded = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
String filePath = uri.getFilePath();
|
||||||
|
// if the uri has no path
|
||||||
|
if (TextUtils.isEmpty(filePath)) {
|
||||||
|
writeUri(uri.getUri(), newContent, encoding);
|
||||||
|
} else {
|
||||||
|
isRootNeeded = !uri.isWritable();
|
||||||
|
if (isRootNeeded == false) {
|
||||||
|
if (Device.hasKitKatApi())
|
||||||
|
writeUri(uri.getUri(), newContent, encoding);
|
||||||
|
else {
|
||||||
|
FileUtils.write(new java.io.File(filePath),
|
||||||
|
newContent,
|
||||||
|
encoding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if we can read the file associated with the uri
|
||||||
|
else {
|
||||||
|
SuFileOutputStream out = new SuFileOutputStream(uri.getFilePath());
|
||||||
|
IOUtils.write(newContent, out, encoding);
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message = positiveMessage;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
message = e.getMessage();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeUri(Uri uri, String newContent, String encoding) throws IOException {
|
||||||
|
ParcelFileDescriptor pfd = activity.getContentResolver().openFileDescriptor(uri, "w");
|
||||||
|
FileOutputStream fileOutputStream = new FileOutputStream(pfd.getFileDescriptor());
|
||||||
|
fileOutputStream.write(newContent.getBytes(Charset.forName(encoding)));
|
||||||
|
fileOutputStream.close();
|
||||||
|
pfd.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(final Void aVoid) {
|
||||||
|
super.onPostExecute(aVoid);
|
||||||
|
Toast.makeText(activity, message, Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
/*android.content.ClipboardManager clipboard = (android.content.ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
android.content.ClipData clip = android.content.ClipData.newPlainText("Clip",message);
|
||||||
|
clipboard.setPrimaryClip(clip);*/
|
||||||
|
|
||||||
|
if (mCompletionHandler != null)
|
||||||
|
mCompletionHandler.fileSaved(message.equals(positiveMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface SaveFileInterface {
|
||||||
|
void fileSaved(Boolean success);
|
||||||
|
}
|
||||||
|
}
|
@ -1,39 +1,45 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.texteditor;
|
package com.maskyn.fileeditorpro.texteditor;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import sharedcode.turboeditor.util.PixelDipConverter;
|
import com.maskyn.fileeditorpro.preferences.PreferenceHelper;
|
||||||
|
import com.maskyn.fileeditorpro.util.PixelDipConverter;
|
||||||
public class EditTextPadding {
|
|
||||||
|
public class EditTextPadding {
|
||||||
public static int getPaddingWithoutLineNumbers(Context context) {
|
|
||||||
return (int) PixelDipConverter.convertDpToPixel(5, context);
|
public static int getPaddingWithoutLineNumbers(Context context) {
|
||||||
}
|
return (int) PixelDipConverter.convertDpToPixel(5, context);
|
||||||
|
}
|
||||||
public static int getPaddingWithLineNumbers(Context context, float fontSize) {
|
|
||||||
return (int) PixelDipConverter.convertDpToPixel(fontSize * 2f, context);
|
public static int getPaddingBottom(Context context) {
|
||||||
}
|
boolean useAccessoryView = PreferenceHelper.getUseAccessoryView(context);
|
||||||
|
return (int) PixelDipConverter.convertDpToPixel(useAccessoryView ? 50 : 0, context);
|
||||||
public static int getPaddingTop(Context context) {
|
}
|
||||||
return getPaddingWithoutLineNumbers(context);
|
|
||||||
}
|
public static int getPaddingWithLineNumbers(Context context, float fontSize) {
|
||||||
}
|
return (int) PixelDipConverter.convertDpToPixel(fontSize * 2f, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPaddingTop(Context context) {
|
||||||
|
return getPaddingWithoutLineNumbers(context);
|
||||||
|
}
|
||||||
|
}
|
@ -1,58 +1,61 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.texteditor;
|
package com.maskyn.fileeditorpro.texteditor;
|
||||||
|
|
||||||
import org.mozilla.universalchardet.UniversalDetector;
|
import org.mozilla.universalchardet.UniversalDetector;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.InputStream;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.io.InputStream;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
public class FileUtils {
|
|
||||||
public static String getDetectedEncoding(File file) {
|
public class FileUtils {
|
||||||
InputStream is = null;
|
public static String getDetectedEncoding(InputStream is) {
|
||||||
String encoding = null;
|
String encoding = null;
|
||||||
try {
|
try {
|
||||||
is = new FileInputStream(file);
|
UniversalDetector detector = new UniversalDetector(null);
|
||||||
UniversalDetector detector = new UniversalDetector(null);
|
byte[] buf = new byte[4096];
|
||||||
byte[] buf = new byte[4096];
|
int nread;
|
||||||
int nread;
|
while ((nread = is.read(buf)) > 0 && !detector.isDone()) {
|
||||||
while ((nread = is.read(buf)) > 0 && !detector.isDone()) {
|
detector.handleData(buf, 0, nread);
|
||||||
detector.handleData(buf, 0, nread);
|
}
|
||||||
}
|
detector.dataEnd();
|
||||||
detector.dataEnd();
|
encoding = detector.getDetectedCharset();
|
||||||
encoding = detector.getDetectedCharset();
|
} catch (IOException e) {
|
||||||
} catch (IOException e) {
|
// nothing to do
|
||||||
// nothing to do
|
} finally {
|
||||||
} finally {
|
try {
|
||||||
try {
|
is.close();
|
||||||
is.close();
|
} catch (IOException e) {
|
||||||
} catch (IOException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
if (encoding == null) {
|
||||||
if (encoding == null) {
|
return Charset.defaultCharset().name();
|
||||||
return Charset.defaultCharset().name();
|
}
|
||||||
}
|
}
|
||||||
}
|
return encoding;
|
||||||
return encoding;
|
}
|
||||||
}
|
|
||||||
}
|
public static String getDetectedEncoding(File file) throws FileNotFoundException {
|
||||||
|
return getDetectedEncoding(new FileInputStream(file));
|
||||||
|
}
|
||||||
|
}
|
@ -1,128 +1,138 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.texteditor;
|
package com.maskyn.fileeditorpro.texteditor;
|
||||||
|
|
||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
import android.widget.ScrollView;
|
import android.text.TextUtils;
|
||||||
|
import android.widget.ScrollView;
|
||||||
public class LineUtils {
|
|
||||||
private boolean[] toCountLinesArray;
|
public class LineUtils {
|
||||||
private int[] realLines;
|
private boolean[] toCountLinesArray;
|
||||||
|
private int[] realLines;
|
||||||
public boolean[] getToCountLinesArray() {
|
|
||||||
return toCountLinesArray;
|
public boolean[] getGoodLines() {
|
||||||
}
|
return toCountLinesArray;
|
||||||
|
}
|
||||||
public int[] getRealLines() {
|
|
||||||
return realLines;
|
public int[] getRealLines() {
|
||||||
}
|
return realLines;
|
||||||
|
}
|
||||||
public int getYAtLine(ScrollView scrollView, int lineCount, int line) {
|
|
||||||
return scrollView.getChildAt(0).getHeight() / lineCount * line;
|
public static int getYAtLine(ScrollView scrollView, int lineCount, int line) {
|
||||||
}
|
return scrollView.getChildAt(0).getHeight() / lineCount * line;
|
||||||
|
}
|
||||||
public int getFirstVisibleLine(ScrollView scrollView, int childHeight, int lineCount) throws ArithmeticException {
|
|
||||||
int line = (scrollView.getScrollY() * lineCount) / childHeight;
|
public static int getFirstVisibleLine(ScrollView scrollView, int childHeight, int lineCount) throws ArithmeticException {
|
||||||
if (line < 0) line = 0;
|
int line = (scrollView.getScrollY() * lineCount) / childHeight;
|
||||||
return line;
|
if (line < 0) line = 0;
|
||||||
}
|
return line;
|
||||||
|
}
|
||||||
public int getLastVisibleLine(ScrollView scrollView, int childHeight, int lineCount, int deviceHeight) {
|
|
||||||
int line = ((scrollView.getScrollY() + deviceHeight) * lineCount) / childHeight;
|
public static int getLastVisibleLine(ScrollView scrollView, int childHeight, int lineCount, int deviceHeight) {
|
||||||
if (line > lineCount) line = lineCount;
|
int line = ((scrollView.getScrollY() + deviceHeight) * lineCount) / childHeight;
|
||||||
return line;
|
if (line > lineCount) line = lineCount;
|
||||||
}
|
return line;
|
||||||
|
}
|
||||||
public void updateHasNewLineArray(int startingLine, int lineCount, Layout layout, String text) {
|
|
||||||
|
public void updateHasNewLineArray(int startingLine, int lineCount, Layout layout, String text) {
|
||||||
boolean[] hasNewLineArray = new boolean[lineCount];
|
|
||||||
toCountLinesArray = new boolean[lineCount];
|
boolean[] hasNewLineArray = new boolean[lineCount];
|
||||||
realLines = new int[lineCount];
|
toCountLinesArray = new boolean[lineCount];
|
||||||
|
realLines = new int[lineCount];
|
||||||
int i;
|
|
||||||
|
if(TextUtils.isEmpty(text)) {
|
||||||
// for every line on the edittext
|
toCountLinesArray[0] = false;
|
||||||
for (i = 0; i < lineCount; i++) {
|
realLines[0] = 1;
|
||||||
// check if this line contains "\n"
|
return;
|
||||||
hasNewLineArray[i] = text.substring(layout.getLineStart(i), layout.getLineEnd(i)).endsWith("\n");
|
}
|
||||||
// if true
|
|
||||||
if (hasNewLineArray[i]) {
|
int i;
|
||||||
int j = i - 1;
|
|
||||||
while (j > -1 && !hasNewLineArray[j]) {
|
// for every line on the edittext
|
||||||
j--;
|
for (i = 0; i < lineCount; i++) {
|
||||||
}
|
// check if this line contains "\n"
|
||||||
toCountLinesArray[j + 1] = true;
|
//hasNewLineArray[i] = text.substring(layout.getLineStart(i), layout.getLineEnd(i)).endsWith("\n");
|
||||||
|
hasNewLineArray[i] = text.charAt(layout.getLineEnd(i) - 1) == '\n';
|
||||||
}
|
// if true
|
||||||
}
|
if (hasNewLineArray[i]) {
|
||||||
|
int j = i - 1;
|
||||||
int realLine = startingLine; // the first line is not 0, is 1. We start counting from 1
|
while (j > -1 && !hasNewLineArray[j]) {
|
||||||
|
j--;
|
||||||
for (i = 0; i < toCountLinesArray.length; i++) {
|
}
|
||||||
if (toCountLinesArray[i]) {
|
toCountLinesArray[j + 1] = true;
|
||||||
realLine++;
|
|
||||||
}
|
}
|
||||||
realLines[i] = realLine;
|
}
|
||||||
}
|
|
||||||
}
|
toCountLinesArray[lineCount-1] = true;
|
||||||
|
|
||||||
/**
|
int realLine = startingLine; // the first line is not 0, is 1. We start counting from 1
|
||||||
* Gets the line from the index of the letter in the text
|
|
||||||
*
|
for (i = 0; i < toCountLinesArray.length; i++) {
|
||||||
* @param index
|
if (toCountLinesArray[i]) {
|
||||||
* @param lineCount
|
realLine++;
|
||||||
* @param layout
|
}
|
||||||
* @return
|
realLines[i] = realLine;
|
||||||
*/
|
}
|
||||||
public int getLineFromIndex(int index, int lineCount, Layout layout) {
|
}
|
||||||
int line;
|
|
||||||
int currentIndex = 0;
|
/**
|
||||||
|
* Gets the line from the index of the letter in the text
|
||||||
for (line = 0; line < lineCount; line++) {
|
*
|
||||||
currentIndex += layout.getLineEnd(line) - layout.getLineStart(line);
|
* @param index
|
||||||
if (currentIndex > index) {
|
* @param lineCount
|
||||||
break;
|
* @param layout
|
||||||
}
|
* @return
|
||||||
}
|
*/
|
||||||
|
public static int getLineFromIndex(int index, int lineCount, Layout layout) {
|
||||||
return line;
|
int line;
|
||||||
}
|
int currentIndex = 0;
|
||||||
|
|
||||||
public int firstReadLine() {
|
for (line = 0; line < lineCount; line++) {
|
||||||
return realLines[0];
|
currentIndex += layout.getLineEnd(line) - layout.getLineStart(line);
|
||||||
}
|
if (currentIndex > index) {
|
||||||
|
break;
|
||||||
public int lastReadLine() {
|
}
|
||||||
return realLines[realLines.length - 1];
|
}
|
||||||
}
|
|
||||||
|
return line;
|
||||||
public int fakeLineFromRealLine(int realLine) {
|
}
|
||||||
int i;
|
|
||||||
int fakeLine = 0;
|
public int firstReadLine() {
|
||||||
for (i = 0; i < realLines.length; i++) {
|
return realLines[0];
|
||||||
if (realLine == realLines[i]) {
|
}
|
||||||
fakeLine = i;
|
|
||||||
break;
|
public int lastReadLine() {
|
||||||
}
|
return realLines[realLines.length - 1];
|
||||||
}
|
}
|
||||||
return fakeLine;
|
|
||||||
}
|
public int fakeLineFromRealLine(int realLine) {
|
||||||
|
int i;
|
||||||
|
int fakeLine = 0;
|
||||||
|
for (i = 0; i < realLines.length; i++) {
|
||||||
|
if (realLine == realLines[i]) {
|
||||||
|
fakeLine = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fakeLine;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,170 +1,203 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.texteditor;
|
package com.maskyn.fileeditorpro.texteditor;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import sharedcode.turboeditor.preferences.PreferenceHelper;
|
import com.maskyn.fileeditorpro.preferences.PreferenceHelper;
|
||||||
|
|
||||||
public class PageSystem {
|
public class PageSystem {
|
||||||
|
|
||||||
private List<String> pages;
|
private List<String> pages;
|
||||||
private int[] startingLines;
|
private int[] startingLines;
|
||||||
private int currentPage = 0;
|
private int currentPage = 0;
|
||||||
private PageSystemInterface pageSystemInterface;
|
private PageSystemInterface pageSystemInterface;
|
||||||
|
|
||||||
public PageSystem(Context context, PageSystemInterface pageSystemInterface, String text) {
|
public PageSystem(Context context, PageSystemInterface pageSystemInterface, String text) {
|
||||||
this.pageSystemInterface = pageSystemInterface;
|
|
||||||
pages = new LinkedList<>();
|
final int charForPage = 20000;
|
||||||
|
final int firstPageChars = 50000;
|
||||||
int i = 0;
|
final int lineForPage = 250;
|
||||||
int charForPage = 15000;
|
|
||||||
int maxLenghtInOnePage = 30000;
|
|
||||||
int to;
|
this.pageSystemInterface = pageSystemInterface;
|
||||||
int indexOfReturn;
|
pages = new LinkedList<>();
|
||||||
int textLenght = text.length();
|
|
||||||
boolean pageSystemEnabled = PreferenceHelper.getPageSystemEnabled(context);
|
int i = 0;
|
||||||
if (pageSystemEnabled && textLenght > maxLenghtInOnePage) {
|
int to;
|
||||||
while (i < textLenght && pageSystemEnabled) {
|
int nextIndexOfReturn;
|
||||||
to = i + charForPage;
|
final int textLength = text.length();
|
||||||
indexOfReturn = text.indexOf("\n", to);
|
boolean pageSystemEnabled = PreferenceHelper.getSplitText(context);
|
||||||
if (indexOfReturn > to) to = indexOfReturn;
|
boolean splitByLineEnablec = PreferenceHelper.getSplitByLine(context);
|
||||||
if (to > text.length()) to = text.length();
|
|
||||||
pages.add(text.substring(i, to));
|
if (pageSystemEnabled && !splitByLineEnablec) {
|
||||||
i = to + 1;
|
while (i < textLength) {
|
||||||
}
|
// first page is longer
|
||||||
|
to = i + (i == 0 ? firstPageChars : charForPage);
|
||||||
|
nextIndexOfReturn = text.indexOf("\n", to);
|
||||||
if (i == 0)
|
if (nextIndexOfReturn > to) to = nextIndexOfReturn;
|
||||||
pages.add("");
|
if (to > text.length()) to = text.length();
|
||||||
} else {
|
pages.add(text.substring(i, to));
|
||||||
pages.add(text);
|
i = to + 1;
|
||||||
}
|
}
|
||||||
|
if (i == 0)
|
||||||
startingLines = new int[pages.size()];
|
pages.add("");
|
||||||
setStartingLines();
|
} else if(pageSystemEnabled && splitByLineEnablec){
|
||||||
}
|
int linecount = 0;
|
||||||
|
to = 0;
|
||||||
public int getStartingLine() {
|
while (i < textLength) {
|
||||||
return startingLines[currentPage];
|
// first page is longer
|
||||||
}
|
nextIndexOfReturn = text.indexOf("\n", to);
|
||||||
|
if (nextIndexOfReturn > to) {
|
||||||
public String getCurrentPageText() {
|
to = nextIndexOfReturn;
|
||||||
return pages.get(currentPage);
|
linecount++;
|
||||||
}
|
}
|
||||||
|
if (to > text.length()) {
|
||||||
public String getTextOfNextPages(boolean includeCurrent, int nOfPages) {
|
to = text.length();
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
pages.add(text.substring(i, to));
|
||||||
int i;
|
i = to;
|
||||||
for (i = includeCurrent ? 0 : 1; i < nOfPages; i++) {
|
}
|
||||||
if (pages.size() > (currentPage + i)) {
|
if (linecount >= lineForPage) {
|
||||||
stringBuilder.append(pages.get(currentPage + 1));
|
pages.add(text.substring(i, to));
|
||||||
}
|
i = to;
|
||||||
}
|
linecount = 0;
|
||||||
|
}
|
||||||
return stringBuilder.toString();
|
|
||||||
}
|
to++;
|
||||||
|
}
|
||||||
public void savePage(String currentText) {
|
if (i == 0)
|
||||||
pages.set(currentPage, currentText);
|
pages.add("");
|
||||||
}
|
} else {
|
||||||
|
pages.add(text);
|
||||||
public void nextPage() {
|
}
|
||||||
if (!canReadNextPage()) return;
|
|
||||||
goToPage(currentPage + 1);
|
|
||||||
}
|
startingLines = new int[pages.size()];
|
||||||
|
setStartingLines();
|
||||||
public void prevPage() {
|
}
|
||||||
if (!canReadPrevPage()) return;
|
|
||||||
goToPage(currentPage - 1);
|
public int getStartingLine() {
|
||||||
}
|
return startingLines[currentPage];
|
||||||
|
}
|
||||||
public void goToPage(int page) {
|
|
||||||
if (page >= pages.size()) page = pages.size() - 1;
|
public String getCurrentPageText() {
|
||||||
if (page < 0) page = 0;
|
return pages.get(currentPage);
|
||||||
boolean shouldUpdateLines = page > currentPage && canReadNextPage();
|
}
|
||||||
if (shouldUpdateLines) {
|
|
||||||
String text = getCurrentPageText();
|
public String getTextOfNextPages(boolean includeCurrent, int nOfPages) {
|
||||||
int nOfNewLineNow = (text.length() - text.replace("\n", "").length()) + 1; // normally the last line is not counted so we have to add 1
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
int nOfNewLineBefore = startingLines[currentPage + 1] - startingLines[currentPage];
|
int i;
|
||||||
int difference = nOfNewLineNow - nOfNewLineBefore;
|
for (i = includeCurrent ? 0 : 1; i < nOfPages; i++) {
|
||||||
updateStartingLines(currentPage + 1, difference);
|
if (pages.size() > (currentPage + i)) {
|
||||||
}
|
stringBuilder.append(pages.get(currentPage + 1));
|
||||||
currentPage = page;
|
}
|
||||||
pageSystemInterface.onPageChanged(page);
|
}
|
||||||
}
|
|
||||||
|
return stringBuilder.toString();
|
||||||
public void setStartingLines() {
|
}
|
||||||
int i;
|
|
||||||
int startingLine;
|
public void savePage(String currentText) {
|
||||||
int nOfNewLines;
|
pages.set(currentPage, currentText);
|
||||||
String text;
|
}
|
||||||
startingLines[0] = 0;
|
|
||||||
for (i = 1; i < pages.size(); i++) {
|
public void nextPage() {
|
||||||
text = pages.get(i - 1);
|
if (!canReadNextPage()) return;
|
||||||
nOfNewLines = text.length() - text.replace("\n", "").length() + 1;
|
goToPage(currentPage + 1);
|
||||||
startingLine = startingLines[i - 1] + nOfNewLines;
|
}
|
||||||
startingLines[i] = startingLine;
|
|
||||||
}
|
public void prevPage() {
|
||||||
}
|
if (!canReadPrevPage()) return;
|
||||||
|
goToPage(currentPage - 1);
|
||||||
public void updateStartingLines(int fromPage, int difference) {
|
}
|
||||||
if (difference == 0)
|
|
||||||
return;
|
public void goToPage(int page) {
|
||||||
int i;
|
if (page >= pages.size()) page = pages.size() - 1;
|
||||||
if (fromPage < 1) fromPage = 1;
|
if (page < 0) page = 0;
|
||||||
for (i = fromPage; i < pages.size(); i++) {
|
boolean shouldUpdateLines = page > currentPage && canReadNextPage();
|
||||||
startingLines[i] += difference;
|
if (shouldUpdateLines) {
|
||||||
}
|
String text = getCurrentPageText();
|
||||||
}
|
int nOfNewLineNow = (text.length() - text.replace("\n", "").length()) + 1; // normally the last line is not counted so we have to add 1
|
||||||
|
int nOfNewLineBefore = startingLines[currentPage + 1] - startingLines[currentPage];
|
||||||
public int getMaxPage() {
|
int difference = nOfNewLineNow - nOfNewLineBefore;
|
||||||
return pages.size() - 1;
|
updateStartingLines(currentPage + 1, difference);
|
||||||
}
|
}
|
||||||
|
currentPage = page;
|
||||||
public int getCurrentPage() {
|
pageSystemInterface.onPageChanged(page);
|
||||||
return currentPage;
|
}
|
||||||
}
|
|
||||||
|
public void setStartingLines() {
|
||||||
public String getAllText(String currentPageText) {
|
int i;
|
||||||
pages.set(currentPage, currentPageText);
|
int startingLine;
|
||||||
int i;
|
int nOfNewLines;
|
||||||
StringBuilder allText = new StringBuilder();
|
String text;
|
||||||
for (i = 0; i < pages.size(); i++) {
|
startingLines[0] = 0;
|
||||||
allText.append(pages.get(i)).append("\n");
|
for (i = 1; i < pages.size(); i++) {
|
||||||
}
|
text = pages.get(i - 1);
|
||||||
return allText.toString();
|
nOfNewLines = text.length() - text.replace("\n", "").length() + 1;
|
||||||
}
|
startingLine = startingLines[i - 1] + nOfNewLines;
|
||||||
|
startingLines[i] = startingLine;
|
||||||
public boolean canReadNextPage() {
|
}
|
||||||
return currentPage < pages.size() - 1;
|
}
|
||||||
}
|
|
||||||
|
public void updateStartingLines(int fromPage, int difference) {
|
||||||
public boolean canReadPrevPage() {
|
if (difference == 0)
|
||||||
return currentPage >= 1;
|
return;
|
||||||
}
|
int i;
|
||||||
|
if (fromPage < 1) fromPage = 1;
|
||||||
public interface PageSystemInterface {
|
for (i = fromPage; i < pages.size(); i++) {
|
||||||
void onPageChanged(int page);
|
startingLines[i] += difference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxPage() {
|
||||||
|
return pages.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCurrentPage() {
|
||||||
|
return currentPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAllText(String currentPageText) {
|
||||||
|
pages.set(currentPage, currentPageText);
|
||||||
|
int i;
|
||||||
|
StringBuilder allText = new StringBuilder();
|
||||||
|
for (i = 0; i < pages.size(); i++) {
|
||||||
|
allText.append(pages.get(i));
|
||||||
|
if(i < pages.size() - 1)
|
||||||
|
allText.append("\n");
|
||||||
|
}
|
||||||
|
return allText.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canReadNextPage() {
|
||||||
|
return currentPage < pages.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canReadPrevPage() {
|
||||||
|
return currentPage >= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface PageSystemInterface {
|
||||||
|
void onPageChanged(int page);
|
||||||
|
}
|
||||||
|
}
|
@ -1,134 +1,134 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.texteditor;
|
package com.maskyn.fileeditorpro.texteditor;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.faizmalkani.floatingactionbutton.FloatingActionButton;
|
import com.faizmalkani.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.R;
|
||||||
|
|
||||||
public class PageSystemButtons {
|
public class PageSystemButtons {
|
||||||
|
|
||||||
private static final int TIME_TO_SHOW_FABS = 2000;
|
private static final int TIME_TO_SHOW_FABS = 2000;
|
||||||
final Handler handler = new Handler();
|
final Handler handler = new Handler();
|
||||||
final Runnable runnable = new Runnable() {
|
final Runnable runnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PageSystemButtons.this.next.setVisibility(View.GONE);
|
PageSystemButtons.this.next.setVisibility(View.GONE);
|
||||||
PageSystemButtons.this.prev.setVisibility(View.GONE);
|
PageSystemButtons.this.prev.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
FloatingActionButton prev, next;
|
FloatingActionButton prev, next;
|
||||||
PageButtonsInterface pageButtonsInterface;
|
PageButtonsInterface pageButtonsInterface;
|
||||||
|
|
||||||
public PageSystemButtons(Context context, final PageButtonsInterface pageButtonsInterface, FloatingActionButton prev, FloatingActionButton next) {
|
public PageSystemButtons(Context context, final PageButtonsInterface pageButtonsInterface, FloatingActionButton prev, FloatingActionButton next) {
|
||||||
this.prev = prev;
|
this.prev = prev;
|
||||||
this.next = next;
|
this.next = next;
|
||||||
this.pageButtonsInterface = pageButtonsInterface;
|
this.pageButtonsInterface = pageButtonsInterface;
|
||||||
|
|
||||||
this.next.setColor(context.getResources().getColor(R.color.fab_light));
|
this.next.setColor(context.getResources().getColor(R.color.fab_light));
|
||||||
this.next.setDrawable(context.getResources().getDrawable(R.drawable.ic_keyboard_arrow_right));
|
this.next.setDrawable(context.getResources().getDrawable(R.drawable.ic_keyboard_arrow_right));
|
||||||
|
|
||||||
this.prev.setColor(context.getResources().getColor(R.color.fab_light));
|
this.prev.setColor(context.getResources().getColor(R.color.fab_light));
|
||||||
this.prev.setDrawable(context.getResources().getDrawable(R.drawable.ic_keyboard_arrow_left));
|
this.prev.setDrawable(context.getResources().getDrawable(R.drawable.ic_keyboard_arrow_left));
|
||||||
|
|
||||||
if (pageButtonsInterface.canReadNextPage())
|
if (pageButtonsInterface.canReadNextPage())
|
||||||
next.setVisibility(View.VISIBLE);
|
next.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (pageButtonsInterface.canReadPrevPage())
|
if (pageButtonsInterface.canReadPrevPage())
|
||||||
prev.setVisibility(View.VISIBLE);
|
prev.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
this.next.setOnClickListener(new View.OnClickListener() {
|
this.next.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
pageButtonsInterface.nextPageClicked();
|
pageButtonsInterface.nextPageClicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.next.setOnLongClickListener(new View.OnLongClickListener() {
|
this.next.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
pageButtonsInterface.pageSystemButtonLongClicked();
|
pageButtonsInterface.pageSystemButtonLongClicked();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.prev.setOnClickListener(new View.OnClickListener() {
|
this.prev.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
pageButtonsInterface.prevPageClicked();
|
pageButtonsInterface.prevPageClicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.prev.setOnLongClickListener(new View.OnLongClickListener() {
|
this.prev.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
pageButtonsInterface.pageSystemButtonLongClicked();
|
pageButtonsInterface.pageSystemButtonLongClicked();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateVisibility(boolean autoHide) {
|
public void updateVisibility(boolean autoHide) {
|
||||||
|
|
||||||
if (pageButtonsInterface.canReadNextPage())
|
if (pageButtonsInterface.canReadNextPage())
|
||||||
PageSystemButtons.this.next.setVisibility(View.VISIBLE);
|
PageSystemButtons.this.next.setVisibility(View.VISIBLE);
|
||||||
else
|
else
|
||||||
PageSystemButtons.this.next.setVisibility(View.GONE);
|
PageSystemButtons.this.next.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (pageButtonsInterface.canReadPrevPage())
|
if (pageButtonsInterface.canReadPrevPage())
|
||||||
PageSystemButtons.this.prev.setVisibility(View.VISIBLE);
|
PageSystemButtons.this.prev.setVisibility(View.VISIBLE);
|
||||||
else
|
else
|
||||||
PageSystemButtons.this.prev.setVisibility(View.GONE);
|
PageSystemButtons.this.prev.setVisibility(View.GONE);
|
||||||
|
|
||||||
/*if(pageButtonsInterface.hasNext())
|
/*if(pageButtonsInterface.hasNext())
|
||||||
next.showFab();
|
next.showFab();
|
||||||
else
|
else
|
||||||
next.hideFab();
|
next.hideFab();
|
||||||
|
|
||||||
if(pageButtonsInterface.hasPrev())
|
if(pageButtonsInterface.hasPrev())
|
||||||
prev.showFab();
|
prev.showFab();
|
||||||
else
|
else
|
||||||
prev.hideFab();*/
|
prev.hideFab();*/
|
||||||
|
|
||||||
if (autoHide) {
|
if (autoHide) {
|
||||||
handler.removeCallbacks(runnable);
|
handler.removeCallbacks(runnable);
|
||||||
handler.postDelayed(runnable, TIME_TO_SHOW_FABS);
|
handler.postDelayed(runnable, TIME_TO_SHOW_FABS);
|
||||||
} else {
|
} else {
|
||||||
handler.removeCallbacks(runnable);
|
handler.removeCallbacks(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface PageButtonsInterface {
|
public interface PageButtonsInterface {
|
||||||
public void nextPageClicked();
|
public void nextPageClicked();
|
||||||
|
|
||||||
public void prevPageClicked();
|
public void prevPageClicked();
|
||||||
|
|
||||||
public void pageSystemButtonLongClicked();
|
public void pageSystemButtonLongClicked();
|
||||||
|
|
||||||
public boolean canReadNextPage();
|
public boolean canReadNextPage();
|
||||||
|
|
||||||
public boolean canReadPrevPage();
|
public boolean canReadPrevPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,90 +1,93 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.texteditor;
|
package com.maskyn.fileeditorpro.texteditor;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Patterns {
|
public class Patterns {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public static final int COLOR_NUMBER = 0xffff6600;
|
public static final int COLOR_NUMBER = 0xffff6600;
|
||||||
public static final int COLOR_KEYWORD = 0xff2f6f9f;
|
public static final int COLOR_KEYWORD = 0xff2f6f9f;
|
||||||
public static final int COLOR_ATTR = 0xff4f9fcf;
|
public static final int COLOR_ATTR = 0xff4f9fcf;
|
||||||
public static final int COLOR_ATTR_VALUE = 0xffd44950;
|
public static final int COLOR_ATTR_VALUE = 0xffd44950;
|
||||||
public static final int COLOR_STRING = 0xffd44950;
|
public static final int COLOR_STRING = 0xffd44950;
|
||||||
public static final int COLOR_COMMENT = 0xff999999;
|
public static final int COLOR_COMMENT = 0xff999999;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Strings
|
// Strings
|
||||||
public static final Pattern GENERAL_STRINGS = Pattern.compile("\"(.*?)\"|'(.*?)'");
|
public static final Pattern GENERAL_STRINGS = Pattern.compile("\"(.*?)\"|'(.*?)'");
|
||||||
|
|
||||||
public static final Pattern HTML_OPEN_TAGS = Pattern.compile(
|
public static final Pattern HTML_TAGS = Pattern.compile(
|
||||||
"<([A-Za-z][A-Za-z0-9]*)\\b[^>]*>");
|
"<([A-Za-z][A-Za-z0-9]*)\\b[^>]*>|</([A-Za-z][A-Za-z0-9]*)\\b[^>]*>");
|
||||||
public static final Pattern HTML_CLOSE_TAGS = Pattern.compile(
|
public static final Pattern HTML_ATTRS = Pattern.compile(
|
||||||
"</([A-Za-z][A-Za-z0-9]*)\\b[^>]*>");
|
"(\\S+)=[\"']?((?:.(?![\"']?\\s+(?:\\S+)=|[>\"']))+.)[\"']?");
|
||||||
public static final Pattern HTML_ATTRS = Pattern.compile(
|
|
||||||
"(\\S+)=[\"']?((?:.(?![\"']?\\s+(?:\\S+)=|[>\"']))+.)[\"']?");
|
//static final Pattern CSS_STYLE_NAME= Pattern.compile(
|
||||||
|
// "[ \\t\\n\\r\\f](.+?)\\{([^\\)]+)\\}");
|
||||||
//static final Pattern CSS_STYLE_NAME= Pattern.compile(
|
public static final Pattern CSS_ATTRS = Pattern.compile(
|
||||||
// "[ \\t\\n\\r\\f](.+?)\\{([^\\)]+)\\}");
|
"(.+?):(.+?);");
|
||||||
public static final Pattern CSS_ATTRS = Pattern.compile(
|
public static final Pattern CSS_ATTR_VALUE = Pattern.compile(
|
||||||
"(.+?):(.+?);");
|
":[ \t](.+?);");
|
||||||
public static final Pattern CSS_ATTR_VALUE = Pattern.compile(
|
|
||||||
":[ \t](.+?);");
|
public static final Pattern NUMBERS = Pattern.compile(
|
||||||
|
"(\\b(\\d*[.]?\\d+)\\b)");
|
||||||
public static final Pattern NUMBERS = Pattern.compile(
|
//public static final Pattern CSS_NUMBERS = Pattern.compile(
|
||||||
"\\b(\\d*[.]?\\d+)\\b");
|
// "/^auto$|^[+-]?[0-9]+\\.?([0-9]+)?(px|em|ex|%|in|cm|mm|pt|pc)?$/ig");
|
||||||
public static final Pattern CSS_NUMBERS = Pattern.compile(
|
public static final Pattern SYMBOLS = Pattern.compile(
|
||||||
"/^auto$|^[+-]?[0-9]+\\.?([0-9]+)?(px|em|ex|%|in|cm|mm|pt|pc)?$/ig");
|
"(!|,|\\(|\\)|\\+|\\-|\\*|<|>|=|\\.|\\?|;|\\{|\\}|\\[|\\]|\\|)");
|
||||||
public static final Pattern SYMBOLS = Pattern.compile(
|
public static final Pattern NUMBERS_OR_SYMBOLS = Pattern.compile(NUMBERS.pattern()+"|"+SYMBOLS.pattern());
|
||||||
"(!|,|\\(|\\)|\\+|\\-|\\*|<|>|=|\\.|\\?|;|\\{|\\}|\\[|\\])");
|
public static final Pattern GENERAL_KEYWORDS = Pattern.compile(
|
||||||
public static final Pattern GENERAL_KEYWORDS = Pattern.compile(
|
"(?<=\\b)((alignas)|(alignof)|(and)|(and_eq)|(asm)|(auto)|(bitand)|(bitorbool)|(break)|(case)|(catch)|(char)|("
|
||||||
"\\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"
|
||||||
+ "char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype"
|
+ ")|(default)|(delete)|(do)|(double)|(dynamic_cast)|(echo)|(else)|(enum)|(explicit)|(export)|(extern)|("
|
||||||
+ "|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)|("
|
||||||
+ "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)|("
|
||||||
+ "not|not_eq|null|nullptr|operator|or|or_eq|private|protected|public|register|"
|
+ "reinterpret_cast)|(return)|(short)|(signed)|(sizeof)|(static)|(static_assert)|(static_cast"
|
||||||
+ "reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast"
|
+ ")|(struct)|(switch)|(template)|(this)|(thread_local)|(throw)|(true)|(try)|(typedef)|(typeid)|(typename)|(undefined"
|
||||||
+ "|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);
|
||||||
+ "|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(
|
||||||
public static final Pattern PY_KEYWORDS = Pattern.compile(
|
"(?<=\\b)((int)|(float)|(long)|(complex)|(str)|(unicode)|(list)|(tuple)|(bytearray)|(buffer)|(xrange)|(set)|(frozenset)|(dict)|(bool)" +
|
||||||
"\\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);
|
"|(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)" +
|
||||||
public static final Pattern LUA_KEYWORDS = Pattern.compile(
|
"|(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);
|
||||||
"@[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" +
|
|
||||||
"|(?i)\\b(editsetText|editText|inkey|touch|system.exit|system.expCall|system.getAppPath|system.getCardMnt|system.getSec|system.impCallActionSend|system.impCallActionView|system.setrun|system.setScreen|system.version|El_Psy_Congroo|canvas.drawCircle|canvas.drawCls|canvas.drawLine|canvas.drawRect|canvas.getBmpSize|canvas.getColor|canvas.getg|canvas.getviewSize|canvas.loadBmp|canvas.putCircle|canvas.putCls|canvas.putflush|canvas.putg|canvas.putLine|canvas.putRect|canvas.putrotg|canvas.putWork|canvas.saveBmp|canvas.setMainBmp|canvas.setWorkBmp|canvas.workCls|canvas.workflush|color|canvas.drawText|canvas.drawTextBox|canvas.drawTextCenter|canvas.drawTextRotate|canvas.putText|canvas.putTextBox|canvas.putTextRotate|http.addHeader|http.addParam|http.clrHeader|http.clrParam|http.get|http.post|http.setContentType|http.setPostFile|http.status|dialog|item.add|item.check|item.clear|item.list|item.radio|toast|sensor.getAccel|sensor.setdevAccel|sensor.setdevMagnet|sensor.setdevOrient|sensor.getGdirection|sensor.getMagnet|sensor.getOrient|sound.beep|sound.isPlay|sound.pause|sound.restart|sound.setSoundFile|sound.start|sound.stop|zip.addFile|zip.exec|zip.status|sock.close|sock.connectOpen|sock.getAddress|sock.listenOpen|sock.recv|sock.send|sprite.clear|sprite.define|sprite.init|sprite.move|sprite.put)\\b" +
|
public static final Pattern LUA_KEYWORDS = Pattern.compile(
|
||||||
"|(?i)\\b(assert|collectgarbage|coroutine.create|coroutine.resume|coroutine.running|coroutine.status|coroutine.wrap|coroutine.yield|debug.debug|debug.getfenv|debug.gethook|debug.getinfo|debug.getlocal|debug.getmetatable|debug.getregistry|debug.getupvalue|debug.setfenv|debug.sethook|debug.setlocal|debug.setmetatable|debug.setupvalue|debug.traceback|dofile|error|file:close|file:flush|file:lines|file:read|file:seek|file:setvbuf|file:write|getfenv|getmetatable|io.close|io.flush|io.input|io.lines|io.open|io.output|io.popen|io.read|io.tmpfile|io.type|io.write|ipairs|load|loadfile|loadstring|math.abs|math.acos|math.asin|math.atan2|math.atan|math.ceil|math.cosh|math.cos|math.deg|math.exp|math.floor|math.fmod|math.frexp|math.ldexp|math.log10|math.log|math.max|math.min|math.modf|math.pow|math.rad|math.random|math.randomseed|math.sinh|math.sin|math.sqrt|math.tanh|math.tan|module|next|os.clock|os.date|os.difftime|os.execute|os.exit|os.getenv|os.remove|os.rename|os.setlocale|os.time|os.tmpname|package.cpath|package.loaded|package.loadlib|package.path|package.preload|package.seeal|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|string.byte|string.char|string.dump|string.find|string.format|string.gmatch|string.gsub|string.len|string.lower|string.match|string.rep|string.reverse|string.sub|string.upper|table.concat|table.insert|table.maxn|table.remove|table.sort|tonumber|tostring|type|unpack|xpcall)\\b"
|
"@[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" +
|
||||||
);
|
"|(?i)\\b(editsetText|editText|inkey|touch|system.exit|system.expCall|system.getAppPath|system.getCardMnt|system.getSec|system.impCallActionSend|system.impCallActionView|system.setrun|system.setScreen|system.version|El_Psy_Congroo|canvas.drawCircle|canvas.drawCls|canvas.drawLine|canvas.drawRect|canvas.getBmpSize|canvas.getColor|canvas.getg|canvas.getviewSize|canvas.loadBmp|canvas.putCircle|canvas.putCls|canvas.putflush|canvas.putg|canvas.putLine|canvas.putRect|canvas.putrotg|canvas.putWork|canvas.saveBmp|canvas.setMainBmp|canvas.setWorkBmp|canvas.workCls|canvas.workflush|color|canvas.drawText|canvas.drawTextBox|canvas.drawTextCenter|canvas.drawTextRotate|canvas.putText|canvas.putTextBox|canvas.putTextRotate|http.addHeader|http.addParam|http.clrHeader|http.clrParam|http.get|http.post|http.setContentType|http.setPostFile|http.status|dialog|item.add|item.check|item.clear|item.list|item.radio|toast|sensor.getAccel|sensor.setdevAccel|sensor.setdevMagnet|sensor.setdevOrient|sensor.getGdirection|sensor.getMagnet|sensor.getOrient|sound.beep|sound.isPlay|sound.pause|sound.restart|sound.setSoundFile|sound.start|sound.stop|zip.addFile|zip.exec|zip.status|sock.close|sock.connectOpen|sock.getAddress|sock.listenOpen|sock.recv|sock.send|sprite.clear|sprite.define|sprite.init|sprite.move|sprite.put)\\b" +
|
||||||
|
"|(?i)\\b(assert|collectgarbage|coroutine.create|coroutine.resume|coroutine.running|coroutine.status|coroutine.wrap|coroutine.yield|debug.debug|debug.getfenv|debug.gethook|debug.getinfo|debug.getlocal|debug.getmetatable|debug.getregistry|debug.getupvalue|debug.setfenv|debug.sethook|debug.setlocal|debug.setmetatable|debug.setupvalue|debug.traceback|dofile|error|file:close|file:flush|file:lines|file:read|file:seek|file:setvbuf|file:write|getfenv|getmetatable|io.close|io.flush|io.input|io.lines|io.open|io.output|io.popen|io.read|io.tmpfile|io.type|io.write|ipairs|load|loadfile|loadstring|math.abs|math.acos|math.asin|math.atan2|math.atan|math.ceil|math.cosh|math.cos|math.deg|math.exp|math.floor|math.fmod|math.frexp|math.ldexp|math.log10|math.log|math.max|math.min|math.modf|math.pow|math.rad|math.random|math.randomseed|math.sinh|math.sin|math.sqrt|math.tanh|math.tan|module|next|os.clock|os.date|os.difftime|os.execute|os.exit|os.getenv|os.remove|os.rename|os.setlocale|os.time|os.tmpname|package.cpath|package.loaded|package.loadlib|package.path|package.preload|package.seeal|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|string.byte|string.char|string.dump|string.find|string.format|string.gmatch|string.gsub|string.len|string.lower|string.match|string.rep|string.reverse|string.sub|string.upper|table.concat|table.insert|table.maxn|table.remove|table.sort|tonumber|tostring|type|unpack|xpcall)\\b"
|
||||||
public static final Pattern PHP_VARIABLES = Pattern.compile("\\$\\s*(\\w+)");
|
);
|
||||||
// Comments
|
|
||||||
public static final Pattern XML_COMMENTS = Pattern.compile("(?s)<!--.*?-->");
|
public static final Pattern PHP_VARIABLES = Pattern.compile("\\$\\s*(\\w+)");
|
||||||
public static final Pattern GENERAL_COMMENTS = Pattern.compile(
|
// Comments
|
||||||
"/\\*(?:.|[\\n\\r])*?\\*/|//.*|#.*");
|
public static final Pattern XML_COMMENTS = Pattern.compile("(?s)<!--.*?-->");
|
||||||
public static final Pattern GENERAL_COMMENTS_NO_SLASH = Pattern.compile(
|
public static final Pattern GENERAL_COMMENTS = Pattern.compile(
|
||||||
"/\\*(?:.|[\\n\\r])*?\\*/|#.*");
|
"/\\*(?:.|[\\n\\r])*?\\*/|(?<!:)//.*|#.*");
|
||||||
public static final Pattern SQL_KEYWORDS = Pattern.compile(
|
// same as GENERAL_COMMENTS but without -> //
|
||||||
"\\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 GENERAL_COMMENTS_NO_SLASH = Pattern.compile(
|
||||||
|
"/\\*(?:.|[\\n\\r])*?\\*/|#.*");
|
||||||
|
public static final Pattern SQL_KEYWORDS = Pattern.compile(
|
||||||
public static final Pattern LINK = android.util.Patterns.WEB_URL;
|
"(?<=\\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;
|
||||||
|
|
||||||
|
}
|
@ -1,63 +1,68 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.texteditor;
|
package com.maskyn.fileeditorpro.texteditor;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
public class SearchResult {
|
public class SearchResult {
|
||||||
// list of index
|
// list of index
|
||||||
public LinkedList<Integer> foundIndex;
|
public LinkedList<Integer> foundIndex;
|
||||||
public int textLength;
|
public int textLength;
|
||||||
public boolean isReplace;
|
public boolean isReplace;
|
||||||
public String textToReplace;
|
public String textToReplace;
|
||||||
public int index;
|
public int index;
|
||||||
|
public String whatToSearch;
|
||||||
public SearchResult(LinkedList<Integer> foundIndex, int textLength, boolean isReplace, String textToReplace) {
|
public boolean isRegex;
|
||||||
this.foundIndex = foundIndex;
|
|
||||||
this.textLength = textLength;
|
|
||||||
this.isReplace = isReplace;
|
public SearchResult(LinkedList<Integer> foundIndex, int textLength, boolean isReplace, String whatToSearch, String textToReplace, boolean isRegex) {
|
||||||
this.textToReplace = textToReplace;
|
this.foundIndex = foundIndex;
|
||||||
}
|
this.textLength = textLength;
|
||||||
|
this.isReplace = isReplace;
|
||||||
public void doneReplace() {
|
this.whatToSearch = whatToSearch;
|
||||||
foundIndex.remove(index);
|
this.textToReplace = textToReplace;
|
||||||
int i;
|
this.isRegex = isRegex;
|
||||||
for (i = index; i < foundIndex.size(); i++) {
|
}
|
||||||
foundIndex.set(i, foundIndex.get(i) + textToReplace.length() - textLength);
|
|
||||||
}
|
public void doneReplace() {
|
||||||
index--; // an element was removed so we decrease the index
|
foundIndex.remove(index);
|
||||||
}
|
int i;
|
||||||
|
for (i = index; i < foundIndex.size(); i++) {
|
||||||
public int numberOfResults() {
|
foundIndex.set(i, foundIndex.get(i) + textToReplace.length() - textLength);
|
||||||
return foundIndex.size();
|
}
|
||||||
}
|
index--; // an element was removed so we decrease the index
|
||||||
|
}
|
||||||
public boolean hasNext() {
|
|
||||||
return index < foundIndex.size() - 1;
|
public int numberOfResults() {
|
||||||
}
|
return foundIndex.size();
|
||||||
|
}
|
||||||
public boolean hasPrevious() {
|
|
||||||
return index > 0;
|
public boolean hasNext() {
|
||||||
}
|
return index < foundIndex.size() - 1;
|
||||||
|
}
|
||||||
public boolean canReplaceSomething() {
|
|
||||||
return isReplace && foundIndex.size() > 0;
|
public boolean hasPrevious() {
|
||||||
}
|
return index > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canReplaceSomething() {
|
||||||
|
return isReplace && foundIndex.size() > 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,266 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ContentUris;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.provider.DocumentsContract;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class AccessStorageApi {
|
||||||
|
|
||||||
|
public static Bitmap loadPrescaledBitmap(String filename) throws IOException {
|
||||||
|
// Facebook image size
|
||||||
|
final int IMAGE_MAX_SIZE = 630;
|
||||||
|
|
||||||
|
File file = null;
|
||||||
|
FileInputStream fis;
|
||||||
|
|
||||||
|
BitmapFactory.Options opts;
|
||||||
|
int resizeScale;
|
||||||
|
Bitmap bmp;
|
||||||
|
|
||||||
|
file = new File(filename);
|
||||||
|
|
||||||
|
// This bit determines only the width/height of the bitmap without loading the contents
|
||||||
|
opts = new BitmapFactory.Options();
|
||||||
|
opts.inJustDecodeBounds = true;
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
BitmapFactory.decodeStream(fis, null, opts);
|
||||||
|
fis.close();
|
||||||
|
|
||||||
|
// Find the correct scale value. It should be a power of 2
|
||||||
|
resizeScale = 1;
|
||||||
|
|
||||||
|
if (opts.outHeight > IMAGE_MAX_SIZE || opts.outWidth > IMAGE_MAX_SIZE) {
|
||||||
|
resizeScale = (int) Math.pow(2, (int) Math.round(Math.log(IMAGE_MAX_SIZE / (double) Math.max(opts.outHeight, opts.outWidth)) / Math.log(0.5)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load pre-scaled bitmap
|
||||||
|
opts = new BitmapFactory.Options();
|
||||||
|
opts.inSampleSize = resizeScale;
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
bmp = BitmapFactory.decodeStream(fis, null, opts);
|
||||||
|
|
||||||
|
fis.close();
|
||||||
|
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a file path from a Uri. This will get the the path for Storage Access
|
||||||
|
* Framework Documents, as well as the _data field for the MediaStore and
|
||||||
|
* other file-based ContentProviders.
|
||||||
|
*
|
||||||
|
* @param context The context.
|
||||||
|
* @param uri The Uri to query.
|
||||||
|
* @author paulburke
|
||||||
|
*/
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
public static String getPath(final Context context, final Uri uri) {
|
||||||
|
|
||||||
|
String path = "";
|
||||||
|
|
||||||
|
if (uri == null || uri.equals(Uri.EMPTY))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||||
|
// DocumentProvider
|
||||||
|
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
|
||||||
|
if (isTurboDocument(uri)) {
|
||||||
|
final String docId = DocumentsContract.getDocumentId(uri);
|
||||||
|
final String[] split = docId.split(":");
|
||||||
|
path = "/" + split[1];
|
||||||
|
}
|
||||||
|
// ExternalStorageProvider
|
||||||
|
else if (isExternalStorageDocument(uri)) {
|
||||||
|
|
||||||
|
final String docId = DocumentsContract.getDocumentId(uri);
|
||||||
|
final String[] split = docId.split(":");
|
||||||
|
final String type = split[0];
|
||||||
|
|
||||||
|
if ("primary".equalsIgnoreCase(type)) {
|
||||||
|
path = Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO handle non-primary volumes
|
||||||
|
}
|
||||||
|
// DownloadsProvider
|
||||||
|
else if (isDownloadsDocument(uri)) {
|
||||||
|
|
||||||
|
final String id = DocumentsContract.getDocumentId(uri);
|
||||||
|
final Uri contentUri = ContentUris.withAppendedId(
|
||||||
|
Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
||||||
|
|
||||||
|
path = getDataColumn(context, contentUri, null, null);
|
||||||
|
}
|
||||||
|
// MediaProvider
|
||||||
|
else if (isMediaDocument(uri)) {
|
||||||
|
final String docId = DocumentsContract.getDocumentId(uri);
|
||||||
|
final String[] split = docId.split(":");
|
||||||
|
final String type = split[0];
|
||||||
|
|
||||||
|
Uri contentUri = null;
|
||||||
|
if ("image".equals(type)) {
|
||||||
|
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||||
|
} else if ("video".equals(type)) {
|
||||||
|
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||||
|
} else if ("audio".equals(type)) {
|
||||||
|
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String selection = "_id=?";
|
||||||
|
final String[] selectionArgs = new String[]{
|
||||||
|
split[1]
|
||||||
|
};
|
||||||
|
|
||||||
|
path = getDataColumn(context, contentUri, selection, selectionArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// MediaStore (and general)
|
||||||
|
else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
||||||
|
path = getDataColumn(context, uri, null, null);
|
||||||
|
}
|
||||||
|
// File
|
||||||
|
else if ("file".equalsIgnoreCase(uri.getScheme())) {
|
||||||
|
path = uri.getPath();
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getName(Context context, Uri uri)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (uri == null || uri.equals(Uri.EMPTY))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
String fileName = "";
|
||||||
|
try {
|
||||||
|
String scheme = uri.getScheme();
|
||||||
|
if (scheme.equals("file")) {
|
||||||
|
fileName = uri.getLastPathSegment();
|
||||||
|
}
|
||||||
|
else if (scheme.equals("content")) {
|
||||||
|
String[] proj = { MediaStore.Images.Media.DISPLAY_NAME };
|
||||||
|
Cursor cursor = context.getContentResolver().query(uri, proj, null, null, null);
|
||||||
|
if (cursor != null && cursor.getCount() != 0) {
|
||||||
|
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DISPLAY_NAME);
|
||||||
|
cursor.moveToFirst();
|
||||||
|
fileName = cursor.getString(columnIndex);
|
||||||
|
}
|
||||||
|
if (cursor != null) {
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getExtension(Context context, Uri uri) {
|
||||||
|
return FilenameUtils.getExtension(getName(context, uri));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of the data column for this Uri. This is useful for
|
||||||
|
* MediaStore Uris, and other file-based ContentProviders.
|
||||||
|
*
|
||||||
|
* @param context The context.
|
||||||
|
* @param uri The Uri to query.
|
||||||
|
* @param selection (Optional) Filter used in the query.
|
||||||
|
* @param selectionArgs (Optional) Selection arguments used in the query.
|
||||||
|
* @return The value of the _data column, which is typically a file path.
|
||||||
|
*/
|
||||||
|
public static String getDataColumn(Context context, Uri uri, String selection,
|
||||||
|
String[] selectionArgs) {
|
||||||
|
|
||||||
|
Cursor cursor = null;
|
||||||
|
final String column = "_data";
|
||||||
|
final String[] projection = {
|
||||||
|
column
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
|
||||||
|
null);
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
final int column_index = cursor.getColumnIndexOrThrow(column);
|
||||||
|
return cursor.getString(column_index);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (cursor != null)
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uri The Uri to check.
|
||||||
|
* @return Whether the Uri authority is ExternalStorageProvider.
|
||||||
|
*/
|
||||||
|
public static boolean isExternalStorageDocument(Uri uri) {
|
||||||
|
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uri The Uri to check.
|
||||||
|
* @return Whether the Uri authority is DownloadsProvider.
|
||||||
|
*/
|
||||||
|
public static boolean isDownloadsDocument(Uri uri) {
|
||||||
|
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uri The Uri to check.
|
||||||
|
* @return Whether the Uri authority is MediaProvider.
|
||||||
|
*/
|
||||||
|
public static boolean isMediaDocument(Uri uri) {
|
||||||
|
return "com.android.providers.media.documents".equals(uri.getAuthority());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param uri The Uri to check.
|
||||||
|
* @return Whether the Uri authority is Turbo Storage.
|
||||||
|
*/
|
||||||
|
public static boolean isTurboDocument(Uri uri) {
|
||||||
|
return "com.maskyn.fileeditorpro.util.documents".equals(uri.getAuthority());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.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 com.maskyn.fileeditorpro.R;
|
||||||
|
import com.maskyn.fileeditorpro.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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,138 +1,138 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.util;/*
|
package com.maskyn.fileeditorpro.util;/*
|
||||||
* The Alphanum Algorithm is an improved sorting algorithm for strings
|
* The Alphanum Algorithm is an improved sorting algorithm for strings
|
||||||
* containing numbers. Instead of sorting numbers in ASCII order like
|
* containing numbers. Instead of sorting numbers in ASCII order like
|
||||||
* a standard sort, this algorithm sorts numbers in numeric order.
|
* a standard sort, this algorithm sorts numbers in numeric order.
|
||||||
*
|
*
|
||||||
* The Alphanum Algorithm is discussed at http://www.DaveKoelle.com
|
* The Alphanum Algorithm is discussed at http://www.DaveKoelle.com
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or any later version.
|
* version 2.1 of the License, or any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an updated version with enhancements made by Daniel Migowski, Andre Bogus, and David
|
* This is an updated version with enhancements made by Daniel Migowski, Andre Bogus, and David
|
||||||
* Koelle
|
* Koelle
|
||||||
* <p/>
|
* <p/>
|
||||||
* To convert to use Templates (Java 1.5+): - Change "implements Comparator" to "implements
|
* To convert to use Templates (Java 1.5+): - Change "implements Comparator" to "implements
|
||||||
* Comparator<String>" - Change "compare(Object o1, Object o2)" to "compare(String s1, String s2)" -
|
* Comparator<String>" - Change "compare(Object o1, Object o2)" to "compare(String s1, String s2)" -
|
||||||
* Remove the type checking and casting in compare().
|
* Remove the type checking and casting in compare().
|
||||||
* <p/>
|
* <p/>
|
||||||
* To use this class: Use the static "sort" method from the java.util.Collections class:
|
* To use this class: Use the static "sort" method from the java.util.Collections class:
|
||||||
* Collections.sort(your list, new AlphanumComparator());
|
* Collections.sort(your list, new AlphanumComparator());
|
||||||
*/
|
*/
|
||||||
public class AlphanumComparator implements Comparator {
|
public class AlphanumComparator implements Comparator {
|
||||||
private boolean isDigit(char ch) {
|
private boolean isDigit(char ch) {
|
||||||
return ch >= 48 && ch <= 57;
|
return ch >= 48 && ch <= 57;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Length of string is passed in for improved efficiency (only need to calculate it once) *
|
* Length of string is passed in for improved efficiency (only need to calculate it once) *
|
||||||
*/
|
*/
|
||||||
private String getChunk(String s, int slength, int marker) {
|
private String getChunk(String s, int slength, int marker) {
|
||||||
StringBuilder chunk = new StringBuilder();
|
StringBuilder chunk = new StringBuilder();
|
||||||
char c = s.charAt(marker);
|
char c = s.charAt(marker);
|
||||||
chunk.append(c);
|
chunk.append(c);
|
||||||
marker++;
|
marker++;
|
||||||
if (isDigit(c)) {
|
if (isDigit(c)) {
|
||||||
while (marker < slength) {
|
while (marker < slength) {
|
||||||
c = s.charAt(marker);
|
c = s.charAt(marker);
|
||||||
if (!isDigit(c)) {
|
if (!isDigit(c)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
chunk.append(c);
|
chunk.append(c);
|
||||||
marker++;
|
marker++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (marker < slength) {
|
while (marker < slength) {
|
||||||
c = s.charAt(marker);
|
c = s.charAt(marker);
|
||||||
if (isDigit(c)) {
|
if (isDigit(c)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
chunk.append(c);
|
chunk.append(c);
|
||||||
marker++;
|
marker++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return chunk.toString();
|
return chunk.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTheString(Object obj) {
|
public String getTheString(Object obj) {
|
||||||
return (String) obj;
|
return (String) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compare(Object o1, Object o2) {
|
public int compare(Object o1, Object o2) {
|
||||||
String s1 = getTheString(o1);
|
String s1 = getTheString(o1);
|
||||||
String s2 = getTheString(o2);
|
String s2 = getTheString(o2);
|
||||||
|
|
||||||
int thisMarker = 0;
|
int thisMarker = 0;
|
||||||
int thatMarker = 0;
|
int thatMarker = 0;
|
||||||
int s1Length = s1.length();
|
int s1Length = s1.length();
|
||||||
int s2Length = s2.length();
|
int s2Length = s2.length();
|
||||||
|
|
||||||
while (thisMarker < s1Length && thatMarker < s2Length) {
|
while (thisMarker < s1Length && thatMarker < s2Length) {
|
||||||
String thisChunk = getChunk(s1, s1Length, thisMarker);
|
String thisChunk = getChunk(s1, s1Length, thisMarker);
|
||||||
thisMarker += thisChunk.length();
|
thisMarker += thisChunk.length();
|
||||||
|
|
||||||
String thatChunk = getChunk(s2, s2Length, thatMarker);
|
String thatChunk = getChunk(s2, s2Length, thatMarker);
|
||||||
thatMarker += thatChunk.length();
|
thatMarker += thatChunk.length();
|
||||||
|
|
||||||
// If both chunks contain numeric characters, sort them numerically
|
// If both chunks contain numeric characters, sort them numerically
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) {
|
if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) {
|
||||||
// Simple chunk comparison by length.
|
// Simple chunk comparison by length.
|
||||||
int thisChunkLength = thisChunk.length();
|
int thisChunkLength = thisChunk.length();
|
||||||
result = thisChunkLength - thatChunk.length();
|
result = thisChunkLength - thatChunk.length();
|
||||||
// If equal, the first different number counts
|
// If equal, the first different number counts
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
for (int i = 0; i < thisChunkLength; i++) {
|
for (int i = 0; i < thisChunkLength; i++) {
|
||||||
result = thisChunk.charAt(i) - thatChunk.charAt(i);
|
result = thisChunk.charAt(i) - thatChunk.charAt(i);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result = thisChunk.compareTo(thatChunk);
|
result = thisChunk.compareTo(thatChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s1Length - s2Length;
|
return s1Length - s2Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,52 +1,52 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.util;
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.ActivityOptionsCompat;
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
public class AnimationUtils {
|
public class AnimationUtils {
|
||||||
public static Bundle getScaleBundle(View view) {
|
public static Bundle getScaleBundle(View view) {
|
||||||
return ActivityOptionsCompat.makeScaleUpAnimation(
|
return ActivityOptionsCompat.makeScaleUpAnimation(
|
||||||
view, 0, 0, view.getWidth(), view.getHeight()).toBundle();
|
view, 0, 0, view.getWidth(), view.getHeight()).toBundle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startActivityWithScale(@NonNull Activity startActivity, @NonNull Intent subActivity, @NonNull boolean forResult, @Nullable int code, @NonNull View view) {
|
public static void startActivityWithScale(@NonNull Activity startActivity, @NonNull Intent subActivity, @NonNull boolean forResult, @Nullable int code, @NonNull View view) {
|
||||||
if(forResult){
|
if(forResult){
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
|
||||||
startActivity.startActivityForResult(subActivity, code, AnimationUtils.getScaleBundle
|
startActivity.startActivityForResult(subActivity, code, AnimationUtils.getScaleBundle
|
||||||
(view));
|
(view));
|
||||||
else
|
else
|
||||||
startActivity.startActivityForResult(subActivity, code);
|
startActivity.startActivityForResult(subActivity, code);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
|
||||||
startActivity.startActivity(subActivity, AnimationUtils.getScaleBundle
|
startActivity.startActivity(subActivity, AnimationUtils.getScaleBundle
|
||||||
(view));
|
(view));
|
||||||
else
|
else
|
||||||
startActivity.startActivity(subActivity);
|
startActivity.startActivity(subActivity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,42 +1,42 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.util;
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
|
||||||
public class AppInfoHelper {
|
public class AppInfoHelper {
|
||||||
public static String getApplicationName(final Context context) {
|
public static String getApplicationName(final Context context) {
|
||||||
final ApplicationInfo applicationInfo = context.getApplicationInfo();
|
final ApplicationInfo applicationInfo = context.getApplicationInfo();
|
||||||
return context.getString(applicationInfo.labelRes);
|
return context.getString(applicationInfo.labelRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCurrentVersion(final Context context) {
|
public static String getCurrentVersion(final Context context) {
|
||||||
try {
|
try {
|
||||||
final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(),
|
final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(),
|
||||||
0);
|
0);
|
||||||
return packageInfo.versionName;
|
return packageInfo.versionName;
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
@ -16,9 +16,10 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package sharedcode.turboeditor.util;
|
|
||||||
|
|
||||||
import sharedcode.turboeditor.BuildConfig;
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
|
import com.maskyn.fileeditorpro.BuildConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Artem on 30.12.13.
|
* Created by Artem on 30.12.13.
|
@ -1,14 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
@ -16,7 +16,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package sharedcode.turboeditor.util;
|
|
||||||
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
@ -52,6 +53,14 @@ public class Device {
|
|||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@code true} if device is running
|
||||||
|
* {@link android.os.Build.VERSION_CODES#KITKAT KitKat} {@code false} otherwise.
|
||||||
|
*/
|
||||||
|
public static boolean isKitKatApi() {
|
||||||
|
return Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {@code true} if device is running
|
* @return {@code true} if device is running
|
||||||
* {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2 Jelly Bean 4.3} or higher, {@code false} otherwise.
|
* {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2 Jelly Bean 4.3} or higher, {@code false} otherwise.
|
100
app/src/main/java/com/maskyn/fileeditorpro/util/GreatUri.java
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mac on 19/03/15.
|
||||||
|
*/
|
||||||
|
public class GreatUri {
|
||||||
|
private Uri uri;
|
||||||
|
private String filePath;
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
public GreatUri(Uri uri, String filePath, String fileName) {
|
||||||
|
this.uri = uri;
|
||||||
|
this.filePath = filePath;
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return new HashCodeBuilder(17, 31). // two randomly chosen prime numbers
|
||||||
|
// if deriving: appendSuper(super.hashCode()).
|
||||||
|
append(uri).
|
||||||
|
toHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (!(obj instanceof GreatUri))
|
||||||
|
return false;
|
||||||
|
if (obj == this)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
GreatUri rhs = (GreatUri) obj;
|
||||||
|
return new EqualsBuilder().
|
||||||
|
// if deriving: appendSuper(super.equals(obj)).
|
||||||
|
append(uri, rhs.uri).
|
||||||
|
isEquals();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Uri getUri() {
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUri(Uri uri) {
|
||||||
|
this.uri = uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFilePath() {
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilePath(String filePath) {
|
||||||
|
this.filePath = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentFolder() {
|
||||||
|
return new File(filePath).getParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileName(String fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isReadable() {
|
||||||
|
return new File(getFilePath()).canRead();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWritable() {
|
||||||
|
return new File(getFilePath()).canWrite();
|
||||||
|
}
|
||||||
|
}
|
@ -1,32 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor;
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
import android.app.Application;
|
public interface IHomeActivity {
|
||||||
import android.test.ApplicationTestCase;
|
public abstract boolean showInterstitial();
|
||||||
|
}
|
||||||
/**
|
|
||||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
|
||||||
*/
|
|
||||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
|
||||||
public ApplicationTest() {
|
|
||||||
super(Application.class);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +1,57 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.util;
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
public class MimeTypes {
|
public class MimeTypes {
|
||||||
public static final String[] MIME_TEXT = {
|
public static final String[] MIME_TEXT = {
|
||||||
"ajx", "am", "asa", "asc", "asp", "aspx", "awk", "bat", "c", "cdf", "cf", "cfg", "cfm", "cgi", "cnf", "conf",
|
"ajx", "am", "asa", "asc", "asp", "aspx", "awk", "bat", "c", "cdf", "cf", "cfg", "cfm", "cgi", "cnf", "conf",
|
||||||
"cc", "cpp", "css", "csv", "ctl", "dat", "dhtml", "diz", "file", "forward", "grp", "h", "hh", "hpp", "hqx", "hta", "htaccess",
|
"cc", "cpp", "css", "csv", "ctl", "dat", "dhtml", "diz", "file", "forward", "grp", "h", "hh", "hpp", "hqx", "hta", "htaccess",
|
||||||
"htc", "htm", "html", "htpasswd", "htt", "htx", "in", "inc", "info", "ini", "ink", "java", "js", "jsp", "key", "latex", "log",
|
"htc", "htm", "html", "htpasswd", "htt", "htx", "in", "inc", "info", "ini", "ink", "java", "js", "jsp", "key", "latex", "log",
|
||||||
"logfile", "m3u", "m4", "m4a", "mak", "map", "md", "markdown", "model", "msg", "nfo", "nsi", "info", "old", "pas", "patch", "perl",
|
"logfile", "m3u", "m4", "m4a", "mak", "map", "md", "markdown", "model", "msg", "nfo", "nsi", "info", "old", "pas", "patch", "perl",
|
||||||
"php", "php2", "php3", "php4", "php5", "php6", "phtml", "pix", "pl", "pm", "po", "pwd", "py", "qmail", "rb", "rbl", "rbw",
|
"php", "php2", "php3", "php4", "php5", "php6", "phtml", "pix", "pl", "pm", "po", "pwd", "py", "qmail", "rb", "rbl", "rbw",
|
||||||
"readme", "reg", "rss", "rtf", "ruby", "session", "setup", "sh", "shtm", "shtml", "sql", "ssh", "stm", "style", "svg", "tcl",
|
"readme", "reg", "rss", "rtf", "ruby", "session", "setup", "sh", "shtm", "shtml", "sql", "ssh", "stm", "style", "svg", "tcl",
|
||||||
"tex", "text", "threads", "tmpl", "tpl", "txt", "ubb", "vbs", "xhtml", "xml", "xrc", "xsl"
|
"tex", "text", "threads", "tmpl", "tpl", "txt", "ubb", "vbs", "xhtml", "xml", "xrc", "xsl"
|
||||||
};
|
};
|
||||||
public static final String[] MIME_CODE = {
|
public static final String[] MIME_CODE = {
|
||||||
"cs", "php", "js", "java", "py", "rb", "aspx", "cshtml", "vbhtml", "go", "c", "h", "cc", "cpp", "hh", "hpp", "pl", "pm", "t", "pod",
|
"cs", "php", "js", "java", "py", "rb", "aspx", "cshtml", "vbhtml", "go", "c", "h", "cc", "cpp", "hh", "hpp", "pl", "pm", "t", "pod",
|
||||||
"m", "f", "for", "f90", "f95", "asp", "json", "wiki", "lua", "r"
|
"m", "f", "for", "f90", "f95", "asp", "json", "wiki", "lua", "r"
|
||||||
};
|
};
|
||||||
public static final String[] MIME_HTML = {
|
public static final String[] MIME_HTML = {
|
||||||
"htm", "html", "xhtml"
|
"htm", "html", "xhtml"
|
||||||
};
|
};
|
||||||
public static final String[] MIME_PICTURE = {
|
public static final String[] MIME_PICTURE = {
|
||||||
"bmp", "eps", "png", "jpeg", "jpg", "ico", "gif", "tiff", "webp"
|
"bmp", "eps", "png", "jpeg", "jpg", "ico", "gif", "tiff", "webp"
|
||||||
};
|
};
|
||||||
public static final String[] MIME_MUSIC = {
|
public static final String[] MIME_MUSIC = {
|
||||||
"aac", "flac", "mp3", "mpga", "oga", "ogg", "opus", "webma", "wav"
|
"aac", "flac", "mp3", "mpga", "oga", "ogg", "opus", "webma", "wav"
|
||||||
};
|
};
|
||||||
public static final String[] MIME_VIDEO = {
|
public static final String[] MIME_VIDEO = {
|
||||||
"avi", "mp4", "mkv", "wmw", "ogv", "webm"
|
"avi", "mp4", "mkv", "wmw", "ogv", "webm"
|
||||||
};
|
};
|
||||||
public static final String[] MIME_ARCHIVE = {
|
public static final String[] MIME_ARCHIVE = {
|
||||||
"7z", "arj", "bz2", "gz", "rar", "tar", "tgz", "zip", "xz"
|
"7z", "arj", "bz2", "gz", "rar", "tar", "tgz", "zip", "xz"
|
||||||
};
|
};
|
||||||
public static final String[] MIME_SQL = {
|
public static final String[] MIME_SQL = {
|
||||||
"sql", "mdf", "ndf", "ldf"
|
"sql", "mdf", "ndf", "ldf"
|
||||||
};
|
};
|
||||||
}
|
public static final String[] MIME_MARKDOWN = {
|
||||||
|
"md", "mdown", "markdown",
|
||||||
|
};
|
||||||
|
}
|
@ -1,56 +1,56 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.util;
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
|
||||||
public final class PixelDipConverter {
|
public final class PixelDipConverter {
|
||||||
|
|
||||||
private PixelDipConverter() {
|
private PixelDipConverter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method convets dp unit to equivalent device specific value in pixels.
|
* This method convets dp unit to equivalent device specific value in pixels.
|
||||||
*
|
*
|
||||||
* @param dp A value in dp(Device independent pixels) unit. Which we need to convert into pixels
|
* @param dp A value in dp(Device independent pixels) unit. Which we need to convert into pixels
|
||||||
* @param context Context to get resources and device specific display metrics
|
* @param context Context to get resources and device specific display metrics
|
||||||
* @return A float value to represent Pixels equivalent to dp according to device
|
* @return A float value to represent Pixels equivalent to dp according to device
|
||||||
*/
|
*/
|
||||||
public static float convertDpToPixel(final float dp, final Context context) {
|
public static float convertDpToPixel(final float dp, final Context context) {
|
||||||
final Resources resources = context.getResources();
|
final Resources resources = context.getResources();
|
||||||
final DisplayMetrics metrics = resources.getDisplayMetrics();
|
final DisplayMetrics metrics = resources.getDisplayMetrics();
|
||||||
return dp * metrics.densityDpi / 160f;
|
return dp * metrics.densityDpi / 160f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method converts device specific pixels to device independent pixels.
|
* This method converts device specific pixels to device independent pixels.
|
||||||
*
|
*
|
||||||
* @param px A value in px (pixels) unit. Which we need to convert into db
|
* @param px A value in px (pixels) unit. Which we need to convert into db
|
||||||
* @param context Context to get resources and device specific display metrics
|
* @param context Context to get resources and device specific display metrics
|
||||||
* @return A float value to represent db equivalent to px value
|
* @return A float value to represent db equivalent to px value
|
||||||
*/
|
*/
|
||||||
public static float convertPixelsToDp(final float px, final Context context) {
|
public static float convertPixelsToDp(final float px, final Context context) {
|
||||||
final Resources resources = context.getResources();
|
final Resources resources = context.getResources();
|
||||||
final DisplayMetrics metrics = resources.getDisplayMetrics();
|
final DisplayMetrics metrics = resources.getDisplayMetrics();
|
||||||
return px / (metrics.densityDpi / 160f);
|
return px / (metrics.densityDpi / 160f);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,46 +1,50 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.util;
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.R;
|
||||||
import sharedcode.turboeditor.preferences.PreferenceHelper;
|
import com.maskyn.fileeditorpro.preferences.PreferenceHelper;
|
||||||
|
|
||||||
public class ThemeUtils {
|
public class ThemeUtils {
|
||||||
|
|
||||||
public static void setTheme(Activity activity){
|
public static void setTheme(Activity activity){
|
||||||
boolean light = PreferenceHelper.getLightTheme(activity);
|
boolean light = PreferenceHelper.getLightTheme(activity);
|
||||||
if (light) {
|
if (light) {
|
||||||
activity.setTheme(R.style.AppThemeBaseLight);
|
activity.setTheme(R.style.AppThemeBaseLight);
|
||||||
} else {
|
} else {
|
||||||
activity.setTheme(R.style.AppThemeBaseDark);
|
activity.setTheme(R.style.AppThemeBaseDark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setWindowsBackground(Activity activity) {
|
public static void setWindowsBackground(Activity activity) {
|
||||||
boolean whiteTheme = PreferenceHelper.getLightTheme(activity);
|
boolean whiteTheme = PreferenceHelper.getLightTheme(activity);
|
||||||
if (whiteTheme) {
|
boolean darkTheme = PreferenceHelper.getDarkTheme(activity);
|
||||||
activity.getWindow().setBackgroundDrawableResource(R.color.window_background_light);
|
boolean blackTheme = PreferenceHelper.getBlackTheme(activity);
|
||||||
} else {
|
if (whiteTheme) {
|
||||||
activity.getWindow().setBackgroundDrawableResource(R.color.window_background);
|
activity.getWindow().setBackgroundDrawableResource(R.color.window_background_light);
|
||||||
}
|
} else if (darkTheme) {
|
||||||
}
|
activity.getWindow().setBackgroundDrawableResource(R.color.window_background);
|
||||||
}
|
} else {
|
||||||
|
activity.getWindow().setBackgroundDrawableResource(android.R.color.black);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
@ -16,7 +16,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package sharedcode.turboeditor.util;
|
|
||||||
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
@ -1,14 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
@ -16,7 +16,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package sharedcode.turboeditor.util;
|
|
||||||
|
package com.maskyn.fileeditorpro.util;
|
||||||
|
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
@ -0,0 +1,290 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.util.systemui;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for controlling the visibility of the System UI across the various API levels. To use
|
||||||
|
* this API, instantiate an instance of this class with the required level. The level specifies the
|
||||||
|
* extent to which the System UI's visibility is changed when you call {@link #hide()}
|
||||||
|
* or {@link #toggle()}.
|
||||||
|
*/
|
||||||
|
public final class SystemUiHelper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In this level, the helper will toggle low profile mode.
|
||||||
|
*/
|
||||||
|
public static final int LEVEL_LOW_PROFILE = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In this level, the helper will toggle the visibility of the status bar.
|
||||||
|
* If there is a navigation bar, it will toggle low profile mode.
|
||||||
|
*/
|
||||||
|
public static final int LEVEL_HIDE_STATUS_BAR = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In this level, the helper will toggle the visibility of the navigation bar
|
||||||
|
* (if present and if possible) and status bar. In cases where the navigation
|
||||||
|
* bar is present but cannot be hidden, it will toggle low profile mode.
|
||||||
|
*/
|
||||||
|
public static final int LEVEL_LEAN_BACK = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In this level, the helper will toggle the visibility of the navigation bar
|
||||||
|
* (if present and if possible) and status bar, in an immersive mode. This means that the app
|
||||||
|
* will continue to receive all touch events. The user can reveal the system bars with an
|
||||||
|
* inward swipe along the region where the system bars normally appear.
|
||||||
|
*
|
||||||
|
* <p>The {@link #FLAG_IMMERSIVE_STICKY} flag can be used to control how the system bars are
|
||||||
|
* displayed.
|
||||||
|
*/
|
||||||
|
public static final int LEVEL_IMMERSIVE = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When this flag is set, the
|
||||||
|
* {@link android.view.WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN}
|
||||||
|
* flag will be set on older devices, making the status bar "float" on top
|
||||||
|
* of the activity layout. This is most useful when there are no controls at
|
||||||
|
* the top of the activity layout.
|
||||||
|
* <p>
|
||||||
|
* This flag isn't used on newer devices because the <a
|
||||||
|
* href="http://developer.android.com/design/patterns/actionbar.html">action
|
||||||
|
* bar</a>, the most important structural element of an Android app, should
|
||||||
|
* be visible and not obscured by the system UI.
|
||||||
|
*/
|
||||||
|
public static final int FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES = 0x1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used with {@link #LEVEL_IMMERSIVE}. When this flag is set, an inward swipe in the system
|
||||||
|
* bars areas will cause the system bars to temporarily appear in a semi-transparent state,
|
||||||
|
* but no flags are cleared, and your system UI visibility change listeners are not triggered.
|
||||||
|
* The bars automatically hide again after a short delay, or if the user interacts with the
|
||||||
|
* middle of the screen.
|
||||||
|
*/
|
||||||
|
public static final int FLAG_IMMERSIVE_STICKY = 0x2;
|
||||||
|
|
||||||
|
private static final String LOG_TAG = SystemUiHelper.class.getSimpleName();
|
||||||
|
|
||||||
|
private final SystemUiHelperImpl mImpl;
|
||||||
|
|
||||||
|
private final Handler mHandler;
|
||||||
|
private final Runnable mHideRunnable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new SystemUiHelper.
|
||||||
|
*
|
||||||
|
* @param activity The Activity who's system UI should be changed
|
||||||
|
* @param level The level of hiding. Should be either {@link #LEVEL_LOW_PROFILE},
|
||||||
|
* {@link #LEVEL_HIDE_STATUS_BAR}, {@link #LEVEL_LEAN_BACK} or
|
||||||
|
* {@link #LEVEL_IMMERSIVE}
|
||||||
|
* @param flags Additional options. See {@link #FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES} and
|
||||||
|
* {@link #FLAG_IMMERSIVE_STICKY}
|
||||||
|
*/
|
||||||
|
public SystemUiHelper(Activity activity, int level, int flags) {
|
||||||
|
this(activity, level, flags, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new SystemUiHelper.
|
||||||
|
*
|
||||||
|
* @param activity The Activity who's system UI should be changed
|
||||||
|
* @param level The level of hiding. Should be either {@link #LEVEL_LOW_PROFILE},
|
||||||
|
* {@link #LEVEL_HIDE_STATUS_BAR}, {@link #LEVEL_LEAN_BACK} or
|
||||||
|
* {@link #LEVEL_IMMERSIVE}
|
||||||
|
* @param flags Additional options. See {@link #FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES} and
|
||||||
|
* {@link #FLAG_IMMERSIVE_STICKY}
|
||||||
|
* @param listener A listener which is called when the system visibility is changed
|
||||||
|
*/
|
||||||
|
public SystemUiHelper(Activity activity, int level, int flags,
|
||||||
|
OnVisibilityChangeListener listener) {
|
||||||
|
|
||||||
|
mHandler = new Handler(Looper.getMainLooper());
|
||||||
|
mHideRunnable = new HideRunnable();
|
||||||
|
|
||||||
|
// Create impl
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
|
mImpl = new SystemUiHelperImplKK(activity, level, flags, listener);
|
||||||
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
mImpl = new SystemUiHelperImplJB(activity, level, flags, listener);
|
||||||
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||||
|
mImpl = new SystemUiHelperImplICS(activity, level, flags, listener);
|
||||||
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
mImpl = new SystemUiHelperImplHC(activity, level, flags, listener);
|
||||||
|
} else {
|
||||||
|
mImpl = new SystemUiHelperImplBase(activity, level, flags, listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the system UI is currently showing. What this means depends on the mode this
|
||||||
|
* {@link android.example.android.systemuivis.SystemUiHelper} was instantiated with.
|
||||||
|
*/
|
||||||
|
public boolean isShowing() {
|
||||||
|
return mImpl.isShowing();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the system UI. What this means depends on the mode this {@link android.example.android.systemuivis.SystemUiHelper} was
|
||||||
|
* instantiated with.
|
||||||
|
*
|
||||||
|
* <p>Any currently queued delayed hide requests will be removed.
|
||||||
|
*/
|
||||||
|
public void show() {
|
||||||
|
// Ensure that any currently queued hide calls are removed
|
||||||
|
removeQueuedRunnables();
|
||||||
|
|
||||||
|
mImpl.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide the system UI. What this means depends on the mode this {@link android.example.android.systemuivis.SystemUiHelper} was
|
||||||
|
* instantiated with.
|
||||||
|
*
|
||||||
|
* <p>Any currently queued delayed hide requests will be removed.
|
||||||
|
*/
|
||||||
|
public void hide() {
|
||||||
|
// Ensure that any currently queued hide calls are removed
|
||||||
|
removeQueuedRunnables();
|
||||||
|
|
||||||
|
mImpl.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request that the system UI is hidden after a delay.
|
||||||
|
*
|
||||||
|
* <p>Any currently queued delayed hide requests will be removed.
|
||||||
|
*
|
||||||
|
* @param delayMillis The delay (in milliseconds) until the Runnable
|
||||||
|
* will be executed.
|
||||||
|
*/
|
||||||
|
public void delayHide(long delayMillis) {
|
||||||
|
// Ensure that any currently queued hide calls are removed
|
||||||
|
removeQueuedRunnables();
|
||||||
|
|
||||||
|
mHandler.postDelayed(mHideRunnable, delayMillis);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle whether the system UI is displayed.
|
||||||
|
*/
|
||||||
|
public void toggle() {
|
||||||
|
if (mImpl.isShowing()) {
|
||||||
|
mImpl.hide();
|
||||||
|
} else {
|
||||||
|
mImpl.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeQueuedRunnables() {
|
||||||
|
// Ensure that any currently queued hide calls are removed
|
||||||
|
mHandler.removeCallbacks(mHideRunnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback interface used to listen for system UI visibility changes.
|
||||||
|
*/
|
||||||
|
public interface OnVisibilityChangeListener {
|
||||||
|
/**
|
||||||
|
* Called when the system UI visibility has changed.
|
||||||
|
*
|
||||||
|
* @param visible True if the system UI is visible.
|
||||||
|
*/
|
||||||
|
public void onVisibilityChange(boolean visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
static abstract class SystemUiHelperImpl {
|
||||||
|
|
||||||
|
final Activity mActivity;
|
||||||
|
final int mLevel;
|
||||||
|
final int mFlags;
|
||||||
|
final OnVisibilityChangeListener mOnVisibilityChangeListener;
|
||||||
|
|
||||||
|
boolean mIsShowing = true;
|
||||||
|
|
||||||
|
SystemUiHelperImpl(Activity activity, int level, int flags,
|
||||||
|
OnVisibilityChangeListener onVisibilityChangeListener) {
|
||||||
|
mActivity = activity;
|
||||||
|
mLevel = level;
|
||||||
|
mFlags = flags;
|
||||||
|
mOnVisibilityChangeListener = onVisibilityChangeListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract void show();
|
||||||
|
abstract void hide();
|
||||||
|
|
||||||
|
boolean isShowing() {
|
||||||
|
return mIsShowing;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setIsShowing(boolean isShowing) {
|
||||||
|
mIsShowing = isShowing;
|
||||||
|
|
||||||
|
if (mOnVisibilityChangeListener != null) {
|
||||||
|
mOnVisibilityChangeListener.onVisibilityChange(mIsShowing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base implementation. Used on API level 10 and below.
|
||||||
|
*/
|
||||||
|
static class SystemUiHelperImplBase extends SystemUiHelperImpl {
|
||||||
|
|
||||||
|
SystemUiHelperImplBase(Activity activity, int level, int flags,
|
||||||
|
OnVisibilityChangeListener onVisibilityChangeListener) {
|
||||||
|
super(activity, level, flags, onVisibilityChangeListener);
|
||||||
|
|
||||||
|
if ((mFlags & SystemUiHelper.FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES) != 0) {
|
||||||
|
mActivity.getWindow().addFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
|
||||||
|
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void show() {
|
||||||
|
if (mLevel > SystemUiHelper.LEVEL_LOW_PROFILE) {
|
||||||
|
mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
setIsShowing(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void hide() {
|
||||||
|
if (mLevel > SystemUiHelper.LEVEL_LOW_PROFILE) {
|
||||||
|
mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
setIsShowing(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class HideRunnable implements Runnable {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.util.systemui;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
class SystemUiHelperImplHC extends SystemUiHelper.SystemUiHelperImpl
|
||||||
|
implements View.OnSystemUiVisibilityChangeListener {
|
||||||
|
|
||||||
|
final View mDecorView;
|
||||||
|
|
||||||
|
SystemUiHelperImplHC(Activity activity, int level, int flags,
|
||||||
|
SystemUiHelper.OnVisibilityChangeListener onVisibilityChangeListener) {
|
||||||
|
super(activity, level, flags, onVisibilityChangeListener);
|
||||||
|
|
||||||
|
mDecorView = activity.getWindow().getDecorView();
|
||||||
|
mDecorView.setOnSystemUiVisibilityChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void show() {
|
||||||
|
mDecorView.setSystemUiVisibility(createShowFlags());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void hide() {
|
||||||
|
mDecorView.setSystemUiVisibility(createHideFlags());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void onSystemUiVisibilityChange(int visibility) {
|
||||||
|
if ((visibility & createTestFlags()) != 0) {
|
||||||
|
onSystemUiHidden();
|
||||||
|
} else {
|
||||||
|
onSystemUiShown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onSystemUiShown() {
|
||||||
|
ActionBar ab = ((ActionBarActivity) mActivity).getSupportActionBar();
|
||||||
|
if (ab != null) {
|
||||||
|
ab.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
|
||||||
|
setIsShowing(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onSystemUiHidden() {
|
||||||
|
ActionBar ab = ((ActionBarActivity) mActivity).getSupportActionBar();
|
||||||
|
if (ab != null) {
|
||||||
|
ab.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
|
||||||
|
setIsShowing(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int createShowFlags() {
|
||||||
|
return View.STATUS_BAR_VISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int createHideFlags() {
|
||||||
|
return View.STATUS_BAR_HIDDEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int createTestFlags() {
|
||||||
|
return View.STATUS_BAR_HIDDEN;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.util.systemui;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||||
|
class SystemUiHelperImplICS extends SystemUiHelperImplHC {
|
||||||
|
|
||||||
|
SystemUiHelperImplICS(Activity activity, int level, int flags,
|
||||||
|
SystemUiHelper.OnVisibilityChangeListener onVisibilityChangeListener) {
|
||||||
|
super(activity, level, flags, onVisibilityChangeListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int createShowFlags() {
|
||||||
|
return View.SYSTEM_UI_FLAG_VISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int createTestFlags() {
|
||||||
|
if (mLevel >= SystemUiHelper.LEVEL_LEAN_BACK) {
|
||||||
|
// Intentionally override test flags.
|
||||||
|
return View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
return View.SYSTEM_UI_FLAG_LOW_PROFILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int createHideFlags() {
|
||||||
|
int flag = View.SYSTEM_UI_FLAG_LOW_PROFILE;
|
||||||
|
|
||||||
|
if (mLevel >= SystemUiHelper.LEVEL_LEAN_BACK) {
|
||||||
|
flag |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.util.systemui;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.ActionBar;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||||
|
class SystemUiHelperImplJB extends SystemUiHelperImplICS {
|
||||||
|
|
||||||
|
SystemUiHelperImplJB(Activity activity, int level, int flags,
|
||||||
|
SystemUiHelper.OnVisibilityChangeListener onVisibilityChangeListener) {
|
||||||
|
super(activity, level, flags, onVisibilityChangeListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int createShowFlags() {
|
||||||
|
int flag = super.createShowFlags();
|
||||||
|
|
||||||
|
if (mLevel >= SystemUiHelper.LEVEL_HIDE_STATUS_BAR) {
|
||||||
|
flag |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
||||||
|
|
||||||
|
if (mLevel >= SystemUiHelper.LEVEL_LEAN_BACK) {
|
||||||
|
flag |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int createHideFlags() {
|
||||||
|
int flag = super.createHideFlags();
|
||||||
|
|
||||||
|
if (mLevel >= SystemUiHelper.LEVEL_HIDE_STATUS_BAR) {
|
||||||
|
flag |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
|
| View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||||
|
|
||||||
|
if (mLevel >= SystemUiHelper.LEVEL_LEAN_BACK) {
|
||||||
|
flag |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSystemUiShown() {
|
||||||
|
if (mLevel == SystemUiHelper.LEVEL_LOW_PROFILE) {
|
||||||
|
// Manually show the action bar when in low profile mode.
|
||||||
|
ActionBar ab = mActivity.getActionBar();
|
||||||
|
if (ab != null) {
|
||||||
|
ab.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsShowing(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSystemUiHidden() {
|
||||||
|
if (mLevel == SystemUiHelper.LEVEL_LOW_PROFILE) {
|
||||||
|
// Manually hide the action bar when in low profile mode.
|
||||||
|
ActionBar ab = mActivity.getActionBar();
|
||||||
|
if (ab != null) {
|
||||||
|
ab.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsShowing(true);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
|
*
|
||||||
|
* This file is part of Text Editor 8000.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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.
|
||||||
|
*
|
||||||
|
* Text Editor 8000 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.maskyn.fileeditorpro.util.systemui;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||||
|
class SystemUiHelperImplKK extends SystemUiHelperImplJB {
|
||||||
|
|
||||||
|
SystemUiHelperImplKK(Activity activity, int level, int flags,
|
||||||
|
SystemUiHelper.OnVisibilityChangeListener onVisibilityChangeListener) {
|
||||||
|
super(activity, level, flags, onVisibilityChangeListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int createHideFlags() {
|
||||||
|
int flag = super.createHideFlags();
|
||||||
|
|
||||||
|
if (mLevel == SystemUiHelper.LEVEL_IMMERSIVE) {
|
||||||
|
// If the client requested immersive mode, and we're on Android 4.4
|
||||||
|
// or later, add relevant flags. Applying HIDE_NAVIGATION without
|
||||||
|
// IMMERSIVE prevents the activity from accepting all touch events,
|
||||||
|
// so we only do this on Android 4.4 and later (where IMMERSIVE is
|
||||||
|
// present).
|
||||||
|
flag |= ((mFlags & SystemUiHelper.FLAG_IMMERSIVE_STICKY) != 0)
|
||||||
|
? View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||||
|
: View.SYSTEM_UI_FLAG_IMMERSIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,49 +1,49 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.views;
|
package com.maskyn.fileeditorpro.views;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
|
||||||
public class CustomDrawerLayout extends DrawerLayout {
|
public class CustomDrawerLayout extends DrawerLayout{
|
||||||
public CustomDrawerLayout(Context context) {
|
public CustomDrawerLayout(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomDrawerLayout(Context context, AttributeSet attrs) {
|
public CustomDrawerLayout(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
|
public CustomDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
@ -16,11 +16,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package sharedcode.turboeditor.views;
|
|
||||||
|
|
||||||
/**
|
package com.maskyn.fileeditorpro.views;
|
||||||
* Created by Artem on 28.01.14.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@ -40,9 +37,8 @@ import android.widget.TextView;
|
|||||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
|
|
||||||
import sharedcode.turboeditor.R;
|
import com.maskyn.fileeditorpro.R;
|
||||||
import sharedcode.turboeditor.fragment.AboutDialog;
|
import com.maskyn.fileeditorpro.dialogfragment.AboutDialog;
|
||||||
import sharedcode.turboeditor.iab.DonationFragment;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for showing fragment dialogs.
|
* Helper class for showing fragment dialogs.
|
||||||
@ -51,13 +47,8 @@ public class DialogHelper {
|
|||||||
|
|
||||||
public static final String TAG_FRAGMENT_ABOUT = "dialog_about";
|
public static final String TAG_FRAGMENT_ABOUT = "dialog_about";
|
||||||
public static final String TAG_FRAGMENT_HELP = "dialog_help";
|
public static final String TAG_FRAGMENT_HELP = "dialog_help";
|
||||||
public static final String TAG_FRAGMENT_DONATION = "dialog_donate";
|
|
||||||
public static final String TAG_FRAGMENT_FEEDBACK = "dialog_feedback";
|
public static final String TAG_FRAGMENT_FEEDBACK = "dialog_feedback";
|
||||||
|
|
||||||
public static void showDonateDialog(Activity activity) {
|
|
||||||
showDialog(activity, DonationFragment.class, TAG_FRAGMENT_DONATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showAboutDialog(Activity activity) {
|
public static void showAboutDialog(Activity activity) {
|
||||||
showDialog(activity, AboutDialog.class, TAG_FRAGMENT_ABOUT);
|
showDialog(activity, AboutDialog.class, TAG_FRAGMENT_ABOUT);
|
||||||
}
|
}
|
@ -1,84 +1,84 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Vlad Mihalachi
|
* Copyright (C) 2014 Vlad Mihalachi
|
||||||
*
|
*
|
||||||
* This file is part of Turbo Editor.
|
* This file is part of Text Editor 8000.
|
||||||
*
|
*
|
||||||
* Turbo Editor is free software: you can redistribute it and/or modify
|
* Text Editor 8000 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Turbo Editor is distributed in the hope that it will be useful,
|
* Text Editor 8000 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sharedcode.turboeditor.views;
|
package com.maskyn.fileeditorpro.views;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
public class GoodScrollView extends ScrollView {
|
public class GoodScrollView extends ScrollView {
|
||||||
|
|
||||||
public ScrollInterface scrollInterface;
|
public ScrollInterface scrollInterface;
|
||||||
int lastY;
|
int lastY;
|
||||||
boolean listenerEnabled = true;
|
boolean listenerEnabled = true;
|
||||||
|
|
||||||
public GoodScrollView(Context context) {
|
public GoodScrollView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GoodScrollView(Context context, AttributeSet attrs) {
|
public GoodScrollView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GoodScrollView(Context context, AttributeSet attrs, int defStyle) {
|
public GoodScrollView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScrollInterface(ScrollInterface scrollInterface) {
|
public void setScrollInterface(ScrollInterface scrollInterface) {
|
||||||
this.scrollInterface = scrollInterface;
|
this.scrollInterface = scrollInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||||
super.onScrollChanged(l, t, oldl, oldt);
|
super.onScrollChanged(l, t, oldl, oldt);
|
||||||
|
|
||||||
if (scrollInterface == null || !listenerEnabled) return;
|
if (scrollInterface == null || !listenerEnabled) return;
|
||||||
|
|
||||||
if (Math.abs(lastY - t) > 100) {
|
if (Math.abs(lastY - t) > 100) {
|
||||||
lastY = t;
|
lastY = t;
|
||||||
scrollInterface.onScrollChanged(l, t, oldl, oldt);
|
scrollInterface.onScrollChanged(l, t, oldl, oldt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasReachedBottom() {
|
public boolean hasReachedBottom() {
|
||||||
View firstChild = getChildAt(getChildCount() - 1);
|
View firstChild = getChildAt(getChildCount() - 1);
|
||||||
|
|
||||||
int diff = (firstChild.getBottom() - (getHeight() + getScrollY() + firstChild.getTop()));// Calculate the scrolldiff
|
int diff = (firstChild.getBottom() - (getHeight() + getScrollY() + firstChild.getTop()));// Calculate the scrolldiff
|
||||||
return diff <= 0;
|
return diff <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tempDisableListener(int mills) {
|
public void tempDisableListener(int mills) {
|
||||||
listenerEnabled = false;
|
listenerEnabled = false;
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
listenerEnabled = true;
|
listenerEnabled = true;
|
||||||
}
|
}
|
||||||
}, mills);
|
}, mills);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public interface ScrollInterface {
|
public interface ScrollInterface {
|
||||||
public void onScrollChanged(int l, int t, int oldl, int oldt);
|
public void onScrollChanged(int l, int t, int oldl, int oldt);
|
||||||
}
|
}
|
||||||
}
|
}
|
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 724 B After Width: | Height: | Size: 724 B |
Before Width: | Height: | Size: 621 B After Width: | Height: | Size: 621 B |
Before Width: | Height: | Size: 465 B After Width: | Height: | Size: 465 B |
Before Width: | Height: | Size: 615 B After Width: | Height: | Size: 615 B |
Before Width: | Height: | Size: 531 B After Width: | Height: | Size: 531 B |
Before Width: | Height: | Size: 495 B After Width: | Height: | Size: 495 B |
Before Width: | Height: | Size: 875 B After Width: | Height: | Size: 875 B |
Before Width: | Height: | Size: 713 B After Width: | Height: | Size: 713 B |
Before Width: | Height: | Size: 644 B After Width: | Height: | Size: 644 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 365 B After Width: | Height: | Size: 365 B |
BIN
app/src/main/res/drawable-hdpi/ic_fab_ok.png
Normal file
After Width: | Height: | Size: 401 B |
Before Width: | Height: | Size: 853 B After Width: | Height: | Size: 853 B |
Before Width: | Height: | Size: 898 B After Width: | Height: | Size: 898 B |
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 212 B |
Before Width: | Height: | Size: 475 B After Width: | Height: | Size: 475 B |
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 462 B |
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 291 B |
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 377 B |
Before Width: | Height: | Size: 403 B After Width: | Height: | Size: 403 B |
Before Width: | Height: | Size: 290 B After Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 596 B After Width: | Height: | Size: 596 B |
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 535 B |