Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial import

  • Loading branch information...
commit 6f8b2defa20bdf4bdc67a7a83a9264cb428dd798 0 parents
Mark Murphy authored
Showing with 1,339 additions and 0 deletions.
  1. +9 −0 .classpath
  2. +33 −0 .project
  3. +32 −0 AndroidManifest.xml
  4. +202 −0 LICENSE
  5. +85 −0 build.xml
  6. +8 −0 demo/.classpath
  7. +33 −0 demo/.project
  8. +31 −0 demo/AndroidManifest.xml
  9. +85 −0 demo/build.xml
  10. +35 −0 demo/proguard-project.txt
  11. +13 −0 demo/project.properties
  12. BIN  demo/res/drawable-hdpi/ic_launcher.png
  13. BIN  demo/res/drawable-ldpi/ic_launcher.png
  14. BIN  demo/res/drawable-mdpi/ic_launcher.png
  15. BIN  demo/res/drawable-xhdpi/ic_launcher.png
  16. +7 −0 demo/res/values/strings.xml
  17. BIN  libs/android-support-v4.jar
  18. +40 −0 proguard.cfg
  19. +14 −0 project.properties
  20. BIN  res/drawable-hdpi/ic_launcher.png
  21. BIN  res/drawable-ldpi/ic_launcher.png
  22. BIN  res/drawable-mdpi/ic_launcher.png
  23. BIN  res/drawable-xhdpi/ic_launcher.png
  24. +5 −0 res/layout/empub_chapter.xml
  25. +27 −0 res/layout/empub_main.xml
  26. +20 −0 res/layout/empub_zoom.xml
  27. +9 −0 res/menu/empub_actions.xml
  28. +8 −0 res/values/strings.xml
  29. +49 −0 src/com/commonsware/empub/BookContents.java
  30. +219 −0 src/com/commonsware/empub/ChapterFragment.java
  31. +51 −0 src/com/commonsware/empub/ContentsLoader.java
  32. +211 −0 src/com/commonsware/empub/EmPubActivity.java
  33. +6 −0 src/com/commonsware/empub/NavListener.java
  34. +107 −0 src/com/commonsware/empub/WebViewFragment.java
9 .classpath
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="lib" path="libs/android-support-v4.jar"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
33 .project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>EmPub</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
32 AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.commonsware.empub"
+ android:installLocation="auto"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="11"/>
+
+ <supports-screens
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="false"
+ android:xlargeScreens="true"/>
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/Theme.Sherlock"
+ android:uiOptions="splitActionBarWhenNarrow">
+ <activity android:name=".EmPubActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
202 LICENSE
@@ -0,0 +1,202 @@
+
+ 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
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ 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
+
+ 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.
85 build.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="EmPubActivity" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="ant.properties" />
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
+
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
+ unless="sdk.dir"
+ />
+
+
+<!-- extension targets. Uncomment the ones where you want to do custom work
+ in between standard targets -->
+<!--
+ <target name="-pre-build">
+ </target>
+ <target name="-pre-compile">
+ </target>
+
+ /* This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir} */
+ <target name="-post-compile">
+ </target>
+-->
+
+ <!-- Import the actual build file.
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
+ -->
+ <!-- version-tag: 1 -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>
8 demo/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
33 demo/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>EmPubDemo</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
31 demo/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.commonsware.empub.demo"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="11"/>
+
+ <supports-screens
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="false"
+ android:xlargeScreens="true"/>
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/Theme.Sherlock"
+ android:uiOptions="splitActionBarWhenNarrow">
+ <activity android:name="com.commonsware.empub.EmPubActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
85 demo/build.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="EmPub" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="ant.properties" />
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
+
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
+ unless="sdk.dir"
+ />
+
+
+<!-- extension targets. Uncomment the ones where you want to do custom work
+ in between standard targets -->
+<!--
+ <target name="-pre-build">
+ </target>
+ <target name="-pre-compile">
+ </target>
+
+ /* This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir} */
+ <target name="-post-compile">
+ </target>
+-->
+
+ <!-- Import the actual build file.
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
+ -->
+ <!-- version-tag: 1 -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>
35 demo/proguard-project.txt
@@ -0,0 +1,35 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# 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 *;
+#}
+
+###########################
+# ActionBarSherlock
+
+-keep class android.support.v4.app.** { *; }
+-keep interface android.support.v4.app.** { *; }
+-keep class com.actionbarsherlock.** { *; }
+-keep interface com.actionbarsherlock.** { *; }
+
+-keepattributes *Annotation*
+
+###########################
+# EmPub
+
+-keep class android.support.v4.content.** { *; }
13 demo/project.properties
@@ -0,0 +1,13 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-15
+android.library.reference.1=..
+proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
BIN  demo/res/drawable-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  demo/res/drawable-ldpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  demo/res/drawable-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  demo/res/drawable-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 demo/res/values/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="hello">Hello World!</string>
+ <string name="app_name">EmPub Demo</string>
+
+</resources>
BIN  libs/android-support-v4.jar
Binary file not shown
40 proguard.cfg
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
14 project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-14
+android.library.reference.1=../CWAC/LoaderEx
+android.library=true
+android.library.reference.2=../3rdParty/ActionBarSherlock-4.0.1/library
BIN  res/drawable-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-ldpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 res/layout/empub_chapter.xml
@@ -0,0 +1,5 @@
+<WebView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/browser"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="8dip"/>
27 res/layout/empub_main.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/relativeLayout1"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"/>
+
+ <android.support.v4.view.ViewPager
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/pager"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:visibility="gone">
+
+ <android.support.v4.view.PagerTitleStrip
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"/>
+ </android.support.v4.view.ViewPager>
+
+</RelativeLayout>
20 res/layout/empub_zoom.xml
@@ -0,0 +1,20 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/linearLayout1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:text="@string/empub_zoom_caption"
+ android:layout_marginRight="4dip"/>
+
+ <SeekBar
+ android:id="@+id/zoomBar"
+ android:layout_width="100dip"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:max="150"/>
+
+</LinearLayout>
9 res/menu/empub_actions.xml
@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/empub_zoom"
+ android:actionLayout="@layout/empub_zoom"
+ android:showAsAction="ifRoom">
+ </item>
+
+</menu>
8 res/values/strings.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">EmPub Reader</string>
+ <string name="empub_exception_json">Exception loading book contents JSON</string>
+ <string name="empub_toc">Table of Contents</string>
+ <string name="empub_zoom_caption">Zoom:</string>
+
+</resources>
49 src/com/commonsware/empub/BookContents.java
@@ -0,0 +1,49 @@
+package com.commonsware.empub;
+
+import java.util.HashMap;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+public class BookContents {
+ JSONObject raw=null;
+ HashMap<String, Integer> files=new HashMap<String, Integer>();
+ JSONArray chapters;
+
+ BookContents(JSONObject raw) {
+ this.raw=raw;
+ chapters=raw.optJSONArray("chapters");
+
+ for (int i=0;i<getChapterCount();i++) {
+ files.put(getChapterFile(i), i);
+ }
+ }
+
+ int getChapterCount() {
+ return(chapters.length());
+ }
+
+ String getChapterFile(int position) {
+ JSONObject chapter=chapters.optJSONObject(position);
+
+ return(chapter.optString("file"));
+ }
+
+ String getChapterTitle(int position) {
+ JSONObject chapter=chapters.optJSONObject(position);
+ String result=chapter.optString("title");
+
+ if (result==null) {
+ result=String.valueOf(position+1);
+ }
+
+ return(result);
+ }
+
+ int getPositionForFile(String file) {
+ return(files.get(file));
+ }
+
+ String getTOCFile() {
+ return(raw.optString("toc"));
+ }
+}
219 src/com/commonsware/empub/ChapterFragment.java
@@ -0,0 +1,219 @@
+package com.commonsware.empub;
+
+import android.content.SharedPreferences;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import android.widget.SeekBar;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.commonsware.cwac.loaderex.acl.SharedPreferencesLoader;
+
+public class ChapterFragment extends WebViewFragment implements
+ SeekBar.OnSeekBarChangeListener,
+ SharedPreferences.OnSharedPreferenceChangeListener {
+ private static int cacheZoomLevel=100;
+ private static final String KEY_FILE="file";
+ private static final String PREF_ZOOM="zoom";
+ private ChapterClient client=null;
+ private NavListener nav=null;
+ private SeekBar zoom=null;
+ private SharedPreferences prefs=null;
+
+ static ChapterFragment newInstance(String file) {
+ ChapterFragment f=new ChapterFragment();
+
+ Bundle args=new Bundle();
+
+ args.putString(KEY_FILE, file);
+ f.setArguments(args);
+
+ return(f);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setRetainInstance(true);
+ setHasOptionsMenu(true);
+ prefs=((EmPubActivity)getActivity()).getPreferences();
+ this.client=new ChapterClient();
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater,
+ ViewGroup container,
+ Bundle savedInstanceState) {
+ View result=
+ super.onCreateView(inflater, container, savedInstanceState);
+
+ setZoom();
+ getWebView().setWebViewClient(client);
+
+ // following required due to bug
+ // http://code.google.com/p/android/issues/detail?id=3440
+ getWebView().getSettings().setBuiltInZoomControls(false);
+ getWebView().getSettings().setJavaScriptEnabled(true);
+
+ prefs.registerOnSharedPreferenceChangeListener(this);
+ cacheZoomLevel=prefs.getInt(PREF_ZOOM, 100);
+
+ if (zoom != null) {
+ updateZoom();
+ }
+
+ String page=
+ "file:///android_asset/" + getArguments().getString(KEY_FILE);
+
+ getWebView().loadUrl(page);
+
+ final String anchor=((EmPubActivity)getActivity()).popAnchor(getArguments().getString(KEY_FILE));
+
+ // would use onPageFinished(), but it is hopelessly buggy
+
+ if (anchor!=null) {
+ result.postDelayed(new Runnable() {
+ public void run() {
+ jumpTo(anchor);
+ }
+ }, 1000);
+ }
+
+ return(result);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ setZoom();
+ }
+
+ @Override
+ public void onDestroy() {
+ prefs.unregisterOnSharedPreferenceChangeListener(this);
+
+ super.onDestroy();
+ }
+
+ // needed due to Android Support bug
+ // see http://stackoverflow.com/questions/8748064/starting-activity-from-fragment-causes-nullpointerexception
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ setUserVisibleHint(true);
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ inflater.inflate(R.menu.empub_actions, menu);
+
+ View action=menu.findItem(R.id.empub_zoom).getActionView();
+
+ zoom=(SeekBar)action.findViewById(R.id.zoomBar);
+ zoom.setOnSeekBarChangeListener(this);
+
+ if (prefs != null && getWebView() != null) {
+ updateZoom();
+ }
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress,
+ boolean fromUser) {
+ if (fromUser) {
+ cacheZoomLevel=progress + 50;
+ SharedPreferencesLoader.persist(prefs.edit()
+ .putInt(PREF_ZOOM,
+ progress + 50));
+ setZoom();
+ }
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // unused
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ // unused
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
+ String key) {
+ if (getWebView() != null) {
+ setZoom();
+ }
+ }
+
+ void setNavListener(NavListener nav) {
+ this.nav=nav;
+ }
+
+ void jumpTo(String anchor) {
+ if (getWebView()!=null) {
+ StringBuilder buf=new StringBuilder("javascript:location.href=\"#");
+
+ buf.append(anchor);
+ buf.append("\";");
+
+ getWebView().loadUrl(buf.toString());
+ }
+ }
+
+ private void updateZoom() {
+ setZoom();
+ zoom.setProgress(cacheZoomLevel - 50);
+ }
+
+ private void setZoom() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ getWebView().getSettings().setTextZoom(cacheZoomLevel);
+ }
+ else {
+ if (cacheZoomLevel <= 25) {
+ getWebView().getSettings()
+ .setTextSize(WebSettings.TextSize.SMALLEST);
+ }
+ else if (cacheZoomLevel <= 75) {
+ getWebView().getSettings()
+ .setTextSize(WebSettings.TextSize.SMALLER);
+ }
+ else if (cacheZoomLevel <= 125) {
+ getWebView().getSettings()
+ .setTextSize(WebSettings.TextSize.NORMAL);
+ }
+ else if (cacheZoomLevel <= 175) {
+ getWebView().getSettings()
+ .setTextSize(WebSettings.TextSize.LARGER);
+ }
+ else {
+ getWebView().getSettings()
+ .setTextSize(WebSettings.TextSize.LARGEST);
+ }
+ }
+ }
+
+ class ChapterClient extends WebViewClient {
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView view, String url) {
+ if (url.startsWith(EmPubActivity.CONTENT_PREFIX)) {
+ nav.onInternalLinkClicked(url);
+ }
+ else {
+ nav.onExternalLinkClicked(url);
+ }
+
+ return(true);
+ }
+ }
+}
51 src/com/commonsware/empub/ContentsLoader.java
@@ -0,0 +1,51 @@
+package com.commonsware.empub;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import android.content.Context;
+import android.support.v4.content.AsyncTaskLoader;
+import org.json.JSONObject;
+
+public class ContentsLoader extends AsyncTaskLoader<BookContents> {
+ private BookContents contents=null;
+
+ public ContentsLoader(Context context) {
+ super(context);
+ }
+
+ @Override
+ public BookContents loadInBackground() {
+ try {
+ StringBuilder buf=new StringBuilder();
+ InputStream json=
+ getContext().getResources().getAssets().open("contents.json");
+ BufferedReader in=new BufferedReader(new InputStreamReader(json));
+ String str;
+
+ while ((str=in.readLine()) != null) {
+ buf.append(str);
+ }
+
+ in.close();
+
+ return(new BookContents(new JSONObject(buf.toString())));
+ }
+ catch (Exception e) {
+ String msg=getContext().getString(R.string.empub_exception_json);
+
+ throw new RuntimeException(msg, e);
+ }
+ }
+
+ @Override
+ protected void onStartLoading() {
+ if (contents != null) {
+ deliverResult(contents);
+ }
+
+ if (takeContentChanged() || contents == null) {
+ forceLoad();
+ }
+ }
+}
211 src/com/commonsware/empub/EmPubActivity.java
@@ -0,0 +1,211 @@
+package com.commonsware.empub;
+
+import java.util.HashMap;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.ApplicationInfo;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.StrictMode;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.content.Loader;
+import android.support.v4.view.ViewPager;
+import android.view.View;
+import com.actionbarsherlock.app.SherlockFragmentActivity;
+import com.actionbarsherlock.view.MenuItem;
+import com.commonsware.cwac.loaderex.acl.SharedPreferencesLoader;
+
+public class EmPubActivity extends SherlockFragmentActivity implements
+ LoaderManager.LoaderCallbacks<BookContents>, NavListener {
+ public static final String TAG="EmPub";
+ public static final String CONTENT_PREFIX="file:///android_asset/";
+ public static final String EXTRA_FILE="file";
+ private static final int LOADER_CONTENTS=0;
+ private static final int LOADER_PREFS=1;
+ private ViewPager pager=null;
+ private BookContents contents=null;
+ private ContentsAdapter adapter=null;
+ private SharedPreferences prefs=null;
+ private HashMap<String, String> anchors=new HashMap<String, String>();
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
+ ApplicationInfo appInfo=getApplicationInfo();
+ int appFlags=appInfo.flags;
+
+ if ((appFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
+ enableStrictMode();
+ }
+ }
+
+ setContentView(R.layout.empub_main);
+ pager=(ViewPager)findViewById(R.id.pager);
+
+ getSupportLoaderManager().initLoader(LOADER_PREFS, null,
+ new PrefsLoaderCallbacks());
+ getSupportLoaderManager().initLoader(LOADER_CONTENTS, null, this);
+ }
+
+ @Override
+ public Loader<BookContents> onCreateLoader(int id, Bundle args) {
+ return(new ContentsLoader(this));
+ }
+
+ @Override
+ public void onLoadFinished(Loader<BookContents> loader,
+ BookContents contents) {
+ if (this.contents == null) {
+ this.contents=contents;
+ setupPager();
+ }
+ }
+
+ @Override
+ public void onLoaderReset(Loader<BookContents> loader) {
+ // unused
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ pager.setCurrentItem(0, false);
+ }
+
+ return(super.onOptionsItemSelected(item));
+ }
+
+ @Override
+ public void onInternalLinkClicked(String url) {
+ String[] pieces=url.substring(CONTENT_PREFIX.length()).split("#");
+ int position=contents.getPositionForFile(pieces[0]);
+
+ if (pieces.length == 2) {
+ anchors.put(pieces[0], pieces[1]);
+
+ ChapterFragment frag=(ChapterFragment)adapter.getActiveFragment(pager, position+1);
+
+ if (frag!=null) {
+ frag.jumpTo(pieces[1]);
+ }
+ }
+
+ pager.setCurrentItem(position + 1, false);
+ }
+
+ @Override
+ public void onExternalLinkClicked(String url) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+ }
+
+ String popAnchor(String path) {
+ return(anchors.remove(path));
+ }
+
+ SharedPreferences getPreferences() {
+ return(prefs);
+ }
+
+ private void setupPager() {
+ if (contents != null && prefs != null) {
+ adapter=new ContentsAdapter(this, contents, this);
+ pager.setAdapter(adapter);
+ findViewById(R.id.progressBar).setVisibility(View.GONE);
+ findViewById(R.id.pager).setVisibility(View.VISIBLE);
+ }
+ }
+
+ private void enableStrictMode() {
+ StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll()
+ .penaltyLog()
+ .build());
+ StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll()
+ .penaltyLog()
+ .build());
+ }
+
+ private static class ContentsAdapter extends FragmentPagerAdapter {
+ BookContents contents=null;
+ NavListener nav=null;
+ FragmentActivity ctxt=null;
+
+ public ContentsAdapter(FragmentActivity ctxt,
+ BookContents contents, NavListener nav) {
+ super(ctxt.getSupportFragmentManager());
+ this.ctxt=ctxt;
+ this.contents=contents;
+ this.nav=nav;
+ }
+
+ @Override
+ public int getCount() {
+ return(contents.getChapterCount() + 1);
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ ChapterFragment frag=null;
+
+ if (position == 0) {
+ frag=ChapterFragment.newInstance(contents.getTOCFile());
+ }
+ else {
+ String path=contents.getChapterFile(position - 1);
+
+ frag=ChapterFragment.newInstance(path);
+ }
+
+ frag.setNavListener(nav);
+
+ return(frag);
+ }
+
+ @Override
+ public String getPageTitle(int position) {
+ if (position == 0) {
+ return(ctxt.getString(R.string.empub_toc));
+ }
+
+ return(contents.getChapterTitle(position - 1));
+ }
+
+ // nasty nasty hack
+ // http://stackoverflow.com/a/9293207/115145
+
+ Fragment getActiveFragment(ViewPager container, int position) {
+ String name=makeFragmentName(container.getId(), position);
+ return ctxt.getSupportFragmentManager().findFragmentByTag(name);
+ }
+
+ private static String makeFragmentName(int viewId, int index) {
+ return "android:switcher:" + viewId + ":" + index;
+ }
+ }
+
+ private class PrefsLoaderCallbacks implements
+ LoaderManager.LoaderCallbacks<SharedPreferences> {
+
+ @Override
+ public Loader<SharedPreferences> onCreateLoader(int id, Bundle arg1) {
+ return(new SharedPreferencesLoader(EmPubActivity.this));
+ }
+
+ @Override
+ public void onLoadFinished(Loader<SharedPreferences> loader,
+ SharedPreferences prefs) {
+ EmPubActivity.this.prefs=prefs;
+ setupPager();
+ }
+
+ @Override
+ public void onLoaderReset(Loader<SharedPreferences> loader) {
+ // unused
+ }
+ }
+}
6 src/com/commonsware/empub/NavListener.java
@@ -0,0 +1,6 @@
+package com.commonsware.empub;
+
+public interface NavListener {
+ void onInternalLinkClicked(String url);
+ void onExternalLinkClicked(String url);
+}
107 src/com/commonsware/empub/WebViewFragment.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * Portions Copyright (c) 2012 CommonsWare, LLC
+ *
+ * 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
+ *
+ * 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.
+ */
+
+//package android.webkit;
+package com.commonsware.empub;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebView;
+import com.actionbarsherlock.app.SherlockFragment;
+
+/**
+ * A fragment that displays a WebView.
+ * <p>
+ * The WebView is automatically paused or resumed when the Fragment is paused or resumed.
+ */
+public class WebViewFragment extends SherlockFragment {
+ private WebView mWebView;
+ private boolean mIsWebViewAvailable;
+
+ public WebViewFragment() {
+ }
+
+ /**
+ * Called to instantiate the view. Creates and returns the WebView.
+ */
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ if (mWebView != null) {
+ // mWebView.destroy();
+
+ // MLM modification to actually maintain context
+ // when used with setRetainInstance(true)
+ ((ViewGroup)mWebView.getParent()).removeView(mWebView);
+ }
+ else {
+ mWebView = new WebView(getActivity());
+ }
+
+ mIsWebViewAvailable = true;
+ return mWebView;
+ }
+
+ /**
+ * Called when the fragment is visible to the user and actively running. Resumes the WebView.
+ */
+ @Override
+ public void onPause() {
+ super.onPause();
+ mWebView.onPause();
+ }
+
+ /**
+ * Called when the fragment is no longer resumed. Pauses the WebView.
+ */
+ @Override
+ public void onResume() {
+ mWebView.onResume();
+ super.onResume();
+ }
+
+ /**
+ * Called when the WebView has been detached from the fragment.
+ * The WebView is no longer available after this time.
+ */
+ @Override
+ public void onDestroyView() {
+ mIsWebViewAvailable = false;
+ super.onDestroyView();
+ }
+
+ /**
+ * Called when the fragment is no longer in use. Destroys the internal state of the WebView.
+ */
+ @Override
+ public void onDestroy() {
+ if (mWebView != null) {
+ mWebView.destroy();
+ mWebView = null;
+ }
+ super.onDestroy();
+ }
+
+ /**
+ * Gets the WebView.
+ */
+ public WebView getWebView() {
+ return mIsWebViewAvailable ? mWebView : null;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.