From d664f12d0825201f64c755b2b6ecee26e2169e6b Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Mon, 19 May 2014 22:34:56 -0400 Subject: [PATCH] Path refactoring Also fixed an issue with View recycling --- MinimalBible/build.gradle | 14 +- .../components/progressbar/ProgressWheel.java | 1060 ++++++++--------- .../bspeice/minimalbible/MinimalBible.java | 0 .../minimalbible/MinimalBibleModules.java | 0 .../activities/ActivityModules.java | 0 .../minimalbible/activities/BaseActivity.java | 0 .../minimalbible/activities/BaseFragment.java | 0 .../BaseNavigationDrawerFragment.java | 0 .../downloader/ActivityDownloaderModule.java | 0 .../downloader/BookListAdapter.java | 36 +- .../downloader/BookListFragment.java | 4 +- .../downloader/DownloadActivity.java | 0 .../downloader/DownloadNavDrawerFragment.java | 0 .../activities/downloader/DownloadPrefs_.java | 0 .../activities/downloader/_DownloadPrefs.java | 0 .../downloader/manager/BookRefreshTask.java | 0 .../downloader/manager/DownloadManager.java | 0 .../downloader/manager/EventBookList.java | 0 .../activities/viewer/BibleViewer.java | 0 .../viewer/ViewerNavDrawerFragment.java | 0 .../res/drawable-hdpi/drawer_shadow.9.png | Bin .../res/drawable-hdpi/ic_action_download.png | Bin .../res/drawable-hdpi/ic_action_search.png | Bin .../main}/res/drawable-hdpi/ic_drawer.png | Bin .../main}/res/drawable-hdpi/ic_launcher.png | Bin .../res/drawable-mdpi/drawer_shadow.9.png | Bin .../res/drawable-mdpi/ic_action_download.png | Bin .../res/drawable-mdpi/ic_action_search.png | Bin .../main}/res/drawable-mdpi/ic_drawer.png | Bin .../main}/res/drawable-mdpi/ic_launcher.png | Bin .../res/drawable-xhdpi/drawer_shadow.9.png | Bin .../res/drawable-xhdpi/ic_action_download.png | Bin .../res/drawable-xhdpi/ic_action_search.png | Bin .../main}/res/drawable-xhdpi/ic_drawer.png | Bin .../main}/res/drawable-xhdpi/ic_launcher.png | Bin .../res/drawable-xxhdpi/drawer_shadow.9.png | Bin .../drawable-xxhdpi/ic_action_download.png | Bin .../res/drawable-xxhdpi/ic_action_search.png | Bin .../main}/res/drawable-xxhdpi/ic_drawer.png | Bin .../main}/res/drawable-xxhdpi/ic_launcher.png | Bin .../res/layout/activity_bible_viewer.xml | 0 .../main}/res/layout/activity_download.xml | 0 .../main}/res/layout/fragment_download.xml | 0 .../main}/res/layout/fragment_main.xml | 0 .../res/layout/fragment_navigation_drawer.xml | 0 .../main}/res/layout/list_download_items.xml | 13 +- .../{ => src/main}/res/menu/download.xml | 0 .../{ => src/main}/res/menu/downloader.xml | 0 .../{ => src/main}/res/menu/global.xml | 0 MinimalBible/{ => src/main}/res/menu/main.xml | 0 .../main}/res/values-sw600dp/dimens.xml | 0 .../main}/res/values-sw720dp-land/dimens.xml | 0 .../{ => src/main}/res/values-v11/styles.xml | 0 .../{ => src/main}/res/values-v14/styles.xml | 0 .../{ => src/main}/res/values-v19/styles.xml | 0 .../main}/res/values-w820dp/dimens.xml | 0 .../{ => src/main}/res/values/attrs.xml | 36 +- .../{ => src/main}/res/values/colors.xml | 0 .../{ => src/main}/res/values/dimens.xml | 0 .../{ => src/main}/res/values/strings.xml | 0 .../{ => src/main}/res/values/styles.xml | 0 .../test/DownloadActivityTest.java | 20 + 62 files changed, 598 insertions(+), 585 deletions(-) rename MinimalBible/src/{ => main/java}/com/todddavies/components/progressbar/ProgressWheel.java (96%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/MinimalBible.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/MinimalBibleModules.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/ActivityModules.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/BaseActivity.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/BaseFragment.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/BaseNavigationDrawerFragment.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java (65%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/downloader/BookListFragment.java (97%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/downloader/DownloadNavDrawerFragment.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/downloader/DownloadPrefs_.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/downloader/_DownloadPrefs.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/downloader/manager/BookRefreshTask.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/downloader/manager/DownloadManager.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/viewer/BibleViewer.java (100%) rename MinimalBible/src/{ => main/java}/org/bspeice/minimalbible/activities/viewer/ViewerNavDrawerFragment.java (100%) rename MinimalBible/{ => src/main}/res/drawable-hdpi/drawer_shadow.9.png (100%) rename MinimalBible/{ => src/main}/res/drawable-hdpi/ic_action_download.png (100%) rename MinimalBible/{ => src/main}/res/drawable-hdpi/ic_action_search.png (100%) rename MinimalBible/{ => src/main}/res/drawable-hdpi/ic_drawer.png (100%) rename MinimalBible/{ => src/main}/res/drawable-hdpi/ic_launcher.png (100%) rename MinimalBible/{ => src/main}/res/drawable-mdpi/drawer_shadow.9.png (100%) rename MinimalBible/{ => src/main}/res/drawable-mdpi/ic_action_download.png (100%) rename MinimalBible/{ => src/main}/res/drawable-mdpi/ic_action_search.png (100%) rename MinimalBible/{ => src/main}/res/drawable-mdpi/ic_drawer.png (100%) rename MinimalBible/{ => src/main}/res/drawable-mdpi/ic_launcher.png (100%) rename MinimalBible/{ => src/main}/res/drawable-xhdpi/drawer_shadow.9.png (100%) rename MinimalBible/{ => src/main}/res/drawable-xhdpi/ic_action_download.png (100%) rename MinimalBible/{ => src/main}/res/drawable-xhdpi/ic_action_search.png (100%) rename MinimalBible/{ => src/main}/res/drawable-xhdpi/ic_drawer.png (100%) rename MinimalBible/{ => src/main}/res/drawable-xhdpi/ic_launcher.png (100%) rename MinimalBible/{ => src/main}/res/drawable-xxhdpi/drawer_shadow.9.png (100%) rename MinimalBible/{ => src/main}/res/drawable-xxhdpi/ic_action_download.png (100%) rename MinimalBible/{ => src/main}/res/drawable-xxhdpi/ic_action_search.png (100%) rename MinimalBible/{ => src/main}/res/drawable-xxhdpi/ic_drawer.png (100%) rename MinimalBible/{ => src/main}/res/drawable-xxhdpi/ic_launcher.png (100%) rename MinimalBible/{ => src/main}/res/layout/activity_bible_viewer.xml (100%) rename MinimalBible/{ => src/main}/res/layout/activity_download.xml (100%) rename MinimalBible/{ => src/main}/res/layout/fragment_download.xml (100%) rename MinimalBible/{ => src/main}/res/layout/fragment_main.xml (100%) rename MinimalBible/{ => src/main}/res/layout/fragment_navigation_drawer.xml (100%) rename MinimalBible/{ => src/main}/res/layout/list_download_items.xml (78%) rename MinimalBible/{ => src/main}/res/menu/download.xml (100%) rename MinimalBible/{ => src/main}/res/menu/downloader.xml (100%) rename MinimalBible/{ => src/main}/res/menu/global.xml (100%) rename MinimalBible/{ => src/main}/res/menu/main.xml (100%) rename MinimalBible/{ => src/main}/res/values-sw600dp/dimens.xml (100%) rename MinimalBible/{ => src/main}/res/values-sw720dp-land/dimens.xml (100%) rename MinimalBible/{ => src/main}/res/values-v11/styles.xml (100%) rename MinimalBible/{ => src/main}/res/values-v14/styles.xml (100%) rename MinimalBible/{ => src/main}/res/values-v19/styles.xml (100%) rename MinimalBible/{ => src/main}/res/values-w820dp/dimens.xml (100%) rename MinimalBible/{ => src/main}/res/values/attrs.xml (97%) rename MinimalBible/{ => src/main}/res/values/colors.xml (100%) rename MinimalBible/{ => src/main}/res/values/dimens.xml (100%) rename MinimalBible/{ => src/main}/res/values/strings.xml (100%) rename MinimalBible/{ => src/main}/res/values/styles.xml (100%) create mode 100644 MinimalBible/src/test/org/bspeice/minimalbible/test/DownloadActivityTest.java diff --git a/MinimalBible/build.gradle b/MinimalBible/build.gradle index 995e341..6259e02 100644 --- a/MinimalBible/build.gradle +++ b/MinimalBible/build.gradle @@ -47,16 +47,16 @@ android { sourceSets { main { manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src'] - resources.srcDirs = ['src'] + java.srcDirs = ['src/main/java'] + resources.srcDirs = ['src/main/res'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] - res.srcDirs = ['res'] - assets.srcDirs = ['assets'] + res.srcDirs = ['src/main/res'] + assets.srcDirs = ['src/main/assets'] } // Move the tests to tests/java, tests/res, etc... - instrumentTest.setRoot('tests') + instrumentTest.setRoot('src/test') // Move the build types to build-types/ // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... @@ -76,6 +76,4 @@ android { exclude 'META-INF/NOTICE' exclude 'META-INF/services/javax.annotation.processing.Processor' } -} - - +} \ No newline at end of file diff --git a/MinimalBible/src/com/todddavies/components/progressbar/ProgressWheel.java b/MinimalBible/src/main/java/com/todddavies/components/progressbar/ProgressWheel.java similarity index 96% rename from MinimalBible/src/com/todddavies/components/progressbar/ProgressWheel.java rename to MinimalBible/src/main/java/com/todddavies/components/progressbar/ProgressWheel.java index 224d212..9d56b95 100644 --- a/MinimalBible/src/com/todddavies/components/progressbar/ProgressWheel.java +++ b/MinimalBible/src/main/java/com/todddavies/components/progressbar/ProgressWheel.java @@ -1,530 +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 - *

- * 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; - } -} +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 + *

+ * 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; + } +} diff --git a/MinimalBible/src/org/bspeice/minimalbible/MinimalBible.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/MinimalBible.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/MinimalBible.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/MinimalBible.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/MinimalBibleModules.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/MinimalBibleModules.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/MinimalBibleModules.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/MinimalBibleModules.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/ActivityModules.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/ActivityModules.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/ActivityModules.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/ActivityModules.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/BaseActivity.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/BaseActivity.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/BaseActivity.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/BaseActivity.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/BaseFragment.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/BaseFragment.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/BaseFragment.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/BaseFragment.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/BaseNavigationDrawerFragment.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/BaseNavigationDrawerFragment.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/BaseNavigationDrawerFragment.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/BaseNavigationDrawerFragment.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java similarity index 65% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java index 6c76414..7e95be9 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java @@ -1,13 +1,11 @@ package org.bspeice.minimalbible.activities.downloader; -import android.content.Context; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.RelativeLayout; import android.widget.TextView; import com.todddavies.components.progressbar.ProgressWheel; @@ -26,11 +24,11 @@ import butterknife.OnClick; public class BookListAdapter extends BaseAdapter { private List bookList; - private Context ctx; + private LayoutInflater inflater; - public BookListAdapter(Context context, List bookList) { + public BookListAdapter(LayoutInflater inflater, List bookList) { this.bookList = bookList; - this.ctx = context; + this.inflater = inflater; } @Override @@ -50,38 +48,40 @@ public class BookListAdapter extends BaseAdapter { @Override public View getView(int position, View convertView, ViewGroup parent) { - BookItemView itemView; - if (convertView == null) { - itemView = new BookItemView(this.ctx); + BookItemHolder viewHolder; + // Nasty Android issue - if you don't check the getTag(), Android will start recycling, + // and you'll get some really strange issues + if (convertView == null || convertView.getTag() == null) { + convertView = inflater.inflate(R.layout.list_download_items, null); + viewHolder = new BookItemHolder(convertView); } else { - itemView = (BookItemView) convertView; + viewHolder = (BookItemHolder) convertView.getTag(); } - itemView.bind(getItem(position)); - return itemView; + viewHolder.bindHolder(position); + return convertView; } - public class BookItemView extends RelativeLayout { + public class BookItemHolder { - @InjectView(R.id.img_download_icon) ImageView downloadIcon; @InjectView(R.id.download_txt_item_acronym) TextView acronym; @InjectView(R.id.txt_download_item_name) TextView itemName; @InjectView(R.id.download_ibtn_download) ImageButton isDownloaded; @InjectView(R.id.download_prg_download) ProgressWheel downloadProgress; - public BookItemView (Context ctx) { - super(ctx); - View v = LayoutInflater.from(ctx).inflate(R.layout.list_download_items, this); + public BookItemHolder(View v) { ButterKnife.inject(this, v); } - public void bind(Book b) { + public void bindHolder(int position) { + Book b = BookListAdapter.this.getItem(position); acronym.setText(b.getInitials()); itemName.setText(b.getName()); } @OnClick(R.id.download_ibtn_download) public void onDownloadItem(View v) { + Log.d("BookListAdapter", v.toString()); isDownloaded.setVisibility(View.GONE); downloadProgress.setVisibility(View.VISIBLE); downloadProgress.setProgress(75); // Out of 360 diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListFragment.java similarity index 97% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListFragment.java index 9abf0c4..8acad4a 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/BookListFragment.java @@ -54,6 +54,7 @@ public class BookListFragment extends BaseFragment { @Inject DownloadPrefs_ downloadPrefs; private ProgressDialog refreshDialog; + private LayoutInflater inflater; /** * Returns a new instance of this fragment for the given section number. @@ -76,6 +77,7 @@ public class BookListFragment extends BaseFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + this.inflater = inflater; View rootView = inflater.inflate(R.layout.fragment_download, container, false); ButterKnife.inject(this, rootView); @@ -154,7 +156,7 @@ public class BookListFragment extends BaseFragment { displayList = FilterUtil.applyFilter(bookList, f); Collections.sort(displayList, BookComparators.getInitialComparator()); - downloadsAvailable.setAdapter(new BookListAdapter(this.getActivity(), displayList)); + downloadsAvailable.setAdapter(new BookListAdapter(inflater, displayList)); setInsets(getActivity(), downloadsAvailable); } catch (FilterUtil.InvalidFilterCategoryMappingException e) { // To be honest, there should be no reason you end up here. diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadNavDrawerFragment.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/DownloadNavDrawerFragment.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadNavDrawerFragment.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/DownloadNavDrawerFragment.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadPrefs_.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/DownloadPrefs_.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadPrefs_.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/DownloadPrefs_.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/_DownloadPrefs.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/_DownloadPrefs.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/_DownloadPrefs.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/_DownloadPrefs.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/BookRefreshTask.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/BookRefreshTask.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/BookRefreshTask.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/BookRefreshTask.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/DownloadManager.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/DownloadManager.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/DownloadManager.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/DownloadManager.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/viewer/BibleViewer.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/viewer/BibleViewer.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/viewer/BibleViewer.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/viewer/BibleViewer.java diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/viewer/ViewerNavDrawerFragment.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/viewer/ViewerNavDrawerFragment.java similarity index 100% rename from MinimalBible/src/org/bspeice/minimalbible/activities/viewer/ViewerNavDrawerFragment.java rename to MinimalBible/src/main/java/org/bspeice/minimalbible/activities/viewer/ViewerNavDrawerFragment.java diff --git a/MinimalBible/res/drawable-hdpi/drawer_shadow.9.png b/MinimalBible/src/main/res/drawable-hdpi/drawer_shadow.9.png similarity index 100% rename from MinimalBible/res/drawable-hdpi/drawer_shadow.9.png rename to MinimalBible/src/main/res/drawable-hdpi/drawer_shadow.9.png diff --git a/MinimalBible/res/drawable-hdpi/ic_action_download.png b/MinimalBible/src/main/res/drawable-hdpi/ic_action_download.png similarity index 100% rename from MinimalBible/res/drawable-hdpi/ic_action_download.png rename to MinimalBible/src/main/res/drawable-hdpi/ic_action_download.png diff --git a/MinimalBible/res/drawable-hdpi/ic_action_search.png b/MinimalBible/src/main/res/drawable-hdpi/ic_action_search.png similarity index 100% rename from MinimalBible/res/drawable-hdpi/ic_action_search.png rename to MinimalBible/src/main/res/drawable-hdpi/ic_action_search.png diff --git a/MinimalBible/res/drawable-hdpi/ic_drawer.png b/MinimalBible/src/main/res/drawable-hdpi/ic_drawer.png similarity index 100% rename from MinimalBible/res/drawable-hdpi/ic_drawer.png rename to MinimalBible/src/main/res/drawable-hdpi/ic_drawer.png diff --git a/MinimalBible/res/drawable-hdpi/ic_launcher.png b/MinimalBible/src/main/res/drawable-hdpi/ic_launcher.png similarity index 100% rename from MinimalBible/res/drawable-hdpi/ic_launcher.png rename to MinimalBible/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/MinimalBible/res/drawable-mdpi/drawer_shadow.9.png b/MinimalBible/src/main/res/drawable-mdpi/drawer_shadow.9.png similarity index 100% rename from MinimalBible/res/drawable-mdpi/drawer_shadow.9.png rename to MinimalBible/src/main/res/drawable-mdpi/drawer_shadow.9.png diff --git a/MinimalBible/res/drawable-mdpi/ic_action_download.png b/MinimalBible/src/main/res/drawable-mdpi/ic_action_download.png similarity index 100% rename from MinimalBible/res/drawable-mdpi/ic_action_download.png rename to MinimalBible/src/main/res/drawable-mdpi/ic_action_download.png diff --git a/MinimalBible/res/drawable-mdpi/ic_action_search.png b/MinimalBible/src/main/res/drawable-mdpi/ic_action_search.png similarity index 100% rename from MinimalBible/res/drawable-mdpi/ic_action_search.png rename to MinimalBible/src/main/res/drawable-mdpi/ic_action_search.png diff --git a/MinimalBible/res/drawable-mdpi/ic_drawer.png b/MinimalBible/src/main/res/drawable-mdpi/ic_drawer.png similarity index 100% rename from MinimalBible/res/drawable-mdpi/ic_drawer.png rename to MinimalBible/src/main/res/drawable-mdpi/ic_drawer.png diff --git a/MinimalBible/res/drawable-mdpi/ic_launcher.png b/MinimalBible/src/main/res/drawable-mdpi/ic_launcher.png similarity index 100% rename from MinimalBible/res/drawable-mdpi/ic_launcher.png rename to MinimalBible/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/MinimalBible/res/drawable-xhdpi/drawer_shadow.9.png b/MinimalBible/src/main/res/drawable-xhdpi/drawer_shadow.9.png similarity index 100% rename from MinimalBible/res/drawable-xhdpi/drawer_shadow.9.png rename to MinimalBible/src/main/res/drawable-xhdpi/drawer_shadow.9.png diff --git a/MinimalBible/res/drawable-xhdpi/ic_action_download.png b/MinimalBible/src/main/res/drawable-xhdpi/ic_action_download.png similarity index 100% rename from MinimalBible/res/drawable-xhdpi/ic_action_download.png rename to MinimalBible/src/main/res/drawable-xhdpi/ic_action_download.png diff --git a/MinimalBible/res/drawable-xhdpi/ic_action_search.png b/MinimalBible/src/main/res/drawable-xhdpi/ic_action_search.png similarity index 100% rename from MinimalBible/res/drawable-xhdpi/ic_action_search.png rename to MinimalBible/src/main/res/drawable-xhdpi/ic_action_search.png diff --git a/MinimalBible/res/drawable-xhdpi/ic_drawer.png b/MinimalBible/src/main/res/drawable-xhdpi/ic_drawer.png similarity index 100% rename from MinimalBible/res/drawable-xhdpi/ic_drawer.png rename to MinimalBible/src/main/res/drawable-xhdpi/ic_drawer.png diff --git a/MinimalBible/res/drawable-xhdpi/ic_launcher.png b/MinimalBible/src/main/res/drawable-xhdpi/ic_launcher.png similarity index 100% rename from MinimalBible/res/drawable-xhdpi/ic_launcher.png rename to MinimalBible/src/main/res/drawable-xhdpi/ic_launcher.png diff --git a/MinimalBible/res/drawable-xxhdpi/drawer_shadow.9.png b/MinimalBible/src/main/res/drawable-xxhdpi/drawer_shadow.9.png similarity index 100% rename from MinimalBible/res/drawable-xxhdpi/drawer_shadow.9.png rename to MinimalBible/src/main/res/drawable-xxhdpi/drawer_shadow.9.png diff --git a/MinimalBible/res/drawable-xxhdpi/ic_action_download.png b/MinimalBible/src/main/res/drawable-xxhdpi/ic_action_download.png similarity index 100% rename from MinimalBible/res/drawable-xxhdpi/ic_action_download.png rename to MinimalBible/src/main/res/drawable-xxhdpi/ic_action_download.png diff --git a/MinimalBible/res/drawable-xxhdpi/ic_action_search.png b/MinimalBible/src/main/res/drawable-xxhdpi/ic_action_search.png similarity index 100% rename from MinimalBible/res/drawable-xxhdpi/ic_action_search.png rename to MinimalBible/src/main/res/drawable-xxhdpi/ic_action_search.png diff --git a/MinimalBible/res/drawable-xxhdpi/ic_drawer.png b/MinimalBible/src/main/res/drawable-xxhdpi/ic_drawer.png similarity index 100% rename from MinimalBible/res/drawable-xxhdpi/ic_drawer.png rename to MinimalBible/src/main/res/drawable-xxhdpi/ic_drawer.png diff --git a/MinimalBible/res/drawable-xxhdpi/ic_launcher.png b/MinimalBible/src/main/res/drawable-xxhdpi/ic_launcher.png similarity index 100% rename from MinimalBible/res/drawable-xxhdpi/ic_launcher.png rename to MinimalBible/src/main/res/drawable-xxhdpi/ic_launcher.png diff --git a/MinimalBible/res/layout/activity_bible_viewer.xml b/MinimalBible/src/main/res/layout/activity_bible_viewer.xml similarity index 100% rename from MinimalBible/res/layout/activity_bible_viewer.xml rename to MinimalBible/src/main/res/layout/activity_bible_viewer.xml diff --git a/MinimalBible/res/layout/activity_download.xml b/MinimalBible/src/main/res/layout/activity_download.xml similarity index 100% rename from MinimalBible/res/layout/activity_download.xml rename to MinimalBible/src/main/res/layout/activity_download.xml diff --git a/MinimalBible/res/layout/fragment_download.xml b/MinimalBible/src/main/res/layout/fragment_download.xml similarity index 100% rename from MinimalBible/res/layout/fragment_download.xml rename to MinimalBible/src/main/res/layout/fragment_download.xml diff --git a/MinimalBible/res/layout/fragment_main.xml b/MinimalBible/src/main/res/layout/fragment_main.xml similarity index 100% rename from MinimalBible/res/layout/fragment_main.xml rename to MinimalBible/src/main/res/layout/fragment_main.xml diff --git a/MinimalBible/res/layout/fragment_navigation_drawer.xml b/MinimalBible/src/main/res/layout/fragment_navigation_drawer.xml similarity index 100% rename from MinimalBible/res/layout/fragment_navigation_drawer.xml rename to MinimalBible/src/main/res/layout/fragment_navigation_drawer.xml diff --git a/MinimalBible/res/layout/list_download_items.xml b/MinimalBible/src/main/res/layout/list_download_items.xml similarity index 78% rename from MinimalBible/res/layout/list_download_items.xml rename to MinimalBible/src/main/res/layout/list_download_items.xml index 0f5c5fc..de9cf98 100644 --- a/MinimalBible/res/layout/list_download_items.xml +++ b/MinimalBible/src/main/res/layout/list_download_items.xml @@ -6,13 +6,6 @@ android:layout_height="match_parent" android:padding="8dp"> - - + android:layout_alignParentStart="true" + android:layout_toLeftOf="@+id/download_ibtn_download"/> - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MinimalBible/res/values/colors.xml b/MinimalBible/src/main/res/values/colors.xml similarity index 100% rename from MinimalBible/res/values/colors.xml rename to MinimalBible/src/main/res/values/colors.xml diff --git a/MinimalBible/res/values/dimens.xml b/MinimalBible/src/main/res/values/dimens.xml similarity index 100% rename from MinimalBible/res/values/dimens.xml rename to MinimalBible/src/main/res/values/dimens.xml diff --git a/MinimalBible/res/values/strings.xml b/MinimalBible/src/main/res/values/strings.xml similarity index 100% rename from MinimalBible/res/values/strings.xml rename to MinimalBible/src/main/res/values/strings.xml diff --git a/MinimalBible/res/values/styles.xml b/MinimalBible/src/main/res/values/styles.xml similarity index 100% rename from MinimalBible/res/values/styles.xml rename to MinimalBible/src/main/res/values/styles.xml diff --git a/MinimalBible/src/test/org/bspeice/minimalbible/test/DownloadActivityTest.java b/MinimalBible/src/test/org/bspeice/minimalbible/test/DownloadActivityTest.java new file mode 100644 index 0000000..a719601 --- /dev/null +++ b/MinimalBible/src/test/org/bspeice/minimalbible/test/DownloadActivityTest.java @@ -0,0 +1,20 @@ +package test.org.bspeice.minimalbible.test; + +import android.test.InstrumentationTestCase; + +/** + * Tests for the Download activity + */ +public class DownloadActivityTest extends InstrumentationTestCase { + + /** + * For whatever reason, when we create one ProgressWheel with ButterKnife, multiple + * others are shown as well... + */ + public void testOnlyOneProgressWheelShown() { + + + + } + +}