mirror of
https://github.com/MinimalBible/MinimalBible-Legacy
synced 2024-11-09 01:28:25 -05:00
Initial commit for the re-code
This commit is contained in:
commit
0c383c088a
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
local.properties
|
||||
/.gradle
|
||||
/MinimalBible/build
|
||||
/MinimalBible/.gradle
|
||||
/appcompat_v7/build
|
||||
/.idea
|
||||
/build
|
||||
*.iml
|
9
.gitmodules
vendored
Normal file
9
.gitmodules
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
[submodule "jsword"]
|
||||
path = jsword
|
||||
url = https://github.com/crosswire/jsword.git
|
||||
[submodule "jsword-minimalbible"]
|
||||
path = jsword-minimalbible
|
||||
url = https://github.com/MinimalBible/jsword-minimalbible.git
|
||||
[submodule "ProgressWheel"]
|
||||
path = ProgressWheel
|
||||
url = git@github.com:Todd-Davies/ProgressWheel
|
15
.travis.yml
Normal file
15
.travis.yml
Normal file
@ -0,0 +1,15 @@
|
||||
language: android
|
||||
env:
|
||||
matrix:
|
||||
- ANDROID_SDKS=android-19,sysimg-19 ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
|
||||
|
||||
android:
|
||||
components:
|
||||
- build-tools-20.0.0
|
||||
|
||||
before_install:
|
||||
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
|
||||
- emulator -avd test -no-skin -no-audio -no-window &
|
||||
before_script:
|
||||
- ./wait_for_emulator
|
||||
- adb shell input keyevent 82 &
|
73
Minimal Bible.svg
Normal file
73
Minimal Bible.svg
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="48"
|
||||
height="48"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="New document 1">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="7.9195959"
|
||||
inkscape:cx="1.3613333"
|
||||
inkscape:cy="24.040952"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:snap-bbox="false"
|
||||
inkscape:window-width="1918"
|
||||
inkscape:window-height="1055"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Background"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-1004.3622)">
|
||||
<rect
|
||||
style="fill:#000000;stroke:#000000;stroke-width:6.05299997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;opacity:1;stroke-dashoffset:0"
|
||||
id="rect2985"
|
||||
width="41.946575"
|
||||
height="41.946575"
|
||||
x="3.0267119"
|
||||
y="1007.3889" />
|
||||
<path
|
||||
style="fill:#ffffff;stroke:none"
|
||||
d="M 21 4 L 21 13 L 9 13 L 9 19 L 21 19 L 21 44 L 27 44 L 27 19 L 39 19 L 39 13 L 27 13 L 27 4 L 21 4 z "
|
||||
transform="translate(0,1004.3622)"
|
||||
id="rect3937" />
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer2"
|
||||
inkscape:label="Cross" />
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
9
MinimalBible/.classpath
Normal file
9
MinimalBible/.classpath
Normal file
@ -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 exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
3
MinimalBible/.gitignore
vendored
Normal file
3
MinimalBible/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/gen
|
||||
/bin
|
||||
/libs-src
|
33
MinimalBible/.project
Normal file
33
MinimalBible/.project
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>MinimalBible</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>
|
4
MinimalBible/.settings/org.eclipse.jdt.core.prefs
Normal file
4
MinimalBible/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
184
MinimalBible/README.md
Normal file
184
MinimalBible/README.md
Normal file
@ -0,0 +1,184 @@
|
||||
MinimalBible
|
||||
============
|
||||
|
||||
A Bible app for android designed to be more focused in both UI and feature set.
|
||||
|
||||
Project Outline
|
||||
===============
|
||||
|
||||
This outline is intended to show the tasks needing to be accomplished, and give an idea of when releases will happen.
|
||||
|
||||
Core:
|
||||
-----
|
||||
These are the tasks that will need to be accomplished before the 1.0 major release.
|
||||
|
||||
* Project setup
|
||||
* Add the appcompat project to the Git repository
|
||||
|
||||
**Done as of [d6c7f498e6e1f5bbd7895f979dc25c5537e7cae5](https://github.com/DjBushido/MinimalBible/commit/d6c7f498e6e1f5bbd7895f979dc25c5537e7cae5)**
|
||||
|
||||
* Integration with JSword
|
||||
* Build JSword
|
||||
* Distribute an Android binary that contains JSword and 3rd party libraries
|
||||
|
||||
**Done as of [fd6c0630799d360cef83871cc6b3af05e4dc3a0d](https://github.com/DjBushido/MinimalBible/commit/fd6c0630799d360cef83871cc6b3af05e4dc3a0d)**
|
||||
|
||||
* Download Manager
|
||||
* Bible browser
|
||||
* Can download Bibles
|
||||
* Can remove Bibles
|
||||
* Generate search indexes for Bibles
|
||||
|
||||
* Bible Viewer
|
||||
* UI design finalized
|
||||
* Use Immersive mode for 4.4+?
|
||||
* Panels for footnotes, commentary?
|
||||
* Navigation drawer for books?
|
||||
* What gestures should be used? (Swipe left/right for chapter search?)
|
||||
* How to get to Download Manager / some form of home page?
|
||||
* Navigation of books working
|
||||
* Can display Bible text
|
||||
* Time from launch to viewing text under 5s. Ideally, under 3s. as well.
|
||||
* Can use navigation drawer to open a book
|
||||
* Infinite scroll between chapters
|
||||
* Research how to accomplish infinite scroll
|
||||
* Implement infinite scroll
|
||||
* Red letter enabled
|
||||
|
||||
* Cleanup
|
||||
* Include only necessary libraries for jSword, rather than all dependencies. APK ~20MB is way too big.
|
||||
|
||||
**Release v.1 to Play store**
|
||||
|
||||
* * *
|
||||
|
||||
* Search
|
||||
* UI design finalized (integration in Bible Viewer, separate activity?)
|
||||
* Search functionality implemented
|
||||
* Get Lucene search working (included in JSword)
|
||||
* Tweak search (fuzzy? Lord -> LORD? Are we actually getting results we want?)
|
||||
* Search history recorded
|
||||
* Record when search took place?
|
||||
|
||||
**Release v.2**
|
||||
|
||||
* * *
|
||||
|
||||
* Download Manager
|
||||
* Download manager can fetch commentaries
|
||||
|
||||
* Footnotes/Commentaries
|
||||
* UI design finalized
|
||||
* Frame on bottom of Bible Viewer a la [this](http://blog.neteril.org/blog/2013/10/10/framelayout-your-best-ui-friend/)?
|
||||
* Switch between footnotes/commentaries by swiping on panel?
|
||||
* Right-side nav drawer like FB?
|
||||
* Can we synchronize scroll between commentaries/footnotes?
|
||||
* Should Bible search also search commentaries?
|
||||
* Implement/Show commentaries/footnotes
|
||||
* Synchronize scrolling Bible to footnotes/commentaries
|
||||
* Is this possible?
|
||||
* Implement it!
|
||||
* Clicking on note in text opens commentary
|
||||
|
||||
**Release v.3**
|
||||
|
||||
* * *
|
||||
|
||||
* Settings Manager
|
||||
* Night mode?
|
||||
* Automatic night mode?
|
||||
* Text font/size
|
||||
* Clear searches?
|
||||
* Disable red-letter?
|
||||
* Send feedback
|
||||
|
||||
* Home screen
|
||||
* Allow access to settings, download manager, and Bible Viewer
|
||||
|
||||
**Release v1.0**
|
||||
**Party!**
|
||||
|
||||
* * *
|
||||
|
||||
Feature Addition
|
||||
----------------
|
||||
|
||||
These are features I want to add, but are not considered part of the "core" product. Many (most) are necessary features of a modern app, but follow after the first major release.
|
||||
|
||||
### Usage statistics
|
||||
* Include usage statistics?
|
||||
* Only send statistics on WiFi?
|
||||
* Disable by default? Prompt user?
|
||||
|
||||
### Sharing
|
||||
* UI Design finalized
|
||||
* Click on text to select it, then share?
|
||||
* Long-click text to share?
|
||||
* Share currently active text?
|
||||
* Dialog to select what range of text is included?
|
||||
* Share commentary/footnotes?
|
||||
* Intent filter created to share via FB, email, etc.
|
||||
* Settings
|
||||
* Share link to app alongside text? Allow disabling?
|
||||
|
||||
* * *
|
||||
|
||||
### Highlighting
|
||||
* UI Design finalized
|
||||
* Click on text to select like share?
|
||||
* Highlight colors / custom colors?
|
||||
* Multiple highlight colors?
|
||||
* Remove highlights?
|
||||
|
||||
* Database backing
|
||||
* First feature to need a database! Success!
|
||||
* How to store sections of highlighted material?
|
||||
* Store start/end range, along with highlight color?
|
||||
* Store when highlight was created?
|
||||
|
||||
* Bible Viewer
|
||||
* How to show highlights?
|
||||
* More specifically, how does showing highlights impact performance on start?
|
||||
* Show text first, then highlights after loaded?
|
||||
|
||||
* * *
|
||||
|
||||
### Notes
|
||||
* UI Design finalized
|
||||
* Likely very similar to highlighting
|
||||
|
||||
* Database backing
|
||||
* Likely very similar to highlighting
|
||||
* Store note instead of highlight color?
|
||||
* Store when note was created / updated?
|
||||
|
||||
* Bible Viewer
|
||||
* Same concerns as highlighting, how does it impact speed?
|
||||
* How do we display notes? Highlighting changes background color, have a separate link for our notes?
|
||||
* Do notes get added to a panel on bottom? Can user browse notes?
|
||||
|
||||
* Home Screen
|
||||
* Notes browser
|
||||
|
||||
* * *
|
||||
|
||||
### Widgets
|
||||
|
||||
* Text to display here?
|
||||
* Shortcut to specific verse/chapter?
|
||||
* How to create shortcuts?
|
||||
|
||||
* * *
|
||||
|
||||
### Cloud support
|
||||
|
||||
* Backup notes/highlights to cloud service?
|
||||
* Just backup entire app database to cloud?
|
||||
* Google Drive/Dropbox?
|
||||
* Settings
|
||||
* Automated backups?
|
||||
* Backup on WiFi only?
|
||||
|
||||
* * *
|
||||
|
||||
Plenty to get done!
|
83
MinimalBible/build.gradle
Normal file
83
MinimalBible/build.gradle
Normal file
@ -0,0 +1,83 @@
|
||||
apply plugin: 'android'
|
||||
apply plugin: 'android-apt'
|
||||
//apply plugin: 'retrolambda'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':jsword-minimalbible', configuration: 'buildJSword')
|
||||
compile project(':appcompat_v7')
|
||||
apt 'com.squareup.dagger:dagger-compiler:1.2.0'
|
||||
compile 'com.squareup.dagger:dagger:1.2.0'
|
||||
apt 'com.jakewharton:butterknife:5.0.1'
|
||||
compile 'com.jakewharton:butterknife:5.0.1'
|
||||
compile 'de.devland.esperandro:esperandro-api:1.1.2'
|
||||
apt 'de.devland.esperandro:esperandro:1.1.2'
|
||||
// compile 'com.f2prateek.dart:dart:1.1.0'
|
||||
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
|
||||
compile 'com.netflix.rxjava:rxjava-android:0.19.0'
|
||||
|
||||
// Handled by appcompat
|
||||
// compile 'com.google.android:support-v4:r7'
|
||||
|
||||
// And our unit testing needs some specific stuff (and specific stuff included again)
|
||||
androidTestCompile 'junit:junit:4.11+'
|
||||
androidTestCompile 'com.jayway.awaitility:awaitility:1.6.0'
|
||||
androidTestProvided 'com.squareup.dagger:dagger-compiler:1.2.0'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion '20'
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile 'src/main/AndroidManifest.xml'
|
||||
java.srcDirs = ['src/main/java']
|
||||
resources.srcDirs = ['src/main/res']
|
||||
aidl.srcDirs = ['src']
|
||||
renderscript.srcDirs = ['src']
|
||||
res.srcDirs = ['src/main/res']
|
||||
assets.srcDirs = ['src/main/assets']
|
||||
}
|
||||
|
||||
// Move the tests to tests/java, tests/res, etc...
|
||||
androidTest {
|
||||
manifest.srcFile 'src/test/AndroidManifest.xml'
|
||||
java.srcDirs = ['src/test/java']
|
||||
resources.srcDirs = ['src/test/res']
|
||||
assets.srcDirs = ['src/test/assets']
|
||||
}
|
||||
|
||||
// Move the build types to build-types/<type>
|
||||
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
|
||||
// This moves them out of them default location under src/<type>/... which would
|
||||
// conflict with src/ being used by the main source set.
|
||||
// Adding new build types or product flavors should be accompanied
|
||||
// by a similar customization.
|
||||
debug.setRoot('build-types/debug')
|
||||
release.setRoot('build-types/release')
|
||||
}
|
||||
packagingOptions {
|
||||
exclude 'META-INF/LICENSE.txt'
|
||||
exclude 'LICENSE.txt'
|
||||
exclude 'META-INF/NOTICE.txt'
|
||||
exclude 'META-INF/DEPENDENCIES'
|
||||
exclude 'META-INF/LICENSE'
|
||||
exclude 'META-INF/NOTICE'
|
||||
exclude 'META-INF/services/javax.annotation.processing.Processor'
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
BIN
MinimalBible/ic_launcher-web.png
Normal file
BIN
MinimalBible/ic_launcher-web.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
1
MinimalBible/libs/.gitignore
vendored
Normal file
1
MinimalBible/libs/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.jar
|
20
MinimalBible/proguard-project.txt
Normal file
20
MinimalBible/proguard-project.txt
Normal file
@ -0,0 +1,20 @@
|
||||
# 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 *;
|
||||
#}
|
15
MinimalBible/project.properties
Normal file
15
MinimalBible/project.properties
Normal file
@ -0,0 +1,15 @@
|
||||
# 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 edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-19
|
||||
android.library.reference.1=../appcompat_v7
|
34
MinimalBible/src/main/AndroidManifest.xml
Normal file
34
MinimalBible/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.bspeice.minimalbible"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="20" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme"
|
||||
android:name="org.bspeice.minimalbible.MinimalBible" >
|
||||
<activity
|
||||
android:name="org.bspeice.minimalbible.activities.viewer.BibleViewer"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.bspeice.minimalbible.activities.downloader.DownloadActivity"
|
||||
android:label="@string/title_activity_download" >
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
11
MinimalBible/src/main/assets/book.html
Normal file
11
MinimalBible/src/main/assets/book.html
Normal file
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<body>
|
||||
<div id="content" />
|
||||
|
||||
<script type="text/javascript">
|
||||
function set_content(content) {
|
||||
document.getElementById("content").innerHTML = content;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,530 @@
|
||||
package com.todddavies.components.progressbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import org.bspeice.minimalbible.R;
|
||||
|
||||
|
||||
/**
|
||||
* An indicator of progress, similar to Android's ProgressBar.
|
||||
* Can be used in 'spin mode' or 'increment mode'
|
||||
*
|
||||
* @author Todd Davies
|
||||
* <p/>
|
||||
* Licensed under the Creative Commons Attribution 3.0 license see:
|
||||
* http://creativecommons.org/licenses/by/3.0/
|
||||
*/
|
||||
public class ProgressWheel extends View {
|
||||
|
||||
//Sizes (with defaults)
|
||||
private int layout_height = 0;
|
||||
private int layout_width = 0;
|
||||
private int fullRadius = 100;
|
||||
private int circleRadius = 80;
|
||||
private int barLength = 60;
|
||||
private int barWidth = 20;
|
||||
private int rimWidth = 20;
|
||||
private int textSize = 20;
|
||||
private float contourSize = 0;
|
||||
|
||||
//Padding (with defaults)
|
||||
private int paddingTop = 5;
|
||||
private int paddingBottom = 5;
|
||||
private int paddingLeft = 5;
|
||||
private int paddingRight = 5;
|
||||
|
||||
//Colors (with defaults)
|
||||
private int barColor = 0xAA000000;
|
||||
private int contourColor = 0xAA000000;
|
||||
private int circleColor = 0x00000000;
|
||||
private int rimColor = 0xAADDDDDD;
|
||||
private int textColor = 0xFF000000;
|
||||
|
||||
//Paints
|
||||
private Paint barPaint = new Paint();
|
||||
private Paint circlePaint = new Paint();
|
||||
private Paint rimPaint = new Paint();
|
||||
private Paint textPaint = new Paint();
|
||||
private Paint contourPaint = new Paint();
|
||||
|
||||
//Rectangles
|
||||
@SuppressWarnings("unused")
|
||||
private RectF rectBounds = new RectF();
|
||||
private RectF circleBounds = new RectF();
|
||||
private RectF circleOuterContour = new RectF();
|
||||
private RectF circleInnerContour = new RectF();
|
||||
|
||||
//Animation
|
||||
//The amount of pixels to move the bar by on each draw
|
||||
private int spinSpeed = 2;
|
||||
//The number of milliseconds to wait inbetween each draw
|
||||
private int delayMillis = 0;
|
||||
private Handler spinHandler = new Handler() {
|
||||
/**
|
||||
* This is the code that will increment the progress variable
|
||||
* and so spin the wheel
|
||||
*/
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
invalidate();
|
||||
if (isSpinning) {
|
||||
progress += spinSpeed;
|
||||
if (progress > 360) {
|
||||
progress = 0;
|
||||
}
|
||||
spinHandler.sendEmptyMessageDelayed(0, delayMillis);
|
||||
}
|
||||
//super.handleMessage(msg);
|
||||
}
|
||||
};
|
||||
int progress = 0;
|
||||
boolean isSpinning = false;
|
||||
|
||||
//Other
|
||||
private String text = "";
|
||||
private String[] splitText = {};
|
||||
|
||||
/**
|
||||
* The constructor for the ProgressWheel
|
||||
*
|
||||
* @param context
|
||||
* @param attrs
|
||||
*/
|
||||
public ProgressWheel(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
parseAttributes(context.obtainStyledAttributes(attrs,
|
||||
R.styleable.ProgressWheel));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
//Setting up stuff
|
||||
//----------------------------------
|
||||
|
||||
/*
|
||||
* When this is called, make the view square.
|
||||
* From: http://www.jayway.com/2012/12/12/creating-custom-android-views-part-4-measuring-and-how-to-force-a-view-to-be-square/
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
// The first thing that happen is that we call the superclass
|
||||
// implementation of onMeasure. The reason for that is that measuring
|
||||
// can be quite a complex process and calling the super method is a
|
||||
// convenient way to get most of this complexity handled.
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
// We can’t use getWidth() or getHight() here. During the measuring
|
||||
// pass the view has not gotten its final size yet (this happens first
|
||||
// at the start of the layout pass) so we have to use getMeasuredWidth()
|
||||
// and getMeasuredHeight().
|
||||
int size = 0;
|
||||
int width = getMeasuredWidth();
|
||||
int height = getMeasuredHeight();
|
||||
int widthWithoutPadding = width - getPaddingLeft() - getPaddingRight();
|
||||
int heigthWithoutPadding = height - getPaddingTop() - getPaddingBottom();
|
||||
|
||||
// Finally we have some simple logic that calculates the size of the view
|
||||
// and calls setMeasuredDimension() to set that size.
|
||||
// Before we compare the width and height of the view, we remove the padding,
|
||||
// and when we set the dimension we add it back again. Now the actual content
|
||||
// of the view will be square, but, depending on the padding, the total dimensions
|
||||
// of the view might not be.
|
||||
if (widthWithoutPadding > heigthWithoutPadding) {
|
||||
size = heigthWithoutPadding;
|
||||
} else {
|
||||
size = widthWithoutPadding;
|
||||
}
|
||||
|
||||
// If you override onMeasure() you have to call setMeasuredDimension().
|
||||
// This is how you report back the measured size. If you don’t call
|
||||
// setMeasuredDimension() the parent will throw an exception and your
|
||||
// application will crash.
|
||||
// We are calling the onMeasure() method of the superclass so we don’t
|
||||
// actually need to call setMeasuredDimension() since that takes care
|
||||
// of that. However, the purpose with overriding onMeasure() was to
|
||||
// change the default behaviour and to do that we need to call
|
||||
// setMeasuredDimension() with our own values.
|
||||
setMeasuredDimension(size + getPaddingLeft() + getPaddingRight(), size + getPaddingTop() + getPaddingBottom());
|
||||
}
|
||||
|
||||
/**
|
||||
* Use onSizeChanged instead of onAttachedToWindow to get the dimensions of the view,
|
||||
* because this method is called after measuring the dimensions of MATCH_PARENT & WRAP_CONTENT.
|
||||
* Use this dimensions to setup the bounds and paints.
|
||||
*/
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
|
||||
// Share the dimensions
|
||||
layout_width = w;
|
||||
layout_height = h;
|
||||
|
||||
setupBounds();
|
||||
setupPaints();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the properties of the paints we're using to
|
||||
* draw the progress wheel
|
||||
*/
|
||||
private void setupPaints() {
|
||||
barPaint.setColor(barColor);
|
||||
barPaint.setAntiAlias(true);
|
||||
barPaint.setStyle(Style.STROKE);
|
||||
barPaint.setStrokeWidth(barWidth);
|
||||
|
||||
rimPaint.setColor(rimColor);
|
||||
rimPaint.setAntiAlias(true);
|
||||
rimPaint.setStyle(Style.STROKE);
|
||||
rimPaint.setStrokeWidth(rimWidth);
|
||||
|
||||
circlePaint.setColor(circleColor);
|
||||
circlePaint.setAntiAlias(true);
|
||||
circlePaint.setStyle(Style.FILL);
|
||||
|
||||
textPaint.setColor(textColor);
|
||||
textPaint.setStyle(Style.FILL);
|
||||
textPaint.setAntiAlias(true);
|
||||
textPaint.setTextSize(textSize);
|
||||
|
||||
contourPaint.setColor(contourColor);
|
||||
contourPaint.setAntiAlias(true);
|
||||
contourPaint.setStyle(Style.STROKE);
|
||||
contourPaint.setStrokeWidth(contourSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bounds of the component
|
||||
*/
|
||||
private void setupBounds() {
|
||||
// Width should equal to Height, find the min value to steup the circle
|
||||
int minValue = Math.min(layout_width, layout_height);
|
||||
|
||||
// Calc the Offset if needed
|
||||
int xOffset = layout_width - minValue;
|
||||
int yOffset = layout_height - minValue;
|
||||
|
||||
// Add the offset
|
||||
paddingTop = this.getPaddingTop() + (yOffset / 2);
|
||||
paddingBottom = this.getPaddingBottom() + (yOffset / 2);
|
||||
paddingLeft = this.getPaddingLeft() + (xOffset / 2);
|
||||
paddingRight = this.getPaddingRight() + (xOffset / 2);
|
||||
|
||||
int width = getWidth(); //this.getLayoutParams().width;
|
||||
int height = getHeight(); //this.getLayoutParams().height;
|
||||
|
||||
rectBounds = new RectF(paddingLeft,
|
||||
paddingTop,
|
||||
width - paddingRight,
|
||||
height - paddingBottom);
|
||||
|
||||
circleBounds = new RectF(paddingLeft + barWidth,
|
||||
paddingTop + barWidth,
|
||||
width - paddingRight - barWidth,
|
||||
height - paddingBottom - barWidth);
|
||||
circleInnerContour = new RectF(circleBounds.left + (rimWidth / 2.0f) + (contourSize / 2.0f), circleBounds.top + (rimWidth / 2.0f) + (contourSize / 2.0f), circleBounds.right - (rimWidth / 2.0f) - (contourSize / 2.0f), circleBounds.bottom - (rimWidth / 2.0f) - (contourSize / 2.0f));
|
||||
circleOuterContour = new RectF(circleBounds.left - (rimWidth / 2.0f) - (contourSize / 2.0f), circleBounds.top - (rimWidth / 2.0f) - (contourSize / 2.0f), circleBounds.right + (rimWidth / 2.0f) + (contourSize / 2.0f), circleBounds.bottom + (rimWidth / 2.0f) + (contourSize / 2.0f));
|
||||
|
||||
fullRadius = (width - paddingRight - barWidth) / 2;
|
||||
circleRadius = (fullRadius - barWidth) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the attributes passed to the view from the XML
|
||||
*
|
||||
* @param a the attributes to parse
|
||||
*/
|
||||
private void parseAttributes(TypedArray a) {
|
||||
barWidth = (int) a.getDimension(R.styleable.ProgressWheel_barWidth,
|
||||
barWidth);
|
||||
|
||||
rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_rimWidth,
|
||||
rimWidth);
|
||||
|
||||
spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_spinSpeed,
|
||||
spinSpeed);
|
||||
|
||||
delayMillis = a.getInteger(R.styleable.ProgressWheel_delayMillis,
|
||||
delayMillis);
|
||||
if (delayMillis < 0) {
|
||||
delayMillis = 0;
|
||||
}
|
||||
|
||||
barColor = a.getColor(R.styleable.ProgressWheel_barColor, barColor);
|
||||
|
||||
barLength = (int) a.getDimension(R.styleable.ProgressWheel_barLength,
|
||||
barLength);
|
||||
|
||||
textSize = (int) a.getDimension(R.styleable.ProgressWheel_textSize,
|
||||
textSize);
|
||||
|
||||
textColor = (int) a.getColor(R.styleable.ProgressWheel_textColor,
|
||||
textColor);
|
||||
|
||||
//if the text is empty , so ignore it
|
||||
if (a.hasValue(R.styleable.ProgressWheel_text)) {
|
||||
setText(a.getString(R.styleable.ProgressWheel_text));
|
||||
}
|
||||
|
||||
rimColor = (int) a.getColor(R.styleable.ProgressWheel_rimColor,
|
||||
rimColor);
|
||||
|
||||
circleColor = (int) a.getColor(R.styleable.ProgressWheel_circleColor,
|
||||
circleColor);
|
||||
|
||||
contourColor = a.getColor(R.styleable.ProgressWheel_contourColor, contourColor);
|
||||
contourSize = a.getDimension(R.styleable.ProgressWheel_contourSize, contourSize);
|
||||
|
||||
|
||||
// Recycle
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
//Animation stuff
|
||||
//----------------------------------
|
||||
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
//Draw the inner circle
|
||||
canvas.drawArc(circleBounds, 360, 360, false, circlePaint);
|
||||
//Draw the rim
|
||||
canvas.drawArc(circleBounds, 360, 360, false, rimPaint);
|
||||
canvas.drawArc(circleOuterContour, 360, 360, false, contourPaint);
|
||||
canvas.drawArc(circleInnerContour, 360, 360, false, contourPaint);
|
||||
//Draw the bar
|
||||
if (isSpinning) {
|
||||
canvas.drawArc(circleBounds, progress - 90, barLength, false,
|
||||
barPaint);
|
||||
} else {
|
||||
canvas.drawArc(circleBounds, -90, progress, false, barPaint);
|
||||
}
|
||||
//Draw the text (attempts to center it horizontally and vertically)
|
||||
float textHeight = textPaint.descent() - textPaint.ascent();
|
||||
float verticalTextOffset = (textHeight / 2) - textPaint.descent();
|
||||
|
||||
for (String s : splitText) {
|
||||
float horizontalTextOffset = textPaint.measureText(s) / 2;
|
||||
canvas.drawText(s, this.getWidth() / 2 - horizontalTextOffset,
|
||||
this.getHeight() / 2 + verticalTextOffset, textPaint);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the wheel is currently spinning
|
||||
*/
|
||||
|
||||
public boolean isSpinning() {
|
||||
if(isSpinning){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the count (in increment mode)
|
||||
*/
|
||||
public void resetCount() {
|
||||
progress = 0;
|
||||
setText("0%");
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn off spin mode
|
||||
*/
|
||||
public void stopSpinning() {
|
||||
isSpinning = false;
|
||||
progress = 0;
|
||||
spinHandler.removeMessages(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Puts the view on spin mode
|
||||
*/
|
||||
public void spin() {
|
||||
isSpinning = true;
|
||||
spinHandler.sendEmptyMessage(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the progress by 1 (of 360)
|
||||
*/
|
||||
public void incrementProgress() {
|
||||
isSpinning = false;
|
||||
progress++;
|
||||
if (progress > 360)
|
||||
progress = 0;
|
||||
// setText(Math.round(((float) progress / 360) * 100) + "%");
|
||||
spinHandler.sendEmptyMessage(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the progress to a specific value
|
||||
*/
|
||||
public void setProgress(int i) {
|
||||
isSpinning = false;
|
||||
progress = i;
|
||||
spinHandler.sendEmptyMessage(0);
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
//Getters + setters
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* Set the text in the progress bar
|
||||
* Doesn't invalidate the view
|
||||
*
|
||||
* @param text the text to show ('\n' constitutes a new line)
|
||||
*/
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
splitText = this.text.split("\n");
|
||||
}
|
||||
|
||||
public int getCircleRadius() {
|
||||
return circleRadius;
|
||||
}
|
||||
|
||||
public void setCircleRadius(int circleRadius) {
|
||||
this.circleRadius = circleRadius;
|
||||
}
|
||||
|
||||
public int getBarLength() {
|
||||
return barLength;
|
||||
}
|
||||
|
||||
public void setBarLength(int barLength) {
|
||||
this.barLength = barLength;
|
||||
}
|
||||
|
||||
public int getBarWidth() {
|
||||
return barWidth;
|
||||
}
|
||||
|
||||
public void setBarWidth(int barWidth) {
|
||||
this.barWidth = barWidth;
|
||||
}
|
||||
|
||||
public int getTextSize() {
|
||||
return textSize;
|
||||
}
|
||||
|
||||
public void setTextSize(int textSize) {
|
||||
this.textSize = textSize;
|
||||
}
|
||||
|
||||
public int getPaddingTop() {
|
||||
return paddingTop;
|
||||
}
|
||||
|
||||
public void setPaddingTop(int paddingTop) {
|
||||
this.paddingTop = paddingTop;
|
||||
}
|
||||
|
||||
public int getPaddingBottom() {
|
||||
return paddingBottom;
|
||||
}
|
||||
|
||||
public void setPaddingBottom(int paddingBottom) {
|
||||
this.paddingBottom = paddingBottom;
|
||||
}
|
||||
|
||||
public int getPaddingLeft() {
|
||||
return paddingLeft;
|
||||
}
|
||||
|
||||
public void setPaddingLeft(int paddingLeft) {
|
||||
this.paddingLeft = paddingLeft;
|
||||
}
|
||||
|
||||
public int getPaddingRight() {
|
||||
return paddingRight;
|
||||
}
|
||||
|
||||
public void setPaddingRight(int paddingRight) {
|
||||
this.paddingRight = paddingRight;
|
||||
}
|
||||
|
||||
public int getBarColor() {
|
||||
return barColor;
|
||||
}
|
||||
|
||||
public void setBarColor(int barColor) {
|
||||
this.barColor = barColor;
|
||||
}
|
||||
|
||||
public int getCircleColor() {
|
||||
return circleColor;
|
||||
}
|
||||
|
||||
public void setCircleColor(int circleColor) {
|
||||
this.circleColor = circleColor;
|
||||
}
|
||||
|
||||
public int getRimColor() {
|
||||
return rimColor;
|
||||
}
|
||||
|
||||
public void setRimColor(int rimColor) {
|
||||
this.rimColor = rimColor;
|
||||
}
|
||||
|
||||
|
||||
public Shader getRimShader() {
|
||||
return rimPaint.getShader();
|
||||
}
|
||||
|
||||
public void setRimShader(Shader shader) {
|
||||
this.rimPaint.setShader(shader);
|
||||
}
|
||||
|
||||
public int getTextColor() {
|
||||
return textColor;
|
||||
}
|
||||
|
||||
public void setTextColor(int textColor) {
|
||||
this.textColor = textColor;
|
||||
}
|
||||
|
||||
public int getSpinSpeed() {
|
||||
return spinSpeed;
|
||||
}
|
||||
|
||||
public void setSpinSpeed(int spinSpeed) {
|
||||
this.spinSpeed = spinSpeed;
|
||||
}
|
||||
|
||||
public int getRimWidth() {
|
||||
return rimWidth;
|
||||
}
|
||||
|
||||
public void setRimWidth(int rimWidth) {
|
||||
this.rimWidth = rimWidth;
|
||||
}
|
||||
|
||||
public int getDelayMillis() {
|
||||
return delayMillis;
|
||||
}
|
||||
|
||||
public void setDelayMillis(int delayMillis) {
|
||||
this.delayMillis = delayMillis;
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package org.bspeice.minimalbible;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.crosswire.jsword.book.sword.SwordBookPath;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import dagger.ObjectGraph;
|
||||
|
||||
public class MinimalBible extends Application {
|
||||
|
||||
/**
|
||||
* The graph used by Dagger to track dependencies
|
||||
*/
|
||||
private ObjectGraph graph;
|
||||
|
||||
/**
|
||||
* A singleton reference to the Application currently being run.
|
||||
* Used mostly so we have a fixed point to get the App Context from
|
||||
*/
|
||||
private static MinimalBible instance;
|
||||
|
||||
private String TAG = "MinimalBible";
|
||||
|
||||
/**
|
||||
* Create the application, and persist the application Context
|
||||
*/
|
||||
public MinimalBible() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Application Context. Please note, all attempts to get the App Context should come
|
||||
* through here, and please be sure that the Application won't satisfy what you need.
|
||||
* @return The Application Context
|
||||
*/
|
||||
public static Context getAppContext() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Application, rather than just the Application Context. You likely should be using
|
||||
* this, rather than {@link #getAppContext()}
|
||||
* @return The MinimalBible {@link android.app.Application} object
|
||||
*/
|
||||
public static MinimalBible getApplication() {
|
||||
return (MinimalBible)getAppContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the {@link android.app.Application}. Responsible for building and
|
||||
* holding on to the master ObjectGraph.
|
||||
*/
|
||||
@Override
|
||||
public void onCreate() {
|
||||
//TODO: Is this necessary?
|
||||
inject(this);
|
||||
setJswordHome();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject a Dagger object
|
||||
* @param o The object to be injected
|
||||
*/
|
||||
public void inject(Object o) {
|
||||
getObjGraph().inject(o);
|
||||
}
|
||||
|
||||
public ObjectGraph getObjGraph() {
|
||||
if (graph == null) {
|
||||
graph = ObjectGraph.create(MinimalBibleModules.class);
|
||||
}
|
||||
return graph;
|
||||
}
|
||||
|
||||
public void plusObjGraph(Object... modules) {
|
||||
graph = graph.plus(modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify jSword that it needs to store files in the Android internal directory
|
||||
* NOTE: Android will uninstall these files if you uninstall MinimalBible.
|
||||
*/
|
||||
@SuppressWarnings("null")
|
||||
private void setJswordHome() {
|
||||
// We need to set the download directory for jSword to stick with
|
||||
// Android.
|
||||
String home = MinimalBible.getAppContext().getFilesDir().toString();
|
||||
Log.d(TAG, "Setting jsword.home to: " + home);
|
||||
System.setProperty("jsword.home", home);
|
||||
System.setProperty("sword.home", home);
|
||||
SwordBookPath.setDownloadDir(new File(home));
|
||||
Log.d(TAG, "Sword download path: " + SwordBookPath.getSwordDownloadDir());
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package org.bspeice.minimalbible;
|
||||
|
||||
import org.bspeice.minimalbible.activities.ActivityModules;
|
||||
|
||||
import dagger.Module;
|
||||
|
||||
/**
|
||||
* Master module for MinimalBible
|
||||
*/
|
||||
@Module(
|
||||
injects = {
|
||||
MinimalBible.class
|
||||
},
|
||||
includes = {
|
||||
ActivityModules.class
|
||||
}
|
||||
)
|
||||
public class MinimalBibleModules {
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package org.bspeice.minimalbible.activities;
|
||||
|
||||
import org.bspeice.minimalbible.activities.downloader.ActivityDownloaderModule;
|
||||
import org.bspeice.minimalbible.activities.viewer.ActivityViewerModule;
|
||||
|
||||
import dagger.Module;
|
||||
|
||||
/**
|
||||
* Modules for all activities
|
||||
*/
|
||||
@Module(
|
||||
includes = {
|
||||
ActivityDownloaderModule.class,
|
||||
ActivityViewerModule.class
|
||||
}
|
||||
)
|
||||
public class ActivityModules {
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.bspeice.minimalbible.activities;
|
||||
|
||||
import org.bspeice.minimalbible.R;
|
||||
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
/**
|
||||
* Wrapper for activities in MinimalBible to make sure we can support
|
||||
* common functionality between them all.
|
||||
*/
|
||||
public class BaseActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Only set the tint if the device is running KitKat or above
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
SystemBarTintManager tintManager = new SystemBarTintManager(this);
|
||||
tintManager.setStatusBarTintEnabled(true);
|
||||
tintManager.setStatusBarTintColor(getResources().getColor(
|
||||
R.color.statusbar));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package org.bspeice.minimalbible.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.View;
|
||||
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
|
||||
/**
|
||||
* Base class that defines all behavior common to Fragments in MinimalBible
|
||||
*/
|
||||
public class BaseFragment extends Fragment {
|
||||
|
||||
/**
|
||||
* Calculate the offset we need to display properly if the System bar is translucent
|
||||
* @param context The {@link android.app.Activity} we are displaying in
|
||||
* @param view The {@link android.view.View} we need to calculate the offset for.
|
||||
*/
|
||||
protected static void setInsets(Activity context, View view) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
|
||||
SystemBarTintManager tintManager = new SystemBarTintManager(context);
|
||||
SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
|
||||
view.setPadding(0, config.getPixelInsetTop(true), config.getPixelInsetRight(), config.getPixelInsetBottom());
|
||||
}
|
||||
}
|
@ -0,0 +1,302 @@
|
||||
package org.bspeice.minimalbible.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.ActionBarDrawerToggle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
|
||||
import org.bspeice.minimalbible.R;
|
||||
|
||||
/**
|
||||
* Fragment used for managing interactions for and presentation of a navigation
|
||||
* drawer. See the <a href=
|
||||
* "https://developer.android.com/design/patterns/navigation-drawer.html#Interaction"
|
||||
* > design guidelines</a> for a complete explanation of the behaviors
|
||||
* implemented here.
|
||||
*/
|
||||
public class BaseNavigationDrawerFragment extends Fragment {
|
||||
|
||||
/**
|
||||
* Remember the position of the selected item.
|
||||
*/
|
||||
private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
|
||||
|
||||
/**
|
||||
* Per the design guidelines, you should show the drawer on launch until the
|
||||
* user manually expands it. This shared preference tracks this.
|
||||
*/
|
||||
private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned";
|
||||
|
||||
/**
|
||||
* A pointer to the current callbacks instance (the Activity).
|
||||
*/
|
||||
private NavigationDrawerCallbacks mCallbacks;
|
||||
|
||||
/**
|
||||
* Helper component that ties the action bar to the navigation drawer.
|
||||
*/
|
||||
private ActionBarDrawerToggle mDrawerToggle;
|
||||
|
||||
private DrawerLayout mDrawerLayout;
|
||||
protected ListView mDrawerListView;
|
||||
private View mFragmentContainerView;
|
||||
|
||||
protected int mCurrentSelectedPosition = 0;
|
||||
private boolean mFromSavedInstanceState;
|
||||
private boolean mUserLearnedDrawer;
|
||||
|
||||
public BaseNavigationDrawerFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Read in the flag indicating whether or not the user has demonstrated
|
||||
// awareness of the
|
||||
// drawer. See PREF_USER_LEARNED_DRAWER for details.
|
||||
SharedPreferences sp = PreferenceManager
|
||||
.getDefaultSharedPreferences(getActivity());
|
||||
mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mCurrentSelectedPosition = savedInstanceState
|
||||
.getInt(STATE_SELECTED_POSITION);
|
||||
mFromSavedInstanceState = true;
|
||||
}
|
||||
|
||||
// Select either the default item (0) or the last selected item.
|
||||
selectItem(mCurrentSelectedPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
// Indicate that this fragment would like to influence the set of
|
||||
// actions in the action bar.
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
public boolean isDrawerOpen() {
|
||||
return mDrawerLayout != null
|
||||
&& mDrawerLayout.isDrawerOpen(mFragmentContainerView);
|
||||
}
|
||||
|
||||
/**
|
||||
* Users of this fragment must call this method to set up the navigation
|
||||
* drawer interactions.
|
||||
*
|
||||
* @param fragmentId
|
||||
* The android:id of this fragment in its activity's layout.
|
||||
* @param drawerLayout
|
||||
* The DrawerLayout containing this fragment's UI.
|
||||
*/
|
||||
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
|
||||
mFragmentContainerView = getActivity().findViewById(fragmentId);
|
||||
mDrawerLayout = drawerLayout;
|
||||
|
||||
// set a custom shadow that overlays the main content when the drawer
|
||||
// opens
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
|
||||
GravityCompat.START);
|
||||
// set up the drawer's list view with items and click listener
|
||||
|
||||
ActionBar actionBar = getActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||