aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java5
-rw-r--r--app/src/main/res/layout/activity_view_post_detail.xml26
-rw-r--r--app/src/main/res/layout/item_post.xml19
8 files changed, 34 insertions, 44 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 82064ea1..6fe85a03 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -39,8 +39,8 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test:runner:1.2.0-alpha03'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha03'
+ androidTestImplementation 'androidx.test:runner:1.2.0-alpha04'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha04'
implementation 'com.google.android.exoplayer:exoplayer:2.9.6'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.9.6'
implementation 'androidx.browser:browser:1.0.0'
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java
index 970c9ed6..c2808e97 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java
@@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit;
import android.os.AsyncTask;
+import android.text.Html;
import android.util.Log;
import org.json.JSONArray;
@@ -116,7 +117,7 @@ class ParseComment {
boolean isSubmitter = data.getBoolean(JSONUtils.IS_SUBMITTER_KEY);
String commentContent = "";
if(!data.isNull(JSONUtils.BODY_HTML_KEY)) {
- commentContent = data.getString(JSONUtils.BODY_HTML_KEY);
+ commentContent = Html.fromHtml(data.getString(JSONUtils.BODY_HTML_KEY).trim()).toString();
}
String permalink = data.getString(JSONUtils.PERMALINK_KEY);
int score = data.getInt(JSONUtils.SCORE_KEY);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java
index f3d92f70..6cb68323 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java
@@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit;
import android.os.AsyncTask;
+import android.text.Html;
import android.util.Log;
import org.json.JSONArray;
@@ -148,7 +149,7 @@ class ParsePost {
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
post.setSelfText("");
} else {
- post.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
+ post.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString());
}
bestPostData.add(post);
} else {
@@ -161,7 +162,7 @@ class ParsePost {
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
linkPost.setSelfText("");
} else {
- linkPost.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
+ linkPost.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString());
}
bestPostData.add(linkPost);
}
@@ -252,7 +253,7 @@ class ParsePost {
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
textWithImagePost.setSelfText("");
} else {
- textWithImagePost.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
+ textWithImagePost.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString());
}
bestPostData.add(textWithImagePost);
} else {
@@ -265,7 +266,7 @@ class ParsePost {
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
linkPost.setSelfText("");
} else {
- linkPost.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
+ linkPost.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString());
}
linkPost.setPreviewWidth(previewWidth);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
index 5b2fecb7..0bc59909 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
@@ -298,7 +298,6 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
switch (post.getPostType()) {
case Post.IMAGE_TYPE:
- ((DataViewHolder) holder).typeChip.setVisibility(View.VISIBLE);
((DataViewHolder) holder).typeChip.setText("IMAGE");
final String imageUrl = post.getUrl();
@@ -312,7 +311,6 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
});
break;
case Post.LINK_TYPE:
- ((DataViewHolder) holder).typeChip.setVisibility(View.VISIBLE);
((DataViewHolder) holder).typeChip.setText("LINK");
((DataViewHolder) holder).imageView.setOnClickListener(view -> {
@@ -325,7 +323,6 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
});
break;
case Post.GIF_VIDEO_TYPE:
- ((DataViewHolder) holder).typeChip.setVisibility(View.VISIBLE);
((DataViewHolder) holder).typeChip.setText("GIF");
final Uri gifVideoUri = Uri.parse(post.getVideoUrl());
@@ -344,7 +341,6 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
});
break;
case Post.VIDEO_TYPE:
- ((DataViewHolder) holder).typeChip.setVisibility(View.VISIBLE);
((DataViewHolder) holder).typeChip.setText("VIDEO");
final Uri videoUri = Uri.parse(post.getVideoUrl());
@@ -363,7 +359,6 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
});
break;
case Post.NO_PREVIEW_LINK_TYPE:
- ((DataViewHolder) holder).typeChip.setVisibility(View.VISIBLE);
((DataViewHolder) holder).typeChip.setText("LINK");
final String noPreviewLinkUrl = post.getUrl();
((DataViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
@@ -377,7 +372,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
});
break;
case Post.TEXT_TYPE:
- ((DataViewHolder) holder).typeChip.setVisibility(View.GONE);
+ ((DataViewHolder) holder).typeChip.setText("TEXT");
break;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java
index 4003c2d4..18fd09cb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java
@@ -2,9 +2,10 @@ package ml.docilealligator.infinityforreddit;
import android.content.SharedPreferences;
import android.os.AsyncTask;
-import androidx.annotation.NonNull;
import android.util.Log;
+import androidx.annotation.NonNull;
+
import java.util.HashMap;
import java.util.Map;
@@ -109,7 +110,7 @@ class UserFollowing {
if(isSubscribing) {
subscribedUserDao.insert(subscribedUserData);
} else {
- subscribedUserDao.deleteSubscribedUser(userName);;
+ subscribedUserDao.deleteSubscribedUser(userName);
}
return null;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
index fb449ac6..55e064df 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
@@ -245,6 +245,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
switch (mPost.getPostType()) {
case Post.IMAGE_TYPE:
mTypeChip.setText("IMAGE");
+
mImageView.setOnClickListener(view -> {
Intent intent = new Intent(ViewPostDetailActivity.this, ViewImageActivity.class);
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, mPost.getUrl());
@@ -304,6 +305,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
break;
case Post.NO_PREVIEW_LINK_TYPE:
mTypeChip.setText("LINK");
+
if(!mPost.getSelfText().equals("")) {
mContentMarkdownView.setVisibility(View.VISIBLE);
mContentMarkdownView.setMarkdown(getCustomSpannableConfiguration(), mPost.getSelfText());
@@ -319,7 +321,8 @@ public class ViewPostDetailActivity extends AppCompatActivity {
});
break;
case Post.TEXT_TYPE:
- mTypeChip.setVisibility(View.GONE);
+ mTypeChip.setText("TEXT");
+
if(!mPost.getSelfText().equals("")) {
mContentMarkdownView.setVisibility(View.VISIBLE);
mContentMarkdownView.setMarkdown(getCustomSpannableConfiguration(), mPost.getSelfText());
diff --git a/app/src/main/res/layout/activity_view_post_detail.xml b/app/src/main/res/layout/activity_view_post_detail.xml
index 1a0be45d..26239fef 100644
--- a/app/src/main/res/layout/activity_view_post_detail.xml
+++ b/app/src/main/res/layout/activity_view_post_detail.xml
@@ -73,10 +73,8 @@
android:id="@+id/title_text_view_view_post_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginEnd="16dp"
- android:layout_marginLeft="16dp"
- android:layout_marginRight="16dp"
- android:layout_marginStart="16dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
android:textColor="#000000"
android:textSize="18sp" />
@@ -84,24 +82,23 @@
android:id="@+id/content_markdown_view_view_post_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginEnd="16dp"
- android:layout_marginStart="16dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
android:layout_marginTop="16dp"
android:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="16dp"
- android:layout_marginEnd="16dp">
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:paddingTop="16dp">
<com.google.android.material.chip.Chip
android:id="@+id/type_text_view_view_post_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
- android:textSize="12sp"
android:textColor="@android:color/white"
android:layout_centerVertical="true"
app:chipBackgroundColor="@color/colorPrimaryDark"/>
@@ -110,18 +107,18 @@
android:id="@+id/gilded_image_view_view_post_detail"
android:layout_width="24dp"
android:layout_height="24dp"
- android:layout_marginTop="8dp"
android:layout_toEndOf="@id/type_text_view_view_post_detail"
+ android:layout_centerVertical="true"
android:visibility="gone"/>
<TextView
android:id="@+id/gilded_number_text_view_view_post_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:layout_toEndOf="@id/gilded_image_view_view_post_detail"
+ android:layout_centerVertical="true"
android:visibility="gone"
android:textSize="20sp"
android:textColor="@color/gold"/>
@@ -130,11 +127,10 @@
android:id="@+id/crosspost_image_view_view_post_detail"
android:layout_width="24dp"
android:layout_height="24dp"
- android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
- android:layout_toStartOf="@id/nsfw_text_view_item_best_post"
android:layout_toEndOf="@id/gilded_number_text_view_view_post_detail"
+ android:layout_centerVertical="true"
android:src="@drawable/crosspost"
android:tint="@color/colorAccent"
android:visibility="gone"/>
@@ -145,10 +141,10 @@
android:layout_height="wrap_content"
android:text="@string/nsfw"
android:layout_alignParentEnd="true"
- android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:textColor="@android:color/white"
android:visibility="gone"
+ android:layout_centerVertical="true"
app:chipBackgroundColor="@color/colorAccent"/>
</RelativeLayout>
diff --git a/app/src/main/res/layout/item_post.xml b/app/src/main/res/layout/item_post.xml
index 9d94cb2a..45024d78 100644
--- a/app/src/main/res/layout/item_post.xml
+++ b/app/src/main/res/layout/item_post.xml
@@ -71,34 +71,32 @@
android:id="@+id/title_text_view_best_post_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="16dp"
- android:layout_marginEnd="16dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
android:textSize="18sp"
android:textColor="#000000"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="16dp"
- android:layout_marginEnd="16dp">
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:paddingTop="16dp">
<com.google.android.material.chip.Chip
android:id="@+id/type_text_view_item_best_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
- android:textSize="12sp"
android:textColor="@android:color/white"
android:layout_centerVertical="true"
- app:chipBackgroundColor="@color/colorPrimaryDark"/>
+ app:chipBackgroundColor="@color/colorPrimaryDark" />
<ImageView
android:id="@+id/gilded_image_view_item_best_post"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_toEndOf="@id/type_text_view_item_best_post"
- android:layout_marginTop="8dp"
android:layout_centerVertical="true"
android:visibility="gone"/>
@@ -106,7 +104,6 @@
android:id="@+id/gilded_number_text_view_item_best_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:layout_toEndOf="@id/gilded_image_view_item_best_post"
@@ -119,10 +116,8 @@
android:id="@+id/crosspost_image_view_item_best_post"
android:layout_width="24dp"
android:layout_height="24dp"
- android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
- android:layout_toStartOf="@id/nsfw_text_view_item_best_post"
android:layout_toEndOf="@id/gilded_number_text_view_item_best_post"
android:src="@drawable/crosspost"
android:tint="@color/colorAccent"
@@ -135,9 +130,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
- android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
- android:textSize="12sp"
android:textColor="@android:color/white"
android:visibility="gone"
android:layout_centerVertical="true"