diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fb7c2b6a..7620bcf7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -124,7 +124,7 @@ android:value=".activities.upload.UploadActivity" /> diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java similarity index 83% rename from app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java rename to app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java index 20ecfd28..0a65da94 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java @@ -27,11 +27,11 @@ import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; //TODO proper handling with adapter etc. //TODO after clicking bookmark and then back button should return to this activity -public class BookmarkActivity extends BaseActivity { +public class BookmarksActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_bookmark); + setContentView(R.layout.activity_bookmarks); //Initialize toolbar toolbar = findViewById(R.id.toolbar); @@ -47,8 +47,8 @@ public class BookmarkActivity extends BaseActivity { //Creates the adapter that will return a fragment for each section of the activity SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); - sectionsPagerAdapter.addFragment(TopicBookmarksFragment.newInstance(1, Bookmark.arrayToString(getTopicsBookmarked())), "Topics"); - sectionsPagerAdapter.addFragment(BoardBookmarksFragment.newInstance(2, Bookmark.arrayToString(getBoardsBookmarked())), "Boards"); + sectionsPagerAdapter.addFragment(BookmarksTopicFragment.newInstance(1, Bookmark.arrayToString(getTopicsBookmarked())), "Topics"); + sectionsPagerAdapter.addFragment(BookmarksBoardFragment.newInstance(2, Bookmark.arrayToString(getBoardsBookmarked())), "Boards"); //Sets up the ViewPager with the sections adapter. ViewPager viewPager = findViewById(R.id.bookmarks_container); @@ -66,8 +66,8 @@ public class BookmarkActivity extends BaseActivity { public boolean onTopicInteractionListener(String interactionType, Bookmark bookmarkedTopic) { switch (interactionType) { - case TopicBookmarksFragment.INTERACTION_CLICK_TOPIC_BOOKMARK: - Intent intent = new Intent(BookmarkActivity.this, TopicActivity.class); + case BookmarksTopicFragment.INTERACTION_CLICK_TOPIC_BOOKMARK: + Intent intent = new Intent(BookmarksActivity.this, TopicActivity.class); Bundle extras = new Bundle(); extras.putString(BUNDLE_TOPIC_URL, "https://www.thmmy.gr/smf/index.php?topic=" + bookmarkedTopic.getId() + "." + 2147483647); @@ -75,11 +75,11 @@ public class BookmarkActivity extends BaseActivity { intent.putExtras(extras); startActivity(intent); break; - case TopicBookmarksFragment.INTERACTION_TOGGLE_TOPIC_NOTIFICATION: + case BookmarksTopicFragment.INTERACTION_TOGGLE_TOPIC_NOTIFICATION: return toggleNotification(bookmarkedTopic); - case TopicBookmarksFragment.INTERACTION_REMOVE_TOPIC_BOOKMARK: + case BookmarksTopicFragment.INTERACTION_REMOVE_TOPIC_BOOKMARK: removeBookmark(bookmarkedTopic); - Toast.makeText(BookmarkActivity.this, "Bookmark removed", Toast.LENGTH_SHORT).show(); + Toast.makeText(BookmarksActivity.this, "Bookmark removed", Toast.LENGTH_SHORT).show(); break; } return true; @@ -87,8 +87,8 @@ public class BookmarkActivity extends BaseActivity { public boolean onBoardInteractionListener(String interactionType, Bookmark bookmarkedBoard) { switch (interactionType) { - case BoardBookmarksFragment.INTERACTION_CLICK_BOARD_BOOKMARK: - Intent intent = new Intent(BookmarkActivity.this, BoardActivity.class); + case BookmarksBoardFragment.INTERACTION_CLICK_BOARD_BOOKMARK: + Intent intent = new Intent(BookmarksActivity.this, BoardActivity.class); Bundle extras = new Bundle(); extras.putString(BUNDLE_BOARD_URL, "https://www.thmmy.gr/smf/index.php?board=" + bookmarkedBoard.getId() + ".0"); @@ -96,11 +96,11 @@ public class BookmarkActivity extends BaseActivity { intent.putExtras(extras); startActivity(intent); break; - case BoardBookmarksFragment.INTERACTION_TOGGLE_BOARD_NOTIFICATION: + case BookmarksBoardFragment.INTERACTION_TOGGLE_BOARD_NOTIFICATION: return toggleNotification(bookmarkedBoard); - case BoardBookmarksFragment.INTERACTION_REMOVE_BOARD_BOOKMARK: + case BookmarksBoardFragment.INTERACTION_REMOVE_BOARD_BOOKMARK: removeBookmark(bookmarkedBoard); - Toast.makeText(BookmarkActivity.this, "Bookmark removed", Toast.LENGTH_SHORT).show(); + Toast.makeText(BookmarksActivity.this, "Bookmark removed", Toast.LENGTH_SHORT).show(); break; } return true; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksBoardFragment.java similarity index 87% rename from app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java rename to app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksBoardFragment.java index 913d2ce7..a73bbe6a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BoardBookmarksFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksBoardFragment.java @@ -22,10 +22,10 @@ import gr.thmmy.mthmmy.model.Bookmark; /** * A {@link Fragment} subclass. - * Use the {@link BoardBookmarksFragment#newInstance} factory method to + * Use the {@link BookmarksBoardFragment#newInstance} factory method to * create an instance of this fragment. */ -public class BoardBookmarksFragment extends Fragment { +public class BookmarksBoardFragment extends Fragment { private static final String ARG_SECTION_NUMBER = "SECTION_NUMBER"; private static final String ARG_BOARD_BOOKMARKS = "BOARD_BOOKMARKS"; @@ -39,7 +39,7 @@ public class BoardBookmarksFragment extends Fragment { private static Drawable notificationsDisabledButtonImage; // Required empty public constructor - public BoardBookmarksFragment() { } + public BookmarksBoardFragment() { } /** * Use ONLY this factory method to create a new instance of @@ -47,8 +47,8 @@ public class BoardBookmarksFragment extends Fragment { * * @return A new instance of fragment Forum. */ - public static BoardBookmarksFragment newInstance(int sectionNumber, String boardBookmarks) { - BoardBookmarksFragment fragment = new BoardBookmarksFragment(); + public static BookmarksBoardFragment newInstance(int sectionNumber, String boardBookmarks) { + BookmarksBoardFragment fragment = new BookmarksBoardFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); args.putString(ARG_BOARD_BOOKMARKS, boardBookmarks); @@ -92,8 +92,8 @@ public class BoardBookmarksFragment extends Fragment { R.layout.fragment_bookmarks_row, bookmarksLinearView, false); row.setOnClickListener(view -> { Activity activity = getActivity(); - if (activity instanceof BookmarkActivity){ - ((BookmarkActivity) activity).onBoardInteractionListener(INTERACTION_CLICK_BOARD_BOOKMARK, bookmarkedBoard); + if (activity instanceof BookmarksActivity){ + ((BookmarksActivity) activity).onBoardInteractionListener(INTERACTION_CLICK_BOARD_BOOKMARK, bookmarkedBoard); } }); ((TextView) row.findViewById(R.id.bookmark_title)).setText(bookmarkedBoard.getTitle()); @@ -105,8 +105,8 @@ public class BoardBookmarksFragment extends Fragment { notificationsEnabledButton.setOnClickListener(view -> { Activity activity = getActivity(); - if (activity instanceof BookmarkActivity) { - if (((BookmarkActivity) activity).onBoardInteractionListener(INTERACTION_TOGGLE_BOARD_NOTIFICATION, bookmarkedBoard)) { + if (activity instanceof BookmarksActivity) { + if (((BookmarksActivity) activity).onBoardInteractionListener(INTERACTION_TOGGLE_BOARD_NOTIFICATION, bookmarkedBoard)) { notificationsEnabledButton.setImageDrawable(notificationsEnabledButtonImage); } else { notificationsEnabledButton.setImageDrawable(notificationsDisabledButtonImage); @@ -116,8 +116,8 @@ public class BoardBookmarksFragment extends Fragment { (row.findViewById(R.id.remove_bookmark)).setOnClickListener(view -> { Activity activity = getActivity(); - if (activity instanceof BookmarkActivity){ - ((BookmarkActivity) activity).onBoardInteractionListener(INTERACTION_REMOVE_BOARD_BOOKMARK, bookmarkedBoard); + if (activity instanceof BookmarksActivity){ + ((BookmarksActivity) activity).onBoardInteractionListener(INTERACTION_REMOVE_BOARD_BOOKMARK, bookmarkedBoard); boardBookmarks.remove(bookmarkedBoard); } row.setVisibility(View.GONE); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksTopicFragment.java similarity index 82% rename from app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java rename to app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksTopicFragment.java index 77992b2d..5c6232b7 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksTopicFragment.java @@ -22,16 +22,16 @@ import gr.thmmy.mthmmy.model.Bookmark; /** * A {@link Fragment} subclass. - * Use the {@link TopicBookmarksFragment#newInstance} factory method to + * Use the {@link BookmarksTopicFragment#newInstance} factory method to * create an instance of this fragment. */ -public class TopicBookmarksFragment extends Fragment { - protected static final String ARG_SECTION_NUMBER = "SECTION_NUMBER"; - protected static final String ARG_TOPIC_BOOKMARKS = "TOPIC_BOOKMARKS"; +public class BookmarksTopicFragment extends Fragment { + private static final String ARG_SECTION_NUMBER = "SECTION_NUMBER"; + private static final String ARG_TOPIC_BOOKMARKS = "TOPIC_BOOKMARKS"; - public static final String INTERACTION_CLICK_TOPIC_BOOKMARK = "CLICK_TOPIC_BOOKMARK"; - public static final String INTERACTION_TOGGLE_TOPIC_NOTIFICATION = "TOGGLE_TOPIC_NOTIFICATION"; - public static final String INTERACTION_REMOVE_TOPIC_BOOKMARK = "REMOVE_TOPIC_BOOKMARK"; + static final String INTERACTION_CLICK_TOPIC_BOOKMARK = "CLICK_TOPIC_BOOKMARK"; + static final String INTERACTION_TOGGLE_TOPIC_NOTIFICATION = "TOGGLE_TOPIC_NOTIFICATION"; + static final String INTERACTION_REMOVE_TOPIC_BOOKMARK = "REMOVE_TOPIC_BOOKMARK"; ArrayList topicBookmarks = null; @@ -39,7 +39,7 @@ public class TopicBookmarksFragment extends Fragment { private static Drawable notificationsDisabledButtonImage; // Required empty public constructor - public TopicBookmarksFragment() { + public BookmarksTopicFragment() { } /** @@ -48,8 +48,8 @@ public class TopicBookmarksFragment extends Fragment { * * @return A new instance of fragment Forum. */ - public static TopicBookmarksFragment newInstance(int sectionNumber, String topicBookmarks) { - TopicBookmarksFragment fragment = new TopicBookmarksFragment(); + public static BookmarksTopicFragment newInstance(int sectionNumber, String topicBookmarks) { + BookmarksTopicFragment fragment = new BookmarksTopicFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); args.putString(ARG_TOPIC_BOOKMARKS, topicBookmarks); @@ -93,8 +93,8 @@ public class TopicBookmarksFragment extends Fragment { R.layout.fragment_bookmarks_row, bookmarksLinearView, false); row.setOnClickListener(view -> { Activity activity = getActivity(); - if (activity instanceof BookmarkActivity) { - ((BookmarkActivity) activity).onTopicInteractionListener(INTERACTION_CLICK_TOPIC_BOOKMARK, bookmarkedTopic); + if (activity instanceof BookmarksActivity) { + ((BookmarksActivity) activity).onTopicInteractionListener(INTERACTION_CLICK_TOPIC_BOOKMARK, bookmarkedTopic); } }); ((TextView) row.findViewById(R.id.bookmark_title)).setText(bookmarkedTopic.getTitle()); @@ -106,8 +106,8 @@ public class TopicBookmarksFragment extends Fragment { notificationsEnabledButton.setOnClickListener(view -> { Activity activity = getActivity(); - if (activity instanceof BookmarkActivity) { - if (((BookmarkActivity) activity).onTopicInteractionListener(INTERACTION_TOGGLE_TOPIC_NOTIFICATION, bookmarkedTopic)) { + if (activity instanceof BookmarksActivity) { + if (((BookmarksActivity) activity).onTopicInteractionListener(INTERACTION_TOGGLE_TOPIC_NOTIFICATION, bookmarkedTopic)) { notificationsEnabledButton.setImageDrawable(notificationsEnabledButtonImage); } else { notificationsEnabledButton.setImageDrawable(notificationsDisabledButtonImage); @@ -116,8 +116,8 @@ public class TopicBookmarksFragment extends Fragment { }); (row.findViewById(R.id.remove_bookmark)).setOnClickListener(view -> { Activity activity = getActivity(); - if (activity instanceof BookmarkActivity) { - ((BookmarkActivity) activity).onTopicInteractionListener(INTERACTION_REMOVE_TOPIC_BOOKMARK, bookmarkedTopic); + if (activity instanceof BookmarksActivity) { + ((BookmarksActivity) activity).onTopicInteractionListener(INTERACTION_REMOVE_TOPIC_BOOKMARK, bookmarkedTopic); topicBookmarks.remove(bookmarkedTopic); } row.setVisibility(View.GONE); 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 162ea1f6..db6d9238 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 @@ -129,6 +129,8 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment if (!Objects.equals(avatarUrl, "")) //noinspection ConstantConditions loadAvatar(); + else + loadDefaultAvatar(); usernameView = findViewById(R.id.profile_activity_username); usernameView.setTypeface(Typeface.createFromAsset(this.getAssets() , "fonts/fontawesome-webfont.ttf")); @@ -222,6 +224,19 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment .into(avatarView); } + private void loadDefaultAvatar(){ + Picasso.with(this) + .load(R.drawable.ic_default_user_avatar) + .fit() + .centerCrop() + .error(Objects.requireNonNull(ResourcesCompat.getDrawable(this.getResources() + , R.drawable.ic_default_user_avatar, null))) + .placeholder(Objects.requireNonNull(ResourcesCompat.getDrawable(this.getResources() + , R.drawable.ic_default_user_avatar, null))) + .transform(new CircleTransform()) + .into(avatarView); + } + /** * An {@link AsyncTask} that handles asynchronous fetching of a profile page and parsing this * user's personal text. The {@link Document} resulting from the parse is stored for use in @@ -303,6 +318,8 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment if (avatarUrl != null && !Objects.equals(avatarUrl, "")) //noinspection ConstantConditions loadAvatar(); + else + loadDefaultAvatar(); if (personalText != null) { personalTextView.setText(personalText); personalTextView.setVisibility(View.VISIBLE); 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 75c7d081..86b2e367 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -46,7 +46,7 @@ import androidx.preference.PreferenceManager; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.activities.AboutActivity; import gr.thmmy.mthmmy.activities.LoginActivity; -import gr.thmmy.mthmmy.activities.bookmarks.BookmarkActivity; +import gr.thmmy.mthmmy.activities.bookmarks.BookmarksActivity; import gr.thmmy.mthmmy.activities.downloads.DownloadsActivity; import gr.thmmy.mthmmy.activities.main.MainActivity; import gr.thmmy.mthmmy.activities.profile.ProfileActivity; @@ -380,8 +380,8 @@ public abstract class BaseActivity extends AppCompatActivity { // startActivity(intent); // } } else if (drawerItem.equals(BOOKMARKS_ID)) { - if (!(BaseActivity.this instanceof BookmarkActivity)) { - Intent intent = new Intent(BaseActivity.this, BookmarkActivity.class); + if (!(BaseActivity.this instanceof BookmarksActivity)) { + Intent intent = new Intent(BaseActivity.this, BookmarksActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent); } diff --git a/app/src/main/res/layout-v21/activity_profile.xml b/app/src/main/res/layout-v21/activity_profile.xml index 3db974f5..c5da47d9 100644 --- a/app/src/main/res/layout-v21/activity_profile.xml +++ b/app/src/main/res/layout-v21/activity_profile.xml @@ -37,11 +37,11 @@ android:id="@+id/user_thumbnail" android:layout_width="@dimen/profile_activity_avatar_size" android:layout_height="@dimen/profile_activity_avatar_size" + android:layout_marginBottom="5dp" android:layout_gravity="center" android:adjustViewBounds="true" android:contentDescription="@string/post_thumbnail" android:fitsSystemWindows="true" - app:srcCompat="@drawable/ic_default_user_avatar" android:transitionName="user_thumbnail" app:layout_collapseMode="parallax"/> diff --git a/app/src/main/res/layout-v21/activity_topic_post_row.xml b/app/src/main/res/layout-v21/activity_topic_post_row.xml index 5147852f..1cdb357c 100644 --- a/app/src/main/res/layout-v21/activity_topic_post_row.xml +++ b/app/src/main/res/layout-v21/activity_topic_post_row.xml @@ -58,7 +58,6 @@ android:layout_gravity="center" android:adjustViewBounds="true" android:contentDescription="@string/post_thumbnail" - app:srcCompat="@drawable/ic_default_user_avatar_darker" android:transitionName="user_thumbnail" /> diff --git a/app/src/main/res/layout/activity_bookmark.xml b/app/src/main/res/layout/activity_bookmarks.xml similarity index 100% rename from app/src/main/res/layout/activity_bookmark.xml rename to app/src/main/res/layout/activity_bookmarks.xml diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index 5ca3cbbb..8a51cbd9 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -37,11 +37,11 @@ android:id="@+id/user_thumbnail" android:layout_width="@dimen/profile_activity_avatar_size" android:layout_height="@dimen/profile_activity_avatar_size" + android:layout_marginBottom="5dp" android:layout_gravity="center" android:adjustViewBounds="true" android:contentDescription="@string/post_thumbnail" android:fitsSystemWindows="true" - app:srcCompat="@drawable/ic_default_user_avatar" app:layout_collapseMode="parallax"/> + android:contentDescription="@string/post_thumbnail" /> + android:contentDescription="@string/post_thumbnail" /> + android:contentDescription="@string/post_thumbnail" />