Skip to content

Commit

Permalink
Merge pull request #35 from b-lam/develop
Browse files Browse the repository at this point in the history
v1.1.3
  • Loading branch information
b-lam authored Jan 12, 2018
2 parents 211834d + 7703138 commit 3ff975b
Show file tree
Hide file tree
Showing 32 changed files with 285 additions and 259 deletions.
65 changes: 35 additions & 30 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
compileSdkVersion 27
Expand All @@ -7,8 +8,8 @@ android {
applicationId "com.b_lam.resplash"
minSdkVersion 21
targetSdkVersion 27
versionCode 13
versionName "1.1.2"
versionCode 14
versionName "1.1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildConfigField("String", "RELEASE_APP_ID", RELEASE_APP_ID)
buildConfigField("String", "RELEASE_SECRET", RELEASE_SECRET)
Expand Down Expand Up @@ -38,41 +39,45 @@ repositories {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:okhttp:3.9.0'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.7.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.chrisbanes:PhotoView:2.0.0'
compile('com.mikepenz:materialdrawer:5.9.5@aar') {
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.9.1'
implementation 'com.github.bumptech.glide:glide:4.5.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation ('com.mikepenz:materialdrawer:6.0.2@aar') {
transitive = true
}
compile('com.mikepenz:fastadapter:2.6.3@aar') {
implementation ('com.mikepenz:fastadapter:3.0.5@aar') {
transitive = true
}
compile 'com.mikepenz:fastadapter-commons:2.6.3@aar'
compile 'com.mikepenz:fastadapter-extensions:2.6.3@aar'
compile 'com.mikepenz:materialize:1.0.3@aar'
compile 'com.mikepenz:iconics-core:2.9.1@aar'
compile 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
compile 'com.mikepenz:community-material-typeface:1.5.54.2@aar'
compile 'com.github.xiprox.errorview:library:2.2.0'
compile 'com.jakewharton:butterknife:8.8.1'
compile 'com.github.clans:fab:1.6.4'
compile 'com.pacioianu.david:ink-page-indicator:1.2.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-crash:11.8.0'
testCompile 'junit:junit:4.12'
implementation 'com.mikepenz:fastadapter-commons:3.0.5@aar'
implementation 'com.mikepenz:fastadapter-extensions:3.0.5@aar'
implementation 'com.mikepenz:materialize:1.1.2@aar'
implementation 'com.mikepenz:iconics-core:3.0.0@aar'
implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@aar'
implementation 'com.mikepenz:community-material-typeface:2.0.46.1@aar'
implementation 'tr.xip.errorview:library:3.0.0'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.pacioianu.david:ink-page-indicator:1.2.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
}
testImplementation 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'
}

apply plugin: 'com.google.gms.google-services'
Binary file added app/resplash-1.1.3.apk
Binary file not shown.
20 changes: 19 additions & 1 deletion app/src/main/java/com/b_lam/resplash/Utils.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package com.b_lam.resplash;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityCompat;

/**
* Created by Brandon on 10/7/2016.
*/

public class Utils {


public static int getToolbarHeight(Context context) {
final TypedArray styledAttributes = context.getTheme().obtainStyledAttributes(
new int[]{R.attr.actionBarSize});
Expand Down Expand Up @@ -50,4 +53,19 @@ public static boolean isLandscape(Context context) {
.getConfiguration()
.orientation == Configuration.ORIENTATION_LANDSCAPE;
}

public static boolean isStoragePermissionGranted(Activity activity) {
if (Build.VERSION.SDK_INT >= 23) {
if (ActivityCompat.checkSelfPermission(activity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED) {
return true;
} else {
ActivityCompat.requestPermissions(activity, new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
return false;
}
}
else {
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
import com.b_lam.resplash.util.LocaleUtils;
import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.IAdapter;
import com.mikepenz.fastadapter.adapters.FooterAdapter;
import com.mikepenz.fastadapter.adapters.ItemAdapter;
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter;
import com.mikepenz.fastadapter.listeners.OnClickListener;
import com.mikepenz.fastadapter_extensions.items.ProgressItem;
import com.mikepenz.fastadapter_extensions.scroll.EndlessRecyclerOnScrollListener;

Expand Down Expand Up @@ -67,7 +67,7 @@ public class CollectionDetailActivity extends AppCompatActivity {
private FastItemAdapter<Photo> mPhotoAdapter;
private List<Photo> mPhotos;
private List<Photo> mCurrentPhotos;
private FooterAdapter<ProgressItem> mFooterAdapter;
private ItemAdapter mFooterAdapter;
private int mPage, mColumns;
private PhotoService.OnRequestPhotosListener mPhotosRequestListener;
private String mLayoutType;
Expand Down Expand Up @@ -130,9 +130,11 @@ public boolean onTouch(View v, MotionEvent event) {

mPhotoAdapter.withOnClickListener(onClickListener);

mFooterAdapter = new FooterAdapter<>();
mFooterAdapter = new ItemAdapter<>();

mImageRecycler.setAdapter(mFooterAdapter.wrap(mPhotoAdapter));
mPhotoAdapter.addAdapter(1, mFooterAdapter);

mImageRecycler.setAdapter(mPhotoAdapter);

mImageRecycler.addOnScrollListener(new EndlessRecyclerOnScrollListener(mFooterAdapter) {
@Override
Expand All @@ -157,7 +159,7 @@ public void onRefresh() {
loadMore();
}

private FastAdapter.OnClickListener<Photo> onClickListener = new FastAdapter.OnClickListener<Photo>(){
private OnClickListener<Photo> onClickListener = new OnClickListener<Photo>(){
@Override
public boolean onClick(View v, IAdapter<Photo> adapter, Photo item, int position) {
Intent i = new Intent(getApplicationContext(), DetailActivity.class);
Expand Down Expand Up @@ -228,7 +230,7 @@ public void onRequestPhotosSuccess(Call<List<Photo>> call, Response<List<Photo>>
@Override
public void onRequestPhotosFailed(Call<List<Photo>> call, Throwable t) {
Log.d(TAG, t.toString());
mImagesErrorView.showRetryButton(false);
mImagesErrorView.setRetryVisible(false);
mImagesErrorView.setTitle(R.string.error_network);
mImagesErrorView.setSubtitle(R.string.error_network_subtitle);
mImagesProgress.setVisibility(View.GONE);
Expand Down
46 changes: 31 additions & 15 deletions app/src/main/java/com/b_lam/resplash/activities/DetailActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.PorterDuff;
Expand All @@ -35,6 +34,7 @@

import com.b_lam.resplash.R;
import com.b_lam.resplash.Resplash;
import com.b_lam.resplash.Utils;
import com.b_lam.resplash.data.data.LikePhotoResult;
import com.b_lam.resplash.data.data.Photo;
import com.b_lam.resplash.data.data.PhotoDetails;
Expand All @@ -46,12 +46,11 @@
import com.b_lam.resplash.util.LocaleUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.github.clans.fab.FloatingActionButton;
import com.github.clans.fab.FloatingActionMenu;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.gson.Gson;

import java.text.NumberFormat;
import java.util.Locale;

Expand Down Expand Up @@ -116,9 +115,27 @@ public void onReceive(Context context, Intent intent) {
getApplicationContext().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, downloadManager.getUriForDownloadedFile(downloadReference)));
if (currentAction == ActionType.WALLPAPER) {
Uri uri = downloadManager.getUriForDownloadedFile(downloadReference);
Log.d(TAG, uri.toString());
Intent wallpaperIntent = WallpaperManager.getInstance(DetailActivity.this).getCropAndSetWallpaperIntent(uri);
DetailActivity.this.startActivityForResult(wallpaperIntent, 13451);
Bundle params = new Bundle();
params.putString("file_uri", uri.toString());
try {
Log.d(TAG, "Crop and Set: " + uri.toString());
Intent wallpaperIntent = WallpaperManager.getInstance(context).getCropAndSetWallpaperIntent(uri);
wallpaperIntent.setDataAndType(uri, "image/jpg");
wallpaperIntent.putExtra("mimeType", "image/jpg");
startActivityForResult(wallpaperIntent, 13451);
mFirebaseAnalytics.logEvent("set_wallpaper", params);
} catch (Exception e) {
Log.d(TAG, "Chooser: " + uri.toString());
Intent wallpaperIntent = new Intent(Intent.ACTION_ATTACH_DATA);
wallpaperIntent.setDataAndType(uri, "image/jpg");
wallpaperIntent.putExtra("mimeType", "image/jpg");
wallpaperIntent.addCategory(Intent.CATEGORY_DEFAULT);
wallpaperIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
wallpaperIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
wallpaperIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
startActivity(Intent.createChooser(wallpaperIntent, getString(R.string.set_as_wallpaper)));
mFirebaseAnalytics.logEvent("set_wallpaper_alternative", params);
}
wallpaperDialog.setDownloadFinished(true);
}
break;
Expand Down Expand Up @@ -226,15 +243,14 @@ protected void onCreate(Bundle savedInstanceState) {
}else {
Glide.with(DetailActivity.this)
.load(mPhoto.urls.regular)
.priority(Priority.HIGH)
.placeholder(R.drawable.placeholder)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.apply(new RequestOptions()
.priority(Priority.HIGH)
.placeholder(R.drawable.placeholder))
.into(imgFull);
}
Glide.with(DetailActivity.this)
.load(mPhoto.user.profile_image.large)
.priority(Priority.HIGH)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.apply(new RequestOptions().priority(Priority.HIGH))
.into(imgProfile);

colorIcon = getResources().getDrawable(R.drawable.ic_fiber_manual_record_white_18dp, getTheme());
Expand Down Expand Up @@ -310,7 +326,7 @@ public void onBackPressed(){
public void onClick(View view) {
switch (view.getId()) {
case R.id.fab_download:
if (mPhoto != null) {
if (Utils.isStoragePermissionGranted(DetailActivity.this) && mPhoto != null) {
mFirebaseAnalytics.logEvent(Resplash.FIREBASE_EVENT_DOWNLOAD, null);
floatingActionMenu.close(true);
Toast.makeText(getApplicationContext(), getString(R.string.download_started), Toast.LENGTH_SHORT).show();
Expand All @@ -332,12 +348,12 @@ public void onClick(View view) {
downloadImage(mPhoto.urls.thumb, ActionType.DOWNLOAD);
break;
default:
throw new IllegalArgumentException("Invalid download quality");
downloadImage(mPhoto.urls.full, ActionType.DOWNLOAD);
}
}
break;
case R.id.fab_wallpaper:
if (mPhoto != null) {
if (Utils.isStoragePermissionGranted(DetailActivity.this) && mPhoto != null) {
mFirebaseAnalytics.logEvent(Resplash.FIREBASE_EVENT_SET_WALLPAPER, null);
floatingActionMenu.close(true);
currentAction = ActionType.WALLPAPER;
Expand Down Expand Up @@ -367,7 +383,7 @@ public void onCancel() {
downloadImage(mPhoto.urls.thumb, ActionType.WALLPAPER);
break;
default:
throw new IllegalArgumentException("Invalid wallpaper quality");
downloadImage(mPhoto.urls.full, ActionType.WALLPAPER);
}
}

Expand Down
Loading

0 comments on commit 3ff975b

Please sign in to comment.