Added some helpful information and licensing stuff

This commit is contained in:
William Brawner 2017-08-23 21:17:50 -05:00
parent 7ce7bbc60d
commit c912b32d5c
16 changed files with 881 additions and 27 deletions

195
NOTICE-ASL.txt Normal file
View file

@ -0,0 +1,195 @@
Notice for all the files in this folder.
------------------------------------------------------------
Copyright (c) 2005-2013, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View file

@ -53,7 +53,7 @@ dependencies {
compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0' compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
compile 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0' compile 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'
compile 'com.google.dagger:dagger:2.11' compile 'com.google.dagger:dagger:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0' annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
} }

View file

@ -4,24 +4,31 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<application <application
android:name="com.wbrawner.simplemarkdown.MarkdownApplication" android:name=".MarkdownApplication"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".view.activity.MainActivity"> <activity android:name=".view.activity.SplashActivity"
android:theme="@style/AppTheme.Splash">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"></action> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"></category>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity>
<activity android:name=".view.activity.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.EDIT" /> <action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" /> <data android:scheme="file" />
<data android:scheme="content" /> <data android:scheme="content" />
<data android:mimeType="text/plain" /> <data android:mimeType="text/plain" />
@ -32,6 +39,7 @@
<data android:host="*" /> <data android:host="*" />
</intent-filter> </intent-filter>
</activity> </activity>
<provider <provider
android:name="android.support.v4.content.FileProvider" android:name="android.support.v4.content.FileProvider"
android:authorities="com.wbrawner.simplemarkdown.fileprovider" android:authorities="com.wbrawner.simplemarkdown.fileprovider"
@ -42,6 +50,11 @@
android:resource="@xml/file_paths" /> android:resource="@xml/file_paths" />
</provider> </provider>
<activity android:name=".view.activity.MarkdownInfoActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".view.activity.MainActivity" />
</activity>
</application> </application>
</manifest> </manifest>

View file

@ -0,0 +1,168 @@
# Introduction
***
Markdown is a markup language that allows you to quickly and easily write for the web! Many blogging platforms allow you to use markdown in your posts, WordPress for example. This document has also been written in Markdown :)
Using Markdown is quite simple. There are just a few syntax rules you'll need to remember. Below I have written a few to get you started, followed by their appearance in this app.
# Headings/Titles
***
`# Biggest`
# Biggest
`## Bigger`
## Bigger
`### Big`
### Big
`#### Small`
#### Small
`##### Smaller`
##### Smaller
`###### Smallest`
###### Smallest
```
Alt Biggest
=========
```
Alt Biggest
=========
```
Alt Bigger
---------------
```
Alt Bigger
---------------
# Inline Elements
***
`*italics*`
*italics*
`**BOLD**`
**BOLD**
`~~strikethrough~~`
~~strikethrough~~
```
`monospace`
```
`monospace`
```
[Here's a link](https://github.com/wbrawner/simplemarkdown)
```
[Here's a link](https://github.com/wbrawner/simplemarkdown)
# Block-level Elements
***
### Tables
Note that with tables, the placement of the colon character (`:`) determines the alignment of the text inside.
```
Left Content|Center Content|Right Content
:--------|:--------:|--------:
data 1|data 2|data 3
data 1|data 2|data 3
data 1|data 2|data 3
```
Left Content|Center Content|Right Content
:--------|:--------:|--------:
data 1|data 2|data 3
data 1|data 2|data 3
data 1|data 2|data 3
### Images
Note that with images, the text in the square brackets corresponds to the alt text of the image.
```
![My Logo](https://wbrawner.com/wp-content/uploads/cubiq-add-to-home/application-icon-305-196x196.png)
```
![My Logo](https://wbrawner.com/wp-content/uploads/cubiq-add-to-home/application-icon-305-196x196.png)
### Code
In addition to the monospace inline element, code blocks can be created by indenting each line a minimum of 4 spaces:
public static void main(String[] args) {
System.out.println("Hello, world!");
}
Or by wrapping the code in three backticks (\`\`\`):
```
function helloWorld() {
console.log("Hello, world!")
}
```
### Line breaks
`***`
***
### Blockquotes
```
> What if I want to quote someone?
> asking for a friend
```
> What if I want to quote someone?
> asking for a friend
### Lists
Unordered lists can be created by either using asterisks (*) or hyphens (-). Indenting them by two spaces will also indent the bullets.
* Get rich
* Buy an island
- Learn Android development
- Contribute to open source software
Numbered lists work similarly, though the actual number you use is irrelevant.
1. Do work
0. get paid
3. save money
0. the actual number isn't important
234234. it just needs to be a number
# Final Notes
Don't forget that you can, of course, write regular HTML here and it will get parsed as normal. You can view this file here: [link](https://github.com/wbrawner/SimpleMarkdown/)
If you need any assistance with the app or you run into a bug, please [open an issue](https://github.com/wbrawner/SimpleMarkdown/). You can also [visit me on my personal website](https://wbrawner.com), or [send me an email](billybrawner@gmail.com).

View file

@ -0,0 +1,303 @@
# Libraries
***
The following libraries were a huge help in the development of SimpleMarkdown.
Big thanks to the deveopers of them :)
## AndDown
[https://github.com/commonsguy/cwac-anddown](https://github.com/commonsguy/cwac-anddown)
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
## Android Support Library
Copyright (c) 2005-2013, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
## ButterKnife
[https://github.com/JakeWharton/butterknife](https://github.com/JakeWharton/butterknife)
Copyright 2013 Jake Wharton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
## Dagger 2
[https://github.com/google/dagger](https://github.com/google/dagger)
Copyright 2012 The Dagger Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
## Hoedown
[https://github.com/hoedown/hoedown](https://github.com/hoedown/hoedown)
Copyright (c) 2008, Natacha Porté
Copyright (c) 2011, Vicent Martí
Copyright (c) 2014, Xavier Mendez, Devin Torres and the Hoedown authors
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
## RxAndroid
[https://github.com/ReactiveX/RxAndroid](https://github.com/ReactiveX/RxAndroid)
Copyright 2015 The RxAndroid authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
## RxJava
[https://github.com/ReactiveX/RxJava](https://github.com/ReactiveX/RxJava)
Copyright (c) 2016-present, RxJava Contributors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

View file

@ -12,6 +12,7 @@ import java.io.InputStream;
public interface MarkdownPresenter extends LifecyclePresenter { public interface MarkdownPresenter extends LifecyclePresenter {
void loadMarkdown(String filePath); void loadMarkdown(String filePath);
void loadMarkdown(InputStream in); void loadMarkdown(InputStream in);
void loadTempMarkdown(InputStream in, OnTempFileLoadedListener listener);
void setEditView(MarkdownEditView editView); void setEditView(MarkdownEditView editView);
void setPreviewView(MarkdownPreviewView previewView); void setPreviewView(MarkdownPreviewView previewView);
void saveMarkdown(String filePath); void saveMarkdown(String filePath);
@ -19,6 +20,12 @@ public interface MarkdownPresenter extends LifecyclePresenter {
void onMarkdownEdited(String markdown); void onMarkdownEdited(String markdown);
String getFileName(); String getFileName();
void setFileName(String name); void setFileName(String name);
String generateHTML();
String generateHTML(String markdown);
String getMarkdown(); String getMarkdown();
void setMarkdown(String markdown); void setMarkdown(String markdown);
public abstract class OnTempFileLoadedListener {
public abstract void onSuccess(String markdown);
public abstract void onError(int code);
}
} }

View file

@ -16,13 +16,18 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
private MarkdownEditView editView; private MarkdownEditView editView;
private MarkdownPreviewView previewView; private MarkdownPreviewView previewView;
private String TAG = MarkdownPresenterImpl.class.getSimpleName(); private String TAG = MarkdownPresenterImpl.class.getSimpleName();
private int HOEDOWN_FLAGS =
AndDown.HOEDOWN_EXT_STRIKETHROUGH | AndDown.HOEDOWN_EXT_TABLES |
AndDown.HOEDOWN_EXT_UNDERLINE | AndDown.HOEDOWN_EXT_SUPERSCRIPT |
AndDown.HOEDOWN_EXT_FENCED_CODE;
public MarkdownPresenterImpl(MarkdownFile file) { public MarkdownPresenterImpl(MarkdownFile file) {
this.file = file; this.file = file;
} }
@Override @Override
public void resume() {} public void resume() {
}
@Override @Override
public void pause() { public void pause() {
@ -57,6 +62,22 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
fileLoader.run(); fileLoader.run();
} }
@Override
public void loadTempMarkdown(InputStream in, OnTempFileLoadedListener listener) {
Runnable fileLoader = () -> {
MarkdownFile tmpFile = new MarkdownFile();
int result = tmpFile.load(in);
if (result == MarkdownFile.SUCCESS) {
String html = generateHTML(tmpFile.getContent());
listener.onSuccess(html);
} else {
listener.onError(result);
}
tmpFile = null;
};
fileLoader.run();
}
@Override @Override
public void setEditView(MarkdownEditView editView) { public void setEditView(MarkdownEditView editView) {
this.editView = editView; this.editView = editView;
@ -85,17 +106,23 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
public void onMarkdownEdited(String markdown) { public void onMarkdownEdited(String markdown) {
setMarkdown(markdown); setMarkdown(markdown);
Runnable generateMarkdown = () -> { Runnable generateMarkdown = () -> {
AndDown andDown = new AndDown();
int hoedownFlags =
AndDown.HOEDOWN_EXT_STRIKETHROUGH | AndDown.HOEDOWN_EXT_TABLES |
AndDown.HOEDOWN_EXT_UNDERLINE | AndDown.HOEDOWN_EXT_SUPERSCRIPT |
AndDown.HOEDOWN_EXT_FENCED_CODE;
if (previewView != null) if (previewView != null)
previewView.updatePreview(andDown.markdownToHtml(markdown, hoedownFlags, 0)); previewView.updatePreview(generateHTML());
}; };
generateMarkdown.run(); generateMarkdown.run();
} }
@Override
public String generateHTML() {
return generateHTML(getMarkdown());
}
@Override
public String generateHTML(String markdown) {
AndDown andDown = new AndDown();
return andDown.markdownToHtml(markdown, HOEDOWN_FLAGS, 0);
}
@Override @Override
public void onMarkdownEdited() { public void onMarkdownEdited() {
onMarkdownEdited(getMarkdown()); onMarkdownEdited(getMarkdown());

View file

@ -6,7 +6,6 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
@ -60,8 +59,6 @@ public class MainActivity extends AppCompatActivity
((MarkdownApplication) getApplication()).getComponent().inject(this); ((MarkdownApplication) getApplication()).getComponent().inject(this);
setTitle(presenter.getFileName()); setTitle(presenter.getFileName());
// Reset the background color
getWindow().setBackgroundDrawable(new ColorDrawable(0xFFFFFFFF));
ButterKnife.bind(this); ButterKnife.bind(this);
pager.setAdapter( pager.setAdapter(
new EditPagerAdapter(getSupportFragmentManager(), MainActivity.this) new EditPagerAdapter(getSupportFragmentManager(), MainActivity.this)
@ -69,7 +66,7 @@ public class MainActivity extends AppCompatActivity
pager.setPageMargin(1); pager.setPageMargin(1);
pager.setPageMarginDrawable(R.color.colorAccent); pager.setPageMarginDrawable(R.color.colorAccent);
Intent intent = getIntent(); Intent intent = getIntent();
if (intent != null && !intent.getAction().equals(Intent.ACTION_MAIN) && intent.getData() != null) { if (intent != null && intent.getData() != null) {
loadFromUri(intent.getData()); loadFromUri(intent.getData());
} }
if (getResources().getConfiguration().orientation if (getResources().getConfiguration().orientation
@ -123,10 +120,58 @@ public class MainActivity extends AppCompatActivity
case R.id.action_load: case R.id.action_load:
requestOpen(); requestOpen();
break; break;
case R.id.action_help:
showInfoActivity(R.id.action_help);
break;
case R.id.action_libraries:
showInfoActivity(R.id.action_libraries);
break;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
private void showInfoActivity(int action) {
Intent infoIntent = new Intent(MainActivity.this, MarkdownInfoActivity.class);
String fileName = "";
String title = "";
switch (action) {
case R.id.action_help:
fileName = "Cheatsheet.md";
title = getString(R.string.action_help);
break;
case R.id.action_libraries:
fileName = "Libraries.md";
title = getString(R.string.action_libraries);
break;
}
infoIntent.putExtra("title", title);
InputStream in = null;
try {
in = getAssets().open(fileName);
presenter.loadTempMarkdown(in, new MarkdownPresenter.OnTempFileLoadedListener() {
@Override
public void onSuccess(String html) {
infoIntent.putExtra("html", html);
startActivity(infoIntent);
}
@Override
public void onError(int code) {
Toast.makeText(MainActivity.this, R.string.file_load_error, Toast.LENGTH_SHORT)
.show();
}
});
} catch (Exception e) {
Toast.makeText(MainActivity.this, R.string.file_load_error, Toast.LENGTH_SHORT).show();
}
if (in != null) {
try {
in.close();
} catch (Exception e) {
}
}
}
private void showSaveDialog() { private void showSaveDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.action_save); builder.setTitle(R.string.action_save);

View file

@ -0,0 +1,43 @@
package com.wbrawner.simplemarkdown.view.activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import com.wbrawner.simplemarkdown.R;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MarkdownInfoActivity extends AppCompatActivity {
@BindView(R.id.info_webview)
WebView infoWebview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_markdown_info);
ButterKnife.bind(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Intent intent = getIntent();
if (intent == null || !intent.hasExtra("title") || !intent.hasExtra("html"))
finish();
setTitle(intent.getStringExtra("title"));
infoWebview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
infoWebview.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
infoWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
infoWebview.loadDataWithBaseURL(
null,
intent.getStringExtra("html"),
"text/html",
"UTF-8",
null
);
}
}

View file

@ -0,0 +1,18 @@
package com.wbrawner.simplemarkdown.view.activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
/**
* Created by billy on 8/23/17.
*/
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startActivity(new Intent(this, MainActivity.class));
}
}

View file

@ -21,6 +21,7 @@ import javax.inject.Inject;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.Unbinder;
import io.reactivex.Observable; import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
@ -29,6 +30,7 @@ public class EditFragment extends Fragment implements MarkdownEditView {
public static final String SAVE_ACTION = "com.wbrawner.simplemarkdown.ACTION_SAVE"; public static final String SAVE_ACTION = "com.wbrawner.simplemarkdown.ACTION_SAVE";
public static final String LOAD_ACTION = "com.wbrawner.simplemarkdown.ACTION_LOAD"; public static final String LOAD_ACTION = "com.wbrawner.simplemarkdown.ACTION_LOAD";
private String TAG = EditFragment.class.getSimpleName(); private String TAG = EditFragment.class.getSimpleName();
private Unbinder unbinder;
@Inject @Inject
MarkdownPresenter presenter; MarkdownPresenter presenter;
@ -45,7 +47,7 @@ public class EditFragment extends Fragment implements MarkdownEditView {
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_edit, container, false); View view = inflater.inflate(R.layout.fragment_edit, container, false);
ButterKnife.bind(this, view); unbinder = ButterKnife.bind(this, view);
((MarkdownApplication) getActivity().getApplication()).getComponent().inject(this); ((MarkdownApplication) getActivity().getApplication()).getComponent().inject(this);
Observable<String> obs = RxTextView.textChanges(markdownEditor) Observable<String> obs = RxTextView.textChanges(markdownEditor)
@ -109,4 +111,10 @@ public class EditFragment extends Fragment implements MarkdownEditView {
public void setMarkdown(String markdown) { public void setMarkdown(String markdown) {
markdownEditor.setText(markdown); markdownEditor.setText(markdown);
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
} }

View file

@ -1,13 +1,11 @@
package com.wbrawner.simplemarkdown.view.fragment; package com.wbrawner.simplemarkdown.view.fragment;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
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.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import com.wbrawner.simplemarkdown.BuildConfig; import com.wbrawner.simplemarkdown.BuildConfig;
@ -20,9 +18,11 @@ import javax.inject.Inject;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.Unbinder;
public class PreviewFragment extends Fragment implements MarkdownPreviewView { public class PreviewFragment extends Fragment implements MarkdownPreviewView {
private static final String TAG = PreviewFragment.class.getSimpleName(); private static final String TAG = PreviewFragment.class.getSimpleName();
private Unbinder unbinder;
@Inject @Inject
MarkdownPresenter presenter; MarkdownPresenter presenter;
@ -39,7 +39,7 @@ public class PreviewFragment extends Fragment implements MarkdownPreviewView {
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_preview, container, false); View view = inflater.inflate(R.layout.fragment_preview, container, false);
ButterKnife.bind(this, view); unbinder = ButterKnife.bind(this, view);
((MarkdownApplication) getActivity().getApplication()).getComponent().inject(this); ((MarkdownApplication) getActivity().getApplication()).getComponent().inject(this);
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG)
WebView.setWebContentsDebuggingEnabled(true); WebView.setWebContentsDebuggingEnabled(true);
@ -67,6 +67,12 @@ public class PreviewFragment extends Fragment implements MarkdownPreviewView {
presenter.onMarkdownEdited(); presenter.onMarkdownEdited();
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.wbrawner.simplemarkdown.view.activity.MarkdownInfoActivity">
<WebView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/info_webview" />
</FrameLayout>

View file

@ -16,9 +16,14 @@
android:orderInCategory="100" android:orderInCategory="100"
android:title="@string/action_load" android:title="@string/action_load"
app:showAsAction="never" /> app:showAsAction="never" />
<!--<item--> <item
<!--android:id="@+id/action_help"--> android:id="@+id/action_help"
<!--android:orderInCategory="100"--> android:orderInCategory="200"
<!--android:title="@string/action_help"--> android:title="@string/action_help"
<!--app:showAsAction="never" />--> app:showAsAction="never" />
<item
android:id="@+id/action_libraries"
android:orderInCategory="300"
android:title="@string/action_libraries"
app:showAsAction="never" />
</menu> </menu>

View file

@ -23,4 +23,5 @@
<string name="file_loaded">File successfully loaded</string> <string name="file_loaded">File successfully loaded</string>
<string name="error_write">An error occurred while writing the file</string> <string name="error_write">An error occurred while writing the file</string>
<string name="file_load_error">An error occurred while opening the file</string> <string name="file_load_error">An error occurred while opening the file</string>
<string name="action_libraries">Libraries</string>
</resources> </resources>

View file

@ -6,6 +6,9 @@
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.Splash" parent="AppTheme">
<item name="android:windowBackground">@drawable/bg_splash</item> <item name="android:windowBackground">@drawable/bg_splash</item>
</style> </style>