From f378e7c46560e982d8f3a5daa04a52170236f5a5 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Tue, 23 Aug 2022 12:51:59 +0300 Subject: [PATCH 01/14] feat: improved handling of board parsing errors --- .../thmmy/mthmmy/activities/board/BoardActivity.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java index 3bed0b07..6a427b53 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java @@ -59,6 +59,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo private String boardUrl; private String boardTitle; + private String boardId; private String parsedTitle; private String newTopicUrl; @@ -88,6 +89,8 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo if (!tmpUrlSbstr.substring(tmpUrlSbstr.indexOf("board=")).contains(".")) boardUrl = tmpUrlSbstr + ".0"; + boardId = ThmmyPage.getBoardId(boardUrl); + //Initializes graphics toolbar = findViewById(R.id.toolbar); if (boardTitle != null && !Objects.equals(boardTitle, "")) toolbar.setTitle(boardTitle); @@ -98,7 +101,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo getSupportActionBar().setDisplayShowHomeEnabled(true); } - thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl), true); + thisPageBookmark = new Bookmark(boardTitle, boardId, true); if (boardTitle != null && !Objects.equals(boardTitle, "")) setBoardBookmark(findViewById(R.id.bookmark)); @@ -303,7 +306,8 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo if (!parsingFailed) tempSubBoards.add(new Board(pUrl, pTitle, pMods, pStats, pLastPost, pLastPostUrl)); else - Timber.e("Parsing failed (pLastPost came with: \"%s\", subBoardColumns html was \"%s\")", pLastPost, subBoardColumns); + Timber.e("Parsing failed for a subBoard in board %s (subBoardRow html was \"%s\")", + boardId, subBoardRow); } } } @@ -338,7 +342,8 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo pLastUser = matcher.group(2); } else { - Timber.e("Parsing failed (pLastPost came with: \"%s\", topicColumns html was \"%s\")", pLastPost, topicColumns); + Timber.e("Parsing failed for a topic in board %s (topicRow html was \"%s\")", + boardId, topicRow); continue; } From ea400f4e6544c013d42470c1ba87a4c79e166bce Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 14 Sep 2022 19:22:23 +0300 Subject: [PATCH 02/14] fix: improved handling, messages of some errors --- .../activities/downloads/DownloadsActivity.java | 2 +- .../activities/main/recent/RecentAdapter.java | 2 +- .../mthmmy/activities/topic/TopicAdapter.java | 4 ++-- .../topic/tasks/PrepareForEditTask.java | 8 ++++++-- .../topic/tasks/PrepareForReplyResult.java | 10 +++++----- .../topic/tasks/PrepareForReplyTask.java | 16 ++++++++-------- .../utils/parsing/ThmmyDateTimeParser.java | 6 +++--- .../thmmy/mthmmy/viewmodel/TopicViewModel.java | 4 ++-- .../utils/UploadsCoursesJSONReadingTest.java | 2 +- 9 files changed, 29 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java index 0e9ba74f..cb684da0 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java @@ -283,7 +283,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. parsedDownloads.add(download); } } catch (Exception e) { - throw new ParseException("Parsing failed (DownloadsActivity)"); + throw new ParseException("Parsing failed (DownloadsActivity) for url " + downloadsUrl); } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java index 9d1ab90d..c5c782c8 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java @@ -47,7 +47,7 @@ class RecentAdapter extends RecyclerView.Adapter { if (BaseApplication.getInstance().isDisplayRelativeTimeEnabled()) { String timestamp = topicSummary.getLastPostTimestamp(); try { - holder.mDateTimeView.setReferenceTime(Long.valueOf(timestamp)); + holder.mDateTimeView.setReferenceTime(Long.parseLong(timestamp)); } catch (NumberFormatException e) { Timber.e(e, "Invalid number format: %s", timestamp); holder.mDateTimeView.setText(topicSummary.getLastPostSimplifiedDateTime()); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 79528a0f..076414f8 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -709,8 +709,8 @@ class TopicAdapter extends RecyclerView.Adapter { SharedPreferences drafts = context.getSharedPreferences(context.getString(R.string.pref_topic_drafts_key), Context.MODE_PRIVATE); replyText += drafts.getString(String.valueOf(viewModel.getTopicId()), ""); - if (viewModel.getBuildedQuotes() != null && !viewModel.getBuildedQuotes().isEmpty()) - replyText += viewModel.getBuildedQuotes(); + if (viewModel.getBuiltQuotes() != null && !viewModel.getBuiltQuotes().isEmpty()) + replyText += viewModel.getBuiltQuotes(); } holder.replyEditor.setText(replyText); holder.replyEditor.getEditText().setSelection(holder.replyEditor.getText().length()); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java index 8d62aed1..3428bb8e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java @@ -61,8 +61,12 @@ public class PrepareForEditTask extends AsyncTaskoption[selected]").first().attr("value"); return new PrepareForEditResult(postText, commitEditURL, numReplies, seqnum, sc, topic, icon, position, true); - } catch (IOException | Selector.SelectorParseException e) { - Timber.e(e, "Prepare failed."); + } catch (NullPointerException | Selector.SelectorParseException e) { + // TODO: Convert this task to (New)ParseTask (?) / handle parsing errors in a better way + Timber.e(e, "Preparing for edit failed (parsing error)."); + return new PrepareForEditResult(null, null, null, null, null, null, null, position, false); + } catch (Exception e) { + Timber.i("Preparing for edit failed (other error)."); return new PrepareForEditResult(null, null, null, null, null, null, null, position, false); } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyResult.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyResult.java index 3e44f423..9b9a14d6 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyResult.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyResult.java @@ -1,17 +1,17 @@ package gr.thmmy.mthmmy.activities.topic.tasks; public class PrepareForReplyResult { - private final String numReplies, seqnum, sc, topic, buildedQuotes; + private final String numReplies, seqnum, sc, topic, builtQuotes; private boolean successful; - public PrepareForReplyResult(boolean successful, String numReplies, String seqnum, String sc, String topic, String buildedQuotes) { + public PrepareForReplyResult(boolean successful, String numReplies, String seqnum, String sc, String topic, String builtQuotes) { this.successful = successful; this.numReplies = numReplies; this.seqnum = seqnum; this.sc = sc; this.topic = topic; - this.buildedQuotes = buildedQuotes; + this.builtQuotes = builtQuotes; } public String getNumReplies() { @@ -30,8 +30,8 @@ public class PrepareForReplyResult { return topic; } - public String getBuildedQuotes() { - return buildedQuotes; + public String getBuiltQuotes() { + return builtQuotes; } public boolean isSuccessful() { diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyTask.java index bd342477..b67b2157 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyTask.java @@ -49,16 +49,16 @@ public class PrepareForReplyTask extends AsyncTask") + 7, body.indexOf(""))); - buildedQuotes.append("\n\n"); + builtQuotes.append(body.substring(body.indexOf("") + 7, body.indexOf(""))); + builtQuotes.append("\n\n"); } catch (IOException | Selector.SelectorParseException e) { Timber.e(e, "Quote building failed."); return new PrepareForReplyResult(false, null, null, null, null, null); } } - return new PrepareForReplyResult(true, numReplies, seqnum, sc, topic, buildedQuotes.toString()); + return new PrepareForReplyResult(true, numReplies, seqnum, sc, topic, builtQuotes.toString()); } @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java index 393f0b2b..cfc40ae2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java @@ -40,8 +40,7 @@ public class ThmmyDateTimeParser { private static final Pattern pattern = Pattern.compile("\\s((1[3-9]|2[0-3]):)"); - private ThmmyDateTimeParser() { - } + private ThmmyDateTimeParser() {} public static String convertToTimestamp(String thmmyDateTime) { Timber.v("Will attempt to convert %s to timestamp.", thmmyDateTime); @@ -78,7 +77,8 @@ public class ThmmyDateTimeParser { localDateTime = formatter.withLocale(greekLocale).parseLocalDateTime(thmmyDateTime); } catch (IllegalArgumentException e2) { Timber.v("Parsing DateTime %s using Greek Locale failed too.", thmmyDateTime); - Timber.e("Couldn't convert DateTime %s to timestamp!", originalDateTime); + Timber.e("Couldn't convert DateTime to timestamp (original: \"%s\", modified: \"%s\")!", + originalDateTime, thmmyDateTime); return null; } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java index d8cc3bba..fd621bb2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java @@ -484,10 +484,10 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa return prepareForEditResult.getValue().getPostText(); } - public String getBuildedQuotes() { + public String getBuiltQuotes() { if (prepareForReplyResult.getValue() == null) throw new NullPointerException("Reply preparation was not found"); - return prepareForReplyResult.getValue().getBuildedQuotes(); + return prepareForReplyResult.getValue().getBuiltQuotes(); } public int postCount() { diff --git a/app/src/test/java/gr/thmmy/mthmmy/utils/UploadsCoursesJSONReadingTest.java b/app/src/test/java/gr/thmmy/mthmmy/utils/UploadsCoursesJSONReadingTest.java index 999cfe4b..16d4ebb5 100644 --- a/app/src/test/java/gr/thmmy/mthmmy/utils/UploadsCoursesJSONReadingTest.java +++ b/app/src/test/java/gr/thmmy/mthmmy/utils/UploadsCoursesJSONReadingTest.java @@ -33,7 +33,7 @@ public class UploadsCoursesJSONReadingTest { InputStream is = this.getClass().getClassLoader().getResourceAsStream(filePath); assertNotNull(is); String uploadsCoursesJSON = ResourceUtils.readJSONResourceToString(is); - assertNotNull(uploadsCoursesJSON);; + assertNotNull(uploadsCoursesJSON); JSONObject jsonObject = new JSONObject(uploadsCoursesJSON); assertTrue(jsonObject.has("categories")); HashMap coursesHashMap = generateCoursesFromJSON(jsonObject); From 88430f312665b3466f5c630c8ac02cc175c21b10 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 3 Oct 2022 14:06:27 +0300 Subject: [PATCH 03/14] fix: add additional checks to expandable views of BoardAdapter --- .../mthmmy/activities/board/BoardAdapter.java | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java index 6468d130..a7eac058 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java @@ -3,7 +3,6 @@ package gr.thmmy.mthmmy.activities.board; import android.content.Context; import android.content.Intent; import android.graphics.Typeface; -import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -104,7 +103,7 @@ class BoardAdapter extends RecyclerView.Adapter { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }); - if (boardExpandableVisibility.get(subBoardViewHolder.getAdapterPosition())) { + if (boardExpandableVisibility.get(subBoardViewHolder.getBindingAdapterPosition())) { subBoardViewHolder.boardExpandable.setVisibility(View.VISIBLE); subBoardViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_up_accent_24dp); } @@ -113,16 +112,19 @@ class BoardAdapter extends RecyclerView.Adapter { subBoardViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_down_accent_24dp); } subBoardViewHolder.showHideExpandable.setOnClickListener(view -> { - final boolean visible = boardExpandableVisibility.get(subBoardViewHolder.getAdapterPosition()); - if (visible) { - subBoardViewHolder.boardExpandable.setVisibility(View.GONE); - subBoardViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_down_accent_24dp); + final int pos = subBoardViewHolder.getBindingAdapterPosition(); + if (pos >=0 && pos < boardExpandableVisibility.size()){ + final boolean visible = boardExpandableVisibility.get(subBoardViewHolder.getBindingAdapterPosition()); + if (visible) { + subBoardViewHolder.boardExpandable.setVisibility(View.GONE); + subBoardViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_down_accent_24dp); + } + else { + subBoardViewHolder.boardExpandable.setVisibility(View.VISIBLE); + subBoardViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_up_accent_24dp); + } + boardExpandableVisibility.set(subBoardViewHolder.getBindingAdapterPosition(), !visible); } - else { - subBoardViewHolder.boardExpandable.setVisibility(View.VISIBLE); - subBoardViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_up_accent_24dp); - } - boardExpandableVisibility.set(subBoardViewHolder.getAdapterPosition(), !visible); }); subBoardViewHolder.boardTitle.setText(subBoard.getTitle()); String mods = subBoard.getMods(); @@ -174,7 +176,7 @@ class BoardAdapter extends RecyclerView.Adapter { intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); context.startActivity(intent); }); - if (topicExpandableVisibility.get(topicViewHolder.getAdapterPosition() - parsedSubBoards + if (topicExpandableVisibility.get(topicViewHolder.getBindingAdapterPosition() - parsedSubBoards .size())) { topicViewHolder.topicExpandable.setVisibility(View.VISIBLE); topicViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_up_accent_24dp); @@ -184,27 +186,29 @@ class BoardAdapter extends RecyclerView.Adapter { topicViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_down_accent_24dp); } topicViewHolder.showHideExpandable.setOnClickListener(view -> { - final boolean visible = topicExpandableVisibility.get(topicViewHolder. - getAdapterPosition() - parsedSubBoards.size()); - if (visible) { - topicViewHolder.topicExpandable.setVisibility(View.GONE); - topicViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_down_accent_24dp); - } - else { - topicViewHolder.topicExpandable.setVisibility(View.VISIBLE); - topicViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_up_accent_24dp); + final int pos = topicViewHolder.getBindingAdapterPosition() - parsedSubBoards.size(); + if (pos >=0 && pos < topicExpandableVisibility.size()) { + final boolean visible = topicExpandableVisibility.get(topicViewHolder. + getBindingAdapterPosition() - parsedSubBoards.size()); + if (visible) { + topicViewHolder.topicExpandable.setVisibility(View.GONE); + topicViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_down_accent_24dp); + } + else { + topicViewHolder.topicExpandable.setVisibility(View.VISIBLE); + topicViewHolder.showHideExpandable.setImageResource(R.drawable.ic_arrow_drop_up_accent_24dp); + } + topicExpandableVisibility.set(topicViewHolder.getBindingAdapterPosition() - + parsedSubBoards.size(), !visible); } - topicExpandableVisibility.set(topicViewHolder.getAdapterPosition() - - parsedSubBoards.size(), !visible); }); topicViewHolder.topicSubject.setTypeface(Typeface.createFromAsset(context.getAssets() , "fonts/fontawesome-webfont.ttf")); topicViewHolder.topicUnreadDot.setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/fontawesome-webfont.ttf")); if (topic.isUnread()) topicViewHolder.topicUnreadDot.setVisibility(View.VISIBLE); - else { + else topicViewHolder.topicUnreadDot.setVisibility(View.GONE); - } String lockedSticky = topic.getSubject(); if (topic.isLocked()) lockedSticky += " " + context.getResources().getString(R.string.fa_lock); From 610b0fc594b6ee98df372166c1e6428df0c5b153 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 5 Oct 2022 12:30:08 +0300 Subject: [PATCH 04/14] refactor: minor refactoring --- .../activities/topic/TopicActivity.java | 71 ++++++++++--------- .../main/res/layout/activity_bookmarks.xml | 2 +- app/src/main/res/layout/activity_topic.xml | 1 + app/src/main/res/menu/downloads_menu.xml | 2 +- app/src/main/res/menu/shoutbox_menu.xml | 2 +- app/src/main/res/menu/topic_menu.xml | 6 +- .../res/mipmap-anydpi-v26/ic_launcher.xml | 2 +- .../mipmap-anydpi-v26/ic_launcher_round.xml | 2 +- .../res/values/ic_launcher_background.xml | 4 -- app/src/main/res/values/strings.xml | 1 + 10 files changed, 46 insertions(+), 47 deletions(-) delete mode 100644 app/src/main/res/values/ic_launcher_background.xml diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 959a0939..7c2c5d96 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -228,42 +228,43 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items - switch (item.getItemId()) { - case R.id.menu_bookmark: - topicMenuBookmarkClick(); - return true; - case R.id.menu_info: - AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyleAccent); - LayoutInflater inflater = this.getLayoutInflater(); - LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info - , null); - TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods); - treeAndMods.setText(new SpannableStringBuilder("Loading...")); - treeAndMods.setMovementMethod(LinkMovementMethod.getInstance()); - TextView usersViewing = infoDialog.findViewById(R.id.users_viewing); - usersViewing.setText(new SpannableStringBuilder("Loading...")); - usersViewing.setMovementMethod(LinkMovementMethod.getInstance()); - viewModel.getTopicTreeAndMods().observe(this, topicTreeAndMods -> { - if (topicTreeAndMods == null) return; - treeAndMods.setText(HTMLUtils.getSpannableFromHtml(this, topicTreeAndMods)); - }); - viewModel.getTopicViewers().observe(this, topicViewers -> { - if (topicViewers == null) return; - usersViewing.setText(HTMLUtils.getSpannableFromHtml(this, topicViewers)); - }); - builder.setView(infoDialog); - topicInfoDialog = builder.create(); - topicInfoDialog.show(); - return true; - case R.id.menu_share: - Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); - sendIntent.setType("text/plain"); - sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, viewModel.getTopicUrl()); - startActivity(Intent.createChooser(sendIntent, "Share via")); - return true; //invalidateOptionsMenu(); - default: - return super.onOptionsItemSelected(item); + int itemId = item.getItemId(); + if (itemId == R.id.menu_bookmark) { + topicMenuBookmarkClick(); + return true; + } + else if (itemId == R.id.menu_info) { + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyleAccent); + LayoutInflater inflater = this.getLayoutInflater(); + LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info + , null); + TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods); + treeAndMods.setText(new SpannableStringBuilder("Loading...")); + treeAndMods.setMovementMethod(LinkMovementMethod.getInstance()); + TextView usersViewing = infoDialog.findViewById(R.id.users_viewing); + usersViewing.setText(new SpannableStringBuilder("Loading...")); + usersViewing.setMovementMethod(LinkMovementMethod.getInstance()); + viewModel.getTopicTreeAndMods().observe(this, topicTreeAndMods -> { + if (topicTreeAndMods == null) return; + treeAndMods.setText(HTMLUtils.getSpannableFromHtml(this, topicTreeAndMods)); + }); + viewModel.getTopicViewers().observe(this, topicViewers -> { + if (topicViewers == null) return; + usersViewing.setText(HTMLUtils.getSpannableFromHtml(this, topicViewers)); + }); + builder.setView(infoDialog); + topicInfoDialog = builder.create(); + topicInfoDialog.show(); + return true; + } + else if (itemId == R.id.menu_share) { + Intent sendIntent = new Intent(Intent.ACTION_SEND); + sendIntent.setType("text/plain"); + sendIntent.putExtra(Intent.EXTRA_TEXT, viewModel.getTopicUrl()); + startActivity(Intent.createChooser(sendIntent, "Share via")); + return true; //invalidateOptionsMenu(); } + return super.onOptionsItemSelected(item); } @Override diff --git a/app/src/main/res/layout/activity_bookmarks.xml b/app/src/main/res/layout/activity_bookmarks.xml index a57f969d..44c29305 100644 --- a/app/src/main/res/layout/activity_bookmarks.xml +++ b/app/src/main/res/layout/activity_bookmarks.xml @@ -21,7 +21,7 @@ android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:gravity="center" - app:popupTheme="@style/ToolbarTheme"> + app:popupTheme="@style/ToolbarTheme" /> diff --git a/app/src/main/res/menu/downloads_menu.xml b/app/src/main/res/menu/downloads_menu.xml index 04eb3822..be7150a4 100644 --- a/app/src/main/res/menu/downloads_menu.xml +++ b/app/src/main/res/menu/downloads_menu.xml @@ -5,5 +5,5 @@ android:id="@+id/menu_upload" android:icon="@drawable/ic_file_upload_white_24dp" app:showAsAction="ifRoom" - android:title="@string/upload_button"> + android:title="@string/upload_button" /> \ No newline at end of file diff --git a/app/src/main/res/menu/shoutbox_menu.xml b/app/src/main/res/menu/shoutbox_menu.xml index dc5c6ab0..c3e6dd5b 100644 --- a/app/src/main/res/menu/shoutbox_menu.xml +++ b/app/src/main/res/menu/shoutbox_menu.xml @@ -5,5 +5,5 @@ android:id="@+id/menu_refresh" android:icon="@drawable/ic_refresh_white_24dp" app:showAsAction="ifRoom" - android:title="@string/refresh"> + android:title="@string/refresh" /> \ No newline at end of file diff --git a/app/src/main/res/menu/topic_menu.xml b/app/src/main/res/menu/topic_menu.xml index 42a144ef..17352ba9 100644 --- a/app/src/main/res/menu/topic_menu.xml +++ b/app/src/main/res/menu/topic_menu.xml @@ -5,15 +5,15 @@ android:id="@+id/menu_bookmark" android:icon="@drawable/ic_bookmark_false_accent_24dp" app:showAsAction="ifRoom" - android:title="@string/bookmark"> + android:title="@string/bookmark" /> + android:title="@string/share" /> + android:title="@string/info" /> \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index ac94b34f..f78ee51a 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index ac94b34f..f78ee51a 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml deleted file mode 100644 index f2269c54..00000000 --- a/app/src/main/res/values/ic_launcher_background.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #333333 - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1e83bc57..9fc3304b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -76,6 +76,7 @@ hide results preference-topic-drafts-key + Reply Username From a2e3ce1ad73722990525e017836a2332b59071cd Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 10 Oct 2022 14:03:54 +0300 Subject: [PATCH 05/14] fix: improved error handling (UnreadAdapter) --- .../thmmy/mthmmy/activities/main/unread/UnreadAdapter.java | 6 +++--- app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java index 6afd09c4..d3095800 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java @@ -37,16 +37,16 @@ class UnreadAdapter extends RecyclerView.Adapter { @Override public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) { - TopicSummary topicSummary = unreadList.get(holder.getAdapterPosition()); + TopicSummary topicSummary = unreadList.get(holder.getBindingAdapterPosition()); final UnreadAdapter.ViewHolder viewHolder = (UnreadAdapter.ViewHolder) holder; viewHolder.mTitleView.setText(topicSummary.getSubject()); if (BaseApplication.getInstance().isDisplayRelativeTimeEnabled()) { String timestamp = topicSummary.getLastPostTimestamp(); try { - viewHolder.mDateTimeView.setReferenceTime(Long.valueOf(timestamp)); + viewHolder.mDateTimeView.setReferenceTime(Long.parseLong(timestamp)); } catch (NumberFormatException e) { - Timber.e(e, "Invalid number format: %s", timestamp); + Timber.e(e, "Invalid number format \"%s\" for %s", timestamp, topicSummary.getTopicUrl()); viewHolder.mDateTimeView.setText(topicSummary.getLastPostSimplifiedDateTime()); } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java index 282e2247..0b47cb42 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java +++ b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java @@ -184,10 +184,8 @@ public class ThmmyPage { public static String getTopicId(String topicUrl) { if (resolvePageCategory(Uri.parse(topicUrl)) == PageCategory.TOPIC) { Matcher topicIdMatcher = Pattern.compile("topic=[0-9]+").matcher(topicUrl); - if (topicIdMatcher.find()) { + if (topicIdMatcher.find()) return topicUrl.substring(topicIdMatcher.start() + 6, topicIdMatcher.end()); - } - else return null; } return null; } From d6b5c8bec76222b1bdd1b3aebff17060c08ed9c2 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 10 Oct 2022 14:10:50 +0300 Subject: [PATCH 06/14] refactor: update deprecated code --- .../thmmy/mthmmy/activities/main/forum/ForumFragment.java | 8 +++++--- .../mthmmy/activities/main/recent/RecentFragment.java | 6 ++++-- .../mthmmy/activities/main/unread/UnreadFragment.java | 6 +++--- .../profile/latestPosts/LatestPostsFragment.java | 5 +++-- .../mthmmy/activities/profile/stats/StatsFragment.java | 8 +++++--- .../activities/profile/summary/SummaryFragment.java | 6 ++++-- .../mthmmy/activities/shoutbox/ShoutboxFragment.java | 8 ++++---- .../gr/thmmy/mthmmy/activities/topic/TopicActivity.java | 4 ++-- .../mthmmy/activities/topic/tasks/PrepareForEditTask.java | 2 -- app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java | 4 ++-- 10 files changed, 32 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java index 4299c2dd..c5646813 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java @@ -9,6 +9,8 @@ import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @@ -87,14 +89,14 @@ public class ForumFragment extends BaseFragment { } @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); if (categories.isEmpty()) { forumTask = new ForumTask(this::onForumTaskStarted, this::onForumTaskFinished); forumTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } - Timber.d("onActivityCreated"); + Timber.d("onViewCreated"); } @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java index fe33ccc4..42eee73c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java @@ -9,6 +9,8 @@ import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @@ -79,8 +81,8 @@ public class RecentFragment extends BaseFragment { } @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); if (topicSummaries.isEmpty()) { recentTask = new RecentTask(this::onRecentTaskStarted, this::onRecentTaskFinished); recentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.indexUrl.toString()); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java index a660b7ab..7b10e79d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java @@ -10,6 +10,7 @@ import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.recyclerview.widget.DividerItemDecoration; @@ -91,8 +92,8 @@ public class UnreadFragment extends BaseFragment { } @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); if (topicSummaries.isEmpty()) { hideMarkAsReadFAB(); unreadTask = new UnreadTask(this::onUnreadTaskStarted, UnreadFragment.this::onUnreadTaskCancelled, this::onUnreadTaskFinished); @@ -104,7 +105,6 @@ public class UnreadFragment extends BaseFragment { markAsReadTask = new MarkAsReadTask(UnreadFragment.this::onMarkAsReadTaskStarted, UnreadFragment.this::onMarkAsReadTaskFinished); } - @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java index e61d83b2..8e7cdde7 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java @@ -7,6 +7,7 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -118,8 +119,8 @@ public class LatestPostsFragment extends BaseFragment { } @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); if (parsedTopicSummaries.isEmpty() && userHasPosts) { profileLatestPostsTask = new LatestPostsTask(); profileLatestPostsTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, profileUrl + ";sa=showPosts"); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java index 698e2492..03bd5ba1 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java @@ -10,6 +10,8 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import com.github.mikephil.charting.charts.HorizontalBarChart; @@ -99,13 +101,13 @@ public class StatsFragment extends Fragment { } @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); if (profileStatsTask == null) { profileStatsTask = new ProfileStatsTask(); profileStatsTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, profileUrl + ";sa=statPanel"); } - Timber.d("onActivityCreated"); + Timber.d("onViewCreated"); } @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java index fd62ad4a..1b1e99c4 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java @@ -12,6 +12,8 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import org.jsoup.Jsoup; @@ -84,8 +86,8 @@ public class SummaryFragment extends Fragment { } @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); if (parsedProfileSummaryData.isEmpty()) { summaryTask = new SummaryTask(); summaryTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, profileSummaryDocument); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java index 7d13f990..5f47d56d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java @@ -14,7 +14,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; -import androidx.lifecycle.ViewModelProviders; +import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.LinearLayoutManager; import gr.thmmy.mthmmy.R; @@ -100,9 +100,9 @@ public class ShoutboxFragment extends Fragment { } @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - shoutboxViewModel = ViewModelProviders.of(getActivity()).get(ShoutboxViewModel.class); + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + shoutboxViewModel = new ViewModelProvider(getActivity()).get(ShoutboxViewModel.class); shoutboxViewModel.getShoutboxMutableLiveData().observe(getViewLifecycleOwner(), shoutbox -> { if (shoutbox != null) { Timber.i("Shoutbox loaded successfully"); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 7c2c5d96..bd47aa4d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -31,7 +31,7 @@ import android.widget.Toast; import androidx.appcompat.app.AlertDialog; import androidx.core.content.res.ResourcesCompat; -import androidx.lifecycle.ViewModelProviders; +import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -131,7 +131,7 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo super.onCreate(savedInstanceState); setContentView(R.layout.activity_topic); // get TopicViewModel instance - viewModel = ViewModelProviders.of(this).get(TopicViewModel.class); + viewModel = new ViewModelProvider(this).get(TopicViewModel.class); subscribeUI(); Bundle extras = getIntent().getExtras(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java index 3428bb8e..6a17e880 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java @@ -7,8 +7,6 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Selector; -import java.io.IOException; - import gr.thmmy.mthmmy.base.BaseApplication; import okhttp3.OkHttpClient; import okhttp3.Request; diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index 21e1af95..0fc7d749 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -23,7 +23,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; -import androidx.lifecycle.ViewModelProviders; +import androidx.lifecycle.ViewModelProvider; import androidx.preference.PreferenceManager; import com.google.android.material.bottomsheet.BottomSheetDialog; @@ -126,7 +126,7 @@ public abstract class BaseActivity extends AppCompatActivity { sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - BaseViewModel baseViewModel = ViewModelProviders.of(this).get(BaseViewModel.class); + BaseViewModel baseViewModel = new ViewModelProvider(this).get(BaseViewModel.class); baseViewModel.getCurrentPageBookmark().observe(this, thisPageBookmark -> setTopicBookmark(thisPageBookmarkMenuButton)); storage = new Storage(getApplicationContext()); From b2657e5fe2a03da9bfdf0214c369d419fa736557 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Sun, 2 Apr 2023 12:38:01 +0300 Subject: [PATCH 07/14] refactor: variable forum URL --- app/src/main/AndroidManifest.xml | 16 +- .../bookmarks/BookmarksActivity.java | 4 +- .../bookmarks/BookmarksFragment.java | 3 - .../downloads/DownloadsActivity.java | 2 +- .../activities/main/forum/ForumFragment.java | 2 +- .../topic/tasks/PrepareForReplyTask.java | 2 +- .../activities/topic/tasks/ReplyTask.java | 2 +- .../activities/upload/UploadActivity.java | 2 +- .../gr/thmmy/mthmmy/base/BaseActivity.java | 4 +- .../gr/thmmy/mthmmy/base/BaseApplication.java | 25 +- .../java/gr/thmmy/mthmmy/model/ThmmyPage.java | 25 +- .../mthmmy/services/NotificationService.java | 2 +- .../thmmy/mthmmy/session/SessionManager.java | 22 +- .../mthmmy/utils/networking/NetworkTask.java | 2 +- .../mthmmy/utils/parsing/ParseHelpers.java | 244 +++++++++--------- app/src/main/res/layout/activity_login.xml | 2 +- app/src/main/res/values/strings.xml | 5 +- 17 files changed, 204 insertions(+), 160 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7c7d5b18..be988ad9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -54,19 +54,21 @@ + - + + + - > { - private HttpUrl forumUrl = SessionManager.forumUrl; //may change upon collapse/expand + private HttpUrl forumUrl = SessionManager.getForumUrl(); //may change upon collapse/expand ForumTask(OnTaskStartedListener onTaskStartedListener, OnNetworkTaskFinishedListener> onParseTaskFinishedListener) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyTask.java index b67b2157..373bde04 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForReplyTask.java @@ -61,7 +61,7 @@ public class PrepareForReplyTask extends AsyncTask { .addFormDataPart("icon", "xx") .build(); Request post = new Request.Builder() - .url("https://www.thmmy.gr/smf/index.php?action=post2") + .url(BaseApplication.getForumUrl() + "index.php?action=post2") .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36") .post(postBody) .build(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java index 48ec3b5b..cfb27028 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java @@ -91,7 +91,7 @@ public class UploadActivity extends BaseActivity { public static final String BUNDLE_UPLOAD_CATEGORY = "UPLOAD_CATEGORY"; public static final String firebaseConfigUploadsCoursesKey = "uploads_courses"; - private static final String uploadIndexUrl = "https://www.thmmy.gr/smf/index.php?action=tpmod;dl=upload"; + private static final String uploadIndexUrl = forumUrl + "index.php?action=tpmod;dl=upload"; private static final String uploadedFromTHMMYPromptHtml = "
uploaded from mTHMMY"; /** * Request codes used in activities for result (AFR) calls diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index 0fc7d749..e983bb8d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -106,6 +106,8 @@ public abstract class BaseActivity extends AppCompatActivity { private boolean isMainActivity; private boolean isUserConsentDialogShown; //Needed because sometimes onResume is being called twice + protected static String forumUrl = BaseApplication.getForumUrl(); // For convenience + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -346,7 +348,7 @@ public abstract class BaseActivity extends AppCompatActivity { if (sessionManager.isLoggedIn()) { Intent intent = new Intent(BaseActivity.this, ProfileActivity.class); Bundle extras = new Bundle(); - extras.putString(BUNDLE_PROFILE_URL, "https://www.thmmy.gr/smf/index.php?action=profile"); + extras.putString(BUNDLE_PROFILE_URL, forumUrl + "index.php?action=profile"); if (!sessionManager.hasAvatar()) extras.putString(BUNDLE_PROFILE_THUMBNAIL_URL, ""); else diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java index 5b1d0154..e38f4472 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java @@ -3,6 +3,7 @@ package gr.thmmy.mthmmy.base; import android.app.Application; import android.content.Context; import android.content.SharedPreferences; +import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; @@ -70,10 +71,27 @@ public class BaseApplication extends Application implements Executor{ private static float widthDp; private static int widthPxl, heightPxl; + private static String forumUrl; + private static String forumHost; + private static String forumHostSimple; + public static BaseApplication getInstance() { return baseApplication; } + public static String getForumUrl() { + return forumUrl; + } + + public static String getForumHost() { + return forumHost; + } + + + public static String getForumHostSimple() { + return forumHostSimple; + } + @Override public void onCreate() { super.onCreate(); @@ -83,6 +101,11 @@ public class BaseApplication extends Application implements Executor{ if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree()); + Resources resources = getApplicationContext().getResources(); + forumUrl = resources.getString(R.string.forum_url); + forumHost = resources.getString(R.string.forum_host); + forumHostSimple= resources.getString(R.string.forum_host_simple); + //Shared Preferences SharedPreferences sessionSharedPrefs = getSharedPreferences(getString(R.string.session_shared_prefs), MODE_PRIVATE); SharedPreferences settingsSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); @@ -157,7 +180,7 @@ public class BaseApplication extends Application implements Executor{ .addInterceptor(chain -> { Request request = chain.request(); HttpUrl oldUrl = chain.request().url(); - if (Objects.equals(chain.request().url().host(), "www.thmmy.gr") + if (Objects.equals(chain.request().url().host(), forumHost) && !oldUrl.toString().contains("theme=4")) { //Probably works but needs more testing: HttpUrl newUrl = oldUrl.newBuilder().addQueryParameter("theme", "4").build(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java index 0b47cb42..dbaf4e23 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java +++ b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java @@ -6,6 +6,7 @@ import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; +import gr.thmmy.mthmmy.base.BaseApplication; import timber.log.Timber; /** @@ -20,6 +21,14 @@ public class ThmmyPage { @SuppressWarnings("unused") private static final String TAG = "LinkTarget"; + private static final String forumUrl = BaseApplication.getForumUrl(); + private static final String forumHost = BaseApplication.getForumHost(); + private static final String forumHostHttp = "http://" + forumHost; + private static final String forumHostHttps = "https://" + forumHost; + private static final String forumHostSimple = BaseApplication.getForumHostSimple(); + private static final String forumHostSimpleHttp = "http://" + forumHostSimple; + private static final String forumHostSimpleHttps = "https://" + forumHostSimple; + /** * An enum describing a link's target by defining the types:
    *
  • {@link #NOT_THMMY}
  • @@ -142,9 +151,9 @@ public class ThmmyPage { final String host = uri.getHost(); final String uriString = uri.toString(); - if (Objects.equals(uriString, "http://thmmy.gr") - || Objects.equals(uriString, "https://thmmy.gr")) return PageCategory.INDEX; - if (Objects.equals(host, "www.thmmy.gr")) { + if (Objects.equals(uriString, forumHostSimpleHttp) + || Objects.equals(uriString, forumHostSimpleHttps)) return PageCategory.INDEX; + if (Objects.equals(host, forumHost)) { if (uriString.contains("topic=")) return PageCategory.TOPIC; else if (uriString.contains("board=")) return PageCategory.BOARD; else if (uriString.contains("action=profile")) { @@ -160,12 +169,12 @@ public class ThmmyPage { return PageCategory.DOWNLOADS_FILE; else if (uriString.contains("action=tpmod;dl")) return PageCategory.DOWNLOADS_CATEGORY; - else if (uriString.contains("action=forum") || Objects.equals(uriString, "www.thmmy.gr") - || Objects.equals(uriString, "http://www.thmmy.gr") - || Objects.equals(uriString, "https://www.thmmy.gr") - || Objects.equals(uriString, "https://www.thmmy.gr/smf/index.php")) + else if (uriString.contains("action=forum") || Objects.equals(uriString, forumHost) + || Objects.equals(uriString, forumHostHttp) + || Objects.equals(uriString, forumHostHttps) + || Objects.equals(uriString, forumUrl + "index.php")) return PageCategory.INDEX; - Timber.v("Unknown thmmy link found, link: %s", uriString); + Timber.v("Unknown thmmy link found, link: %s", uriString); //TODO: maybe report this? return PageCategory.UNKNOWN_THMMY; } return PageCategory.NOT_THMMY; diff --git a/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java b/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java index 482dffdb..07ea15af 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java +++ b/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java @@ -171,7 +171,7 @@ public class NotificationService extends FirebaseMessagingService { } //Builds notification - String topicUrl = "https://www.thmmy.gr/smf/index.php?topic=" + postNotification.getTopicId() + "." + postNotification.getPostId(); + String topicUrl = BaseApplication.getForumUrl() + "index.php?topic=" + postNotification.getTopicId() + "." + postNotification.getPostId(); Intent intent = new Intent(this, MainActivity.class); Bundle extras = new Bundle(); extras.putString(BUNDLE_TOPIC_URL, topicUrl); diff --git a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java index d199d539..207336a5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java +++ b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import gr.thmmy.mthmmy.base.BaseApplication; import gr.thmmy.mthmmy.utils.parsing.ParseException; import okhttp3.Cookie; import okhttp3.FormBody; @@ -34,13 +35,14 @@ import timber.log.Timber; */ public class SessionManager { //Generic constants - public static final HttpUrl indexUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?theme=4"); - public static final HttpUrl forumUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=forum;theme=4"); - private static final HttpUrl loginUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=login2"); - public static final HttpUrl unreadUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=unread;all;start=0;theme=4"); - public static final HttpUrl shoutboxUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=tpmod;sa=shoutbox;theme=4"); - static final String baseLogoutLink = "https://www.thmmy.gr/smf/index.php?action=logout;sesc="; - static final String baseMarkAllAsReadLink = "https://www.thmmy.gr/smf/index.php?action=markasread;sa=all;sesc="; + private final static String FORUM_URL = BaseApplication.getForumUrl(); + public static final HttpUrl indexUrl = HttpUrl.parse(FORUM_URL + "index.php?theme=4"); + private static final HttpUrl forumUrl = HttpUrl.parse(FORUM_URL + "index.php?action=forum;theme=4"); + private static final HttpUrl loginUrl = HttpUrl.parse(FORUM_URL + "index.php?action=login2"); + public static final HttpUrl unreadUrl = HttpUrl.parse(FORUM_URL + "index.php?action=unread;all;start=0;theme=4"); + public static final HttpUrl shoutboxUrl = HttpUrl.parse(FORUM_URL + "index.php?action=tpmod;sa=shoutbox;theme=4"); + static final String baseLogoutLink = FORUM_URL + "index.php?action=logout;sesc="; + static final String baseMarkAllAsReadLink = FORUM_URL + "index.php?action=markasread;sa=all;sesc="; private static final String guestName = "Guest"; //Response Codes - make sure they do not overlap with NetworkResultCodes, just in case @@ -190,6 +192,10 @@ public class SessionManager { } //--------------------------------------- GETTERS ------------------------------------------------ + public static HttpUrl getForumUrl() { + return forumUrl; + } + public String getUsername() { return sessionSharedPrefs.getString(USERNAME, USERNAME); } @@ -291,7 +297,7 @@ public class SessionManager { if (elements.size() == 1) { String link = elements.first().attr("href"); - Pattern pattern = Pattern.compile("https://www.thmmy.gr/smf/index.php\\?action=profile;u=(\\d*);sa=showPosts"); + Pattern pattern = Pattern.compile(FORUM_URL + "index.php\\?action=profile;u=(\\d*);sa=showPosts"); Matcher matcher = pattern.matcher(link); if (matcher.find()) return Integer.parseInt(matcher.group(1)); diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/networking/NetworkTask.java b/app/src/main/java/gr/thmmy/mthmmy/utils/networking/NetworkTask.java index 7d1c2189..bdf79ae9 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/networking/NetworkTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/networking/NetworkTask.java @@ -57,7 +57,7 @@ public abstract class NetworkTask extends ExternalAsyncTask try { response = sendRequest(BaseApplication.getInstance().getClient(), input); } catch (IOException e) { - Timber.e(e, "Error connecting to thmmy.gr"); + Timber.e(e, "Error connecting to forum!"); return new Parcel<>(NetworkResultCodes.NETWORK_ERROR, null); } String responseBodyString; diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ParseHelpers.java b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ParseHelpers.java index 2aea53c4..af00157d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ParseHelpers.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ParseHelpers.java @@ -9,13 +9,15 @@ import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; +import gr.thmmy.mthmmy.base.BaseApplication; + /** * This class consists exclusively of static classes (enums) and methods (excluding methods of inner * classes). It can be used to resolve a page's language and state or fix embedded videos html code * and obfuscated emails. */ public class ParseHelpers { - + private final static String FORUM_URL = BaseApplication.getForumUrl(); /** * An enum describing a forum page's language by defining the types:
      *
    • {@link #PAGE_INCOMPLETE}
    • @@ -185,138 +187,138 @@ public class ParseHelpers { * @return the base URL of the given topic */ public static String getBaseURL(String topicURL) { - String forumUrl = "https://www.thmmy.gr/smf/index.php?"; + String indexUrl = FORUM_URL + "index.php?"; Matcher baseUrlMatcher = Pattern.compile("topic=[0-9]+").matcher(topicURL); if (baseUrlMatcher.find()) - return forumUrl + topicURL.substring(baseUrlMatcher.start(), baseUrlMatcher.end()); + return indexUrl + topicURL.substring(baseUrlMatcher.start(), baseUrlMatcher.end()); else return ""; } public static String emojiTagToHtml(String emojiTagedString) { HashMap tagToHtmlMap = new HashMap<>(); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":)"), Pattern.MULTILINE), "\"Smiley\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(";)"), Pattern.MULTILINE), "\"Wink\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":D"), Pattern.MULTILINE), "\"Cheesy\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(";D"), Pattern.MULTILINE), "\"Grin\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(">:("), Pattern.MULTILINE), "\"Angry\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":("), Pattern.MULTILINE), "\"Sad\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":o"), Pattern.MULTILINE), "\"Shocked\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("8))"), Pattern.MULTILINE), "\"Cool\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":???:"), Pattern.MULTILINE), "\"Huh\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":P"), Pattern.MULTILINE), "\"Tongue\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":-["), Pattern.MULTILINE), "\"Embarrassed\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":-X"), Pattern.MULTILINE), "\"Lips"); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":-\\"), Pattern.MULTILINE), "\"Undecided\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":-*"), Pattern.MULTILINE), "\"Kiss\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":'("), Pattern.MULTILINE), "\"Cry\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("<3"), Pattern.MULTILINE), "\"heart\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^locked^"), Pattern.MULTILINE), "\"kleidaria\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^rollover^"), Pattern.MULTILINE), "\"roll_over\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^redface^"), Pattern.MULTILINE), "\"redface\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^confused^"), Pattern.MULTILINE), "\"confused\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^innocent^"), Pattern.MULTILINE), "\"innocent\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^sleep^"), Pattern.MULTILINE), "\"sleep\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^sealed^"), Pattern.MULTILINE), "\"lips_sealed\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^cool^"), Pattern.MULTILINE), "\"cool\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^crazy^"), Pattern.MULTILINE), "\"crazy\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^mad^"), Pattern.MULTILINE), "\"mad\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^wav^"), Pattern.MULTILINE), "\"wav\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^binkybaby^"), Pattern.MULTILINE), "\"BinkyBaby\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^Police^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^dontknow^"), Pattern.MULTILINE), "\"DontKnow\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote(":angry4:"), Pattern.MULTILINE), "\"angry4\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^angryhot^"), Pattern.MULTILINE), "\"angryAndHot\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^angry^"), Pattern.MULTILINE), "\"angry\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^fouska^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^nysta^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^sfinaki^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^banghead^"), Pattern.MULTILINE), "\"bang_head\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^crybaby^"), Pattern.MULTILINE), "\"CryBaby\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^hello^"), Pattern.MULTILINE), "\"Hello\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^jerk^"), Pattern.MULTILINE), "\"jerk\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^nono^"), Pattern.MULTILINE), "\"NoNo\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^notworthy^"), Pattern.MULTILINE), "\"NotWorthy\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^off-topic^"), Pattern.MULTILINE), "\"Off-topic\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^puke^"), Pattern.MULTILINE), "\"Puke\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^shout^"), Pattern.MULTILINE), "\"Shout\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^slurp^"), Pattern.MULTILINE), "\"Slurp\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^superconfused^"), Pattern.MULTILINE), "\"SuperConfused\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^superinnocent^"), Pattern.MULTILINE), "\"SuperInnocent\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^cellPhone^"), Pattern.MULTILINE), "\"CellPhone\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^idiot^"), Pattern.MULTILINE), "\"Idiot\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^knuppel^"), Pattern.MULTILINE), "\"Knuppel\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^tickedOff^"), Pattern.MULTILINE), "\"TickedOff\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^peace^"), Pattern.MULTILINE), "\"Peace\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^suspicious^"), Pattern.MULTILINE), "\"Suspicious\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^caffine^"), Pattern.MULTILINE), "\"Caffine\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^argue^"), Pattern.MULTILINE), "\"argue\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^banned2^"), Pattern.MULTILINE), "\"banned2\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^banned^"), Pattern.MULTILINE), "\"banned\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^bath^"), Pattern.MULTILINE), "\"bath\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^beg^"), Pattern.MULTILINE), "\"beg\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^bluescreen^"), Pattern.MULTILINE), "\"bluescreen\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^boil^"), Pattern.MULTILINE), "\"boil\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^bye^"), Pattern.MULTILINE), "\"bye\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^callmerip^"), Pattern.MULTILINE), "\"callmerip\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^carnaval^"), Pattern.MULTILINE), "\"carnaval\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^clap^"), Pattern.MULTILINE), "\"clap\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^coffepot^"), Pattern.MULTILINE), "\"coffepot\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^crap^"), Pattern.MULTILINE), "\"crap\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^curses^"), Pattern.MULTILINE), "\"curses\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^funny^"), Pattern.MULTILINE), "\"funny\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^guitar^"), Pattern.MULTILINE), "\"guitar\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^kissy^"), Pattern.MULTILINE), "\"kissy\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^band^"), Pattern.MULTILINE), "\"band\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^ivres^"), Pattern.MULTILINE), "\"ivres\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^kaloe^"), Pattern.MULTILINE), "\"kaloe\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^kremala^"), Pattern.MULTILINE), "\"kremala\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^moon^"), Pattern.MULTILINE), "\"moon\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^mopping^"), Pattern.MULTILINE), "\"mopping\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^mountza^"), Pattern.MULTILINE), "\"mountza\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^pcsleep^"), Pattern.MULTILINE), "\"pcsleep\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^pinokio^"), Pattern.MULTILINE), "\"pinokio\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^poke^"), Pattern.MULTILINE), "\"poke\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^seestars^"), Pattern.MULTILINE), "\"seestars\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^sfyri^"), Pattern.MULTILINE), "\"sfyri\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^spam^"), Pattern.MULTILINE), "\"spam\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^super^"), Pattern.MULTILINE), "\"super\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^tafos^"), Pattern.MULTILINE), "\"tafos\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^tomato^"), Pattern.MULTILINE), "\"tomato\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^ytold^"), Pattern.MULTILINE), "\"ytold\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^beer^"), Pattern.MULTILINE), "\"beer\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^yue^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^eatpaper^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^fritz^"), Pattern.MULTILINE), "\"ο"); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^wade^"), Pattern.MULTILINE), "\"o"); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^lypi^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^aytoxeir^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^victory^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^filarakia^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^hat^"), Pattern.MULTILINE), "\"bonjour\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^miss^"), Pattern.MULTILINE), "\"bonjour2\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^rolfmao^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^lock^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^que^"), Pattern.MULTILINE), "\"question\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^shifty^"), Pattern.MULTILINE), "\"shifty\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^shy^"), Pattern.MULTILINE), "\"shy\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^music_listen^"), Pattern.MULTILINE), "\"music_listenning\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^bagface^"), Pattern.MULTILINE), "\"bag_face\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^rotate^"), Pattern.MULTILINE), "\"rotation\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^love^"), Pattern.MULTILINE), "\"love\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^speech^"), Pattern.MULTILINE), "\"speech\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^facepalm^"), Pattern.MULTILINE), "\"\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^shocked^"), Pattern.MULTILINE), "\"shocked\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^ex_shocked^"), Pattern.MULTILINE), "\"extremely_shocked\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^smurf^"), Pattern.MULTILINE), "\"smurf\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^monster^"), Pattern.MULTILINE), "\"monster\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^pig^"), Pattern.MULTILINE), "\"pig\""); - tagToHtmlMap.put(Pattern.compile(Pattern.quote("^lol^"), Pattern.MULTILINE), "\"lol\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":)"), Pattern.MULTILINE), "\"Smiley\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(";)"), Pattern.MULTILINE), "\"Wink\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":D"), Pattern.MULTILINE), "\"Cheesy\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(";D"), Pattern.MULTILINE), "\"Grin\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(">:("), Pattern.MULTILINE), "\"Angry\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":("), Pattern.MULTILINE), "\"Sad\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":o"), Pattern.MULTILINE), "\"Shocked\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("8))"), Pattern.MULTILINE), "\"Cool\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":???:"), Pattern.MULTILINE), "\"Huh\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":P"), Pattern.MULTILINE), "\"Tongue\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":-["), Pattern.MULTILINE), "\"Embarrassed\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":-X"), Pattern.MULTILINE), "\"Lips"); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":-\\"), Pattern.MULTILINE), "\"Undecided\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":-*"), Pattern.MULTILINE), "\"Kiss\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":'("), Pattern.MULTILINE), "\"Cry\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("<3"), Pattern.MULTILINE), "\"heart\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^locked^"), Pattern.MULTILINE), "\"kleidaria\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^rollover^"), Pattern.MULTILINE), "\"roll_over\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^redface^"), Pattern.MULTILINE), "\"redface\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^confused^"), Pattern.MULTILINE), "\"confused\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^innocent^"), Pattern.MULTILINE), "\"innocent\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^sleep^"), Pattern.MULTILINE), "\"sleep\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^sealed^"), Pattern.MULTILINE), "\"lips_sealed\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^cool^"), Pattern.MULTILINE), "\"cool\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^crazy^"), Pattern.MULTILINE), "\"crazy\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^mad^"), Pattern.MULTILINE), "\"mad\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^wav^"), Pattern.MULTILINE), "\"wav\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^binkybaby^"), Pattern.MULTILINE), "\"BinkyBaby\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^Police^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^dontknow^"), Pattern.MULTILINE), "\"DontKnow\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote(":angry4:"), Pattern.MULTILINE), "\"angry4\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^angryhot^"), Pattern.MULTILINE), "\"angryAndHot\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^angry^"), Pattern.MULTILINE), "\"angry\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^fouska^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^nysta^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^sfinaki^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^banghead^"), Pattern.MULTILINE), "\"bang_head\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^crybaby^"), Pattern.MULTILINE), "\"CryBaby\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^hello^"), Pattern.MULTILINE), "\"Hello\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^jerk^"), Pattern.MULTILINE), "\"jerk\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^nono^"), Pattern.MULTILINE), "\"NoNo\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^notworthy^"), Pattern.MULTILINE), "\"NotWorthy\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^off-topic^"), Pattern.MULTILINE), "\"Off-topic\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^puke^"), Pattern.MULTILINE), "\"Puke\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^shout^"), Pattern.MULTILINE), "\"Shout\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^slurp^"), Pattern.MULTILINE), "\"Slurp\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^superconfused^"), Pattern.MULTILINE), "\"SuperConfused\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^superinnocent^"), Pattern.MULTILINE), "\"SuperInnocent\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^cellPhone^"), Pattern.MULTILINE), "\"CellPhone\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^idiot^"), Pattern.MULTILINE), "\"Idiot\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^knuppel^"), Pattern.MULTILINE), "\"Knuppel\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^tickedOff^"), Pattern.MULTILINE), "\"TickedOff\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^peace^"), Pattern.MULTILINE), "\"Peace\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^suspicious^"), Pattern.MULTILINE), "\"Suspicious\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^caffine^"), Pattern.MULTILINE), "\"Caffine\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^argue^"), Pattern.MULTILINE), "\"argue\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^banned2^"), Pattern.MULTILINE), "\"banned2\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^banned^"), Pattern.MULTILINE), "\"banned\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^bath^"), Pattern.MULTILINE), "\"bath\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^beg^"), Pattern.MULTILINE), "\"beg\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^bluescreen^"), Pattern.MULTILINE), "\"bluescreen\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^boil^"), Pattern.MULTILINE), "\"boil\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^bye^"), Pattern.MULTILINE), "\"bye\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^callmerip^"), Pattern.MULTILINE), "\"callmerip\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^carnaval^"), Pattern.MULTILINE), "\"carnaval\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^clap^"), Pattern.MULTILINE), "\"clap\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^coffepot^"), Pattern.MULTILINE), "\"coffepot\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^crap^"), Pattern.MULTILINE), "\"crap\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^curses^"), Pattern.MULTILINE), "\"curses\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^funny^"), Pattern.MULTILINE), "\"funny\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^guitar^"), Pattern.MULTILINE), "\"guitar\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^kissy^"), Pattern.MULTILINE), "\"kissy\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^band^"), Pattern.MULTILINE), "\"band\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^ivres^"), Pattern.MULTILINE), "\"ivres\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^kaloe^"), Pattern.MULTILINE), "\"kaloe\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^kremala^"), Pattern.MULTILINE), "\"kremala\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^moon^"), Pattern.MULTILINE), "\"moon\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^mopping^"), Pattern.MULTILINE), "\"mopping\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^mountza^"), Pattern.MULTILINE), "\"mountza\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^pcsleep^"), Pattern.MULTILINE), "\"pcsleep\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^pinokio^"), Pattern.MULTILINE), "\"pinokio\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^poke^"), Pattern.MULTILINE), "\"poke\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^seestars^"), Pattern.MULTILINE), "\"seestars\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^sfyri^"), Pattern.MULTILINE), "\"sfyri\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^spam^"), Pattern.MULTILINE), "\"spam\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^super^"), Pattern.MULTILINE), "\"super\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^tafos^"), Pattern.MULTILINE), "\"tafos\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^tomato^"), Pattern.MULTILINE), "\"tomato\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^ytold^"), Pattern.MULTILINE), "\"ytold\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^beer^"), Pattern.MULTILINE), "\"beer\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^yue^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^eatpaper^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^fritz^"), Pattern.MULTILINE), "\"ο"); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^wade^"), Pattern.MULTILINE), "\"o"); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^lypi^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^aytoxeir^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^victory^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^filarakia^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^hat^"), Pattern.MULTILINE), "\"bonjour\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^miss^"), Pattern.MULTILINE), "\"bonjour2\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^rolfmao^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^lock^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^que^"), Pattern.MULTILINE), "\"question\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^shifty^"), Pattern.MULTILINE), "\"shifty\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^shy^"), Pattern.MULTILINE), "\"shy\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^music_listen^"), Pattern.MULTILINE), "\"music_listenning\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^bagface^"), Pattern.MULTILINE), "\"bag_face\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^rotate^"), Pattern.MULTILINE), "\"rotation\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^love^"), Pattern.MULTILINE), "\"love\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^speech^"), Pattern.MULTILINE), "\"speech\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^facepalm^"), Pattern.MULTILINE), "\"\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^shocked^"), Pattern.MULTILINE), "\"shocked\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^ex_shocked^"), Pattern.MULTILINE), "\"extremely_shocked\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^smurf^"), Pattern.MULTILINE), "\"smurf\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^monster^"), Pattern.MULTILINE), "\"monster\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^pig^"), Pattern.MULTILINE), "\"pig\""); + tagToHtmlMap.put(Pattern.compile(Pattern.quote("^lol^"), Pattern.MULTILINE), "\"lol\""); //Needs priority over the rest tags final Pattern pattern = Pattern.compile(Pattern.quote("::)"), Pattern.MULTILINE); Matcher matcher = pattern.matcher(emojiTagedString); - emojiTagedString = matcher.replaceAll("\"Roll"); + emojiTagedString = matcher.replaceAll("\"Roll"); for (Pattern patternKey : tagToHtmlMap.keySet()) { matcher = patternKey.matcher(emojiTagedString); diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 29c0bb21..9a8a3119 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -31,7 +31,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:contentDescription="@string/thmmy_img_description" /> + android:contentDescription="@string/mthmmy_logo" /> mTHMMY + https://www.thmmy.gr/smf/ + www.thmmy.gr + thmmy.gr Login @@ -26,7 +29,7 @@ No unread topics! - thmmy.gr + mTHMMY Username Password LOGIN From a0b617f3715e24afa753be0b11a88e5adcc85a4f Mon Sep 17 00:00:00 2001 From: Ezerous Date: Sun, 2 Apr 2023 20:02:21 +0300 Subject: [PATCH 08/14] feat: up targetSDK, gradle, bump min Android version, refactoring --- README.md | 2 +- app/build.gradle | 11 ++-- app/gradle/grgit.gradle | 4 +- app/src/main/AndroidManifest.xml | 2 +- .../mthmmy/activities/LoginActivity.java | 16 +++--- .../mthmmy/activities/board/BoardAdapter.java | 10 ++-- .../bookmarks/BookmarksActivity.java | 10 ++-- .../create_content/NewTopicTask.java | 4 +- .../downloads/DownloadsActivity.java | 4 +- .../downloads/DownloadsAdapter.java | 17 ++---- .../mthmmy/activities/main/MainActivity.java | 20 +++---- .../main/unread/UnreadFragment.java | 2 +- .../activities/profile/ProfileActivity.java | 12 ++--- .../profile/stats/StatsFragment.java | 23 ++------ .../profile/summary/SummaryFragment.java | 5 +- .../activities/settings/SettingsFragment.java | 4 +- .../activities/shoutbox/ShoutAdapter.java | 16 +++--- .../activities/topic/TopicActivity.java | 4 +- .../mthmmy/activities/topic/TopicAdapter.java | 39 ++++++-------- .../activities/topic/tasks/EditTask.java | 4 +- .../activities/topic/tasks/ReplyTask.java | 4 +- .../activities/upload/UploadActivity.java | 20 +++---- .../upload/multipart/MultipartUploadTask.java | 5 +- .../gr/thmmy/mthmmy/base/BaseActivity.java | 53 ++++++++----------- .../gr/thmmy/mthmmy/base/BaseApplication.java | 52 +++++++++--------- .../gr/thmmy/mthmmy/base/BaseFragment.java | 2 +- .../java/gr/thmmy/mthmmy/model/Category.java | 4 +- .../thmmy/mthmmy/services/DownloadHelper.java | 4 +- .../mthmmy/services/NotificationService.java | 48 +++++++---------- .../gr/thmmy/mthmmy/session/LogoutTask.java | 6 +-- .../thmmy/mthmmy/session/MarkAsReadTask.java | 6 +-- .../gr/thmmy/mthmmy/utils/DateTimeUtils.java | 4 +- .../java/gr/thmmy/mthmmy/utils/FileUtils.java | 19 ++++--- .../java/gr/thmmy/mthmmy/utils/HTMLUtils.java | 14 ++--- .../utils/ui/ImageDownloadDialogBuilder.java | 4 +- .../thmmy/mthmmy/views/ReactiveWebView.java | 8 +-- .../mthmmy/views/RelativeTimeTextView.java | 4 +- .../mthmmy/views/editorview/EditorView.java | 33 ++++++------ .../activity_topic_overflow_menu.xml | 52 ------------------ .../layout/activity_topic_overflow_menu.xml | 10 ++-- .../thmmy/mthmmy/utils/DateTimeUtilsTest.java | 8 +-- .../utils/UploadsCoursesJSONReadingTest.java | 10 ++-- .../parsing/ThmmyDateTimeParserTest.java | 14 ++--- build.gradle | 26 +++++---- emojis/build.gradle | 11 ++-- emojis/src/main/AndroidManifest.xml | 3 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 47 files changed, 277 insertions(+), 360 deletions(-) delete mode 100644 app/src/main/res/layout-v23/activity_topic_overflow_menu.xml diff --git a/README.md b/README.md index 7d0fd105..d0abfee1 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A mobile app for [thmmy.gr](https://www.thmmy.gr). ## Requirements -mTHMMY can be installed on any smartphone with Android 5.0 Lollipop or newer. +mTHMMY can be installed on any smartphone with Android 6.0 (M) or newer. ## Download diff --git a/app/build.gradle b/app/build.gradle index 777af2d6..2245efc8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,13 +7,12 @@ apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' android { - compileSdkVersion 31 - buildToolsVersion = '30.0.2' + compileSdkVersion 33 defaultConfig { applicationId "gr.thmmy.mthmmy" - minSdkVersion 21 - targetSdkVersion 30 + minSdkVersion 23 + targetSdkVersion 33 versionCode 31 versionName "2.1.0" archivesBaseName = "mTHMMY-v$versionName" @@ -45,6 +44,8 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + namespace 'gr.thmmy.mthmmy' } def firebaseReleaseProjectId = "mthmmy-release-3aef0" @@ -92,7 +93,7 @@ dependencies { implementation 'com.google.firebase:firebase-crashlytics' implementation 'com.google.firebase:firebase-messaging' implementation 'com.google.code.gson:gson:2.8.8' - implementation 'com.snatik:storage:2.1.0' + implementation 'com.snatik:storage:2.1.0' //TODO: Replace (e.g. with https://github.com/anggrayudi/SimpleStorage) implementation 'com.squareup.okhttp3:okhttp:3.14.9' implementation 'org.jsoup:jsoup:1.14.2' implementation 'joda-time:joda-time:2.10.10' diff --git a/app/gradle/grgit.gradle b/app/gradle/grgit.gradle index da262dd7..53ae4204 100644 --- a/app/gradle/grgit.gradle +++ b/app/gradle/grgit.gradle @@ -2,11 +2,11 @@ import org.ajoberstar.grgit.Grgit buildscript { repositories { - jcenter() + mavenCentral() } dependencies { - classpath 'org.ajoberstar.grgit:grgit-core:3.1.1' + classpath 'org.ajoberstar.grgit:grgit-core:5.0.0' } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index be988ad9..db813036 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,11 +1,11 @@ + diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java index bd75f6d5..5c2d3e18 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java @@ -1,5 +1,13 @@ package gr.thmmy.mthmmy.activities; +import static gr.thmmy.mthmmy.session.SessionManager.BANNED_USER; +import static gr.thmmy.mthmmy.session.SessionManager.CONNECTION_ERROR; +import static gr.thmmy.mthmmy.session.SessionManager.EXCEPTION; +import static gr.thmmy.mthmmy.session.SessionManager.FAILURE; +import static gr.thmmy.mthmmy.session.SessionManager.SUCCESS; +import static gr.thmmy.mthmmy.session.SessionManager.WRONG_PASSWORD; +import static gr.thmmy.mthmmy.session.SessionManager.WRONG_USER; + import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; @@ -22,14 +30,6 @@ import gr.thmmy.mthmmy.activities.main.MainActivity; import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.base.BaseApplication; -import static gr.thmmy.mthmmy.session.SessionManager.BANNED_USER; -import static gr.thmmy.mthmmy.session.SessionManager.CONNECTION_ERROR; -import static gr.thmmy.mthmmy.session.SessionManager.EXCEPTION; -import static gr.thmmy.mthmmy.session.SessionManager.FAILURE; -import static gr.thmmy.mthmmy.session.SessionManager.SUCCESS; -import static gr.thmmy.mthmmy.session.SessionManager.WRONG_PASSWORD; -import static gr.thmmy.mthmmy.session.SessionManager.WRONG_USER; - public class LoginActivity extends BaseActivity { //-----------------------------------------CLASS VARIABLES------------------------------------------ diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java index a7eac058..6f8a33ce 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java @@ -1,5 +1,10 @@ package gr.thmmy.mthmmy.activities.board; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; + import android.content.Context; import android.content.Intent; import android.graphics.Typeface; @@ -22,11 +27,6 @@ import gr.thmmy.mthmmy.model.Board; import gr.thmmy.mthmmy.model.Topic; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; - /** * {@link RecyclerView.Adapter} that can display a {@link gr.thmmy.mthmmy.model.Board}. */ diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java index c8f70b5e..09c918f5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java @@ -1,5 +1,10 @@ package gr.thmmy.mthmmy.activities.bookmarks; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; + import android.content.Intent; import android.os.Bundle; import android.widget.Toast; @@ -23,11 +28,6 @@ import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.base.BaseApplication; import gr.thmmy.mthmmy.model.Bookmark; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; - public class BookmarksActivity extends BaseActivity { private static final String TOPIC_URL = forumUrl + "index.php?topic="; private static final String BOARD_URL = forumUrl + "index.php?board="; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java index 7925d315..5255dc15 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java @@ -1,5 +1,7 @@ package gr.thmmy.mthmmy.activities.create_content; +import static gr.thmmy.mthmmy.activities.topic.Posting.replyStatus; + import android.os.AsyncTask; import org.jsoup.Jsoup; @@ -15,8 +17,6 @@ import okhttp3.RequestBody; import okhttp3.Response; import timber.log.Timber; -import static gr.thmmy.mthmmy.activities.topic.Posting.replyStatus; - public class NewTopicTask extends AsyncTask { private NewTopicTaskCallbacks listener; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java index 0b6196e4..0ffdaf9c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java @@ -1,5 +1,7 @@ package gr.thmmy.mthmmy.activities.downloads; +import static gr.thmmy.mthmmy.activities.upload.UploadActivity.BUNDLE_UPLOAD_CATEGORY; + import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; @@ -37,8 +39,6 @@ import okhttp3.Request; import okhttp3.Response; import timber.log.Timber; -import static gr.thmmy.mthmmy.activities.upload.UploadActivity.BUNDLE_UPLOAD_CATEGORY; - public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.OnLoadMoreListener { /** * The key to use when putting download's url String to {@link DownloadsActivity}'s Bundle. diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java index 19413074..293fa457 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java @@ -1,9 +1,12 @@ package gr.thmmy.mthmmy.activities.downloads; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_TITLE; +import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_URL; + import android.content.Context; import android.content.Intent; import android.graphics.Typeface; -import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -25,10 +28,6 @@ import gr.thmmy.mthmmy.model.Download; import gr.thmmy.mthmmy.model.ThmmyFile; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; -import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; -import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_TITLE; -import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_URL; - class DownloadsAdapter extends RecyclerView.Adapter { private final int VIEW_TYPE_DOWNLOAD = 0; private final int VIEW_TYPE_LOADING = 1; @@ -132,13 +131,7 @@ class DownloadsAdapter extends RecyclerView.Adapter { } }); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - downloadViewHolder.upperLinear.setBackgroundColor(context.getResources().getColor(R.color.background, null)); - } - else { - //noinspection deprecation - downloadViewHolder.upperLinear.setBackgroundColor(context.getResources().getColor(R.color.background)); - } + downloadViewHolder.upperLinear.setBackgroundColor(context.getResources().getColor(R.color.background, null)); downloadViewHolder.informationExpandable.setVisibility(View.VISIBLE); downloadViewHolder.informationExpandableBtn.setVisibility(View.GONE); downloadViewHolder.informationExpandableBtn.setEnabled(false); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java index 34ddfc59..1b6468d1 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java @@ -1,5 +1,15 @@ package gr.thmmy.mthmmy.activities.main; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; +import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_TITLE; +import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; + import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; @@ -37,16 +47,6 @@ import gr.thmmy.mthmmy.model.ThmmyPage; import gr.thmmy.mthmmy.model.TopicSummary; import timber.log.Timber; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; -import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_TITLE; -import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; - public class MainActivity extends BaseActivity implements RecentFragment.RecentFragmentInteractionListener, ForumFragment.ForumFragmentInteractionListener, UnreadFragment.UnreadFragmentInteractionListener { //-----------------------------------------CLASS VARIABLES------------------------------------------ diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java index 7b10e79d..32412749 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java @@ -244,7 +244,7 @@ public class UnreadFragment extends BaseFragment { if (loadedPages < numberOfPages) { unreadTask = new UnreadTask(this::onUnreadTaskStarted, UnreadFragment.this::onUnreadTaskCancelled, this::onUnreadTaskFinished); assert SessionManager.unreadUrl != null; - unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl.toString() + ";start=" + loadedPages * 20); + unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl + ";start=" + loadedPages * 20); } else hideProgressUI(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java index 7af974d8..5de4c1c1 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java @@ -1,5 +1,11 @@ package gr.thmmy.mthmmy.activities.profile; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; +import static gr.thmmy.mthmmy.utils.parsing.ParseHelpers.emojiTagToHtml; +import static gr.thmmy.mthmmy.utils.ui.GlideUtils.isValidContextForGlide; +import static gr.thmmy.mthmmy.utils.ui.PhotoViewUtils.displayPhotoViewImage; + import android.content.Intent; import android.graphics.Color; import android.graphics.Typeface; @@ -54,12 +60,6 @@ import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import okhttp3.Response; import timber.log.Timber; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; -import static gr.thmmy.mthmmy.utils.parsing.ParseHelpers.emojiTagToHtml; -import static gr.thmmy.mthmmy.utils.ui.GlideUtils.isValidContextForGlide; -import static gr.thmmy.mthmmy.utils.ui.PhotoViewUtils.displayPhotoViewImage; - /** * Activity for user profile. When creating an Intent of this activity you need to bundle a String * containing this user's profile url using the key {@link #BUNDLE_PROFILE_URL}, a String containing diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java index 03bd5ba1..6ea1d4e4 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java @@ -2,7 +2,6 @@ package gr.thmmy.mthmmy.activities.profile.stats; import android.graphics.Color; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -230,7 +229,6 @@ public class StatsFragment extends Fragment { private void populateLayout() { onLoadingListener.onLoadingStats(true); - ; ((TextView) mainContent.findViewById(R.id.general_statistics_title)) .setText(generalStatisticsTitle); ((TextView) mainContent.findViewById(R.id.general_statistics)) @@ -296,14 +294,9 @@ public class StatsFragment extends Fragment { mostPopularBoardsByPostsChartYAxis.setGranularity(1f); BarDataSet mostPopularBoardsByPostsDataSet = new BarDataSet(mostPopularBoardsByPosts, null); - if (isAdded()) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - mostPopularBoardsByPostsDataSet.setColors(getResources().getColor(R.color.accent, null)); - } - else - //noinspection deprecation - mostPopularBoardsByPostsDataSet.setColors(getResources().getColor(R.color.accent)); - } + if (isAdded()) + mostPopularBoardsByPostsDataSet.setColors(getResources().getColor(R.color.accent, null)); + mostPopularBoardsByPostsDataSet.setDrawValues(false); mostPopularBoardsByPostsDataSet.setValueTextColor(Color.WHITE); @@ -338,14 +331,8 @@ public class StatsFragment extends Fragment { mostPopularBoardsByActivityChartYAxis.setLabelCount(10, false); BarDataSet mostPopularBoardsByActivityDataSet = new BarDataSet(mostPopularBoardsByActivity, null); - if (isAdded()) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - mostPopularBoardsByActivityDataSet.setColors(getResources().getColor(R.color.accent, null)); - } - else - //noinspection deprecation - mostPopularBoardsByActivityDataSet.setColors(getResources().getColor(R.color.accent)); - } + if (isAdded()) + mostPopularBoardsByActivityDataSet.setColors(getResources().getColor(R.color.accent, null)); mostPopularBoardsByActivityDataSet.setDrawValues(false); mostPopularBoardsByActivityDataSet.setValueTextColor(Color.WHITE); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java index 1b1e99c4..034f1f2a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java @@ -189,10 +189,7 @@ public class SummaryFragment extends Fragment { && value.contains("@")) || key.startsWith("Website") || key.startsWith("Ιστοτόπος")) textView.setMovementMethod(LinkMovementMethod.getInstance()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) - textView.setTextColor(getResources().getColor(R.color.primary_text, null)); - else - textView.setTextColor(getResources().getColor(R.color.primary_text)); + textView.setTextColor(getResources().getColor(R.color.primary_text, null)); String textViewContent = "" + key + " " + value; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java index a639c199..355fa8eb 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java @@ -1,5 +1,7 @@ package gr.thmmy.mthmmy.activities.settings; +import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DEFAULT_HOME_TAB; + import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -22,8 +24,6 @@ import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.base.BaseApplication; import timber.log.Timber; -import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DEFAULT_HOME_TAB; - public class SettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { private enum PREFS_TYPE { NOT_SET, USER, GUEST diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java index b2bdff0a..425ad188 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java @@ -1,5 +1,13 @@ package gr.thmmy.mthmmy.activities.shoutbox; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; + import android.content.Context; import android.content.Intent; import android.graphics.Color; @@ -24,14 +32,6 @@ import gr.thmmy.mthmmy.model.ThmmyPage; import gr.thmmy.mthmmy.views.CustomRecyclerView; import gr.thmmy.mthmmy.views.ReactiveWebView; -import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; - public class ShoutAdapter extends CustomRecyclerView.Adapter { private Context context; private Shout[] shouts; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index bd47aa4d..9b953d0b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -1,5 +1,7 @@ package gr.thmmy.mthmmy.activities.topic; +import static gr.thmmy.mthmmy.services.NotificationService.NEW_POST_TAG; + import android.annotation.SuppressLint; import android.app.NotificationManager; import android.content.ClipData; @@ -60,8 +62,6 @@ import gr.thmmy.mthmmy.views.editorview.EmojiKeyboard; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import timber.log.Timber; -import static gr.thmmy.mthmmy.services.NotificationService.NEW_POST_TAG; - /** * Activity for parsing and rendering topics. When creating an Intent of this activity you need to * bundle a String containing this topic's url using the key {@link #BUNDLE_TOPIC_URL}. diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 076414f8..ea5ce606 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -1,5 +1,18 @@ package gr.thmmy.mthmmy.activities.topic; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; +import static gr.thmmy.mthmmy.activities.topic.TopicParser.USER_COLOR_WHITE; +import static gr.thmmy.mthmmy.activities.topic.TopicParser.USER_COLOR_YELLOW; +import static gr.thmmy.mthmmy.base.BaseActivity.getSessionManager; +import static gr.thmmy.mthmmy.utils.FileUtils.faIconFromFilename; +import static gr.thmmy.mthmmy.utils.ui.GlideUtils.isValidContextForGlide; + import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; @@ -77,19 +90,6 @@ import gr.thmmy.mthmmy.views.editorview.EditorView; import gr.thmmy.mthmmy.views.editorview.IEmojiKeyboard; import timber.log.Timber; -import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; -import static gr.thmmy.mthmmy.activities.topic.TopicParser.USER_COLOR_WHITE; -import static gr.thmmy.mthmmy.activities.topic.TopicParser.USER_COLOR_YELLOW; -import static gr.thmmy.mthmmy.base.BaseActivity.getSessionManager; -import static gr.thmmy.mthmmy.utils.FileUtils.faIconFromFilename; -import static gr.thmmy.mthmmy.utils.ui.GlideUtils.isValidContextForGlide; - /** * Custom {@link RecyclerView.Adapter} used for topics. */ @@ -393,11 +393,7 @@ class TopicAdapter extends RecyclerView.Adapter { if (currentPost.getAttachedFiles() != null && currentPost.getAttachedFiles().size() != 0) { int filesTextColor; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - filesTextColor = context.getResources().getColor(R.color.accent, null); - } - else - filesTextColor = context.getResources().getColor(R.color.accent); + filesTextColor = context.getResources().getColor(R.color.accent, null); for (final ThmmyFile attachedFile : currentPost.getAttachedFiles()) { final TextView attached = new TextView(context); @@ -417,11 +413,8 @@ class TopicAdapter extends RecyclerView.Adapter { } if (currentPost.getLastEdit() != null && currentPost.getLastEdit().length() > 0) { int lastEditTextColor; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - lastEditTextColor = context.getResources().getColor(R.color.white, null); - } - else - lastEditTextColor = context.getResources().getColor(R.color.white); + + lastEditTextColor = context.getResources().getColor(R.color.white, null); final TextView lastEdit = new TextView(context); lastEdit.setTextSize(12f); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/EditTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/EditTask.java index 2d49a5a5..8e8645f0 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/EditTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/EditTask.java @@ -1,5 +1,7 @@ package gr.thmmy.mthmmy.activities.topic.tasks; +import static gr.thmmy.mthmmy.activities.topic.Posting.replyStatus; + import android.os.AsyncTask; import java.io.IOException; @@ -12,8 +14,6 @@ import okhttp3.RequestBody; import okhttp3.Response; import timber.log.Timber; -import static gr.thmmy.mthmmy.activities.topic.Posting.replyStatus; - public class EditTask extends AsyncTask { private EditTaskCallbacks listener; private int position; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java index 7da9e5cb..19ee5ba5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java @@ -1,5 +1,7 @@ package gr.thmmy.mthmmy.activities.topic.tasks; +import static gr.thmmy.mthmmy.activities.topic.Posting.replyStatus; + import android.os.AsyncTask; import java.io.IOException; @@ -13,8 +15,6 @@ import okhttp3.RequestBody; import okhttp3.Response; import timber.log.Timber; -import static gr.thmmy.mthmmy.activities.topic.Posting.replyStatus; - public class ReplyTask extends AsyncTask { private ReplyTaskCallbacks listener; private boolean includeAppSignature; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java index cfb27028..3f64a81c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java @@ -1,5 +1,15 @@ package gr.thmmy.mthmmy.activities.upload; +import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.UPLOADING_APP_SIGNATURE_ENABLE_KEY; +import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUNDLE_UPLOAD_FIELD_BUILDER_COURSE_GREEKLISH_NAME; +import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUNDLE_UPLOAD_FIELD_BUILDER_COURSE_MINIFIED_NAME; +import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUNDLE_UPLOAD_FIELD_BUILDER_COURSE_NAME; +import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUNDLE_UPLOAD_FIELD_BUILDER_SEMESTER; +import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_DESCRIPTION; +import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_FILENAME; +import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_TITLE; +import static gr.thmmy.mthmmy.utils.FileUtils.faIconFromFilename; + import android.app.Activity; import android.app.PendingIntent; import android.content.Context; @@ -74,16 +84,6 @@ import gr.thmmy.mthmmy.views.AppCompatSpinnerWithoutDefault; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import timber.log.Timber; -import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.UPLOADING_APP_SIGNATURE_ENABLE_KEY; -import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUNDLE_UPLOAD_FIELD_BUILDER_COURSE_GREEKLISH_NAME; -import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUNDLE_UPLOAD_FIELD_BUILDER_COURSE_MINIFIED_NAME; -import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUNDLE_UPLOAD_FIELD_BUILDER_COURSE_NAME; -import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUNDLE_UPLOAD_FIELD_BUILDER_SEMESTER; -import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_DESCRIPTION; -import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_FILENAME; -import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_TITLE; -import static gr.thmmy.mthmmy.utils.FileUtils.faIconFromFilename; - public class UploadActivity extends BaseActivity { /** * The key to use when putting upload's category String to {@link UploadActivity}'s Bundle. diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/multipart/MultipartUploadTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/multipart/MultipartUploadTask.java index d1b5f7b5..655176be 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/multipart/MultipartUploadTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/multipart/MultipartUploadTask.java @@ -11,6 +11,7 @@ import net.gotev.uploadservice.http.BodyWriter; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * Extended MultipartUploadTask from gotev/android-upload-service to include a fix for the parameter @@ -21,7 +22,7 @@ public class MultipartUploadTask extends HttpUploadTask { static final String PARAM_UTF8_CHARSET = "multipartUtf8Charset"; private static final String BOUNDARY_SIGNATURE = "-------AndroidUploadService"; - private static final Charset US_ASCII = Charset.forName("US-ASCII"); + private static final Charset US_ASCII = StandardCharsets.US_ASCII; private static final String NEW_LINE = "\r\n"; private static final String TWO_HYPHENS = "--"; @@ -42,7 +43,7 @@ public class MultipartUploadTask extends HttpUploadTask { boundaryBytes = (TWO_HYPHENS + boundary + NEW_LINE).getBytes(US_ASCII); trailerBytes = (TWO_HYPHENS + boundary + TWO_HYPHENS + NEW_LINE).getBytes(US_ASCII); charset = intent.getBooleanExtra(PARAM_UTF8_CHARSET, false) ? - Charset.forName("UTF-8") : US_ASCII; + StandardCharsets.UTF_8 : US_ASCII; httpParams.addHeader("Connection", "Keep-Alive"); httpParams.addHeader("Content-Type", "multipart/form-data; boundary=" + boundary); diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index e983bb8d..7c3a009c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -1,5 +1,15 @@ package gr.thmmy.mthmmy.base; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_TITLE; +import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; +import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DEFAULT_HOME_TAB; +import static gr.thmmy.mthmmy.services.DownloadHelper.SAVE_DIR; +import static gr.thmmy.mthmmy.utils.FileUtils.getMimeType; + import android.Manifest; import android.app.ProgressDialog; import android.content.Context; @@ -8,7 +18,6 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.net.Uri; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.view.MenuItem; import android.view.View; @@ -67,16 +76,6 @@ import ru.noties.markwon.Markwon; import ru.noties.markwon.SpannableConfiguration; import timber.log.Timber; -import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; -import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_TITLE; -import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; -import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DEFAULT_HOME_TAB; -import static gr.thmmy.mthmmy.services.DownloadHelper.SAVE_DIR; -import static gr.thmmy.mthmmy.utils.FileUtils.getMimeType; - public abstract class BaseActivity extends AppCompatActivity { // Client & Cookies protected static OkHttpClient client; @@ -695,29 +694,23 @@ public abstract class BaseActivity extends AppCompatActivity { //True if permissions are OK protected boolean checkPerms() { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - Timber.i("Checking storage permissions."); - String[] PERMISSIONS_STORAGE = { - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE}; - - return !(checkSelfPermission(PERMISSIONS_STORAGE[0]) == PackageManager.PERMISSION_DENIED || - checkSelfPermission(PERMISSIONS_STORAGE[1]) == PackageManager.PERMISSION_DENIED); - } - return true; + Timber.i("Checking storage permissions."); + String[] PERMISSIONS_STORAGE = { + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE}; + + return !(checkSelfPermission(PERMISSIONS_STORAGE[0]) == PackageManager.PERMISSION_DENIED || + checkSelfPermission(PERMISSIONS_STORAGE[1]) == PackageManager.PERMISSION_DENIED); } //Display popup for user to grant permission protected void requestPerms(int code) { - //Runtime permissions request for devices with API >= 23 - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - String[] PERMISSIONS_STORAGE = { - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE}; - - Timber.i("Requesting storage permissions (code %d).", code); - requestPermissions(PERMISSIONS_STORAGE, code); - } + String[] PERMISSIONS_STORAGE = { + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE}; + + Timber.i("Requesting storage permissions (code %d).", code); + requestPermissions(PERMISSIONS_STORAGE, code); } @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java index e38f4472..228b67d3 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java @@ -1,5 +1,10 @@ package gr.thmmy.mthmmy.base; +import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DISPLAY_COMPACT_TABS; +import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DISPLAY_RELATIVE_TIME; +import static gr.thmmy.mthmmy.activities.upload.UploadActivity.firebaseConfigUploadsCoursesKey; +import static gr.thmmy.mthmmy.utils.io.ResourceUtils.readJSONResourceToString; + import android.app.Application; import android.content.Context; import android.content.SharedPreferences; @@ -45,16 +50,16 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import timber.log.Timber; -import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DISPLAY_COMPACT_TABS; -import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DISPLAY_RELATIVE_TIME; -import static gr.thmmy.mthmmy.activities.upload.UploadActivity.firebaseConfigUploadsCoursesKey; -import static gr.thmmy.mthmmy.utils.io.ResourceUtils.readJSONResourceToString; - public class BaseApplication extends Application implements Executor{ private static BaseApplication baseApplication; //BaseApplication singleton private CrashReportingTree crashReportingTree; + //Global variables + private static String forumUrl; + private static String forumHost; + private static String forumHostSimple; + //Firebase private static String firebaseProjectId; private FirebaseAnalytics firebaseAnalytics; @@ -71,27 +76,6 @@ public class BaseApplication extends Application implements Executor{ private static float widthDp; private static int widthPxl, heightPxl; - private static String forumUrl; - private static String forumHost; - private static String forumHostSimple; - - public static BaseApplication getInstance() { - return baseApplication; - } - - public static String getForumUrl() { - return forumUrl; - } - - public static String getForumHost() { - return forumHost; - } - - - public static String getForumHostSimple() { - return forumHostSimple; - } - @Override public void onCreate() { super.onCreate(); @@ -231,6 +215,22 @@ public class BaseApplication extends Application implements Executor{ //-------------------- Getters -------------------- + public static BaseApplication getInstance() { + return baseApplication; + } + + public static String getForumUrl() { + return forumUrl; + } + + public static String getForumHost() { + return forumHost; + } + + public static String getForumHostSimple() { + return forumHostSimple; + } + public Context getContext() { return getApplicationContext(); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java index 862b3a61..7c2d4ad0 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java @@ -31,7 +31,7 @@ public abstract class BaseFragment extends Fragment { if (context instanceof FragmentInteractionListener) fragmentInteractionListener = (FragmentInteractionListener) context; else - throw new RuntimeException(context.toString() + throw new RuntimeException(context + " must implement OnFragmentInteractionListener"); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/Category.java b/app/src/main/java/gr/thmmy/mthmmy/model/Category.java index 46142bbf..851da46b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/model/Category.java +++ b/app/src/main/java/gr/thmmy/mthmmy/model/Category.java @@ -1,12 +1,12 @@ package gr.thmmy.mthmmy.model; +import static android.R.attr.id; + import com.bignerdranch.expandablerecyclerview.model.Parent; import java.util.ArrayList; import java.util.List; -import static android.R.attr.id; - public class Category implements Parent { private final String title; private final String categoryURL; diff --git a/app/src/main/java/gr/thmmy/mthmmy/services/DownloadHelper.java b/app/src/main/java/gr/thmmy/mthmmy/services/DownloadHelper.java index b98b21d3..77a006fa 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/services/DownloadHelper.java +++ b/app/src/main/java/gr/thmmy/mthmmy/services/DownloadHelper.java @@ -1,5 +1,7 @@ package gr.thmmy.mthmmy.services; +import static gr.thmmy.mthmmy.utils.FileUtils.getMimeType; + import android.app.DownloadManager; import android.content.Context; import android.net.Uri; @@ -15,8 +17,6 @@ import gr.thmmy.mthmmy.model.ThmmyFile; import okhttp3.Cookie; import timber.log.Timber; -import static gr.thmmy.mthmmy.utils.FileUtils.getMimeType; - /** * Not an actual service, but simply a helper class that adds a download to the queue of Android's * DownloadManager system service. diff --git a/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java b/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java index 07ea15af..ad8b23be 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java +++ b/app/src/main/java/gr/thmmy/mthmmy/services/NotificationService.java @@ -1,5 +1,17 @@ package gr.thmmy.mthmmy.services; +import static androidx.core.app.NotificationCompat.PRIORITY_MAX; +import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.NOTIFICATION_LED_KEY; +import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.NOTIFICATION_VIBRATION_KEY; +import static gr.thmmy.mthmmy.activities.settings.SettingsFragment.SELECTED_RINGTONE; +import static gr.thmmy.mthmmy.activities.settings.SettingsFragment.SETTINGS_SHARED_PREFS; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; +import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; +import static gr.thmmy.mthmmy.base.BaseActivity.BOOKMARKED_BOARDS_KEY; +import static gr.thmmy.mthmmy.base.BaseActivity.BOOKMARKED_TOPICS_KEY; +import static gr.thmmy.mthmmy.base.BaseActivity.BOOKMARKS_SHARED_PREFS; +import static gr.thmmy.mthmmy.model.Bookmark.matchExistsById; + import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; @@ -13,7 +25,6 @@ import android.os.Build; import android.os.Bundle; import android.service.notification.StatusBarNotification; -import androidx.annotation.RequiresApi; import androidx.core.app.NotificationCompat; import androidx.preference.PreferenceManager; @@ -34,18 +45,6 @@ import gr.thmmy.mthmmy.model.Bookmark; import gr.thmmy.mthmmy.model.PostNotification; import timber.log.Timber; -import static androidx.core.app.NotificationCompat.PRIORITY_MAX; -import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.NOTIFICATION_LED_KEY; -import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.NOTIFICATION_VIBRATION_KEY; -import static gr.thmmy.mthmmy.activities.settings.SettingsFragment.SELECTED_RINGTONE; -import static gr.thmmy.mthmmy.activities.settings.SettingsFragment.SETTINGS_SHARED_PREFS; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; -import static gr.thmmy.mthmmy.base.BaseActivity.BOOKMARKED_BOARDS_KEY; -import static gr.thmmy.mthmmy.base.BaseActivity.BOOKMARKED_TOPICS_KEY; -import static gr.thmmy.mthmmy.base.BaseActivity.BOOKMARKS_SHARED_PREFS; -import static gr.thmmy.mthmmy.model.Bookmark.matchExistsById; - public class NotificationService extends FirebaseMessagingService { private static final int buildVersion = Build.VERSION.SDK_INT; private static final int disabledNotifiationsLedColor = Color.argb(0, 0, 0, 0); @@ -204,15 +203,13 @@ public class NotificationService extends FirebaseMessagingService { int newPostsCount = 1; - if (buildVersion >= Build.VERSION_CODES.M) { - Notification existingNotification = getActiveNotification(notificationId); - if (existingNotification != null) { - newPostsCount = existingNotification.extras.getInt(NEW_POSTS_COUNT) + 1; - if (isTopicNotification) - contentText = newPostsCount + " new posts"; - else - contentText = newPostsCount + " new posts in " + postNotification.getTopicTitle(); - } + Notification existingNotification = getActiveNotification(notificationId); + if (existingNotification != null) { + newPostsCount = existingNotification.extras.getInt(NEW_POSTS_COUNT) + 1; + if (isTopicNotification) + contentText = newPostsCount + " new posts"; + else + contentText = newPostsCount + " new posts in " + postNotification.getTopicTitle(); } Bundle notificationExtras = new Bundle(); @@ -250,10 +247,7 @@ public class NotificationService extends FirebaseMessagingService { if (buildVersion < Build.VERSION_CODES.O) notificationBuilder.setPriority(PRIORITY_MAX); - boolean createSummaryNotification = false; - if (buildVersion >= Build.VERSION_CODES.M) - createSummaryNotification = otherNotificationsExist(notificationId); - + boolean createSummaryNotification = otherNotificationsExist(notificationId); NotificationCompat.Builder summaryNotificationBuilder = null; if (createSummaryNotification) { @@ -281,7 +275,6 @@ public class NotificationService extends FirebaseMessagingService { notificationManager.notify(SUMMARY_TAG, 0, summaryNotificationBuilder.build()); } - @RequiresApi(api = Build.VERSION_CODES.M) private Notification getActiveNotification(int notificationId) { NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null) { @@ -295,7 +288,6 @@ public class NotificationService extends FirebaseMessagingService { return null; } - @RequiresApi(api = Build.VERSION_CODES.M) private boolean otherNotificationsExist(int notificationId) { NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/session/LogoutTask.java b/app/src/main/java/gr/thmmy/mthmmy/session/LogoutTask.java index 70674dc1..ac952be4 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/session/LogoutTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/session/LogoutTask.java @@ -1,5 +1,8 @@ package gr.thmmy.mthmmy.session; +import static gr.thmmy.mthmmy.session.SessionManager.baseLogoutLink; +import static gr.thmmy.mthmmy.session.SessionManager.indexUrl; + import org.jsoup.nodes.Document; import org.jsoup.select.Elements; @@ -11,9 +14,6 @@ import gr.thmmy.mthmmy.utils.parsing.ParseException; import okhttp3.Response; import timber.log.Timber; -import static gr.thmmy.mthmmy.session.SessionManager.baseLogoutLink; -import static gr.thmmy.mthmmy.session.SessionManager.indexUrl; - public class LogoutTask extends NetworkTask { private String logoutLink; diff --git a/app/src/main/java/gr/thmmy/mthmmy/session/MarkAsReadTask.java b/app/src/main/java/gr/thmmy/mthmmy/session/MarkAsReadTask.java index e815d295..58940e53 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/session/MarkAsReadTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/session/MarkAsReadTask.java @@ -1,5 +1,8 @@ package gr.thmmy.mthmmy.session; +import static gr.thmmy.mthmmy.session.SessionManager.baseMarkAllAsReadLink; +import static gr.thmmy.mthmmy.session.SessionManager.unreadUrl; + import org.jsoup.nodes.Document; import org.jsoup.select.Elements; @@ -9,9 +12,6 @@ import gr.thmmy.mthmmy.utils.networking.NetworkTask; import gr.thmmy.mthmmy.utils.parsing.ParseException; import okhttp3.Response; -import static gr.thmmy.mthmmy.session.SessionManager.baseMarkAllAsReadLink; -import static gr.thmmy.mthmmy.session.SessionManager.unreadUrl; - public class MarkAsReadTask extends NetworkTask { private String markAsReadLink; diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/DateTimeUtils.java b/app/src/main/java/gr/thmmy/mthmmy/utils/DateTimeUtils.java index deae8522..4064311b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/DateTimeUtils.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/DateTimeUtils.java @@ -1,13 +1,13 @@ package gr.thmmy.mthmmy.utils; -import androidx.annotation.VisibleForTesting; - import static android.text.format.DateUtils.DAY_IN_MILLIS; import static android.text.format.DateUtils.HOUR_IN_MILLIS; import static android.text.format.DateUtils.MINUTE_IN_MILLIS; import static android.text.format.DateUtils.SECOND_IN_MILLIS; import static android.text.format.DateUtils.YEAR_IN_MILLIS; +import androidx.annotation.VisibleForTesting; + public class DateTimeUtils { private static final long MONTH_IN_MILLIS = 30 * DAY_IN_MILLIS; diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/FileUtils.java b/app/src/main/java/gr/thmmy/mthmmy/utils/FileUtils.java index 34a4f831..d5ea88e8 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/FileUtils.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/FileUtils.java @@ -1,5 +1,7 @@ package gr.thmmy.mthmmy.utils; +import static gr.thmmy.mthmmy.services.DownloadHelper.SAVE_DIR; + import android.content.Context; import android.database.Cursor; import android.net.Uri; @@ -10,18 +12,17 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.io.File; +import java.util.Locale; import gr.thmmy.mthmmy.R; -import static gr.thmmy.mthmmy.services.DownloadHelper.SAVE_DIR; - public class FileUtils { @NonNull public static String getMimeType(@NonNull String fileName) { String type = null; final String extension = MimeTypeMap.getFileExtensionFromUrl(fileName); if (extension != null) - type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase()); + type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase(Locale.ROOT)); if (type == null) type = "*/*"; @@ -39,7 +40,7 @@ public class FileUtils { if (!filename.contains(".")) { return null; } - if (filename.toLowerCase().endsWith(".tar.gz")) { + if (filename.toLowerCase(Locale.ROOT).endsWith(".tar.gz")) { fileExtension = filename.substring(filename.length() - 7); } else { @@ -63,7 +64,9 @@ public class FileUtils { if (uri.getScheme().equals("content")) { try (Cursor cursor = context.getContentResolver().query(uri, null, null, null, null)) { if (cursor != null && cursor.moveToFirst()) { - filename = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + final int columnIndex = (cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + if(columnIndex>=0) + filename = cursor.getString(columnIndex); } } } @@ -81,7 +84,9 @@ public class FileUtils { public static long sizeFromUri(Context context, @NonNull Uri uri) { try (Cursor cursor = context.getContentResolver().query(uri, null, null, null, null)) { if (cursor != null && cursor.moveToFirst()) { - return cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE)); + final int columnIndex = (cursor.getColumnIndex(OpenableColumns.SIZE)); + if(columnIndex>=0) + return cursor.getLong(columnIndex); } } return -1; @@ -97,7 +102,7 @@ public class FileUtils { */ @NonNull public static String faIconFromFilename(Context context, String filename) { - filename = filename.toLowerCase(); + filename = filename.toLowerCase(Locale.ROOT); if (filename.contains("jpg") || filename.contains("gif") || filename.contains("jpeg") || filename.contains("png")) diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/HTMLUtils.java b/app/src/main/java/gr/thmmy/mthmmy/utils/HTMLUtils.java index cc2773e6..600fd9ee 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/HTMLUtils.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/HTMLUtils.java @@ -1,5 +1,12 @@ package gr.thmmy.mthmmy.utils; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; +import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; + import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -17,13 +24,6 @@ import gr.thmmy.mthmmy.activities.main.MainActivity; import gr.thmmy.mthmmy.activities.profile.ProfileActivity; import gr.thmmy.mthmmy.model.ThmmyPage; -import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; -import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; -import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; - public class HTMLUtils { private HTMLUtils() { } diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/ui/ImageDownloadDialogBuilder.java b/app/src/main/java/gr/thmmy/mthmmy/utils/ui/ImageDownloadDialogBuilder.java index 0b80d646..da800021 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/ui/ImageDownloadDialogBuilder.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/ui/ImageDownloadDialogBuilder.java @@ -1,5 +1,7 @@ package gr.thmmy.mthmmy.utils.ui; +import static android.content.Context.CLIPBOARD_SERVICE; + import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -18,8 +20,6 @@ import gr.thmmy.mthmmy.base.BaseApplication; import gr.thmmy.mthmmy.model.ThmmyFile; import timber.log.Timber; -import static android.content.Context.CLIPBOARD_SERVICE; - public class ImageDownloadDialogBuilder extends AlertDialog.Builder { private static final String[] colors = {"Copy image location", "Save Image"}; diff --git a/app/src/main/java/gr/thmmy/mthmmy/views/ReactiveWebView.java b/app/src/main/java/gr/thmmy/mthmmy/views/ReactiveWebView.java index c81675e3..a96eeb93 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/views/ReactiveWebView.java +++ b/app/src/main/java/gr/thmmy/mthmmy/views/ReactiveWebView.java @@ -1,5 +1,9 @@ package gr.thmmy.mthmmy.views; +import static android.content.Context.CLIPBOARD_SERVICE; +import static gr.thmmy.mthmmy.utils.parsing.ParseHelpers.VIDEO_ID_PARAMETER; +import static gr.thmmy.mthmmy.utils.ui.PhotoViewUtils.displayPhotoViewImage; + import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -13,10 +17,6 @@ import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.base.BaseApplication; import gr.thmmy.mthmmy.utils.ui.ImageDownloadDialogBuilder; -import static android.content.Context.CLIPBOARD_SERVICE; -import static gr.thmmy.mthmmy.utils.parsing.ParseHelpers.VIDEO_ID_PARAMETER; -import static gr.thmmy.mthmmy.utils.ui.PhotoViewUtils.displayPhotoViewImage; - public class ReactiveWebView extends WebView { private final static long MAX_TOUCH_DURATION = 100; private final Context context; diff --git a/app/src/main/java/gr/thmmy/mthmmy/views/RelativeTimeTextView.java b/app/src/main/java/gr/thmmy/mthmmy/views/RelativeTimeTextView.java index b0678633..f6517228 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/views/RelativeTimeTextView.java +++ b/app/src/main/java/gr/thmmy/mthmmy/views/RelativeTimeTextView.java @@ -1,5 +1,7 @@ package gr.thmmy.mthmmy.views; +import static gr.thmmy.mthmmy.utils.DateTimeUtils.getRelativeTimeSpanString; + import android.annotation.SuppressLint; import android.content.Context; import android.content.res.TypedArray; @@ -15,8 +17,6 @@ import java.lang.ref.WeakReference; import gr.thmmy.mthmmy.R; -import static gr.thmmy.mthmmy.utils.DateTimeUtils.getRelativeTimeSpanString; - /** * A modified version of https://github.com/curioustechizen/android-ago */ diff --git a/app/src/main/java/gr/thmmy/mthmmy/views/editorview/EditorView.java b/app/src/main/java/gr/thmmy/mthmmy/views/editorview/EditorView.java index b5c65f0a..f3831397 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/views/editorview/EditorView.java +++ b/app/src/main/java/gr/thmmy/mthmmy/views/editorview/EditorView.java @@ -8,7 +8,6 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import android.os.Build; import android.text.Editable; import android.text.TextUtils; import android.util.AttributeSet; @@ -201,24 +200,24 @@ public class EditorView extends LinearLayout implements EmojiInputField { }); } popupWindow.showAsDropDown(view); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - new AsyncTask() { - @Override - protected Void doInBackground(Void... voids) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - Timber.e(e); - } - return null; - } - @Override - protected void onPostExecute(Void aVoid) { - editText.setSelection(selectionStart, selectionEnd); + new AsyncTask() { + @Override + protected Void doInBackground(Void... voids) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + Timber.e(e); } - }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + editText.setSelection(selectionStart, selectionEnd); + } + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + break; case R.drawable.ic_format_size: hadTextSelection = editText.hasSelection(); diff --git a/app/src/main/res/layout-v23/activity_topic_overflow_menu.xml b/app/src/main/res/layout-v23/activity_topic_overflow_menu.xml deleted file mode 100644 index 63fd97a2..00000000 --- a/app/src/main/res/layout-v23/activity_topic_overflow_menu.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic_overflow_menu.xml b/app/src/main/res/layout/activity_topic_overflow_menu.xml index 2b7f1634..63fd97a2 100644 --- a/app/src/main/res/layout/activity_topic_overflow_menu.xml +++ b/app/src/main/res/layout/activity_topic_overflow_menu.xml @@ -2,13 +2,15 @@ + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 68581bed..98c614f8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Dec 03 14:56:57 EET 2020 +#Sun Apr 02 13:22:00 EEST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip From 5ccfdc55abaf64ff141d926f32790cc9b7f156d3 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 14 Jun 2023 08:45:08 +0300 Subject: [PATCH 09/14] refactor: rename Github organization --- CONTRIBUTING.md | 8 ++++---- PRIVACY.md | 2 +- README.md | 4 ++-- app/src/main/assets/PRIVACY.md | 2 +- .../java/gr/thmmy/mthmmy/activities/AboutActivity.java | 2 +- app/src/main/res/values/strings.xml | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f53cf71..e7210da9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,15 +35,15 @@ Pull requests with fixes and improvements to mTHMMY are most welcome. Any develo follow the workflow below to make a pull request (PR): 1. Fork the project into your personal space on Github -1. Create a feature branch, away from [develop](https://github.com/ThmmyNoLife/mTHMMY/tree/develop) +1. Create a feature branch, away from [develop](https://github.com/THMMYgr/mTHMMY/tree/develop) 1. Push the commit(s) to your fork -1. Create a PR targeting [develop at mTHMMY](https://github.com/ThmmyNoLife/mTHMMY/tree/develop) +1. Create a PR targeting [develop at mTHMMY](https://github.com/THMMYgr/mTHMMY/tree/develop) 1. Fill the PR title describing the change you want to make 1. Fill the PR description with a brief motive for your change and the method you used to achieve it 1. Submit the PR. [google-play]: https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy -[github-issues]: https://github.com/ThmmyNoLife/mTHMMY/issues +[github-issues]: https://github.com/THMMYgr/mTHMMY/issues [discord-server]: https://discord.gg/CVt3yrn -[sisyphus]: https://github.com/ThmmyNoLife/Sisyphus +[sisyphus]: https://github.com/THMMYgr/Sisyphus [firebase-console]: https://console.firebase.google.com/ diff --git a/PRIVACY.md b/PRIVACY.md index 8e69038c..dcae6885 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -69,7 +69,7 @@ mTHMMY may contain links to third-party websites. Any access to and use of such ## Policy Updates -We may update this Privacy Policy from time to time and, thus, you are advised to review it periodically. The most recent version of our Privacy Policy can be found at . +We may update this Privacy Policy from time to time and, thus, you are advised to review it periodically. The most recent version of our Privacy Policy can be found at . ## Contact Us diff --git a/README.md b/README.md index d0abfee1..c1d3d8c5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # mTHMMY -[![GitHub release](https://img.shields.io/github/release/ThmmyNoLife/mTHMMY.svg?color=orange)](https://github.com/ThmmyNoLife/mTHMMY/releases) +[![GitHub release](https://img.shields.io/github/release/THMMYgr/mTHMMY.svg?color=orange)](https://github.com/THMMYgr/mTHMMY/releases) [![API](https://img.shields.io/badge/API-21%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=21) [![Discord Channel](https://img.shields.io/discord/252539000571559947?style=flat&color=738bd7&label=discord)][discord-server] -![Last Commit](https://img.shields.io/github/last-commit/ThmmyNoLife/mTHMMY/develop.svg?style=flat) +![Last Commit](https://img.shields.io/github/last-commit/THMMYgr/mTHMMY/develop.svg?style=flat) ![mTHMMY logo](app/src/main/res/mipmap-xhdpi/ic_launcher_round.png) diff --git a/app/src/main/assets/PRIVACY.md b/app/src/main/assets/PRIVACY.md index 8e69038c..dcae6885 100644 --- a/app/src/main/assets/PRIVACY.md +++ b/app/src/main/assets/PRIVACY.md @@ -69,7 +69,7 @@ mTHMMY may contain links to third-party websites. Any access to and use of such ## Policy Updates -We may update this Privacy Policy from time to time and, thus, you are advised to review it periodically. The most recent version of our Privacy Policy can be found at . +We may update this Privacy Policy from time to time and, thus, you are advised to review it periodically. The most recent version of our Privacy Policy can be found at . ## Contact Us diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java index 4fb4805b..b0af3c94 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java @@ -105,7 +105,7 @@ public class AboutActivity extends BaseActivity { if (gitExists) { versionTextView.setOnClickListener(view -> { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/ThmmyNoLife/mTHMMY/commit/" + BuildConfig.COMMIT_HASH)); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/THMMYgr/mTHMMY/commit/" + BuildConfig.COMMIT_HASH)); startActivity(intent); }); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 458250d0..27dcaa67 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -102,7 +102,7 @@ Do not hesitate to contact us for any technical matter, either by email at thmmynolife@gmail.com, or by joining our Discord server using https://discord.gg/CVt3yrn​. For account-related issues, please contact the administration team of thmmy.gr by email at contact@thmmy.gr. Open Source - The source code of mTHMMY can be found on Github at https://github.com/ThmmyNoLife/mTHMMY, along with further details of how one can contribute. + The source code of mTHMMY can be found on Github at https://github.com/THMMYgr/mTHMMY, along with further details of how one can contribute. You should see a funny pic! Privacy policy From b60e2e5458b94b3cbf38df729e7f52ae65996bce Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 14 Jun 2023 08:55:38 +0300 Subject: [PATCH 10/14] refactor: change contact email --- CONTRIBUTING.md | 4 ++-- PRIVACY.md | 4 ++-- README.md | 2 +- app/src/main/assets/PRIVACY.md | 2 +- app/src/main/res/values/strings.xml | 3 +-- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e7210da9..e7477cd8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ to contribute to mTHMMY in a way that is efficient for everyone. **Important!** Instead of creating publicly viewable issues for suspected security vulnerabilities, please report them in private to -[thmmynolife@gmail.com](mailto:thmmynolife@gmail.com). +[contact@thmmy.gr](mailto:contact@thmmy.gr). ## I want to contribute! @@ -18,7 +18,7 @@ There are many ways of contributing to mTHMMY: - Submitting bugs and ideas to our [issue tracker][github-issues] - Forking mTHMMY and submitting [pull requests](#pull-requests) - Joining our core team -- Contacting us by email at [thmmynolife@gmail.com](mailto:thmmynolife@gmail.com) +- Contacting us by email at [contact@thmmy.gr](mailto:contact@thmmy.gr) ## Issue tracker diff --git a/PRIVACY.md b/PRIVACY.md index dcae6885..f0fde751 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -29,7 +29,7 @@ The use of each Firebase service is explained below: ### Firebase Cloud Messaging -* **Purpose**: This service is essential for the funcionality of the App. It uses anonymous push notification tokens in order to determine which devices to deliver the appropriate messages to. +* **Purpose**: This service is essential for the functionality of the App. It uses anonymous push notification tokens in order to determine which devices to deliver the appropriate messages to. * **Data collected**: Instance IDs. * **Consent**: You will be prompted to agree to the use of this service when you open the App for the first time. * **Retention**: Firebase retains Instance IDs until we make an API call for deletion. After the call, data are removed from live and backup systems within 180 days. @@ -73,4 +73,4 @@ We may update this Privacy Policy from time to time and, thus, you are advised t ## Contact Us -If you have any questions about our Privacy Policy, please contact us at [thmmynolife@gmail.com](mailto:thmmynolife@gmail.com). +If you have any questions about our Privacy Policy, please contact us at [contact@thmmy.gr](mailto:contact@thmmy.gr). diff --git a/README.md b/README.md index c1d3d8c5..321f2263 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Our Privacy Policy can be found [here](/PRIVACY.md). ## Contact -Do not hesitate to contact us for any matter, either by sending an email to [thmmynolife@gmail.com](mailto:thmmynolife@gmail.com), or by joining our [Discord server][discord-server]. +Do not hesitate to contact us for any matter, either by sending an email to [contact@thmmy.gr](mailto:contact@thmmy.gr), or by joining our [Discord server][discord-server]. **Legal attribution: Google Play and the Google Play logo are trademarks of Google Inc.* diff --git a/app/src/main/assets/PRIVACY.md b/app/src/main/assets/PRIVACY.md index dcae6885..85baa46f 100644 --- a/app/src/main/assets/PRIVACY.md +++ b/app/src/main/assets/PRIVACY.md @@ -73,4 +73,4 @@ We may update this Privacy Policy from time to time and, thus, you are advised t ## Contact Us -If you have any questions about our Privacy Policy, please contact us at [thmmynolife@gmail.com](mailto:thmmynolife@gmail.com). +If you have any questions about our Privacy Policy, please contact us at [contact@thmmy.gr](mailto:contact@thmmy.gr). diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 27dcaa67..7034861f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -99,8 +99,7 @@ Eclipse Public License v1.0 libraries Other libraries Contact - Do not hesitate to contact us for any technical matter, either by email at thmmynolife@gmail.com, or by joining our Discord server using https://discord.gg/CVt3yrn​. - For account-related issues, please contact the administration team of thmmy.gr by email at contact@thmmy.gr. + Do not hesitate to contact us for any matter, either by email at contact@thmmy.gr, or by joining our Discord server using https://discord.gg/CVt3yrn​. Open Source The source code of mTHMMY can be found on Github at https://github.com/THMMYgr/mTHMMY, along with further details of how one can contribute. You should see a funny pic! From 1c3135dc9e45fa403f6d60e848072c34b70fbfe2 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 14 Jun 2023 08:56:08 +0300 Subject: [PATCH 11/14] chore: up version --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2245efc8..e2b0d0f1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { applicationId "gr.thmmy.mthmmy" minSdkVersion 23 targetSdkVersion 33 - versionCode 31 - versionName "2.1.0" + versionCode 32 + versionName "2.1.1" archivesBaseName = "mTHMMY-v$versionName" buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\"" buildConfigField "String", "COMMIT_HASH", "\"" + getCommitHash() + "\"" From 8711121b11acd671769619de41bd1af262a8dd4a Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 14 Jun 2023 09:05:50 +0300 Subject: [PATCH 12/14] fix: disable broken Uploads --- .../downloads/DownloadsActivity.java | 44 +++++++++---------- .../activities/upload/UploadActivity.java | 4 +- .../upload/UploadFieldsBuilderActivity.java | 2 +- .../gr/thmmy/mthmmy/base/BaseActivity.java | 32 +++++++------- .../main/res/layout/activity_downloads.xml | 22 +++++----- .../main/res/xml-v26/app_preferences_user.xml | 12 ----- app/src/main/res/xml/app_preferences_user.xml | 12 ----- 7 files changed, 52 insertions(+), 76 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java index 0ffdaf9c..793a6bba 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java @@ -57,7 +57,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. private MaterialProgressBar progressBar; private RecyclerView recyclerView; private DownloadsAdapter downloadsAdapter; - private FloatingActionButton uploadFAB; +// private FloatingActionButton uploadFAB; private ParseDownloadPageTask parseDownloadPageTask; private int numberOfPages = -1; @@ -124,9 +124,9 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. } }); - uploadFAB = findViewById(R.id.upload_fab); - uploadFAB.setEnabled(false); - uploadFAB.hide(); +// uploadFAB = findViewById(R.id.upload_fab); +// uploadFAB.setEnabled(false); +// uploadFAB.hide(); parseDownloadPageTask = new ParseDownloadPageTask(); parseDownloadPageTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, downloadsUrl); @@ -135,26 +135,26 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflates the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.downloads_menu, menu); +// getMenuInflater().inflate(R.menu.downloads_menu, menu); super.onCreateOptionsMenu(menu); return true; } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle presses on the action bar items - switch (item.getItemId()) { - case R.id.menu_upload: - Intent intent = new Intent(DownloadsActivity.this, UploadActivity.class); - Bundle extras = new Bundle(); - extras.putString(BUNDLE_UPLOAD_CATEGORY, downloadsNav); - intent.putExtras(extras); - startActivity(intent); - return true; - default: - return super.onOptionsItemSelected(item); - } - } +// @Override +// public boolean onOptionsItemSelected(MenuItem item) { +// // Handle presses on the action bar items +// switch (item.getItemId()) { +// case R.id.menu_upload: +// Intent intent = new Intent(DownloadsActivity.this, UploadActivity.class); +// Bundle extras = new Bundle(); +// extras.putString(BUNDLE_UPLOAD_CATEGORY, downloadsNav); +// intent.putExtras(extras); +// startActivity(intent); +// return true; +// default: +// return super.onOptionsItemSelected(item); +// } +// } @Override public void onLoadMore() { @@ -210,7 +210,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. @Override protected void onPreExecute() { if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE); - if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(false); +// if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(false); } @Override @@ -312,7 +312,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. toolbar.setTitle(downloadsTitle); ++pagesLoaded; - if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(true); +// if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(true); progressBar.setVisibility(ProgressBar.INVISIBLE); downloadsAdapter.notifyDataSetChanged(); isLoadingMore = false; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java index 3f64a81c..2cffbfc8 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java @@ -169,7 +169,7 @@ public class UploadActivity extends BaseActivity { } createDrawer(); - drawer.setSelection(UPLOAD_ID); +// drawer.setSelection(UPLOAD_ID); progressBar = findViewById(R.id.progressBar); @@ -434,7 +434,7 @@ public class UploadActivity extends BaseActivity { @Override protected void onResume() { - drawer.setSelection(UPLOAD_ID); +// drawer.setSelection(UPLOAD_ID); super.onResume(); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java index b4d88805..5e7af4b6 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java @@ -99,7 +99,7 @@ public class UploadFieldsBuilderActivity extends BaseActivity { } createDrawer(); - drawer.setSelection(UPLOAD_ID, false); +// drawer.setSelection(UPLOAD_ID, false); semesterChooserLinear = findViewById(R.id.upload_fields_builder_choose_semester); semesterRadio = findViewById(R.id.upload_fields_builder_semester_radio_group); diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index 7c3a009c..9a8f45d4 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -167,7 +167,7 @@ public abstract class BaseActivity extends AppCompatActivity { //------------------------------------------DRAWER STUFF---------------------------------------- protected static final int HOME_ID = 0; protected static final int DOWNLOADS_ID = 1; - protected static final int UPLOAD_ID = 2; + //protected static final int UPLOAD_ID = 2; //Removed until fixed protected static final int BOOKMARKS_ID = 3; protected static final int LOG_ID = 4; protected static final int ABOUT_ID = 5; @@ -267,14 +267,14 @@ public abstract class BaseActivity extends AppCompatActivity { .withIcon(downloadsIcon) .withSelectedIcon(downloadsIconSelected); - uploadItem = new PrimaryDrawerItem() - .withTextColor(primaryColor) - .withSelectedColor(selectedPrimaryColor) - .withSelectedTextColor(selectedSecondaryColor) - .withIdentifier(UPLOAD_ID) - .withName(R.string.upload) - .withIcon(uploadIcon) - .withSelectedIcon(uploadIconSelected); +// uploadItem = new PrimaryDrawerItem() +// .withTextColor(primaryColor) +// .withSelectedColor(selectedPrimaryColor) +// .withSelectedTextColor(selectedSecondaryColor) +// .withIdentifier(UPLOAD_ID) +// .withName(R.string.upload) +// .withIcon(uploadIcon) +// .withSelectedIcon(uploadIconSelected); shoutboxItem = new PrimaryDrawerItem() .withTextColor(primaryColor) @@ -395,12 +395,12 @@ public abstract class BaseActivity extends AppCompatActivity { startActivity(intent); } } - else if (drawerItem.equals(UPLOAD_ID)) { - if (!(BaseActivity.this instanceof UploadActivity)) { - Intent intent = new Intent(BaseActivity.this, UploadActivity.class); - startActivity(intent); - } - } +// else if (drawerItem.equals(UPLOAD_ID)) { +// if (!(BaseActivity.this instanceof UploadActivity)) { +// Intent intent = new Intent(BaseActivity.this, UploadActivity.class); +// startActivity(intent); +// } +// } else if (drawerItem.equals(BOOKMARKS_ID)) { if (!(BaseActivity.this instanceof BookmarksActivity)) { Intent intent = new Intent(BaseActivity.this, BookmarksActivity.class); @@ -453,7 +453,7 @@ public abstract class BaseActivity extends AppCompatActivity { if (drawer != null) { if (!sessionManager.isLoggedIn()) { //When logged out or if user is guest drawer.removeItem(DOWNLOADS_ID); - drawer.removeItem(UPLOAD_ID); + //drawer.removeItem(UPLOAD_ID); loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login profileDrawerItem.withName(sessionManager.getUsername()); setDefaultAvatar(); diff --git a/app/src/main/res/layout/activity_downloads.xml b/app/src/main/res/layout/activity_downloads.xml index ed65473e..23e8ad45 100644 --- a/app/src/main/res/layout/activity_downloads.xml +++ b/app/src/main/res/layout/activity_downloads.xml @@ -20,7 +20,7 @@ android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" - app:popupTheme="@style/ToolbarTheme"> + app:popupTheme="@style/ToolbarTheme" /> + tools:context="gr.thmmy.mthmmy.activities.downloads.DownloadsActivity" /> - + + + + + + + + + diff --git a/app/src/main/res/xml-v26/app_preferences_user.xml b/app/src/main/res/xml-v26/app_preferences_user.xml index 6d5489b5..47ca581e 100644 --- a/app/src/main/res/xml-v26/app_preferences_user.xml +++ b/app/src/main/res/xml-v26/app_preferences_user.xml @@ -40,18 +40,6 @@ app:iconSpaceReserved="false" /> - - - - - - - - Date: Thu, 15 Jun 2023 18:41:26 +0300 Subject: [PATCH 13/14] fix: version --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index e2b0d0f1..0b33d6d3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,7 +14,7 @@ android { minSdkVersion 23 targetSdkVersion 33 versionCode 32 - versionName "2.1.1" + versionName "2.2.0" archivesBaseName = "mTHMMY-v$versionName" buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\"" buildConfigField "String", "COMMIT_HASH", "\"" + getCommitHash() + "\"" From 1fa7bc7c0d8a026f2874eaee7c8d19efa481d3d3 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Thu, 15 Jun 2023 19:21:10 +0300 Subject: [PATCH 14/14] fix: missing space --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7034861f..38263d6c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -99,7 +99,7 @@ Eclipse Public License v1.0 libraries Other libraries Contact - Do not hesitate to contact us for any matter, either by email at contact@thmmy.gr, or by joining our Discord server using https://discord.gg/CVt3yrn​. + Do not hesitate to contact us for any matter, either by email at contact@thmmy.gr, or by joining our Discord server using https://discord.gg/CVt3yrn . Open Source The source code of mTHMMY can be found on Github at https://github.com/THMMYgr/mTHMMY, along with further details of how one can contribute. You should see a funny pic!