diff --git a/app/build.gradle b/app/build.gradle index 063c6901..5f9801aa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,7 +36,6 @@ android { } dependencies { - implementation "androidx.lifecycle:lifecycle-viewmodel:2.6.2" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2" @@ -53,16 +52,16 @@ dependencies { implementation "androidx.window:window:1.1.0" implementation "androidx.window:window-java:1.1.0" implementation 'androidx.startup:startup-runtime:1.1.1' + implementation 'androidx.core:core:1.12.0' //implementation 'org.jsoup:jsoup:1.11.1' implementation 'com.google.android.material:material:1.11.0-alpha02' implementation 'com.android.volley:volley:1.2.1' - //implementation 'org.sufficientlysecure:html-textview:4.0' implementation "com.squareup.okhttp3:okhttp:4.11.0" implementation 'com.squareup.okhttp:okhttp-urlconnection:2.7.5' implementation 'com.facebook.shimmer:shimmer:0.5.0' implementation 'com.squareup.picasso:picasso:2.8' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22' -} +} \ No newline at end of file diff --git a/app/src/main/java/com/simon/harmonichackernews/CommentsFragment.java b/app/src/main/java/com/simon/harmonichackernews/CommentsFragment.java index e9b33b3a..086c19f7 100644 --- a/app/src/main/java/com/simon/harmonichackernews/CommentsFragment.java +++ b/app/src/main/java/com/simon/harmonichackernews/CommentsFragment.java @@ -22,7 +22,6 @@ import android.text.TextUtils; import android.util.Base64; import android.util.Log; -import android.view.LayoutInflater; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; @@ -97,8 +96,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import org.sufficientlysecure.htmltextview.HtmlTextView; -import org.sufficientlysecure.htmltextview.OnClickATagListener; import java.io.ByteArrayInputStream; import java.io.File; @@ -440,9 +437,7 @@ private void initializeRecyclerView() { SettingsUtils.shouldShowWebviewExpandButton(getContext()), ThemeUtils.isDarkMode(getContext())); - adapter.setOnHeaderClickListener(story1 -> { - Utils.launchCustomTab(getActivity(), story1.url); - }); + adapter.setOnHeaderClickListener(story1 -> Utils.launchCustomTab(getActivity(), story1.url)); adapter.setOnCommentClickListener((comment, index, commentView) -> { comment.expanded = !comment.expanded; @@ -1118,21 +1113,16 @@ public void clickShare(View view) { popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - int id = item.getItemId(); - - switch (item.getItemId()) { - case R.id.menu_link: - startActivity(ShareUtils.getShareIntent(adapter.story.url)); - break; - case R.id.menu_link_title: - startActivity(ShareUtils.getShareIntentWithTitle(adapter.story.title, adapter.story.url)); - break; - case R.id.menu_hacker_news_link: - startActivity(ShareUtils.getShareIntent(adapter.story.id)); - break; - case R.id.menu_hacker_news_link_title: - startActivity(ShareUtils.getShareIntentWithTitle(adapter.story.title, adapter.story.id)); - break; + int itemId = item.getItemId(); + + if (itemId == R.id.menu_link) { + startActivity(ShareUtils.getShareIntent(adapter.story.url)); + } else if (itemId == R.id.menu_link_title) { + startActivity(ShareUtils.getShareIntentWithTitle(adapter.story.title, adapter.story.url)); + } else if (itemId == R.id.menu_hacker_news_link) { + startActivity(ShareUtils.getShareIntent(adapter.story.id)); + } else if (itemId == R.id.menu_hacker_news_link_title) { + startActivity(ShareUtils.getShareIntentWithTitle(adapter.story.title, adapter.story.id)); } return true; @@ -1317,7 +1307,7 @@ public void onItemClick(Comment comment, int pos, View view) { new Pair<>("Select text", R.drawable.ic_action_select), new Pair<>("Vote up", R.drawable.ic_action_thumbs_up), new Pair<>("Unvote", R.drawable.ic_action_thumbs), - new Pair<>("Vote down (experimental)", R.drawable.ic_action_thumb_down), + new Pair<>("Vote down", R.drawable.ic_action_thumb_down), }; } else { items = new Pair[]{ @@ -1470,11 +1460,11 @@ public interface BottomSheetFragmentCallback { } public static class PdfAndroidJavascriptBridge { - private File mFile; + private final File mFile; private @Nullable RandomAccessFile mRandomAccessFile; - private @Nullable Callbacks mCallback; - private Handler mHandler; + private final @Nullable Callbacks mCallback; + private final Handler mHandler; PdfAndroidJavascriptBridge(String filePath, @Nullable Callbacks callback) { mFile = new File(filePath); diff --git a/app/src/main/java/com/simon/harmonichackernews/UserDialogFragment.java b/app/src/main/java/com/simon/harmonichackernews/UserDialogFragment.java index c7ff78bd..90dfe679 100644 --- a/app/src/main/java/com/simon/harmonichackernews/UserDialogFragment.java +++ b/app/src/main/java/com/simon/harmonichackernews/UserDialogFragment.java @@ -88,7 +88,7 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { //lets create a request and fill in the data when we have it String url = "https://hacker-news.firebaseio.com/v0/user/" + userName + ".json"; - @SuppressLint("SetTextI18n") StringRequest stringRequest = new StringRequest(Request.Method.GET, url, + StringRequest stringRequest = new StringRequest(Request.Method.GET, url, response -> { try { //lets try to parse the response @@ -99,7 +99,7 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { cal.setTime(new Date(jsonObject.getInt("created") * 1000L)); // Users who have never submitted before do not receive this key as part of their response. - JSONArray submitted = null; + JSONArray submitted; if (jsonObject.has("submitted")) { submitted = jsonObject.getJSONArray("submitted"); } else {