Skip to content

Commit

Permalink
Merge branch 'trunk' into gutenberg/implement-back-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo committed Jan 2, 2024
2 parents 5edcabd + 2ed394c commit 56c03b3
Show file tree
Hide file tree
Showing 66 changed files with 48 additions and 1,662 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [***] [Jetpack-only] Plans: Upgrade to a Plan from domains dashboard in Jetpack app [https://github.com/wordpress-mobile/WordPress-Android/pull/19818]
* [**] [internal] Removes unused resources and code [https://github.com/wordpress-mobile/WordPress-Android/pull/19788]
* [*] Block Editor: Add support for unselecting blocks with the hardware back button [https://github.com/wordpress-mobile/WordPress-Android/pull/19828]
* [**] [internal] Removes unused code using android tool [https://github.com/wordpress-mobile/WordPress-Android/pull/19850]

23.9
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,46 +105,6 @@ public void testSafeToAddAuthToken14() {
assertFalse(WPUrlUtils.safeToAddWordPressComAuthToken(buildURL(NOT_WPCOM_ADDRESS_2)));
}

@Test
public void testSafeToAddAuthToken15() {
// Not HTTPS
assertFalse(WPUrlUtils.safeToAddWordPressComAuthToken(buildURI(WPCOM_ADDRESS_1)));
}

@Test
public void testSafeToAddAuthToken16() {
// Not HTTPS
assertFalse(WPUrlUtils.safeToAddWordPressComAuthToken(buildURI(WPCOM_ADDRESS_2)));
}

@Test
public void testSafeToAddAuthToken17() {
// Not HTTPS
assertFalse(WPUrlUtils.safeToAddWordPressComAuthToken(buildURI(WPCOM_ADDRESS_3)));
}

@Test
public void testSafeToAddAuthToken18() {
assertTrue(WPUrlUtils.safeToAddWordPressComAuthToken(buildURI(WPCOM_ADDRESS_4)));
}

@Test
public void testSafeToAddAuthToken19() {
assertTrue(WPUrlUtils.safeToAddWordPressComAuthToken(buildURI(WPCOM_ADDRESS_5)));
}

@Test
public void testSafeToAddAuthToken20() {
// Not wpcom
assertFalse(WPUrlUtils.safeToAddWordPressComAuthToken(buildURI(NOT_WPCOM_ADDRESS_1)));
}

@Test
public void testSafeToAddAuthToken21() {
// Not wpcom
assertFalse(WPUrlUtils.safeToAddWordPressComAuthToken(buildURI(NOT_WPCOM_ADDRESS_2)));
}

@Test
public void testSafeToAddAuthToken22() {
// Not wpcom
Expand All @@ -157,12 +117,6 @@ public void testSafeToAddAuthToken23() {
assertFalse(WPUrlUtils.safeToAddWordPressComAuthToken(buildURL(NOT_WPCOM_ADDRESS_3)));
}

@Test
public void testSafeToAddAuthToken24() {
// Not wpcom
assertFalse(WPUrlUtils.safeToAddWordPressComAuthToken(buildURI(NOT_WPCOM_ADDRESS_3)));
}

@Test
public void testSafeToAddAuthToken25() {
assertTrue(WPUrlUtils.safeToAddWordPressComAuthToken(WPCOM_ADDRESS_6));
Expand All @@ -173,11 +127,6 @@ public void testSafeToAddAuthToken26() {
assertTrue(WPUrlUtils.safeToAddWordPressComAuthToken(buildURL(WPCOM_ADDRESS_6)));
}

@Test
public void testSafeToAddAuthToken27() {
assertTrue(WPUrlUtils.safeToAddWordPressComAuthToken(buildURI(WPCOM_ADDRESS_6)));
}

@Test
public void testIsWPCOMString1() {
assertTrue(WPUrlUtils.isWordPressCom(WPCOM_ADDRESS_1));
Expand Down Expand Up @@ -257,36 +206,6 @@ private URI buildURI(String address) {
return uri;
}

@Test
public void testIsWPCOMURI1() {
assertTrue(WPUrlUtils.isWordPressCom(buildURI(WPCOM_ADDRESS_1)));
}

@Test
public void testIsWPCOMURI2() {
assertTrue(WPUrlUtils.isWordPressCom(buildURI(WPCOM_ADDRESS_2)));
}

@Test
public void testIsWPCOMURI3() {
assertTrue(WPUrlUtils.isWordPressCom(buildURI(WPCOM_ADDRESS_3)));
}

@Test
public void testIsWPCOMURI4() {
assertTrue(WPUrlUtils.isWordPressCom(buildURI(WPCOM_ADDRESS_4)));
}

@Test
public void testIsWPCOMURI5() {
assertTrue(WPUrlUtils.isWordPressCom(buildURI(WPCOM_ADDRESS_5)));
}

@Test
public void testIsWPCOMURI6() {
assertTrue(WPUrlUtils.isWordPressCom(buildURI(WPCOM_ADDRESS_6)));
}

@Test
public void testIsNOTWPCOM1() {
assertFalse(WPUrlUtils.isWordPressCom(NOT_WPCOM_ADDRESS_1));
Expand All @@ -307,16 +226,6 @@ public void testIsNOTWPCOM4() {
assertFalse(WPUrlUtils.isWordPressCom(buildURL(NOT_WPCOM_ADDRESS_2)));
}

@Test
public void testIsNOTWPCOM5() {
assertFalse(WPUrlUtils.isWordPressCom(buildURI(NOT_WPCOM_ADDRESS_1)));
}

@Test
public void testIsNOTWPCOM6() {
assertFalse(WPUrlUtils.isWordPressCom(buildURI(NOT_WPCOM_ADDRESS_2)));
}

@Test
public void testIsNOTWPCOM7() {
assertFalse(WPUrlUtils.isWordPressCom(NOT_WPCOM_ADDRESS_3));
Expand All @@ -326,9 +235,4 @@ public void testIsNOTWPCOM7() {
public void testIsNOTWPCOM8() {
assertFalse(WPUrlUtils.isWordPressCom(buildURL(NOT_WPCOM_ADDRESS_3)));
}

@Test
public void testIsNOTWPCOM9() {
assertFalse(WPUrlUtils.isWordPressCom(buildURI(NOT_WPCOM_ADDRESS_3)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ private static void savePeople(String table, List<Person> peopleList, int localT
}
}

public static void deletePeopleForLocalBlogId(int localTableBlogId) {
deletePeople(TEAM_TABLE, localTableBlogId);
deletePeople(FOLLOWERS_TABLE, localTableBlogId);
deletePeople(EMAIL_FOLLOWERS_TABLE, localTableBlogId);
deletePeople(VIEWERS_TABLE, localTableBlogId);
}

private static void deletePeople(String table, int localTableBlogId) {
String[] args = new String[]{Integer.toString(localTableBlogId)};
getWritableDb().delete(table, "local_blog_id=?1", args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,6 @@ public static String getConnectUrlForService(String serviceId) {
return SqlUtils.stringForQuery(getReadableDb(), sql, args);
}

public static long getNumServices() {
return SqlUtils.getRowCount(getReadableDb(), SERVICES_TABLE);
}

// ********************************************************************************************

public static PublicizeConnection getConnection(int connectionId) {
String[] args = {Integer.toString(connectionId)};
Cursor c = getReadableDb().rawQuery("SELECT * FROM " + CONNECTIONS_TABLE + " WHERE id=?", args);
try {
if (c.moveToFirst()) {
return getConnectionFromCursor(c);
} else {
return null;
}
} finally {
SqlUtils.closeCursor(c);
}
}

public static String getRefreshUrlForConnection(int connectionId) {
String sql = "SELECT refresh_url FROM " + CONNECTIONS_TABLE + " WHERE id=?";
String[] args = {Integer.toString(connectionId)};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.wordpress.android.models.ReaderBlog;
import org.wordpress.android.models.ReaderBlogList;
import org.wordpress.android.models.ReaderUrlList;
import org.wordpress.android.ui.reader.ReaderConstants;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.DateTimeUtils;
Expand Down Expand Up @@ -198,26 +197,6 @@ public static void setFollowedBlogs(ReaderBlogList followedBlogs) {
db.endTransaction();
}
}

/*
* return list of URLs of followed blogs
*/
public static ReaderUrlList getFollowedBlogUrls() {
Cursor c = ReaderDatabase.getReadableDb()
.rawQuery("SELECT DISTINCT blog_url FROM tbl_blog_info WHERE is_following!=0", null);
try {
ReaderUrlList urls = new ReaderUrlList();
if (c.moveToFirst()) {
do {
urls.add(c.getString(0));
} while (c.moveToNext());
}
return urls;
} finally {
SqlUtils.closeCursor(c);
}
}

/*
* sets the follow state for passed blog without creating a record for it if it doesn't exist
*/
Expand Down Expand Up @@ -286,13 +265,6 @@ public static void setNotificationsEnabledByBlogId(long blogId, boolean isEnable
new String[]{Long.toString(blogId)});
}

public static String getBlogName(long blogId) {
String[] args = {Long.toString(blogId)};
return SqlUtils.stringForQuery(ReaderDatabase.getReadableDb(),
"SELECT name FROM tbl_blog_info WHERE blog_id=?",
args);
}

public static String getBlogUrl(long blogId) {
String[] args = {Long.toString(blogId)};
return SqlUtils.stringForQuery(ReaderDatabase.getReadableDb(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,34 +252,6 @@ public static void deleteComment(ReaderPost post, long commentId) {
ReaderDatabase.getWritableDb().delete("tbl_comments", "blog_id=? AND post_id=? AND comment_id=?", args);
}

/*
* returns true if any of the passed comments don't already exist
* IMPORTANT: assumes passed comments are all for the same post
*/
public static boolean hasNewComments(ReaderCommentList comments) {
if (comments == null || comments.size() == 0) {
return false;
}

StringBuilder sb = new StringBuilder(
"SELECT COUNT(*) FROM tbl_comments WHERE blog_id=? AND post_id=? AND comment_id IN (");
boolean isFirst = true;
for (ReaderComment comment : comments) {
if (isFirst) {
isFirst = false;
} else {
sb.append(",");
}
sb.append(comment.commentId);
}
sb.append(")");

String[] args = {Long.toString(comments.get(0).blogId),
Long.toString(comments.get(0).postId)};
int numExisting = SqlUtils.intForQuery(ReaderDatabase.getReadableDb(), sb.toString(), args);
return numExisting != comments.size();
}

/*
* returns the #likes known to exist for this comment
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ public static ReaderUserIdList getLikesForPost(ReaderPost post) {
}
}

public static int getNumLikesForPost(ReaderPost post) {
if (post == null) {
return 0;
}
String[] args = {Long.toString(post.blogId), Long.toString(post.postId)};
return SqlUtils.intForQuery(ReaderDatabase.getReadableDb(),
"SELECT count(*) FROM tbl_post_likes WHERE blog_id=? AND post_id=?", args);
}

public static void setCurrentUserLikesPost(ReaderPost post, boolean isLiked, long wpComUserId) {
if (post == null) {
return;
Expand Down Expand Up @@ -129,44 +120,6 @@ public static void setLikesForPost(ReaderPost post, ReaderUserIdList userIds) {
}
}


/****
* comment likes
*/

public static ReaderUserIdList getLikesForComment(ReaderComment comment) {
ReaderUserIdList userIds = new ReaderUserIdList();
if (comment == null) {
return userIds;
}

String[] args = {Long.toString(comment.blogId),
Long.toString(comment.commentId)};
Cursor c = ReaderDatabase.getReadableDb().rawQuery(
"SELECT user_id FROM tbl_comment_likes WHERE blog_id=? AND comment_id=?", args);
try {
if (c.moveToFirst()) {
do {
userIds.add(c.getLong(0));
} while (c.moveToNext());
}

return userIds;
} finally {
SqlUtils.closeCursor(c);
}
}

public static int getNumLikesForComment(ReaderComment comment) {
if (comment == null) {
return 0;
}
String[] args = {Long.toString(comment.blogId),
Long.toString(comment.commentId)};
return SqlUtils.intForQuery(ReaderDatabase.getReadableDb(),
"SELECT count(*) FROM tbl_comment_likes WHERE blog_id=? AND comment_id=?", args);
}

public static void setCurrentUserLikesComment(ReaderComment comment, boolean isLiked, long wpComUserId) {
if (comment == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,6 @@ public static String getPostTitle(long blogId, long postId) {
args);
}

public static String getPostBlogName(long blogId, long postId) {
String[] args = {Long.toString(blogId), Long.toString(postId)};
return SqlUtils.stringForQuery(ReaderDatabase.getReadableDb(),
"SELECT blog_name FROM tbl_posts WHERE blog_id=? AND post_id=?",
args);
}

public static String getPostText(long blogId, long postId) {
String[] args = {Long.toString(blogId), Long.toString(postId)};
return SqlUtils.stringForQuery(ReaderDatabase.getReadableDb(),
Expand Down Expand Up @@ -603,23 +596,6 @@ public static int deletePostsWithTag(final ReaderTag tag) {
return rowsDeleted;
}

public static int removeTagsFromPost(long blogId, long postId, final ReaderTagType tagType) {
if (tagType == null) {
return 0;
}

String[] args = {Integer.toString(tagType.toInt()), Long.toString(blogId), Long.toString(postId)};
int rowsDeleted = ReaderDatabase.getWritableDb().delete(
"tbl_posts",
"tag_type=? AND blog_id=? AND post_id=?",
args);

if (rowsDeleted > 0) {
EventBus.getDefault().post(ReaderPostTableActionEnded.INSTANCE);
}
return rowsDeleted;
}

public static int deletePostsInBlog(long blogId) {
String[] args = {Long.toString(blogId)};
int rowsDeleted = ReaderDatabase.getWritableDb().delete("tbl_posts", "blog_id = ?", args);
Expand All @@ -638,12 +614,6 @@ public static int deletePostsForAuthor(long authorId) {
return rowsDeleted;
}

public static void deletePost(long blogId, long postId) {
String[] args = new String[]{Long.toString(blogId), Long.toString(postId)};
ReaderDatabase.getWritableDb().delete("tbl_posts", "blog_id=? AND post_id=?", args);
EventBus.getDefault().post(ReaderPostTableActionEnded.INSTANCE);
}

/*
* ensure that posts in blogs that are no longer followed don't have their followed status
* set to true
Expand Down
Loading

0 comments on commit 56c03b3

Please sign in to comment.