Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from develop #4

Merged
merged 3 commits into from
Apr 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[Resplash]

<img src="https://github.com/b-lam/Resplash/blob/develop/design/Play%20Store/Resplash_Play_Store_Banner.jpg?raw=true" height="350">
<img src="https://github.com/b-lam/Resplash/blob/develop/design/Play%20Store/Resplash_Play_Store_Banner.jpg?raw=true" width="750">

**[Resplash]** is powered by [Unsplash.com](https://unsplash.com/)

Expand Down
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.b_lam.resplash"
minSdkVersion 22
targetSdkVersion 25
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildConfigField("String", "UNSPLASH_APPLICATION_ID", UNSPLASH_APPLICATION_ID)
buildConfigField("String", "UNSPLASH_SECRET", UNSPLASH_SECRET)
Expand Down Expand Up @@ -37,10 +37,10 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
testCompile 'junit:junit:4.12'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.google.code.gson:gson:2.8.0'
Expand Down
Binary file added app/resplash-1.0.1.apk
Binary file not shown.
Binary file added app/src/debug/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
Expand All @@ -18,6 +21,7 @@
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -67,6 +71,7 @@ public class CollectionDetailActivity extends AppCompatActivity {
private PhotoService.OnRequestPhotosListener mPhotosRequestListener;
private String mLayoutType;
private PhotoService photoService;
private SharedPreferences sharedPreferences;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -99,7 +104,7 @@ protected void onCreate(Bundle savedInstanceState) {
mUserProfilePicture.setOnClickListener(userProfileOnClickListener);
mUserCollection.setOnClickListener(userProfileOnClickListener);

SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Resplash.getInstance());
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Resplash.getInstance());
mLayoutType = sharedPreferences.getString("item_layout", "List");
mPage = 1;
if(mLayoutType.equals("List") || mLayoutType.equals("Cards")){
Expand Down Expand Up @@ -153,7 +158,27 @@ public void onRefresh() {
public boolean onClick(View v, IAdapter<Photo> adapter, Photo item, int position) {
Intent i = new Intent(getApplicationContext(), DetailActivity.class);
i.putExtra("Photo", new Gson().toJson(item));
startActivity(i);
String layout = sharedPreferences.getString("item_layout", "List");

ImageView imageView;

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || sharedPreferences.getString("item_layout", "List").equals("Grid")) {
startActivity(i);
} else if (layout.equals("Cards")) {
imageView = (ImageView) v.findViewById(R.id.item_image_card_img);
if (imageView.getDrawable() != null)
Resplash.getInstance().setDrawable(imageView.getDrawable());
startActivity(i);
} else {
imageView = (ImageView) v.findViewById(R.id.item_image_img);
if (imageView.getDrawable() != null)
Resplash.getInstance().setDrawable(imageView.getDrawable());
// v.setTransitionName("photoScale");
// Pair<View, String> p1 = Pair.create(v, v.getTransitionName());
// ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(CollectionDetailActivity.this, p1);
// startActivity(i, options.toBundle());
startActivity(i);
}
return false;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -26,6 +29,8 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.animation.OvershootInterpolator;
import android.widget.ImageButton;
import android.widget.ImageView;
Expand Down Expand Up @@ -126,9 +131,10 @@ protected void onCreate(Bundle savedInstanceState) {

if(Resplash.getInstance().getDrawable() != null){
imgFull.setImageDrawable(Resplash.getInstance().getDrawable());
Resplash.getInstance().setDrawable(null);
}else {
Glide.with(DetailActivity.this)
.load(mPhoto.urls.full)
.load(mPhoto.urls.regular)
.priority(Priority.HIGH)
.placeholder(R.drawable.placeholder)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
Expand Down Expand Up @@ -169,7 +175,6 @@ public void onRequestPhotoDetailsSuccess(Call<PhotoDetails> call, Response<Photo
tvDownloads.setText(NumberFormat.getInstance(Locale.CANADA).format(mPhotoDetails.downloads) + " Downloads");
like = mPhotoDetails.liked_by_user;
updateHeartButton(like);
loadProgress.setVisibility(View.GONE);
content.setVisibility(View.VISIBLE);
floatingActionMenu.setVisibility(View.VISIBLE);
} else if (response.code() == 403) {
Expand Down Expand Up @@ -279,6 +284,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()){
case android.R.id.home:
getWindow().setExitTransition(null);
supportFinishAfterTransition();
return true;
case R.id.action_share:
Expand All @@ -297,6 +303,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

@Override
public void onBackPressed(){
getWindow().setExitTransition(null);
supportFinishAfterTransition();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.transition.Fade;
import android.transition.Transition;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.Toast;

Expand Down Expand Up @@ -207,7 +210,6 @@ public void onClick(View view) {
startActivity(new Intent(Intent.ACTION_VIEW, uri));
}
});

}

private Drawer.OnDrawerItemClickListener drawerItemClickListener = new Drawer.OnDrawerItemClickListener() {
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/com/b_lam/resplash/data/data/Photo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,28 @@
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.ColorUtils;
import android.support.v4.util.Pair;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.b_lam.resplash.Resplash;
import com.b_lam.resplash.activities.DetailActivity;
import com.b_lam.resplash.activities.MainActivity;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.animation.ViewPropertyAnimation;
import com.google.gson.Gson;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.mikepenz.fastadapter.utils.ViewHolderFactory;

Expand Down Expand Up @@ -425,7 +432,6 @@ public void onAnimationUpdate(ValueAnimator animator) {

});
colorAnimation.start();

break;
case "Cards":
Glide.with(holder.itemView.getContext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.Fragment;
import android.support.v4.util.Pair;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
Expand All @@ -13,11 +16,15 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.b_lam.resplash.Resplash;
import com.b_lam.resplash.activities.DetailActivity;
import com.b_lam.resplash.activities.MainActivity;
import com.b_lam.resplash.data.data.Photo;
import com.b_lam.resplash.data.service.PhotoService;
import com.google.gson.Gson;
Expand Down Expand Up @@ -52,6 +59,7 @@ public class FeaturedFragment extends Fragment{
private FooterAdapter<ProgressItem> mFooterAdapter;
private int mPage, mColumns;
private String mSort;
private SharedPreferences sharedPreferences;

public FeaturedFragment() {
// Required empty public constructor
Expand All @@ -72,7 +80,7 @@ public void onCreate(Bundle savedInstanceState) {
setHasOptionsMenu(true);
super.onCreate(savedInstanceState);

SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Resplash.getInstance());
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Resplash.getInstance());
String mLayoutType = sharedPreferences.getString("item_layout", "List");
mSort = getArguments().getString("sort", "latest");
if(mLayoutType.equals("List") || mLayoutType.equals("Cards")){
Expand All @@ -82,7 +90,6 @@ public void onCreate(Bundle savedInstanceState) {
}

mService = PhotoService.getService();

}

@Override
Expand Down Expand Up @@ -152,7 +159,37 @@ public void onDestroy() {
public boolean onClick(View v, IAdapter<Photo> adapter, Photo item, int position) {
Intent i = new Intent(getContext(), DetailActivity.class);
i.putExtra("Photo", new Gson().toJson(item));
startActivity(i);

String layout = sharedPreferences.getString("item_layout", "List");

ImageView imageView;

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || sharedPreferences.getString("item_layout", "List").equals("Grid")) {
startActivity(i);
} else if (layout.equals("Cards")) {
imageView = (ImageView) v.findViewById(R.id.item_image_card_img);
if (imageView.getDrawable() != null)
Resplash.getInstance().setDrawable(imageView.getDrawable());
startActivity(i);
} else {
imageView = (ImageView) v.findViewById(R.id.item_image_img);
if (imageView.getDrawable() != null)
Resplash.getInstance().setDrawable(imageView.getDrawable());
// v.setTransitionName("photoScale");
// View navigationBar = getActivity().findViewById(android.R.id.navigationBarBackground);
// View statusBar = getActivity().findViewById(android.R.id.statusBarBackground);
//
// Pair<View, String> p1 = Pair.create(v, v.getTransitionName());
// Pair<View, String> p2 = Pair.create(statusBar, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME);
// Pair<View, String> p3 = Pair.create(navigationBar, Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME);
//
// ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), p1, p2, p3);
// startActivity(i, options.toBundle());
startActivity(i);
}



return false;
}
};
Expand Down Expand Up @@ -205,7 +242,6 @@ public void onRequestPhotosFailed(Call<List<Photo>> call, Throwable t) {
};

mService.requestCuratedPhotos(mPage, Resplash.DEFAULT_PER_PAGE, mSort, mPhotoRequestListener);

}

public void fetchNew(){
Expand Down
31 changes: 29 additions & 2 deletions app/src/main/java/com/b_lam/resplash/fragments/NewFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.Fragment;
import android.support.v4.util.Pair;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
Expand All @@ -13,6 +16,8 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;

Expand Down Expand Up @@ -52,6 +57,7 @@ public class NewFragment extends Fragment {
private FooterAdapter<ProgressItem> mFooterAdapter;
private int mPage, mColumns;
private String mSort;
private SharedPreferences sharedPreferences;

public NewFragment() {
// Required empty public constructor
Expand All @@ -72,7 +78,7 @@ public void onCreate(Bundle savedInstanceState) {
setHasOptionsMenu(true);
super.onCreate(savedInstanceState);

SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Resplash.getInstance());
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Resplash.getInstance());
String mLayoutType = sharedPreferences.getString("item_layout", "List");
mSort = getArguments().getString("sort", "latest");
if(mLayoutType.equals("List") || mLayoutType.equals("Cards")){
Expand Down Expand Up @@ -147,7 +153,28 @@ public void onDestroy() {
public boolean onClick(View v, IAdapter<Photo> adapter, Photo item, int position) {
Intent i = new Intent(getContext(), DetailActivity.class);
i.putExtra("Photo", new Gson().toJson(item));
startActivity(i);

String layout = sharedPreferences.getString("item_layout", "List");

ImageView imageView;

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || sharedPreferences.getString("item_layout", "List").equals("Grid")) {
startActivity(i);
} else if (layout.equals("Cards")) {
imageView = (ImageView) v.findViewById(R.id.item_image_card_img);
if (imageView.getDrawable() != null)
Resplash.getInstance().setDrawable(imageView.getDrawable());
startActivity(i);
} else {
imageView = (ImageView) v.findViewById(R.id.item_image_img);
if (imageView.getDrawable() != null)
Resplash.getInstance().setDrawable(imageView.getDrawable());
// v.setTransitionName("photoScale");
// Pair<View, String> p1 = Pair.create(v, v.getTransitionName());
// ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), p1);
// startActivity(i, options.toBundle());
startActivity(i);
}
return false;
}
};
Expand Down
Loading