Skip to content

Commit

Permalink
Version 1.1.2
Browse files Browse the repository at this point in the history
- Start recommended subreddits tab in FragmentSearch
- Fix bugs
  • Loading branch information
TheKeeperOfPie committed Jul 28, 2015
1 parent 8919b33 commit e0adc67
Show file tree
Hide file tree
Showing 21 changed files with 320 additions and 106 deletions.
Binary file modified app/app-release.apk
Binary file not shown.
7 changes: 3 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ buildscript {
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.zeroturnaround.jrebel.android'
apply plugin: 'io.fabric'

repositories {
Expand All @@ -25,8 +24,8 @@ android {
applicationId "com.winsonchiu.reader"
minSdkVersion 17
targetSdkVersion 22
versionCode 43
versionName "1.1.1"
versionCode 47
versionName "1.1.2"
}
buildTypes {
release {
Expand Down Expand Up @@ -54,5 +53,5 @@ dependencies {
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:palette-v7:22.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.rjeschke:txtmark:0.13+'
compile 'com.github.rjeschke:txtmark:0.13'
}
10 changes: 6 additions & 4 deletions app/src/main/java/com/winsonchiu/reader/FragmentAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,13 @@ public void onDestroy() {
}

public boolean navigateBack() {
if (webAuth.canGoBack()) {
webAuth.goBack();
return false;
if (webAuth != null) {
if (webAuth.canGoBack()) {
webAuth.goBack();
return false;
}
destroy(false);
}
destroy(false);
return true;
}

Expand Down
27 changes: 1 addition & 26 deletions app/src/main/java/com/winsonchiu/reader/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,6 @@ public void onDrawerStateChanged(int newState) {
}
}

if (getFragmentManager().findFragmentByTag(FragmentComments.TAG) != null) {

hideFragment(FragmentThreadList.TAG);
hideFragment(FragmentProfile.TAG);
hideFragment(FragmentInbox.TAG);
hideFragment(FragmentSearch.TAG);

}

eventListenerBase = new AdapterLink.ViewHolderBase.EventListener() {

@Override
Expand Down Expand Up @@ -572,16 +563,6 @@ public void loadNestedComments(Comment comment) {
}
}

@Override
public boolean isCommentExpanded(int position) {
return getControllerComments().isCommentExpanded(position);
}

@Override
public boolean hasChildren(Comment comment) {
return getControllerComments().hasChildren(comment);
}

@Override
public void voteComment(AdapterCommentList.ViewHolderComment viewHolderComment,
Comment comment,
Expand Down Expand Up @@ -638,13 +619,6 @@ public void jumpToParent(Comment comment) {

}

private void hideFragment(String tag) {
Fragment fragment = getFragmentManager().findFragmentByTag(tag);
if (fragment != null) {
getFragmentManager().beginTransaction().hide(fragment).commit();
}
}

private void inflateNavigationDrawer() {
viewNavigation = (NavigationView) findViewById(R.id.navigation);

Expand Down Expand Up @@ -1059,6 +1033,7 @@ public void onAuthFinished(boolean success) {
loadAccountInfo();
getControllerUser().reloadUser();
getControllerSearch().reloadSubscriptionList();
onNavigationBackClick();
}
else {
Toast.makeText(this, getString(R.string.login_failure), Toast.LENGTH_SHORT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

}

@Override
public void onViewRecycled(RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
if (getItemViewType(holder.getAdapterPosition()) == VIEW_LINK) {
((AdapterLink.ViewHolderBase) holder).onRecycle();
}
}

@Override
public int getItemCount() {
int count = controllerComments.getItemCount();
Expand Down Expand Up @@ -485,6 +493,11 @@ public void onClick(View v) {

final GestureDetectorCompat gestureDetectorCompat = new GestureDetectorCompat(itemView.getContext(), new GestureDetector.SimpleOnGestureListener() {

@Override
public void onLongPress(MotionEvent e) {
eventListener.toggleComment(getAdapterPosition());
}

@Override
public boolean onDoubleTap(MotionEvent e) {
if (!TextUtils.isEmpty(userName)) {
Expand Down Expand Up @@ -1009,8 +1022,6 @@ public void setVisibility(int visibility) {

public interface EventListener {
void loadNestedComments(Comment comment);
boolean isCommentExpanded(int position);
boolean hasChildren(Comment comment);
void voteComment(ViewHolderComment viewHolderComment, Comment comment, int vote);
boolean toggleComment(int position);
void deleteComment(Comment comment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,16 @@ public void insertMessage(Message message) {

public void insertComment(Comment comment) {

// Placeholder to use ArrayList.indexOf() properly
Comment parentComment = new Comment();
parentComment.setId(comment.getParentId());

int commentIndex = data.getChildren().indexOf(parentComment);
if (commentIndex > -1) {
comment.setLevel(((Comment) data.getChildren().get(commentIndex)).getLevel() + 1);
// Level and context are set as they are not provided by the send API
parentComment = (Comment) data.getChildren().get(commentIndex);
comment.setLevel(parentComment.getLevel() + 1);
comment.setContext(parentComment.getContext());
data.getChildren()
.add(commentIndex + 1, comment);

Expand Down Expand Up @@ -387,7 +391,8 @@ public void markAllRead() {
new Response.Listener<String>() {
@Override
public void onResponse(String response) {

Log.d(TAG, "markAllRead response: " + response);
Toast.makeText(activity, R.string.marked_read, Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
Expand Down
13 changes: 0 additions & 13 deletions app/src/main/java/com/winsonchiu/reader/inbox/FragmentInbox.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public class FragmentInbox extends FragmentBase implements Toolbar.OnMenuItemCli
private ScrollAwareFloatingActionButtonBehavior behaviorFloatingActionButton;
private PorterDuffColorFilter colorFilterIcon;
private Menu menu;
private MenuItem itemMarkAllRead;

public static FragmentInbox newInstance() {
FragmentInbox fragment = new FragmentInbox();
Expand Down Expand Up @@ -96,7 +95,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
@Override
public void setPage(Page page) {
spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(page));
itemMarkAllRead.setVisible(ControllerInbox.UNREAD.equals(page.getPage()));
}

@Override
Expand Down Expand Up @@ -211,16 +209,6 @@ public void loadNestedComments(Comment comment) {
mListener.getControllerInbox().loadNestedComments(comment);
}

@Override
public boolean isCommentExpanded(int position) {
return mListener.getControllerInbox().isCommentExpanded(position);
}

@Override
public boolean hasChildren(Comment comment) {
return mListener.getControllerInbox().hasChildren(comment);
}

@Override
public void voteComment(AdapterCommentList.ViewHolderComment viewHolderComment,
Comment comment,
Expand Down Expand Up @@ -322,7 +310,6 @@ private void setUpOptionsMenu() {
toolbar.inflateMenu(R.menu.menu_inbox);
toolbar.setOnMenuItemClickListener(this);
menu = toolbar.getMenu();
itemMarkAllRead = menu.findItem(R.id.item_mark_all_read);

for (int index = 0; index < menu.size(); index++) {
menu.getItem(index).getIcon().setColorFilter(colorFilterIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ public void onClick(View v) {
break;
case R.id.image_thumbnail:
onClickThumbnail();
recyclerCallback.hideToolbar();
break;
case R.id.button_send_reply:
if (!TextUtils.isEmpty(editTextReply.getText())) {
Expand Down Expand Up @@ -904,6 +903,7 @@ public void run() {
public abstract float getRatio();

public void loadFull() {
recyclerCallback.hideToolbar();

addToHistory();
viewOverlay.setVisibility(View.GONE);
Expand All @@ -919,7 +919,6 @@ public void loadFull() {
}

public void onClickThumbnail() {

viewOverlay.setVisibility(View.GONE);
if (!loadSelfText()) {
loadFull();
Expand Down
33 changes: 31 additions & 2 deletions app/src/main/java/com/winsonchiu/reader/links/AdapterLinkGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package com.winsonchiu.reader.links;

import android.animation.Animator;
import android.app.Activity;
import android.content.res.Resources;
import android.graphics.ColorFilter;
Expand Down Expand Up @@ -174,6 +175,7 @@ public void onBind(Link link, boolean showSubbreddit, String userName) {

int position = getAdapterPosition();

link.setBackgroundColor(colorBackgroundDefault);
itemView.setBackgroundColor(colorBackgroundDefault);
buttonComments.setColorFilter(colorFilterIconDefault);
imagePlay.setColorFilter(colorFilterIconDefault);
Expand Down Expand Up @@ -202,7 +204,7 @@ else if (Reddit.showThumbnail(link)) {
loadThumbnail(link, position);
return;
}
else if (!TextUtils.isEmpty(link.getThumbnail())) {
else if (!TextUtils.isEmpty(link.getThumbnail()) && !Reddit.NSFW.equals(link.getThumbnail())) {
imageFull.setVisibility(View.GONE);
imageThumbnail.clearColorFilter();
imageThumbnail.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -373,6 +375,11 @@ public void onError() {
}

public void loadBackgroundColor() {
if (link.getBackgroundColor() != colorBackgroundDefault) {
setBackgroundColor(link.getBackgroundColor());
return;
}

Drawable drawable = imageFull.getDrawable();
if (drawable instanceof BitmapDrawable) {
final int position = getAdapterPosition();
Expand All @@ -395,10 +402,32 @@ public void onGenerated(Palette palette) {

public void setBackgroundColor(int color) {

link.setBackgroundColor(color);

AnimationUtils.animateBackgroundColor(
itemView,
((ColorDrawable) itemView.getBackground())
.getColor(), color);
.getColor(), color, new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {

}

@Override
public void onAnimationEnd(Animator animation) {
itemView.setBackgroundColor(link.getBackgroundColor());
}

@Override
public void onAnimationCancel(Animator animation) {

}

@Override
public void onAnimationRepeat(Animator animation) {

}
});

setTextColors(color);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ public void clearViewed(Historian historian) {

}

public boolean isOnSpecificSubreddit() {
return !TextUtils.isEmpty(subreddit.getDisplayName()) && !"/r/all/".equalsIgnoreCase(
subreddit.getUrl()) && !subreddit.getUrl().contains("+");
}

public interface Listener extends ControllerListener {
void setSortAndTime(Sort sort, Time time);
void showEmptyView(boolean isEmpty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,17 @@ public Link remove(int position) {

public void insertComment(Comment comment) {

// Placeholder to use ArrayList.indexOf() properly
Comment parentComment = new Comment();
parentComment.setId(comment.getParentId());

int commentIndex = data.getChildren()
.indexOf(parentComment);

if (commentIndex > -1) {
comment.setLevel(((Comment) data.getChildren().get(commentIndex)).getLevel() + 1);
// Level and context are set as they are not provided by the send API
parentComment = (Comment) data.getChildren().get(commentIndex);
comment.setLevel(parentComment.getLevel() + 1);
comment.setContext(parentComment.getContext());
data.getChildren()
.add(commentIndex + 1, comment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,6 @@ public void loadNestedComments(Comment comment) {
mListener.getControllerProfile().loadNestedComments(comment);
}

@Override
public boolean isCommentExpanded(int position) {
return mListener.getControllerProfile().isCommentExpanded(position);
}

@Override
public boolean hasChildren(Comment comment) {
return mListener.getControllerProfile().hasChildren(comment);
}

@Override
public void voteComment(AdapterCommentList.ViewHolderComment viewHolderComment,
Comment comment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public class AdapterSearchSubreddits extends RecyclerView.Adapter<AdapterSearchS

private static final String TAG = AdapterSearchSubreddits.class.getCanonicalName();
private RecyclerView.LayoutManager layoutManager;
private ControllerSearch controllerSubreddits;
private ControllerSearchBase controllerSearchBase;
private ViewHolder.EventListener eventListener;

public AdapterSearchSubreddits(Activity activity,
ControllerSearch controllerSubreddits,
ControllerSearchBase controllerSearchBase,
ViewHolder.EventListener eventListener) {
this.controllerSubreddits = controllerSubreddits;
this.controllerSearchBase = controllerSearchBase;
this.eventListener = eventListener;
this.layoutManager = new LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false);
}
Expand All @@ -50,12 +50,12 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.onBind(controllerSubreddits.getSubreddit(position));
holder.onBind(controllerSearchBase.getSubreddit(position));
}

@Override
public int getItemCount() {
return controllerSubreddits.getSubredditCount();
return controllerSearchBase.getSubredditCount();
}

public static class ViewHolder extends RecyclerView.ViewHolder {
Expand Down
Loading

0 comments on commit e0adc67

Please sign in to comment.