Skip to content
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
32 changes: 19 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,37 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
classpath 'com.android.tools.build:gradle:0.7.+'
}
}

apply plugin: 'android'

repositories {
mavenCentral()
maven { url 'http://wordpress-mobile.github.io/WordPress-Android' }
}

project.archivesBaseName="WordPress-Android"
apply plugin: 'android'

android {
lintOptions {
quiet true
abortOnError false
}

packagingOptions {
exclude "META-INF/LICENSE.txt"
exclude "META-INF/NOTICE.txt"
}

buildTypes {
release {
buildConfig "public static String APP_PN_KEY = \"org.wordpress.android.playstore\";"
buildConfigField "String", "APP_PN_KEY", "\"org.wordpress.android.playstore\""
}
debug {
buildConfig "public static String APP_PN_KEY = \"org.wordpress.android.debug.build\";"
buildConfigField "String", "APP_PN_KEY", "\"org.wordpress.android.debug.build\""
}
betagroup.initWith(buildTypes.release)
betagroup {
buildConfig "public static String APP_PN_KEY = \"org.wordpress.android.beta.build\";"
buildConfigField "String", "APP_PN_KEY", "\"org.wordpress.android.beta.build\""
}
}

Expand Down Expand Up @@ -85,7 +91,7 @@ android {

// Generates the Config.java class using properties defined in gradle.properties
// or by other means provided by Gradle
task wordpressConfig(group: "build", description: "Generate Config class") {
task generateWPConfig(group: "generate", description: "Generate Config class") {
def dir = "${buildDir}/source/wordpress"
def file = new File(dir, "org/wordpress/android/Config.java")
android {
Expand Down Expand Up @@ -128,13 +134,13 @@ ${config}
}
}

// Add the wordpressConfig task to every flavor's compile tasks
// Add the generateWPConfig task to every flavor's compile tasks
android.buildTypes.all { buildType ->
def name = "compile${buildType.name.capitalize()}"
def name = "generate${buildType.name.capitalize()}BuildConfig"
tasks.whenTaskAdded { task ->
if (task.name == name) {
task.dependsOn(wordpressConfig)
task.mustRunAfter(wordpressConfig)
task.dependsOn(generateWPConfig)
task.mustRunAfter(generateWPConfig)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Nov 04 14:37:56 PST 2013
#Thu Dec 19 13:13:21 CET 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-all.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip
Binary file removed libs/android-support-v4.jar
Binary file not shown.
Binary file removed libs/commons-lang-2.6.jar
Binary file not shown.
Binary file removed libs/gcm.jar
Binary file not shown.
Binary file removed libs/gson-2.2.2.jar
Binary file not shown.
Binary file removed libs/httpmime-4.1.2.jar
Binary file not shown.
Binary file removed libs/tagsoup-1.2.1.jar
Binary file not shown.
Binary file removed libs/volley.jar
Binary file not shown.
Binary file removed libs/wordpresscom-android-rest-v0.0.3.jar
Binary file not shown.
6 changes: 0 additions & 6 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,6 @@
<string name="reader_toast_err_get_post">Unable to retrieve this post</string>
<string name="reader_toast_err_get_comment">Unable to retrieve this comment</string>

<!--
very important that this string resource is correct for all translations, since it's
the name of the default tag to display in the reader at startup
-->
<string name="reader_default_tag_name">Freshly Pressed</string>

<!-- empty list/grid text -->
<string name="reader_empty_posts_in_topic">No post in this&#160;topic.</string>
<string name="reader_empty_posts_in_topic_updating">Fetching posts…</string>
Expand Down
10 changes: 8 additions & 2 deletions src/org/wordpress/android/datasets/ReaderPostTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.wordpress.android.models.ReaderPost;
import org.wordpress.android.models.ReaderPostList;
import org.wordpress.android.models.ReaderTag;
import org.wordpress.android.util.SqlUtils;

/**
Expand Down Expand Up @@ -338,8 +339,13 @@ public static ReaderPostList getPostsWithTag(String tagName, int maxPosts) {
String sql = "SELECT tbl_posts.* FROM tbl_posts, tbl_post_tags"
+ " WHERE tbl_posts.post_id = tbl_post_tags.post_id"
+ " AND tbl_posts.blog_id = tbl_post_tags.blog_id"
+ " AND tbl_post_tags.tag_name=?"
+ " ORDER BY tbl_posts.timestamp DESC";
+ " AND tbl_post_tags.tag_name=?";

// skip posts that are no longer liked if this is "Posts I Like"
if (tagName.equals(ReaderTag.TAG_NAME_LIKED))
sql += " AND tbl_posts.is_liked != 0";

sql += " ORDER BY tbl_posts.timestamp DESC";

if (maxPosts > 0)
sql += " LIMIT " + Integer.toString(maxPosts);
Expand Down
9 changes: 9 additions & 0 deletions src/org/wordpress/android/models/ReaderTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ public class ReaderTag {
private static final int INT_SUBSCRIBED = 1;
private static final int INT_RECOMMENDED = 2;

public static String TAG_ID_FOLLOWING = "following";
public static String TAG_ID_LIKED = "liked";

// these are the default tag names, which aren't localized in the /read/menu/ response
public static String TAG_NAME_LIKED = "Posts I Like";
public static String TAG_NAME_FOLLOWING = "Blogs I Follow";
public static String TAG_NAME_FRESHLY_PRESSED = "Freshly Pressed";
public static String TAG_NAME_DEFAULT = TAG_NAME_FRESHLY_PRESSED;

public static enum ReaderTagType {SUBSCRIBED,
DEFAULT,
RECOMMENDED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.wordpress.android.ui.reader_native.actions.ReaderAuthActions;
import org.wordpress.android.ui.reader_native.actions.ReaderBlogActions;
import org.wordpress.android.ui.reader_native.actions.ReaderUserActions;
import org.wordpress.android.ui.reader_native.ReaderPostListFragment.RefreshType;
import org.wordpress.android.util.NetworkUtils;
import org.wordpress.android.util.ReaderLog;
import org.wordpress.android.util.ToastUtils;
Expand Down Expand Up @@ -170,7 +171,7 @@ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
if (!NetworkUtils.isNetworkAvailable(this)) {
ToastUtils.showToast(this, R.string.reader_toast_err_no_connection, ToastUtils.Duration.LONG);
} else {
fragment.updatePostsWithCurrentTag(ReaderActions.RequestDataAction.LOAD_NEWER);
fragment.updatePostsWithCurrentTag(ReaderActions.RequestDataAction.LOAD_NEWER, RefreshType.MANUAL);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ public class ReaderPostListFragment extends Fragment implements AbsListView.OnSc
private static final String LIST_STATE = "list_state";
private Parcelable mListState = null;

protected static enum RefreshType {AUTOMATIC, MANUAL};

protected static ReaderPostListFragment newInstance(Context context) {
ReaderLog.d("post list newInstance");

// restore the previously-chosen tag, revert to default if not set or doesn't exist
String tagName = UserPrefs.getReaderTag();
if (TextUtils.isEmpty(tagName) || !ReaderTagTable.tagExists(tagName))
tagName = context.getString(R.string.reader_default_tag_name);
tagName = ReaderTag.TAG_NAME_DEFAULT;

Bundle args = new Bundle();
args.putString(KEY_TAG_NAME, tagName);
Expand Down Expand Up @@ -213,11 +215,11 @@ private void setEmptyTitleAndDecriptionForCurrentTag() {
} else {
tagId = "";
}
if (tagId.equals("following")) {
if (tagId.equals(ReaderTag.TAG_ID_FOLLOWING)) {
title = R.string.reader_empty_followed_blogs_title;
description = R.string.reader_empty_followed_blogs_description;
} else {
if (tagId.equals("liked")) {
if (tagId.equals(ReaderTag.TAG_ID_LIKED)) {
title = R.string.reader_empty_posts_liked;
} else {
title = R.string.reader_empty_posts_in_topic;
Expand Down Expand Up @@ -270,7 +272,7 @@ public void onRequestData(ReaderActions.RequestDataAction action) {
if (ReaderPostTable.getNumPostsWithTag(mCurrentTag) >= Constants.READER_MAX_POSTS_TO_DISPLAY)
return;
// request older posts
updatePostsWithCurrentTag(ReaderActions.RequestDataAction.LOAD_OLDER);
updatePostsWithCurrentTag(ReaderActions.RequestDataAction.LOAD_OLDER, RefreshType.MANUAL);
}
};

Expand Down Expand Up @@ -332,7 +334,7 @@ protected void setCurrentTag(String tagName) {

// update posts in this tag if it's time to do so
if (ReaderTagTable.shouldAutoUpdateTag(tagName))
updatePostsWithTag(tagName, ReaderActions.RequestDataAction.LOAD_NEWER);
updatePostsWithTag(tagName, ReaderActions.RequestDataAction.LOAD_NEWER, RefreshType.AUTOMATIC);
}

/*
Expand Down Expand Up @@ -360,17 +362,17 @@ private void reloadPosts(boolean animateRows) {
}

private boolean hasActivity() {
return (getActivity()!=null);
return (getActivity() != null && !isRemoving());
}

/*
* get latest posts for this tag from the server
*/
protected void updatePostsWithCurrentTag(ReaderActions.RequestDataAction updateAction) {
protected void updatePostsWithCurrentTag(ReaderActions.RequestDataAction updateAction, RefreshType refreshType) {
if (hasCurrentTag())
updatePostsWithTag(mCurrentTag, updateAction);
updatePostsWithTag(mCurrentTag, updateAction, refreshType);
}
private void updatePostsWithTag(final String tagName, final ReaderActions.RequestDataAction updateAction) {
private void updatePostsWithTag(final String tagName, final ReaderActions.RequestDataAction updateAction, RefreshType refreshType) {
if (TextUtils.isEmpty(tagName))
return;

Expand All @@ -383,9 +385,14 @@ private void updatePostsWithTag(final String tagName, final ReaderActions.Reques
}

setIsUpdating(true, updateAction);
// update empty view title and description if the the post list is empty
setEmptyTitleAndDecriptionForCurrentTag();

// if this is "Posts I Like" and it's a manual refresh (user tapped refresh icon), refresh the posts so posts that were unliked
// no longer appear
if (refreshType == RefreshType.MANUAL && isCurrentTagName(tagName) && tagName.equals((ReaderTag.TAG_NAME_LIKED))) {
refreshPosts();
}

ReaderPostActions.updatePostsWithTag(tagName, updateAction, new ReaderActions.UpdateResultAndCountListener() {
@Override
public void onUpdateResult(ReaderActions.UpdateResult result, int numNewPosts) {
Expand Down Expand Up @@ -476,7 +483,7 @@ public void onAnimationRepeat(Animation animation) { }
public void run() {
if (hasCurrentTag()) {
ReaderLog.d("performing automatic update");
updatePostsWithCurrentTag(ReaderActions.RequestDataAction.LOAD_NEWER);
updatePostsWithCurrentTag(ReaderActions.RequestDataAction.LOAD_NEWER, ReaderPostListFragment.RefreshType.AUTOMATIC);
}
}
};
Expand Down Expand Up @@ -571,9 +578,9 @@ protected void refreshTags() {
return;

// make sure current tag still exists, reset to default if it doesn't
if (hasCurrentTag() && !ReaderTagTable.tagExists(getCurrentTagName())) {
mCurrentTag = getActivity().getString(R.string.reader_default_tag_name);
}
if (hasCurrentTag() && !ReaderTagTable.tagExists(getCurrentTagName()))
mCurrentTag = ReaderTag.TAG_NAME_DEFAULT;

getActionBarAdapter().refreshTags();
}

Expand Down