diff --git a/VutaImage-Library/.classpath b/VutaImage-Library/.classpath new file mode 100644 index 0000000..2731f9c --- /dev/null +++ b/VutaImage-Library/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/VutaImage-Library/.project b/VutaImage-Library/.project new file mode 100644 index 0000000..37f1f93 --- /dev/null +++ b/VutaImage-Library/.project @@ -0,0 +1,33 @@ + + + VutaImage + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/VutaImage-Library/.settings/org.eclipse.jdt.core.prefs b/VutaImage-Library/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b080d2d --- /dev/null +++ b/VutaImage-Library/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/VutaImage-Library/AndroidManifest.xml b/VutaImage-Library/AndroidManifest.xml new file mode 100644 index 0000000..db1de86 --- /dev/null +++ b/VutaImage-Library/AndroidManifest.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/VutaImage-Library/bin/AndroidManifest.xml b/VutaImage-Library/bin/AndroidManifest.xml new file mode 100644 index 0000000..db1de86 --- /dev/null +++ b/VutaImage-Library/bin/AndroidManifest.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/VutaImage-Library/bin/R.txt b/VutaImage-Library/bin/R.txt new file mode 100644 index 0000000..a2594e0 --- /dev/null +++ b/VutaImage-Library/bin/R.txt @@ -0,0 +1,10 @@ +int dimen activity_horizontal_margin 0x7f030000 +int dimen activity_vertical_margin 0x7f030001 +int drawable ic_launcher 0x7f020000 +int id action_settings 0x7f070000 +int menu main 0x7f060000 +int string action_settings 0x7f040001 +int string app_name 0x7f040000 +int string hello_world 0x7f040002 +int style AppBaseTheme 0x7f050000 +int style AppTheme 0x7f050001 diff --git a/VutaImage-Library/bin/VutaImage.apk b/VutaImage-Library/bin/VutaImage.apk new file mode 100644 index 0000000..0edf5db Binary files /dev/null and b/VutaImage-Library/bin/VutaImage.apk differ diff --git a/VutaImage-Library/bin/classes.dex b/VutaImage-Library/bin/classes.dex new file mode 100644 index 0000000..c19f842 Binary files /dev/null and b/VutaImage-Library/bin/classes.dex differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/BuildConfig.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/BuildConfig.class new file mode 100644 index 0000000..433dc44 Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/BuildConfig.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$attr.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$attr.class new file mode 100644 index 0000000..a1b2b97 Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$attr.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$dimen.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$dimen.class new file mode 100644 index 0000000..d78227c Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$dimen.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$drawable.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$drawable.class new file mode 100644 index 0000000..b949dcf Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$drawable.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$id.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$id.class new file mode 100644 index 0000000..14cfd25 Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$id.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$menu.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$menu.class new file mode 100644 index 0000000..7baf0ee Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$menu.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$string.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$string.class new file mode 100644 index 0000000..0ce4bd0 Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$string.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$style.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$style.class new file mode 100644 index 0000000..16422b6 Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R$style.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R.class new file mode 100644 index 0000000..b34c1cb Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/R.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImage.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImage.class new file mode 100644 index 0000000..261f39f Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImage.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImageDownloader$DownloadAsyncTask.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImageDownloader$DownloadAsyncTask.class new file mode 100644 index 0000000..511239c Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImageDownloader$DownloadAsyncTask.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImageDownloader.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImageDownloader.class new file mode 100644 index 0000000..6038f1f Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImageDownloader.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImageItem.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImageItem.class new file mode 100644 index 0000000..f79ff6f Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImageItem.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImagesDownloader$1.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImagesDownloader$1.class new file mode 100644 index 0000000..c9e9724 Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImagesDownloader$1.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImagesDownloader.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImagesDownloader.class new file mode 100644 index 0000000..b2eb7f1 Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaImagesDownloader.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaLogger.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaLogger.class new file mode 100644 index 0000000..547b9e3 Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/VutaLogger.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/callbacks/EachImageDownloadCallback.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/callbacks/EachImageDownloadCallback.class new file mode 100644 index 0000000..c313b2e Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/callbacks/EachImageDownloadCallback.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/callbacks/ImageDownloadCallback.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/callbacks/ImageDownloadCallback.class new file mode 100644 index 0000000..0137d30 Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/callbacks/ImageDownloadCallback.class differ diff --git a/VutaImage-Library/bin/classes/net/rebmos/vutaimage/callbacks/ImagesDownloadCallback.class b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/callbacks/ImagesDownloadCallback.class new file mode 100644 index 0000000..4c807b7 Binary files /dev/null and b/VutaImage-Library/bin/classes/net/rebmos/vutaimage/callbacks/ImagesDownloadCallback.class differ diff --git a/VutaImage-Library/bin/dexedLibs/android-support-v4-199acf5c78de928702b0d9ae0716d88a.jar b/VutaImage-Library/bin/dexedLibs/android-support-v4-199acf5c78de928702b0d9ae0716d88a.jar new file mode 100644 index 0000000..41afa9c Binary files /dev/null and b/VutaImage-Library/bin/dexedLibs/android-support-v4-199acf5c78de928702b0d9ae0716d88a.jar differ diff --git a/VutaImage-Library/bin/res/drawable-hdpi/ic_launcher.png b/VutaImage-Library/bin/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..efa7c5f Binary files /dev/null and b/VutaImage-Library/bin/res/drawable-hdpi/ic_launcher.png differ diff --git a/VutaImage-Library/bin/res/drawable-mdpi/ic_launcher.png b/VutaImage-Library/bin/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..ec27f2e Binary files /dev/null and b/VutaImage-Library/bin/res/drawable-mdpi/ic_launcher.png differ diff --git a/VutaImage-Library/bin/res/drawable-xhdpi/ic_launcher.png b/VutaImage-Library/bin/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..92fc57d Binary files /dev/null and b/VutaImage-Library/bin/res/drawable-xhdpi/ic_launcher.png differ diff --git a/VutaImage-Library/bin/res/drawable-xxhdpi/ic_launcher.png b/VutaImage-Library/bin/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b6f8f4e Binary files /dev/null and b/VutaImage-Library/bin/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/VutaImage-Library/bin/resources.ap_ b/VutaImage-Library/bin/resources.ap_ new file mode 100644 index 0000000..a9c5894 Binary files /dev/null and b/VutaImage-Library/bin/resources.ap_ differ diff --git a/VutaImage-Library/bin/vutaimage.jar b/VutaImage-Library/bin/vutaimage.jar new file mode 100644 index 0000000..ee61898 Binary files /dev/null and b/VutaImage-Library/bin/vutaimage.jar differ diff --git a/VutaImage-Library/gen/net/rebmos/vutaimage/BuildConfig.java b/VutaImage-Library/gen/net/rebmos/vutaimage/BuildConfig.java new file mode 100644 index 0000000..945125c --- /dev/null +++ b/VutaImage-Library/gen/net/rebmos/vutaimage/BuildConfig.java @@ -0,0 +1,6 @@ +/** Automatically generated file. DO NOT MODIFY */ +package net.rebmos.vutaimage; + +public final class BuildConfig { + public final static boolean DEBUG = true; +} \ No newline at end of file diff --git a/VutaImage-Library/gen/net/rebmos/vutaimage/R.java b/VutaImage-Library/gen/net/rebmos/vutaimage/R.java new file mode 100644 index 0000000..0be92a2 --- /dev/null +++ b/VutaImage-Library/gen/net/rebmos/vutaimage/R.java @@ -0,0 +1,65 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package net.rebmos.vutaimage; + +public final class R { + public static final class attr { + } + public static final class dimen { + /** Default screen margins, per the Android Design guidelines. + + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. + + */ + public static int activity_horizontal_margin=0x7f030000; + public static int activity_vertical_margin=0x7f030001; + } + public static final class drawable { + public static int ic_launcher=0x7f020000; + } + public static final class id { + public static int action_settings=0x7f070000; + } + public static final class menu { + public static int main=0x7f060000; + } + public static final class string { + public static int action_settings=0x7f040001; + public static int app_name=0x7f040000; + public static int hello_world=0x7f040002; + } + public static final class style { + /** + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + + + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + + + Base application theme for API 11+. This theme completely replaces + AppBaseTheme from res/values/styles.xml on API 11+ devices. + + API 11 theme customizations can go here. + + Base application theme for API 14+. This theme completely replaces + AppBaseTheme from BOTH res/values/styles.xml and + res/values-v11/styles.xml on API 14+ devices. + + API 14 theme customizations can go here. + */ + public static int AppBaseTheme=0x7f050000; + /** Application theme. + All customizations that are NOT specific to a particular API-level can go here. + */ + public static int AppTheme=0x7f050001; + } +} diff --git a/VutaImage-Library/ic_launcher-web.png b/VutaImage-Library/ic_launcher-web.png new file mode 100644 index 0000000..a18cbb4 Binary files /dev/null and b/VutaImage-Library/ic_launcher-web.png differ diff --git a/VutaImage-Library/libs/android-support-v4.jar b/VutaImage-Library/libs/android-support-v4.jar new file mode 100644 index 0000000..9056828 Binary files /dev/null and b/VutaImage-Library/libs/android-support-v4.jar differ diff --git a/VutaImage-Library/proguard-project.txt b/VutaImage-Library/proguard-project.txt new file mode 100644 index 0000000..f2fe155 --- /dev/null +++ b/VutaImage-Library/proguard-project.txt @@ -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 *; +#} diff --git a/VutaImage-Library/project.properties b/VutaImage-Library/project.properties new file mode 100644 index 0000000..1b8c5a3 --- /dev/null +++ b/VutaImage-Library/project.properties @@ -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-18 +android.library=true diff --git a/VutaImage-Library/res/drawable-hdpi/ic_launcher.png b/VutaImage-Library/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..288b665 Binary files /dev/null and b/VutaImage-Library/res/drawable-hdpi/ic_launcher.png differ diff --git a/VutaImage-Library/res/drawable-mdpi/ic_launcher.png b/VutaImage-Library/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..6ae570b Binary files /dev/null and b/VutaImage-Library/res/drawable-mdpi/ic_launcher.png differ diff --git a/VutaImage-Library/res/drawable-xhdpi/ic_launcher.png b/VutaImage-Library/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fb7cd Binary files /dev/null and b/VutaImage-Library/res/drawable-xhdpi/ic_launcher.png differ diff --git a/VutaImage-Library/res/drawable-xxhdpi/ic_launcher.png b/VutaImage-Library/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..85a6081 Binary files /dev/null and b/VutaImage-Library/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/VutaImage-Library/res/menu/main.xml b/VutaImage-Library/res/menu/main.xml new file mode 100644 index 0000000..c002028 --- /dev/null +++ b/VutaImage-Library/res/menu/main.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/VutaImage-Library/res/values-sw600dp/dimens.xml b/VutaImage-Library/res/values-sw600dp/dimens.xml new file mode 100644 index 0000000..44f01db --- /dev/null +++ b/VutaImage-Library/res/values-sw600dp/dimens.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/VutaImage-Library/res/values-sw720dp-land/dimens.xml b/VutaImage-Library/res/values-sw720dp-land/dimens.xml new file mode 100644 index 0000000..61e3fa8 --- /dev/null +++ b/VutaImage-Library/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,9 @@ + + + + 128dp + + diff --git a/VutaImage-Library/res/values-v11/styles.xml b/VutaImage-Library/res/values-v11/styles.xml new file mode 100644 index 0000000..3c02242 --- /dev/null +++ b/VutaImage-Library/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/VutaImage-Library/res/values-v14/styles.xml b/VutaImage-Library/res/values-v14/styles.xml new file mode 100644 index 0000000..a91fd03 --- /dev/null +++ b/VutaImage-Library/res/values-v14/styles.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/VutaImage-Library/res/values/dimens.xml b/VutaImage-Library/res/values/dimens.xml new file mode 100644 index 0000000..55c1e59 --- /dev/null +++ b/VutaImage-Library/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + + 16dp + 16dp + + diff --git a/VutaImage-Library/res/values/strings.xml b/VutaImage-Library/res/values/strings.xml new file mode 100644 index 0000000..8ea4260 --- /dev/null +++ b/VutaImage-Library/res/values/strings.xml @@ -0,0 +1,8 @@ + + + + VutaImage + Settings + Hello world! + + diff --git a/VutaImage-Library/res/values/styles.xml b/VutaImage-Library/res/values/styles.xml new file mode 100644 index 0000000..6ce89c7 --- /dev/null +++ b/VutaImage-Library/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/VutaImage-Library/src/net/rebmos/vutaimage/VutaImage.java b/VutaImage-Library/src/net/rebmos/vutaimage/VutaImage.java new file mode 100644 index 0000000..e097f42 --- /dev/null +++ b/VutaImage-Library/src/net/rebmos/vutaimage/VutaImage.java @@ -0,0 +1,134 @@ +package net.rebmos.vutaimage; + +import java.util.List; + +import net.rebmos.vutaimage.callbacks.EachImageDownloadCallback; +import net.rebmos.vutaimage.callbacks.ImageDownloadCallback; +import net.rebmos.vutaimage.callbacks.ImagesDownloadCallback; +import android.os.Environment; + +/** + * + * @author Mutinda Boniface + * @version 1.0 + * @website http://mutindaz.github.io/vutaimage + */ +public class VutaImage { + + // Keeps the default storage dir for the downloaded images + private static String defaultStorageDir = getExternalStorage(); + + // Debug enabled or not + public static boolean debug = false; + + /** + * Controls whether debugging is enabled or not + * @param debug + */ + public static void setDebug( boolean debug ){ + VutaImage.debug = debug; + } + + /** + * Sets the default storage directory for the downloaded images + * if the filepath was not supplied + *

+ * NB: This is only used if we are resolving filename from the supplied image source url + * + * @param dirPath {@link String} - the storage path as a string e.g. /emulated/sdcard0/dir/ + */ + public static void setDefaultStorageDir( String dirPath ){ + VutaImage.defaultStorageDir = dirPath; + } + + /** + * Get the default set storage directory for the images + * + * @return {@link String} - Storage directory as a string e.g. /emulates/sdcard0/dir/ + */ + public static String getDefaultStorageDir( ){ + return VutaImage.defaultStorageDir; + } + + /** + * Gets the external storage directory as a {@link String} + * + * @return {@link String} - External storage directory as a string e.g. /emulates/sdcard0 + */ + public static String getExternalStorage( ){ + return Environment.getExternalStorageDirectory().getAbsolutePath(); + } + + /** + * Downloads a single image give the image url + *

NB: + *

+ *

+ * + * @param url - {@link String} - The image source url + * @param callback - {@link ImageDownloadCallback} - The callback to be fired during the download progress + */ + public static void download( String url, final ImageDownloadCallback callback ){ + new VutaImageDownloader( url ).download( callback ); + } + + /** + * Downloads a single image give the image url and the filename + *

+ * @param url - {@link String} - The image source + * @param filename - {@link String} - Final destination of the image + * @param callback - {@link ImageDownloadCallback} - The callback to be fired during the download progress + */ + public static void download( String url, String filename, final ImageDownloadCallback callback ){ + new VutaImageDownloader( url, filename ).download( callback ); + } + + /** + * Downloads a single image give the image object + *

+ * @param image - {@link VutaImageItem} - An object with url and filename set + * @param callback {@link ImageDownloadCallback} - The callback to be fired during the download progress + */ + public static void download( VutaImageItem image, final ImageDownloadCallback callback ){ + new VutaImageDownloader(image.url, image.filename ).download( callback ); + } + + /** + * Downloads multiple images with a callback triggered when all the images are downloaded + *

+ *

+ *

+ * @param images {@link List} - A list of images passed in as a collection of {@link VutaImageItem} + * @param callback {@link ImagesDownloadCallback} - The callback to be fired during the download progress and done + */ + public static void download( List images, final ImagesDownloadCallback callback ){ + new VutaImagesDownloader( images ).download( callback ); + } + + /** + * Downloads multiple images with a callback triggered in these states: + *

+ *

+ *

+ * + * @param images {@link List} - A list of images passed in as a collection of {@link VutaImageItem} + * @param callback {@link EachImageDownloadCallback} - The callback to be fired during the download progress and done + */ + public static void download( List images, final EachImageDownloadCallback callback ){ + new VutaImagesDownloader( images ).download( callback ); + } +} \ No newline at end of file diff --git a/VutaImage-Library/src/net/rebmos/vutaimage/VutaImageDownloader.java b/VutaImage-Library/src/net/rebmos/vutaimage/VutaImageDownloader.java new file mode 100644 index 0000000..04e912c --- /dev/null +++ b/VutaImage-Library/src/net/rebmos/vutaimage/VutaImageDownloader.java @@ -0,0 +1,135 @@ +package net.rebmos.vutaimage; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import net.rebmos.vutaimage.callbacks.ImageDownloadCallback; +import android.os.AsyncTask; + +public class VutaImageDownloader { + String imageUrl; + String imageFilename; + ImageDownloadCallback callback = null ; + + public VutaImageDownloader( VutaImageItem image ) { + this.imageUrl = image.getUrl(); + this.imageFilename = image.getFilename(); + } + + public VutaImageDownloader( String imageUrl ) { + this.imageUrl = imageUrl; + this.imageFilename = VutaImageItem.resolveFileName(imageUrl); + } + + public VutaImageDownloader( String imageUrl, String imageFilename ) { + this.imageUrl = imageUrl; + this.imageFilename = imageFilename; + } + + public void download( ImageDownloadCallback callback ){ + this.callback = callback; + + if( this.imageUrl == null ){ + this.callback.done(false); + return; + } + + // Resolve the filename if their was no filename supplied + if( this.imageFilename == null ){ + this.imageFilename = VutaImageItem.resolveFileName( this.imageUrl ); + + // By default we donwload the image to sdcard + this.imageFilename = VutaImage.getExternalStorage()+"/"+this.imageFilename; + } + + new DownloadAsyncTask().execute(); + } + + private class DownloadAsyncTask extends AsyncTask { + boolean download_ok = false; + + @Override + protected String doInBackground(String... params) { + try { + // set the download URL, a url that points to a file on the + // internet + // this is the file to be downloaded + URL url = new URL( imageUrl ); + + // create the new connection + HttpURLConnection urlConnection = (HttpURLConnection) url + .openConnection(); + urlConnection.setConnectTimeout(30000); + urlConnection.setReadTimeout(30000); + urlConnection.setInstanceFollowRedirects(true); + // set up some things on the connection + urlConnection.setRequestMethod("GET"); + urlConnection.setDoOutput(true); + + // and connect! + urlConnection.connect(); + + // set the path where we want to save the file + File file = new File(imageFilename); + + // this will be used to write the downloaded data into the file + // we created + FileOutputStream fileOutput = new FileOutputStream(file); + + // this will be used in reading the data from the internet + InputStream inputStream = urlConnection.getInputStream(); + + // this is the total size of the file + int totalSize = urlConnection.getContentLength(); + // variable to store total downloaded bytes + int downloadedSize = 0; + + // create a buffer... + byte[] buffer = new byte[1024]; + int bufferLength = 0; // used to store a temporary size of the + // buffer + + // now, read through the input buffer and write the contents to + // the file + while ((bufferLength = inputStream.read(buffer)) > 0) { + // add the data in the buffer to the file in the file output + // stream (the file on the sd card + fileOutput.write(buffer, 0, bufferLength); + // add up the size so we know how much is downloaded + downloadedSize += bufferLength; + // this is where you would do something to report the + // prgress, like this maybe + + if( callback !=null ){ + callback.progress(downloadedSize, totalSize); + } + } + // close the output stream when done + fileOutput.close(); + + download_ok = true; + // catch some possible errors... + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch( Exception e ){ + e.printStackTrace(); + } + return null; + } + + @Override + protected void onPostExecute(String result) { + super.onPostExecute(result); + if( callback !=null ){ + callback.done( download_ok ); + } + } + } +} diff --git a/VutaImage-Library/src/net/rebmos/vutaimage/VutaImageItem.java b/VutaImage-Library/src/net/rebmos/vutaimage/VutaImageItem.java new file mode 100644 index 0000000..28365f6 --- /dev/null +++ b/VutaImage-Library/src/net/rebmos/vutaimage/VutaImageItem.java @@ -0,0 +1,34 @@ +package net.rebmos.vutaimage; + +public class VutaImageItem { + String filename; + String url; + + public VutaImageItem( String url ) { + this.url = url; + this.filename = VutaImageItem.resolveFileName( url ); + } + + public VutaImageItem( String url, String filename ) { + this.filename = filename; + this.url = url; + } + + public static String resolveFileName( String url ){ + String name = null; + try{ + String[] segments = url.split("/"); + name = segments[(segments.length - 1)]; + }catch( Exception e ){ + e.printStackTrace(); + } + return name; + } + + public String getUrl(){ + return this.url; + } + public String getFilename(){ + return this.filename; + } +} \ No newline at end of file diff --git a/VutaImage-Library/src/net/rebmos/vutaimage/VutaImagesDownloader.java b/VutaImage-Library/src/net/rebmos/vutaimage/VutaImagesDownloader.java new file mode 100644 index 0000000..831f19f --- /dev/null +++ b/VutaImage-Library/src/net/rebmos/vutaimage/VutaImagesDownloader.java @@ -0,0 +1,87 @@ +package net.rebmos.vutaimage; + +import java.util.ArrayList; +import java.util.List; + +import net.rebmos.vutaimage.callbacks.EachImageDownloadCallback; +import net.rebmos.vutaimage.callbacks.ImageDownloadCallback; +import net.rebmos.vutaimage.callbacks.ImagesDownloadCallback; + +/** + * + * @author Mutinda Boniface + * + */ +public class VutaImagesDownloader { + List images = new ArrayList(); + int total = 0; + int downloaded = 0; + + public VutaImagesDownloader( List images ) { + this.images = images; + this.total = images.size(); + } + + public void download( final ImagesDownloadCallback callback ){ + this.doDownload(callback); + } + + public void download( final EachImageDownloadCallback callback ){ + this.doDownload(callback); + } + + + private void doDownload( final Object callback ){ + for( final VutaImageItem image: this.images ){ + new VutaImageDownloader(image).download( new ImageDownloadCallback() { + @Override + public void progress(int elapsed, int totalSize) { + } + + @Override + public void done(boolean success) { + downloaded++; + // Trigger progress for every downloaded image + triggerDownloadProgress( image, success, callback ); + + // Trigger on error + if( !success ){ + triggerOnError(image, callback ); + } + + // Check if we are done with downloading all images + if( downloaded>= total ){ + triggerDownloadComplete( callback ); + } + } + }); + } + } + + private void triggerDownloadProgress( VutaImageItem image, boolean success, Object callback ){ + if( callback instanceof EachImageDownloadCallback ){ + ((EachImageDownloadCallback) callback).onProgress(image, success); + } + } + + private void triggerOnError( VutaImageItem image, Object callback ){ + if( callback instanceof EachImageDownloadCallback ){ + ((EachImageDownloadCallback) callback).onError(image); + }else if( callback instanceof ImagesDownloadCallback ){ + ((ImagesDownloadCallback) callback).onError(image); + } + } + + /** + * Triggered when all the images passed in are downloaded whether with erros or not + * + * @param callback - The callback to be triggered. This is any of {@link EachImageDownloadCallback} OR {@link ImagesDownloadCallback} + */ + private void triggerDownloadComplete( Object callback ){ + if( callback instanceof EachImageDownloadCallback ){ + ((EachImageDownloadCallback) callback).done(); + }else if( callback instanceof ImagesDownloadCallback ){ + ((ImagesDownloadCallback) callback).done(); + } + } +} \ No newline at end of file diff --git a/VutaImage-Library/src/net/rebmos/vutaimage/VutaLogger.java b/VutaImage-Library/src/net/rebmos/vutaimage/VutaLogger.java new file mode 100644 index 0000000..d0bf346 --- /dev/null +++ b/VutaImage-Library/src/net/rebmos/vutaimage/VutaLogger.java @@ -0,0 +1,34 @@ +package net.rebmos.vutaimage; + +import android.util.Log; + +public class VutaLogger { + + // make false on production + static final boolean debug = true; + static final String LOG_INFO_TAG = "LOG_INFO_TAG"; + static final String LOG_ERROR_TAG = "LOG_ERROR_TAG"; + static final String LOG_DEBUG_TAG = "LOG_DEBUG_TAG"; + + public VutaLogger() { + } + + public static void logInfo(String message) { + if (debug) { + Log.i(VutaLogger.LOG_INFO_TAG, message); + } + } + + public static void logError(String error) { + if (debug) { + Log.e(VutaLogger.LOG_ERROR_TAG, error); + } + } + + public static void logDebug(String message) { + if (debug) { + Log.e(VutaLogger.LOG_DEBUG_TAG, message); + } + } + +} diff --git a/VutaImage-Library/src/net/rebmos/vutaimage/callbacks/EachImageDownloadCallback.java b/VutaImage-Library/src/net/rebmos/vutaimage/callbacks/EachImageDownloadCallback.java new file mode 100644 index 0000000..9ee742d --- /dev/null +++ b/VutaImage-Library/src/net/rebmos/vutaimage/callbacks/EachImageDownloadCallback.java @@ -0,0 +1,9 @@ +package net.rebmos.vutaimage.callbacks; + +import net.rebmos.vutaimage.VutaImageItem; + +public interface EachImageDownloadCallback { + public void onError( VutaImageItem image ); + public void onProgress( VutaImageItem image, boolean success); + public void done(); +} diff --git a/VutaImage-Library/src/net/rebmos/vutaimage/callbacks/ImageDownloadCallback.java b/VutaImage-Library/src/net/rebmos/vutaimage/callbacks/ImageDownloadCallback.java new file mode 100644 index 0000000..d441e0d --- /dev/null +++ b/VutaImage-Library/src/net/rebmos/vutaimage/callbacks/ImageDownloadCallback.java @@ -0,0 +1,6 @@ +package net.rebmos.vutaimage.callbacks; + +public interface ImageDownloadCallback { + public void progress( int elapsed, int totalSize ); + public void done( boolean success ); +} \ No newline at end of file diff --git a/VutaImage-Library/src/net/rebmos/vutaimage/callbacks/ImagesDownloadCallback.java b/VutaImage-Library/src/net/rebmos/vutaimage/callbacks/ImagesDownloadCallback.java new file mode 100644 index 0000000..12af765 --- /dev/null +++ b/VutaImage-Library/src/net/rebmos/vutaimage/callbacks/ImagesDownloadCallback.java @@ -0,0 +1,8 @@ +package net.rebmos.vutaimage.callbacks; + +import net.rebmos.vutaimage.VutaImageItem; + +public interface ImagesDownloadCallback { + public void onError( VutaImageItem image ); + public void done( ); +} diff --git a/VutaImage-demos/.classpath b/VutaImage-demos/.classpath new file mode 100644 index 0000000..2731f9c --- /dev/null +++ b/VutaImage-demos/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/VutaImage-demos/.project b/VutaImage-demos/.project new file mode 100644 index 0000000..f77e0b9 --- /dev/null +++ b/VutaImage-demos/.project @@ -0,0 +1,33 @@ + + + VutaImageDemo + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/VutaImage-demos/.settings/org.eclipse.jdt.core.prefs b/VutaImage-demos/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b080d2d --- /dev/null +++ b/VutaImage-demos/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/VutaImage-demos/AndroidManifest.xml b/VutaImage-demos/AndroidManifest.xml new file mode 100644 index 0000000..fd135a9 --- /dev/null +++ b/VutaImage-demos/AndroidManifest.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VutaImage-demos/bin/AndroidManifest.xml b/VutaImage-demos/bin/AndroidManifest.xml new file mode 100644 index 0000000..fd135a9 --- /dev/null +++ b/VutaImage-demos/bin/AndroidManifest.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VutaImage-demos/bin/R.txt b/VutaImage-demos/bin/R.txt new file mode 100644 index 0000000..58f06a0 --- /dev/null +++ b/VutaImage-demos/bin/R.txt @@ -0,0 +1,11 @@ +int dimen activity_horizontal_margin 0x7f040000 +int dimen activity_vertical_margin 0x7f040001 +int drawable ic_launcher 0x7f020000 +int id action_settings 0x7f080000 +int layout activity_main 0x7f030000 +int menu main 0x7f070000 +int string action_settings 0x7f050001 +int string app_name 0x7f050000 +int string hello_world 0x7f050002 +int style AppBaseTheme 0x7f060000 +int style AppTheme 0x7f060001 diff --git a/VutaImage-demos/bin/VutaImageDemo.apk b/VutaImage-demos/bin/VutaImageDemo.apk new file mode 100644 index 0000000..b154b19 Binary files /dev/null and b/VutaImage-demos/bin/VutaImageDemo.apk differ diff --git a/VutaImage-demos/bin/classes.dex b/VutaImage-demos/bin/classes.dex new file mode 100644 index 0000000..2f8bd79 Binary files /dev/null and b/VutaImage-demos/bin/classes.dex differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$dimen.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$dimen.class new file mode 100644 index 0000000..0d0d6eb Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$dimen.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$drawable.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$drawable.class new file mode 100644 index 0000000..321f2e6 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$drawable.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$id.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$id.class new file mode 100644 index 0000000..bd2cec8 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$id.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$menu.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$menu.class new file mode 100644 index 0000000..42eeba6 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$menu.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$string.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$string.class new file mode 100644 index 0000000..c2dff23 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$string.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$style.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$style.class new file mode 100644 index 0000000..161f574 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R$style.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R.class new file mode 100644 index 0000000..d8a64ac Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/R.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/BuildConfig.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/BuildConfig.class new file mode 100644 index 0000000..b243b14 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/BuildConfig.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/MultipleImagesDemo2$1.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/MultipleImagesDemo2$1.class new file mode 100644 index 0000000..ebe7c18 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/MultipleImagesDemo2$1.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/MultipleImagesDemo2$2.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/MultipleImagesDemo2$2.class new file mode 100644 index 0000000..c9976ad Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/MultipleImagesDemo2$2.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/MultipleImagesDemo2.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/MultipleImagesDemo2.class new file mode 100644 index 0000000..15f4239 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/MultipleImagesDemo2.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$attr.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$attr.class new file mode 100644 index 0000000..51ecc6d Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$attr.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$dimen.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$dimen.class new file mode 100644 index 0000000..45f0fd1 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$dimen.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$drawable.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$drawable.class new file mode 100644 index 0000000..5d4f46b Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$drawable.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$id.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$id.class new file mode 100644 index 0000000..cd5fbe5 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$id.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$layout.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$layout.class new file mode 100644 index 0000000..a1ca713 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$layout.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$menu.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$menu.class new file mode 100644 index 0000000..a48bf0a Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$menu.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$string.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$string.class new file mode 100644 index 0000000..1ca10f8 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$string.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$style.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$style.class new file mode 100644 index 0000000..36ff60a Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R$style.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R.class new file mode 100644 index 0000000..0495981 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/R.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/SingleImageDemoActivity$1.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/SingleImageDemoActivity$1.class new file mode 100644 index 0000000..629cbd4 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/SingleImageDemoActivity$1.class differ diff --git a/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/SingleImageDemoActivity.class b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/SingleImageDemoActivity.class new file mode 100644 index 0000000..d9cf888 Binary files /dev/null and b/VutaImage-demos/bin/classes/net/rebmos/vutaimage/demo/SingleImageDemoActivity.class differ diff --git a/VutaImage-demos/bin/dexedLibs/android-support-v4-199acf5c78de928702b0d9ae0716d88a.jar b/VutaImage-demos/bin/dexedLibs/android-support-v4-199acf5c78de928702b0d9ae0716d88a.jar new file mode 100644 index 0000000..dd2df39 Binary files /dev/null and b/VutaImage-demos/bin/dexedLibs/android-support-v4-199acf5c78de928702b0d9ae0716d88a.jar differ diff --git a/VutaImage-demos/bin/dexedLibs/vutaimage-9139f19253b0ec98d1c70bf0f948ab1b.jar b/VutaImage-demos/bin/dexedLibs/vutaimage-9139f19253b0ec98d1c70bf0f948ab1b.jar new file mode 100644 index 0000000..b2685b9 Binary files /dev/null and b/VutaImage-demos/bin/dexedLibs/vutaimage-9139f19253b0ec98d1c70bf0f948ab1b.jar differ diff --git a/VutaImage-demos/bin/res/drawable-hdpi/ic_launcher.png b/VutaImage-demos/bin/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..efa7c5f Binary files /dev/null and b/VutaImage-demos/bin/res/drawable-hdpi/ic_launcher.png differ diff --git a/VutaImage-demos/bin/res/drawable-mdpi/ic_launcher.png b/VutaImage-demos/bin/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..ec27f2e Binary files /dev/null and b/VutaImage-demos/bin/res/drawable-mdpi/ic_launcher.png differ diff --git a/VutaImage-demos/bin/res/drawable-xhdpi/ic_launcher.png b/VutaImage-demos/bin/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..92fc57d Binary files /dev/null and b/VutaImage-demos/bin/res/drawable-xhdpi/ic_launcher.png differ diff --git a/VutaImage-demos/bin/res/drawable-xxhdpi/ic_launcher.png b/VutaImage-demos/bin/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b6f8f4e Binary files /dev/null and b/VutaImage-demos/bin/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/VutaImage-demos/bin/resources.ap_ b/VutaImage-demos/bin/resources.ap_ new file mode 100644 index 0000000..177f1e4 Binary files /dev/null and b/VutaImage-demos/bin/resources.ap_ differ diff --git a/VutaImage-demos/bin/vutaimagedemo.jar b/VutaImage-demos/bin/vutaimagedemo.jar new file mode 100644 index 0000000..816bfe8 Binary files /dev/null and b/VutaImage-demos/bin/vutaimagedemo.jar differ diff --git a/VutaImage-demos/gen/net/rebmos/vutaimage/R.java b/VutaImage-demos/gen/net/rebmos/vutaimage/R.java new file mode 100644 index 0000000..ba04420 --- /dev/null +++ b/VutaImage-demos/gen/net/rebmos/vutaimage/R.java @@ -0,0 +1,32 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ +package net.rebmos.vutaimage; + +public final class R { + public static final class dimen { + public static final int activity_horizontal_margin = 0x7f040000; + public static final int activity_vertical_margin = 0x7f040001; + } + public static final class drawable { + public static final int ic_launcher = 0x7f020000; + } + public static final class id { + public static final int action_settings = 0x7f080000; + } + public static final class menu { + public static final int main = 0x7f070000; + } + public static final class string { + public static final int action_settings = 0x7f050001; + public static final int app_name = 0x7f050000; + public static final int hello_world = 0x7f050002; + } + public static final class style { + public static final int AppBaseTheme = 0x7f060000; + public static final int AppTheme = 0x7f060001; + } +} diff --git a/VutaImage-demos/gen/net/rebmos/vutaimage/demo/BuildConfig.java b/VutaImage-demos/gen/net/rebmos/vutaimage/demo/BuildConfig.java new file mode 100644 index 0000000..472fece --- /dev/null +++ b/VutaImage-demos/gen/net/rebmos/vutaimage/demo/BuildConfig.java @@ -0,0 +1,6 @@ +/** Automatically generated file. DO NOT MODIFY */ +package net.rebmos.vutaimage.demo; + +public final class BuildConfig { + public final static boolean DEBUG = true; +} \ No newline at end of file diff --git a/VutaImage-demos/gen/net/rebmos/vutaimage/demo/R.java b/VutaImage-demos/gen/net/rebmos/vutaimage/demo/R.java new file mode 100644 index 0000000..8d1872c --- /dev/null +++ b/VutaImage-demos/gen/net/rebmos/vutaimage/demo/R.java @@ -0,0 +1,95 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package net.rebmos.vutaimage.demo; + +public final class R { + public static final class attr { + } + public static final class dimen { + /** Default screen margins, per the Android Design guidelines. + + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. + + Default screen margins, per the Android Design guidelines. + + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. + + */ + public static final int activity_horizontal_margin=0x7f040000; + public static final int activity_vertical_margin=0x7f040001; + } + public static final class drawable { + public static final int ic_launcher=0x7f020000; + } + public static final class id { + public static final int action_settings=0x7f080000; + } + public static final class layout { + public static final int activity_main=0x7f030000; + } + public static final class menu { + public static final int main=0x7f070000; + } + public static final class string { + public static final int action_settings=0x7f050001; + public static final int app_name=0x7f050000; + public static final int hello_world=0x7f050002; + } + public static final class style { + /** + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + + + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + + + Base application theme for API 11+. This theme completely replaces + AppBaseTheme from res/values/styles.xml on API 11+ devices. + + API 11 theme customizations can go here. + + Base application theme for API 14+. This theme completely replaces + AppBaseTheme from BOTH res/values/styles.xml and + res/values-v11/styles.xml on API 14+ devices. + + API 14 theme customizations can go here. + + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + + + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + + + Base application theme for API 11+. This theme completely replaces + AppBaseTheme from res/values/styles.xml on API 11+ devices. + + API 11 theme customizations can go here. + + Base application theme for API 14+. This theme completely replaces + AppBaseTheme from BOTH res/values/styles.xml and + res/values-v11/styles.xml on API 14+ devices. + + API 14 theme customizations can go here. + */ + public static final int AppBaseTheme=0x7f060000; + /** Application theme. + All customizations that are NOT specific to a particular API-level can go here. + Application theme. + All customizations that are NOT specific to a particular API-level can go here. + */ + public static final int AppTheme=0x7f060001; + } +} diff --git a/VutaImage-demos/ic_launcher-web.png b/VutaImage-demos/ic_launcher-web.png new file mode 100644 index 0000000..a18cbb4 Binary files /dev/null and b/VutaImage-demos/ic_launcher-web.png differ diff --git a/VutaImage-demos/libs/android-support-v4.jar b/VutaImage-demos/libs/android-support-v4.jar new file mode 100644 index 0000000..9056828 Binary files /dev/null and b/VutaImage-demos/libs/android-support-v4.jar differ diff --git a/VutaImage-demos/proguard-project.txt b/VutaImage-demos/proguard-project.txt new file mode 100644 index 0000000..f2fe155 --- /dev/null +++ b/VutaImage-demos/proguard-project.txt @@ -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 *; +#} diff --git a/VutaImage-demos/project.properties b/VutaImage-demos/project.properties new file mode 100644 index 0000000..0ce6f05 --- /dev/null +++ b/VutaImage-demos/project.properties @@ -0,0 +1,16 @@ +# 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-18 +android.library=false +android.library.reference.1=../VutaImage diff --git a/VutaImage-demos/res/drawable-hdpi/ic_launcher.png b/VutaImage-demos/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..288b665 Binary files /dev/null and b/VutaImage-demos/res/drawable-hdpi/ic_launcher.png differ diff --git a/VutaImage-demos/res/drawable-mdpi/ic_launcher.png b/VutaImage-demos/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..6ae570b Binary files /dev/null and b/VutaImage-demos/res/drawable-mdpi/ic_launcher.png differ diff --git a/VutaImage-demos/res/drawable-xhdpi/ic_launcher.png b/VutaImage-demos/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fb7cd Binary files /dev/null and b/VutaImage-demos/res/drawable-xhdpi/ic_launcher.png differ diff --git a/VutaImage-demos/res/drawable-xxhdpi/ic_launcher.png b/VutaImage-demos/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..85a6081 Binary files /dev/null and b/VutaImage-demos/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/VutaImage-demos/res/layout/activity_main.xml b/VutaImage-demos/res/layout/activity_main.xml new file mode 100644 index 0000000..3af5d64 --- /dev/null +++ b/VutaImage-demos/res/layout/activity_main.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/VutaImage-demos/res/menu/main.xml b/VutaImage-demos/res/menu/main.xml new file mode 100644 index 0000000..c002028 --- /dev/null +++ b/VutaImage-demos/res/menu/main.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/VutaImage-demos/res/values-sw600dp/dimens.xml b/VutaImage-demos/res/values-sw600dp/dimens.xml new file mode 100644 index 0000000..44f01db --- /dev/null +++ b/VutaImage-demos/res/values-sw600dp/dimens.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/VutaImage-demos/res/values-sw720dp-land/dimens.xml b/VutaImage-demos/res/values-sw720dp-land/dimens.xml new file mode 100644 index 0000000..61e3fa8 --- /dev/null +++ b/VutaImage-demos/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,9 @@ + + + + 128dp + + diff --git a/VutaImage-demos/res/values-v11/styles.xml b/VutaImage-demos/res/values-v11/styles.xml new file mode 100644 index 0000000..3c02242 --- /dev/null +++ b/VutaImage-demos/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/VutaImage-demos/res/values-v14/styles.xml b/VutaImage-demos/res/values-v14/styles.xml new file mode 100644 index 0000000..a91fd03 --- /dev/null +++ b/VutaImage-demos/res/values-v14/styles.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/VutaImage-demos/res/values/dimens.xml b/VutaImage-demos/res/values/dimens.xml new file mode 100644 index 0000000..55c1e59 --- /dev/null +++ b/VutaImage-demos/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + + 16dp + 16dp + + diff --git a/VutaImage-demos/res/values/strings.xml b/VutaImage-demos/res/values/strings.xml new file mode 100644 index 0000000..b0bc039 --- /dev/null +++ b/VutaImage-demos/res/values/strings.xml @@ -0,0 +1,8 @@ + + + + VutaImageDemo + Settings + Hello world! + + diff --git a/VutaImage-demos/res/values/styles.xml b/VutaImage-demos/res/values/styles.xml new file mode 100644 index 0000000..6ce89c7 --- /dev/null +++ b/VutaImage-demos/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/VutaImage-demos/src/net/rebmos/vutaimage/demo/MultipleImagesDemo2.java b/VutaImage-demos/src/net/rebmos/vutaimage/demo/MultipleImagesDemo2.java new file mode 100644 index 0000000..4b02aff --- /dev/null +++ b/VutaImage-demos/src/net/rebmos/vutaimage/demo/MultipleImagesDemo2.java @@ -0,0 +1,65 @@ +package net.rebmos.vutaimage.demo; + +import java.util.ArrayList; +import java.util.List; + +import net.rebmos.vutaimage.VutaImage; +import net.rebmos.vutaimage.VutaImageItem; +import net.rebmos.vutaimage.callbacks.EachImageDownloadCallback; +import net.rebmos.vutaimage.callbacks.ImagesDownloadCallback; +import android.app.Activity; +import android.os.Bundle; +import android.util.Log; + +public class MultipleImagesDemo2 extends Activity { + public static String TAG = "VUTA_IMAGE"; + + @Override + public void onCreate( Bundle savedInstanceState ){ + super.onCreate(savedInstanceState); + setContentView( R.layout.activity_main ); + + // Get the sdcard directory + String sdcard = VutaImage.getExternalStorage(); + + // Create a list of all the images we want to download + List images = new ArrayList(); + images.add( new VutaImageItem("https://avatars0.githubusercontent.com/u/1729141?v=3&s=460" , sdcard+"/Github.png" )); + images.add( new VutaImageItem("http://trendingnewsroom.com/img/logo.png" , sdcard+"/Logo1.png" )); + images.add( new VutaImageItem("http://trendingnewsroom.com/img/logo.png" , sdcard+"/Logo2.png" )); + + // Use all images download callback + VutaImage.download(images, new ImagesDownloadCallback() { + + @Override + public void onError(VutaImageItem image) { + Log.e(TAG, "Image failed to download..."+image.getUrl()+"->"+image.getFilename() ); + } + + @Override + public void done() { + Log.e(TAG, "All images downloaded" ); + } + }); + + // Each image download callback + VutaImage.download(images, new EachImageDownloadCallback() { + + @Override + public void onProgress(VutaImageItem image, boolean success) { + Log.e(TAG, "2 Image downloads progress.."+image.getUrl()+"->success = "+success ); + } + + @Override + public void onError(VutaImageItem image) { + Log.e(TAG, "2 Image downloads error.."+image.getUrl() ); + } + + @Override + public void done() { + Log.e(TAG, "2 All images downloaded" ); + } + }); + } + +} diff --git a/VutaImage-demos/src/net/rebmos/vutaimage/demo/SingleImageDemoActivity.java b/VutaImage-demos/src/net/rebmos/vutaimage/demo/SingleImageDemoActivity.java new file mode 100644 index 0000000..b78518f --- /dev/null +++ b/VutaImage-demos/src/net/rebmos/vutaimage/demo/SingleImageDemoActivity.java @@ -0,0 +1,36 @@ +package net.rebmos.vutaimage.demo; + +import net.rebmos.vutaimage.VutaImage; +import net.rebmos.vutaimage.callbacks.ImageDownloadCallback; +import android.app.Activity; +import android.os.Bundle; +import android.util.Log; + +public class SingleImageDemoActivity extends Activity { + public static String TAG = "VUTA_IMAGE"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + // https://avatars0.githubusercontent.com/u/1729141?v=3&s=460 + // http://mutinda.rebmos.net/wp-content/uploads/2014/12/logo-11.png + final String imageUrl = "http://aymzz.com/depo/nmb/images/StudentAccount.png"; + + String sdCard = VutaImage.getExternalStorage( ); + String filename = sdCard+"/file.png"; + + VutaImage.download( imageUrl, filename, new ImageDownloadCallback() { + @Override + public void progress(int elapsed, int totalSize) { + Log.e( TAG , "Image download progress = "+elapsed+" out of "+totalSize ); + } + + @Override + public void done(boolean success) { + Log.e( TAG , "Image download done with success = "+success ); + } + }); + } +}