Skip to content

Commit

Permalink
Merge pull request #8 from PDDStudio/1.1.0
Browse files Browse the repository at this point in the history
1.1.0 Release
  • Loading branch information
PDDStudio committed Dec 15, 2015
2 parents 9dca19f + b556936 commit 614b6bc
Show file tree
Hide file tree
Showing 17 changed files with 380 additions and 132 deletions.
21 changes: 18 additions & 3 deletions earthview-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2015 - Patrick J - earthview-android
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: 'com.android.library'
apply from: 'maven-push.gradle'

Expand All @@ -8,8 +24,8 @@ android {
defaultConfig {
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
versionCode 3
versionName "1.1.0"
}
buildTypes {
release {
Expand All @@ -25,7 +41,6 @@ dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
//gson for json parsing
compile 'com.google.code.gson:gson:2.5'
compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
//for wallpapers
compile 'com.squareup.okhttp:okhttp:2.6.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.6.0'
Expand Down
16 changes: 16 additions & 0 deletions earthview-android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# Copyright 2015 - Patrick J - earthview-android
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

POM_NAME=EarthView Android
POM_ARTIFACT_ID=earthview-android
POM_PACKAGING=aar
Binary file added earthview-android/libs/commons-io-2.4.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions earthview-android/maven-push.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2013 Chris Banes
* Copyright 2015 - Patrick J - earthview-android
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
26 changes: 16 additions & 10 deletions earthview-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pddstudio.earthview">
<!--
~ Copyright 2015 - Patrick J - earthview-android
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">

</application>

</manifest>
<manifest package="com.pddstudio.earthview" />
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
/*
* Copyright 2015 - Patrick J - earthview-android
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.pddstudio.earthview;

import android.os.AsyncTask;
import android.util.Log;

import com.pddstudio.earthview.utils.AsyncLoader;
import com.pddstudio.earthview.utils.IdUtils;
import com.pddstudio.earthview.utils.RandomLoader;
import com.pddstudio.earthview.utils.SingleLoader;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;


/**
* This Class was created by Patrick J
Expand All @@ -18,7 +40,6 @@
public final class EarthView {

private AsyncLoader asyncLoader;
private RandomLoader randomLoader;
private SingleLoader singleLoader;

private EarthView() {}
Expand All @@ -28,6 +49,7 @@ private EarthView() {}
* @return a new {@link EarthView} instance
*/
public static EarthView withGoogle() {
//just for the Name :P (http://EarthView.withGoogle.com)
return new EarthView();
}

Expand Down Expand Up @@ -55,18 +77,36 @@ public void getEarthWallpaper(String identifier, SingleEarthViewCallback singleE
* @param earthViewCallback - The interface the results will be sent to
*/
public void getAllEarthWallpapers(EarthViewCallback earthViewCallback) {
cancelEarthViewLoadingTask();
asyncLoader = new AsyncLoader(earthViewCallback, IdUtils.getIdList());
asyncLoader.execute();
}

/**
* Fetches a list of random EarthViews with the given size and returns the result to the given {@link EarthViewCallback}
* @param ammount - The amount of EarthViews that should be fetched
* @param amount - The amount of EarthViews that should be fetched
* @param earthViewCallback - The interface the results will be sent to
*/
public void getEarthWallpapers(int ammount, EarthViewCallback earthViewCallback) {
randomLoader = new RandomLoader(ammount, earthViewCallback);
randomLoader.execute();
public void getEarthWallpapers(int amount, EarthViewCallback earthViewCallback) {
//// TODO: 15.12.15 fix
}

public void getEarthWallpapers(Set<String> wallpaperIds, EarthViewCallback earthViewCallback) {
String walls[] = new String[wallpaperIds.size()];
Iterator<String> stringIterator = wallpaperIds.iterator();
for(int i = 0; i < wallpaperIds.size(); i++) {
String id = stringIterator.next();
walls[i] = id;
Log.d("Iterator", "added id -> " + id + " on position " + i);
}
asyncLoader = new AsyncLoader(earthViewCallback, walls);
asyncLoader.execute();
}

public void getEarthWallpapers(String[] wallpaperIds, EarthViewCallback earthViewCallback) {
cancelEarthViewLoadingTask();
asyncLoader = new AsyncLoader(earthViewCallback, wallpaperIds);
asyncLoader.execute();
}

/**
Expand All @@ -76,8 +116,44 @@ public void getEarthWallpapers(int ammount, EarthViewCallback earthViewCallback)
* @param earthViewCallback - The interface the results will be sent to
*/
public void getUniqueEarthWallpapers(int ammount, EarthViewCallback earthViewCallback) {
randomLoader = new RandomLoader(ammount, earthViewCallback).uniqueOnly();
randomLoader.execute();
//TODO // FIXME: 15.12.15
}

/**
* Forces all running tasks to be cancelled. If no task is running this call won't do anything.
* When cancelling a task that is still running {@link EarthViewCallback#onCancelledLoading(Collection)} or
* {@link SingleEarthViewCallback#onCancelledLoading()} will be invoked
*/
public void cancelAllRunningTasks() {
//cancel & rest the async tasks so they can be reused
if(asyncLoader != null && asyncLoader.getStatus() == AsyncTask.Status.RUNNING) asyncLoader.cancel(true);
asyncLoader = null;
if(singleLoader != null && singleLoader.getStatus() == AsyncTask.Status.RUNNING) singleLoader.cancel(true);
singleLoader = null;
}

/**
* Cancels the {@link SingleLoader} task which was started via {@link #getEarthWallpaper(String, SingleEarthViewCallback)}
* This method call will have no affect if no {@link SingleLoader} is running.
* If a running task got cancelled {@link SingleEarthViewCallback#onCancelledLoading()} will be invoked.
*/
public void cancleSingleEarthViewLoadingTask() {
if(singleLoader != null && singleLoader.getStatus() == AsyncTask.Status.RUNNING) singleLoader.cancel(true);
singleLoader = null;
}

/**
* Cancels the running {@link AsyncLoader} task which was started via
* {@link #getAllEarthWallpapers(EarthViewCallback)}
* {@link #getEarthWallpapers(int, EarthViewCallback)}
* {@link #getEarthWallpapers(Set, EarthViewCallback)}
* {@link #getEarthWallpapers(String[], EarthViewCallback)}
* This method call will have no affect if no {@link AsyncLoader} is running.
* If a running task got cancelled {@link EarthViewCallback#onCancelledLoading(Collection)} will be invoked.
*/
public void cancelEarthViewLoadingTask() {
if(asyncLoader != null && asyncLoader.getStatus() == AsyncTask.Status.RUNNING) asyncLoader.cancel(true);
asyncLoader = null;
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2015 - Patrick J - earthview-android
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.pddstudio.earthview;

import java.util.Collection;
Expand All @@ -8,7 +24,8 @@
* have a look at the README.md
*/
public interface EarthViewCallback {
void onStartedLoading();
void onStartedLoading(int totalItemSize);
void onItemLoaded(EarthWallpaper earthWallpaper);
void onFinishedLoading(Collection<EarthWallpaper> earthWallpapers);
void onCancelledLoading(Collection<EarthWallpaper> earthWallpapers);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2015 - Patrick J - earthview-android
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.pddstudio.earthview;

import android.util.Log;
Expand All @@ -16,6 +32,7 @@ public class EarthWallpaper implements Serializable {
//the base url
private static final String EARTHVIEW_BASE_URL = "https://earthview.withgoogle.com";
private static final String WALLPAPER_EXTENSION = ".jpg";
private static final String EARTHVIEW_SHARE_URL = "https://g.co/ev/";

//hidden information for background operations
@SerializedName("id") private String wallpaperId;
Expand Down Expand Up @@ -204,12 +221,20 @@ public String getFormattedWallpaperTitle() {
return wallpaperTitle;
}

public String getFormattedFileName(boolean withExtension) {
public String getFormattedFileName(boolean withExtension, boolean withIdInName) {
int cutIndex = wallpaperSlug.lastIndexOf("-");
String formattedName = wallpaperSlug.substring(0, cutIndex);
Log.d("EarthWallpaper", "formattedFileName: " + formattedName);
if(withExtension) return formattedName + WALLPAPER_EXTENSION;
if(withExtension && !withIdInName) {
return formattedName + WALLPAPER_EXTENSION;
} else if(withExtension && withIdInName) {
return formattedName + "-" + wallpaperId + WALLPAPER_EXTENSION;
}
else return formattedName;
}

public String getShareUrl() {
return EARTHVIEW_SHARE_URL + wallpaperId;
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
/*
* Copyright 2015 - Patrick J - earthview-android
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.pddstudio.earthview;

import android.support.annotation.Nullable;

/**
* This Class was created by Patrick J
* on 10.12.15. For more Details and Licensing
* have a look at the README.md
*/
public interface SingleEarthViewCallback {
void onStartedLoading();
void onFinishedLoading(EarthWallpaper earthWallpaper);
void onFinishedLoading(@Nullable EarthWallpaper earthWallpaper);
void onCancelledLoading();
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2015 - Patrick J - earthview-android
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.pddstudio.earthview.utils;

/**
Expand Down
Loading

0 comments on commit 614b6bc

Please sign in to comment.