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 041c26a6..3ff841f6 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 @@ -13,6 +13,7 @@ import android.os.Bundle; import android.os.Handler; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AlertDialog; +import android.support.v7.app.AppCompatDelegate; import android.support.v7.preference.PreferenceManager; import android.support.v7.widget.RecyclerView; import android.text.Html; @@ -205,6 +206,8 @@ public class TopicActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + //Fix for vector drawables on android <21 + AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); setContentView(R.layout.activity_topic); Bundle extras = getIntent().getExtras(); 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 207b2099..a6556cc3 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 @@ -363,7 +363,7 @@ public class UploadActivity extends BaseActivity { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_CHOOSE_FILE && data != null) { - if (resultCode == Activity.RESULT_OK) { + if (resultCode == Activity.RESULT_CANCELED) { return; } 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 6db1f0d5..32f3e891 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -85,8 +85,6 @@ public abstract class BaseActivity extends AppCompatActivity { private SharedPreferences bookmarksFile; private ArrayList topicsBookmarked; private ArrayList boardsBookmarked; - private static Drawable bookmarked; - private static Drawable notBookmarked; //Common UI elements protected Toolbar toolbar; @@ -104,18 +102,6 @@ public abstract class BaseActivity extends AppCompatActivity { if (sessionManager == null) sessionManager = BaseApplication.getInstance().getSessionManager(); - if (bookmarked == null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - bookmarked = getResources().getDrawable(R.drawable.ic_bookmark_true_accent_24dp, null); - } else //noinspection deprecation - bookmarked = getResources().getDrawable(R.drawable.ic_bookmark_true_accent_24dp); - } - if (notBookmarked == null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - notBookmarked = getResources().getDrawable(R.drawable.ic_bookmark_false_accent_24dp, null); - } else //noinspection deprecation - notBookmarked = getResources().getDrawable(R.drawable.ic_bookmark_false_accent_24dp); - } if (topicsBookmarked == null || boardsBookmarked == null) { bookmarksFile = getSharedPreferences(BOOKMARKS_SHARED_PREFS, Context.MODE_PRIVATE); loadSavedBookmarks(); @@ -506,9 +492,9 @@ public abstract class BaseActivity extends AppCompatActivity { protected void setTopicBookmark(MenuItem thisPageBookmarkMenuButton) { this.thisPageBookmarkMenuButton = thisPageBookmarkMenuButton; if (thisPageBookmark.matchExists(topicsBookmarked)) { - thisPageBookmarkMenuButton.setIcon(bookmarked); + thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_true_accent_24dp); } else { - thisPageBookmarkMenuButton.setIcon(notBookmarked); + thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_false_accent_24dp); } } @@ -518,19 +504,19 @@ public abstract class BaseActivity extends AppCompatActivity { } loadSavedBookmarks(); if (thisPageBookmark.matchExists(topicsBookmarked)) { - thisPageBookmarkMenuButton.setIcon(bookmarked); + thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_true_accent_24dp); } else { - thisPageBookmarkMenuButton.setIcon(notBookmarked); + thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_false_accent_24dp); } } protected void topicMenuBookmarkClick() { if (thisPageBookmark.matchExists(topicsBookmarked)) { - thisPageBookmarkMenuButton.setIcon(notBookmarked); + thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_false_accent_24dp); toggleTopicToBookmarks(thisPageBookmark); Toast.makeText(getBaseContext(), "Bookmark removed", Toast.LENGTH_SHORT).show(); } else { - thisPageBookmarkMenuButton.setIcon(bookmarked); + thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_true_accent_24dp); toggleTopicToBookmarks(thisPageBookmark); Toast.makeText(getBaseContext(), "Bookmark added", Toast.LENGTH_SHORT).show(); } @@ -538,18 +524,18 @@ public abstract class BaseActivity extends AppCompatActivity { protected void setBoardBookmark(final ImageButton thisPageBookmarkImageButton) { if (thisPageBookmark.matchExists(boardsBookmarked)) { - thisPageBookmarkImageButton.setImageDrawable(bookmarked); + thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_true_accent_24dp); } else { - thisPageBookmarkImageButton.setImageDrawable(notBookmarked); + thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_false_accent_24dp); } thisPageBookmarkImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (thisPageBookmark.matchExists(boardsBookmarked)) { - thisPageBookmarkImageButton.setImageDrawable(notBookmarked); + thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_false_accent_24dp); Toast.makeText(getBaseContext(), "Bookmark removed", Toast.LENGTH_SHORT).show(); } else { - thisPageBookmarkImageButton.setImageDrawable(bookmarked); + thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_true_accent_24dp); Toast.makeText(getBaseContext(), "Bookmark added", Toast.LENGTH_SHORT).show(); } toggleBoardToBookmarks(thisPageBookmark); @@ -562,9 +548,9 @@ public abstract class BaseActivity extends AppCompatActivity { return; loadSavedBookmarks(); if (thisPageBookmark.matchExists(boardsBookmarked)) { - thisPageBookmarkImageButton.setImageDrawable(bookmarked); + thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_true_accent_24dp); } else { - thisPageBookmarkImageButton.setImageDrawable(notBookmarked); + thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_false_accent_24dp); } }