diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/BookmarkActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/BookmarkActivity.java
index 48aa8067..db549c12 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/BookmarkActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/BookmarkActivity.java
@@ -1,16 +1,29 @@
package gr.thmmy.mthmmy.activities;
+import android.content.Intent;
+import android.graphics.Typeface;
+import android.os.Build;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import gr.thmmy.mthmmy.R;
+import gr.thmmy.mthmmy.activities.board.BoardActivity;
+import gr.thmmy.mthmmy.activities.topic.TopicActivity;
import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.model.Bookmark;
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;
+
public class BookmarkActivity extends BaseActivity {
ProgressBar progressBar;
@@ -30,32 +43,103 @@ public class BookmarkActivity extends BaseActivity {
createDrawer();
drawer.setSelection(BOOKMARKS_ID);
-
progressBar = (MaterialProgressBar) findViewById(R.id.progressBar);
LinearLayout bookmarksLinearView = (LinearLayout) findViewById(R.id.bookmarks_container);
+ LayoutInflater layoutInflater = getLayoutInflater();
TextView tmp = new TextView(this);
- tmp.setText("Your bookmarked boards:");
+ tmp.setLayoutParams(new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT
+ , LinearLayout.LayoutParams.WRAP_CONTENT));
+ tmp.setText(getString(R.string.board_bookmarks_title));
+ tmp.setTypeface(tmp.getTypeface(), Typeface.BOLD);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ tmp.setTextColor(getColor(R.color.primary_text));
+ } else {
+ //noinspection deprecation
+ tmp.setTextColor(getResources().getColor(R.color.primary_text));
+ }
+ tmp.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
+ tmp.setTextSize(20f);
bookmarksLinearView.addView(tmp);
- for (Bookmark bookmarkedBoard : getBoardsBookmarked()) {
+ for (final Bookmark bookmarkedBoard : getBoardsBookmarked()) {
if (bookmarkedBoard != null && bookmarkedBoard.getTitle() != null) {
- TextView bookmarkedBoardView = new TextView(this);
- bookmarkedBoardView.setText(bookmarkedBoard.getTitle());
- bookmarksLinearView.addView(bookmarkedBoardView);
+ Log.d("TAG", bookmarkedBoard.getTitle() + " - " + bookmarkedBoard.getId());
+ final LinearLayout row = (LinearLayout) layoutInflater.inflate(
+ R.layout.activity_bookmark_row, bookmarksLinearView, false);
+ row.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Log.d("TAG", "https://www.thmmy.gr/smf/index.php?board="
+ + bookmarkedBoard.getId() + ".0");
+ Log.d("TAG", bookmarkedBoard.getTitle());
+ Intent intent = new Intent(BookmarkActivity.this, BoardActivity.class);
+ Bundle extras = new Bundle();
+ extras.putString(BUNDLE_BOARD_URL, "https://www.thmmy.gr/smf/index.php?board="
+ + bookmarkedBoard.getId() + ".0");
+ extras.putString(BUNDLE_BOARD_TITLE, bookmarkedBoard.getTitle());
+ intent.putExtras(extras);
+ startActivity(intent);
+ finish();
+ }
+ });
+ ((TextView) row.findViewById(R.id.bookmark_title)).setText(bookmarkedBoard.getTitle());
+ (row.findViewById(R.id.remove_bookmark)).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ removeBookmark(bookmarkedBoard);
+ row.setVisibility(View.GONE);
+ }
+ });
+ bookmarksLinearView.addView(row);
}
}
tmp = new TextView(this);
- tmp.setText("Your bookmarked topics:");
+ tmp.setLayoutParams(new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT
+ , LinearLayout.LayoutParams.WRAP_CONTENT));
+ tmp.setText(getString(R.string.topic_bookmarks_title));
+ tmp.setTypeface(tmp.getTypeface(), Typeface.BOLD);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ tmp.setTextColor(getColor(R.color.primary_text));
+ } else {
+ //noinspection deprecation
+ tmp.setTextColor(getResources().getColor(R.color.primary_text));
+ }
+ tmp.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
+ tmp.setTextSize(20f);
bookmarksLinearView.addView(tmp);
- for (Bookmark bookmarkedTopic : getTopicsBookmarked()) {
+ for (final Bookmark bookmarkedTopic : getTopicsBookmarked()) {
if (bookmarkedTopic != null && bookmarkedTopic.getTitle() != null) {
- TextView bookmarkedTopicView = new TextView(this);
- bookmarkedTopicView.setText(bookmarkedTopic.getTitle());
- bookmarksLinearView.addView(bookmarkedTopicView);
+ Log.d("TAG", bookmarkedTopic.getTitle() + " - " + bookmarkedTopic.getId());
+ final LinearLayout row = (LinearLayout) layoutInflater.inflate(
+ R.layout.activity_bookmark_row, bookmarksLinearView, false);
+ row.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Intent intent = new Intent(BookmarkActivity.this, TopicActivity.class);
+ Bundle extras = new Bundle();
+ extras.putString(BUNDLE_TOPIC_URL, "https://www.thmmy.gr/smf/index.php?topic="
+ + bookmarkedTopic.getId() + ".0");
+ extras.putString(BUNDLE_TOPIC_TITLE, bookmarkedTopic.getTitle());
+ intent.putExtras(extras);
+ startActivity(intent);
+ finish();
+ }
+ });
+ ((TextView) row.findViewById(R.id.bookmark_title)).setText(bookmarkedTopic.getTitle());
+ (row.findViewById(R.id.remove_bookmark)).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ removeBookmark(bookmarkedTopic);
+ row.setVisibility(View.GONE);
+ }
+ });
+ bookmarksLinearView.addView(row);
}
}
}
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 77067287..ec656a78 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
@@ -91,7 +91,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
- thisPageBookmark = new Bookmark(boardTitle, boardUrl);
+ thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl));
thisPageBookmarkButton = (ImageButton) findViewById(R.id.bookmark);
setBoardBookmark();
createDrawer();
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 b3af480e..ac6429dc 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
@@ -498,6 +498,11 @@ public abstract class BaseActivity extends AppCompatActivity {
SharedPreferences.Editor editor = bookmarksFile.edit();
editor.putString(BOOKMARKED_TOPICS_KEY, tmpString).apply();
}
+
+ protected void removeBookmark(Bookmark bookmark) {
+ if (bookmark.matchExists(boardsBookmarked)) toggleBoardToBookmarks(bookmark);
+ else if (bookmark.matchExists(topicsBookmarked)) toggleTopicToBookmarks(bookmark);
+ }
//-------------------------------------------BOOKMARKS END------------------------------------------
//-------PERMS---------
diff --git a/app/src/main/res/layout/activity_bookmark_row.xml b/app/src/main/res/layout/activity_bookmark_row.xml
new file mode 100644
index 00000000..6b02728b
--- /dev/null
+++ b/app/src/main/res/layout/activity_bookmark_row.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
\ 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 06d28a45..1640a038 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -56,7 +56,12 @@
v%1$s
Logo
- You should watch a funny pic!
+ You should see a funny pic!
+
+
+ Remove
+ Your bookmarked boards:
+ Your bookmarked topics:
Libraries