From cacce7b64079be49013f195163a0ab7ada283730 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 11 Aug 2018 22:57:02 +0200 Subject: [PATCH 01/69] Refactored Utility Classes & Abstracted Database Helper - Renamed most utility classes for the sake of consistency - Abstracted the database helper class instance to use the box query interface instead --- app/src/main/java/com/mxt/anitrend/App.java | 6 +-- .../recycler/detail/ImagePreviewAdapter.java | 11 +++-- .../base/custom/activity/ActivityBase.java | 4 +- .../base/custom/async/WebTokenRequest.java | 11 ++--- .../base/custom/fragment/FragmentBase.java | 9 ++-- .../custom/fragment/FragmentChannelBase.java | 6 +-- .../custom/presenter/CommonPresenter.java | 5 ++- .../custom/recycler/RecyclerViewAdapter.java | 6 +-- .../custom/recycler/RecyclerViewHolder.java | 8 ++-- .../custom/view/editor/ComposerWidget.java | 4 +- .../view/editor/MarkdownInputEditor.java | 6 +-- .../view/text/RichMarkdownTextView.java | 18 ++++---- .../view/widget/StatusContentWidget.java | 14 +++--- .../base/interfaces/dao/BoxQuery.java | 16 +++++++ .../com/mxt/anitrend/data/DatabaseHelper.java | 4 +- .../presenter/base/BasePresenter.java | 6 +-- .../service/JobDispatcherService.java | 2 +- ...ionModeHelper.java => ActionModeUtil.java} | 4 +- .../mxt/anitrend/util/ApplicationPref.java | 4 +- ...ratorProvider.java => ComparatorUtil.java} | 2 +- .../com/mxt/anitrend/util/CompatUtil.java | 4 +- .../com/mxt/anitrend/util/DialogUtil.java | 15 +++---- .../{EpisodeHelper.java => EpisodeUtil.java} | 2 +- ...deImageGetter.java => GlideImageUtil.java} | 9 ++-- .../{HtmlTagHandler.java => HtmlTagUtil.java} | 9 ++-- .../mxt/anitrend/util/IntentBundleUtil.java | 4 +- .../{LocaleHelper.java => LocaleUtil.java} | 2 +- .../util/{MarkDown.java => MarkDownUtil.java} | 45 ++++++++++++------- .../mxt/anitrend/util/MediaDialogUtil.java | 2 +- ...nDispatcher.java => NotificationUtil.java} | 4 +- .../{PatternMatcher.java => RegexUtil.java} | 2 +- ...{ShortcutHelper.java => ShortcutUtil.java} | 2 +- .../activity/base/SharedContentActivity.java | 10 ++--- .../activity/detail/MediaBrowseActivity.java | 4 +- .../view/activity/index/LoginActivity.java | 13 +++--- .../view/activity/index/MainActivity.java | 4 +- .../fragment/detail/NotificationFragment.java | 9 ++-- .../view/fragment/list/WatchListFragment.java | 4 +- .../view/sheet/BottomSheetMessage.java | 1 - ...HelperTests.java => EpisodeUtilTests.java} | 10 ++--- ...va => EpisodeUtil_GetActualTitleTest.java} | 4 +- 41 files changed, 163 insertions(+), 142 deletions(-) rename app/src/main/java/com/mxt/anitrend/util/{ActionModeHelper.java => ActionModeUtil.java} (97%) rename app/src/main/java/com/mxt/anitrend/util/{ComparatorProvider.java => ComparatorUtil.java} (89%) rename app/src/main/java/com/mxt/anitrend/util/{EpisodeHelper.java => EpisodeUtil.java} (97%) rename app/src/main/java/com/mxt/anitrend/util/{GlideImageGetter.java => GlideImageUtil.java} (88%) rename app/src/main/java/com/mxt/anitrend/util/{HtmlTagHandler.java => HtmlTagUtil.java} (64%) rename app/src/main/java/com/mxt/anitrend/util/{LocaleHelper.java => LocaleUtil.java} (98%) rename app/src/main/java/com/mxt/anitrend/util/{MarkDown.java => MarkDownUtil.java} (66%) rename app/src/main/java/com/mxt/anitrend/util/{NotificationDispatcher.java => NotificationUtil.java} (96%) rename app/src/main/java/com/mxt/anitrend/util/{PatternMatcher.java => RegexUtil.java} (99%) rename app/src/main/java/com/mxt/anitrend/util/{ShortcutHelper.java => ShortcutUtil.java} (99%) rename app/src/test/java/com/mxt/anitrend/util/{EpisodeHelperTests.java => EpisodeUtilTests.java} (88%) rename app/src/test/java/com/mxt/anitrend/util/{EpisodeHelper_GetActualTitleTest.java => EpisodeUtil_GetActualTitleTest.java} (86%) diff --git a/app/src/main/java/com/mxt/anitrend/App.java b/app/src/main/java/com/mxt/anitrend/App.java index 1b980865c..a6c4144dc 100644 --- a/app/src/main/java/com/mxt/anitrend/App.java +++ b/app/src/main/java/com/mxt/anitrend/App.java @@ -3,14 +3,12 @@ import android.app.Application; import android.content.Context; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import com.crashlytics.android.core.CrashlyticsCore; -import com.crashlytics.android.core.CrashlyticsListener; import com.google.firebase.analytics.FirebaseAnalytics; import com.mxt.anitrend.model.entity.MyObjectBox; import com.mxt.anitrend.util.ApplicationPref; -import com.mxt.anitrend.util.LocaleHelper; +import com.mxt.anitrend.util.LocaleUtil; import org.greenrobot.eventbus.EventBus; @@ -71,7 +69,7 @@ public void onCreate() { @Override protected void attachBaseContext(Context base) { - super.attachBaseContext(LocaleHelper.onAttach(base)); + super.attachBaseContext(LocaleUtil.onAttach(base)); } /** diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/ImagePreviewAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/ImagePreviewAdapter.java index 851197e1d..5433681df 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/ImagePreviewAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/ImagePreviewAdapter.java @@ -8,14 +8,13 @@ import android.view.ViewGroup; import android.widget.Filter; -import com.annimon.stream.IntPair; import com.bumptech.glide.Glide; import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions; import com.bumptech.glide.request.RequestOptions; import com.mxt.anitrend.base.custom.recycler.RecyclerViewAdapter; import com.mxt.anitrend.base.custom.recycler.RecyclerViewHolder; import com.mxt.anitrend.databinding.AdapterFeedSlideBinding; -import com.mxt.anitrend.util.PatternMatcher; +import com.mxt.anitrend.util.RegexUtil; import java.util.List; @@ -70,18 +69,18 @@ public void onBindViewHolder(String model) { String targetModel; RequestOptions requestOptions = null; switch (contentTypes.get(getAdapterPosition())) { - case PatternMatcher.KEY_IMG: + case RegexUtil.KEY_IMG: targetModel = model; ViewCompat.setTransitionName(binding.feedStatusImage, model); binding.feedPlayBack.setVisibility(View.GONE); break; - case PatternMatcher.KEY_YOU: - targetModel = PatternMatcher.getYoutubeThumb(model); + case RegexUtil.KEY_YOU: + targetModel = RegexUtil.getYoutubeThumb(model); binding.feedPlayBack.setVisibility(View.VISIBLE); requestOptions = RequestOptions.centerCropTransform(); break; default: - targetModel = PatternMatcher.NO_THUMBNAIL; + targetModel = RegexUtil.NO_THUMBNAIL; binding.feedPlayBack.setVisibility(View.VISIBLE); break; } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java index 6b62f2845..fde8d8353 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java @@ -37,7 +37,7 @@ import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.IntentBundleUtil; import com.mxt.anitrend.util.KeyUtil; -import com.mxt.anitrend.util.LocaleHelper; +import com.mxt.anitrend.util.LocaleUtil; import com.mxt.anitrend.util.MediaActionUtil; import com.mxt.anitrend.util.NotifyUtil; import com.mxt.anitrend.view.activity.index.MainActivity; @@ -101,7 +101,7 @@ protected void configureActivity() { @Override protected void attachBaseContext(Context base) { - super.attachBaseContext(LocaleHelper.onAttach(base)); + super.attachBaseContext(LocaleUtil.onAttach(base)); } @Override diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/async/WebTokenRequest.java b/app/src/main/java/com/mxt/anitrend/base/custom/async/WebTokenRequest.java index f8ee55206..10e252fb2 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/async/WebTokenRequest.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/async/WebTokenRequest.java @@ -7,6 +7,7 @@ import android.util.Log; import com.mxt.anitrend.base.custom.presenter.CommonPresenter; +import com.mxt.anitrend.base.interfaces.dao.BoxQuery; import com.mxt.anitrend.data.DatabaseHelper; import com.mxt.anitrend.model.api.retro.WebFactory; import com.mxt.anitrend.model.entity.anilist.WebToken; @@ -15,7 +16,7 @@ import com.mxt.anitrend.util.AnalyticsUtil; import com.mxt.anitrend.util.ApplicationPref; import com.mxt.anitrend.util.JobSchedulerUtil; -import com.mxt.anitrend.util.ShortcutHelper; +import com.mxt.anitrend.util.ShortcutUtil; import java.util.concurrent.ExecutionException; @@ -46,7 +47,7 @@ public static void invalidateInstance(Context context) { WebFactory.invalidate(); token = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) - ShortcutHelper.removeAllDynamicShortcuts(context); + ShortcutUtil.removeAllDynamicShortcuts(context); AnalyticsUtil.clearSession(); } @@ -91,9 +92,9 @@ public static synchronized boolean getToken(Context context, String code) throws WebToken authenticatedToken = new AuthenticationCodeAsync().execute(code).get(); if(authenticatedToken != null) { createNewTokenReference(authenticatedToken); - DatabaseHelper databaseHelper = new DatabaseHelper(context); - databaseHelper.saveWebToken(authenticatedToken); - databaseHelper.saveAuthCode(new AuthBase(code, authenticatedToken.getRefresh_token())); + BoxQuery boxQuery = new DatabaseHelper(context); + boxQuery.saveWebToken(authenticatedToken); + boxQuery.saveAuthCode(new AuthBase(code, authenticatedToken.getRefresh_token())); return true; } return false; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBase.java index 5bc80f89b..d3ba1d800 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBase.java @@ -29,10 +29,9 @@ import com.mxt.anitrend.base.interfaces.event.ActionModeListener; import com.mxt.anitrend.base.interfaces.event.ItemClickListener; import com.mxt.anitrend.base.interfaces.event.ResponseCallback; -import com.mxt.anitrend.util.ActionModeHelper; +import com.mxt.anitrend.util.ActionModeUtil; import com.mxt.anitrend.util.AnalyticsUtil; import com.mxt.anitrend.util.MediaActionUtil; -import com.mxt.anitrend.util.TutorialUtil; import org.greenrobot.eventbus.EventBus; @@ -44,7 +43,7 @@ public abstract class FragmentBase extends Fra protected boolean isFilterable, isPager, isMenuDisabled, isFeed, hasSubscriber; private @MenuRes int inflateMenu; - private ActionModeHelper actionMode; + private ActionModeUtil actionMode; protected ViewModelBase viewModel; private CommonPresenter presenter; protected MediaActionUtil mediaActionUtil; @@ -265,10 +264,10 @@ protected void setViewModel(boolean stateSupported) { public abstract void onChanged(@Nullable VM model); protected void setActionModeEnabled(boolean isEnabled) { - this.actionMode = new ActionModeHelper<>(this, isEnabled); + this.actionMode = new ActionModeUtil<>(this, isEnabled); } - protected ActionModeHelper getActionMode() { + protected ActionModeUtil getActionMode() { return actionMode; } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java index 95d291a6a..5d9130a2d 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java @@ -30,7 +30,7 @@ import com.mxt.anitrend.presenter.widget.WidgetPresenter; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.DialogUtil; -import com.mxt.anitrend.util.EpisodeHelper; +import com.mxt.anitrend.util.EpisodeUtil; import com.mxt.anitrend.util.KeyUtil; import com.mxt.anitrend.util.NotifyUtil; import com.mxt.anitrend.view.activity.index.SearchActivity; @@ -93,7 +93,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { isPopular = getArguments().getBoolean(KeyUtil.arg_popular); externalLinks = getArguments().getParcelableArrayList(KeyUtil.arg_list_model); if(externalLinks != null) - targetLink = EpisodeHelper.episodeSupport(externalLinks); + targetLink = EpisodeUtil.episodeSupport(externalLinks); } } @@ -357,7 +357,7 @@ public void onItemClick(View target, IntPair data) { case NEUTRAL: if(getActivity() != null) { intent = new Intent(getActivity(), SearchActivity.class); - intent.putExtra(KeyUtil.arg_search, EpisodeHelper.getActualTile(data.getSecond().getTitle())); + intent.putExtra(KeyUtil.arg_search, EpisodeUtil.getActualTile(data.getSecond().getTitle())); getActivity().startActivity(intent); } break; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/presenter/CommonPresenter.java b/app/src/main/java/com/mxt/anitrend/base/custom/presenter/CommonPresenter.java index c4bd10975..3f7028ddf 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/presenter/CommonPresenter.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/presenter/CommonPresenter.java @@ -5,6 +5,7 @@ import android.os.Bundle; import com.mxt.anitrend.base.custom.recycler.RecyclerScrollListener; +import com.mxt.anitrend.base.interfaces.dao.BoxQuery; import com.mxt.anitrend.base.interfaces.event.LifecycleListener; import com.mxt.anitrend.data.DatabaseHelper; import com.mxt.anitrend.util.ApplicationPref; @@ -21,7 +22,7 @@ public abstract class CommonPresenter extends RecyclerScrollListener implements private Bundle bundle; private Context context; - private DatabaseHelper databaseHelper; + private BoxQuery databaseHelper; private ApplicationPref applicationPref; public CommonPresenter(Context context) { @@ -42,7 +43,7 @@ public void setParams(Bundle bundle) { this.bundle = bundle; } - public DatabaseHelper getDatabase() { + public BoxQuery getDatabase() { if(databaseHelper == null) databaseHelper = new DatabaseHelper(context); return databaseHelper; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/recycler/RecyclerViewAdapter.java b/app/src/main/java/com/mxt/anitrend/base/custom/recycler/RecyclerViewAdapter.java index 573f89d7e..ffa58cb8e 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/recycler/RecyclerViewAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/recycler/RecyclerViewAdapter.java @@ -16,7 +16,7 @@ import com.mxt.anitrend.base.interfaces.event.ItemClickListener; import com.mxt.anitrend.base.interfaces.event.RecyclerChangeListener; import com.mxt.anitrend.presenter.base.BasePresenter; -import com.mxt.anitrend.util.ActionModeHelper; +import com.mxt.anitrend.util.ActionModeUtil; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; @@ -36,7 +36,7 @@ public abstract class RecyclerViewAdapter extends RecyclerView.Adapter clickListener; - private ActionModeHelper actionMode; + private ActionModeUtil actionMode; private BaseAnimation customAnimation; private int lastPosition; @@ -61,7 +61,7 @@ public long getItemId(int position) { return data.get(position).hashCode(); } - public void setActionModeCallback(ActionModeHelper selectorCallback) { + public void setActionModeCallback(ActionModeUtil selectorCallback) { this.actionMode = selectorCallback; this.actionMode.setRecyclerAdapter(this); } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/recycler/RecyclerViewHolder.java b/app/src/main/java/com/mxt/anitrend/base/custom/recycler/RecyclerViewHolder.java index d23544e24..2985b26ee 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/recycler/RecyclerViewHolder.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/recycler/RecyclerViewHolder.java @@ -7,7 +7,7 @@ import com.annimon.stream.IntPair; import com.mxt.anitrend.base.interfaces.event.ItemClickListener; -import com.mxt.anitrend.util.ActionModeHelper; +import com.mxt.anitrend.util.ActionModeUtil; import java.util.List; @@ -20,7 +20,7 @@ public abstract class RecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { - private ActionModeHelper callback; + private ActionModeUtil callback; /** * Default constructor which includes binding with butter knife @@ -116,7 +116,7 @@ protected boolean isLongClickable (T clicked) { return (callback == null || !callback.onItemLongClick(this, clicked)); } - void setActionMode(ActionModeHelper actionModeHelper) { - callback = actionModeHelper; + void setActionMode(ActionModeUtil actionModeUtil) { + callback = actionModeUtil; } } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/ComposerWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/ComposerWidget.java index 8f661ebb5..c8c35d50e 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/ComposerWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/ComposerWidget.java @@ -33,7 +33,7 @@ import com.mxt.anitrend.util.ErrorUtil; import com.mxt.anitrend.util.GraphUtil; import com.mxt.anitrend.util.KeyUtil; -import com.mxt.anitrend.util.MarkDown; +import com.mxt.anitrend.util.MarkDownUtil; import com.mxt.anitrend.util.NotifyUtil; import org.greenrobot.eventbus.EventBus; @@ -294,7 +294,7 @@ public void onGiphyClicked(IntPair pair) { EditText editor = binding.comment; int start = editor.getSelectionStart(); Gif gif = pair.getSecond().getImages().get(index); - editor.getEditableText().insert(start, MarkDown.convertImage(gif.getUrl())); + editor.getEditableText().insert(start, MarkDownUtil.convertImage(gif.getUrl())); } public void appendText(String textValue) { diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/MarkdownInputEditor.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/MarkdownInputEditor.java index f312b3d22..d2bddf9e6 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/MarkdownInputEditor.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/MarkdownInputEditor.java @@ -12,9 +12,7 @@ import android.support.v13.view.inputmethod.InputConnectionCompat; import android.support.v13.view.inputmethod.InputContentInfoCompat; import android.support.v4.content.ContextCompat; -import android.support.v4.os.BuildCompat; import android.text.InputFilter; -import android.text.Spanned; import android.text.TextUtils; import android.util.AttributeSet; import android.view.ActionMode; @@ -28,7 +26,7 @@ import com.mxt.anitrend.base.interfaces.view.CustomView; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; -import com.mxt.anitrend.util.MarkDown; +import com.mxt.anitrend.util.MarkDownUtil; import static com.mxt.anitrend.util.KeyUtil.MD_BOLD; import static com.mxt.anitrend.util.KeyUtil.MD_BULLET; @@ -275,7 +273,7 @@ public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flag inputContentInfo.requestPermission(); Uri linkUri = inputContentInfo.getLinkUri(); if(linkUri != null) { - String link = MarkDown.convertImage(linkUri.toString()); + String link = MarkDownUtil.convertImage(linkUri.toString()); getText().insert(getSelectionStart(), link); inputContentInfo.releasePermission(); return true; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RichMarkdownTextView.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RichMarkdownTextView.java index 2b6e910bc..a422b62d2 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RichMarkdownTextView.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RichMarkdownTextView.java @@ -13,8 +13,8 @@ import android.widget.TextView; import com.mxt.anitrend.base.interfaces.view.CustomView; -import com.mxt.anitrend.util.MarkDown; -import com.mxt.anitrend.util.PatternMatcher; +import com.mxt.anitrend.util.MarkDownUtil; +import com.mxt.anitrend.util.RegexUtil; import com.zzhoujay.richtext.RichText; import com.zzhoujay.richtext.RichType; import com.zzhoujay.richtext.ig.DefaultImageGetter; @@ -56,14 +56,14 @@ public void onViewRecycled() { @BindingAdapter("markDown") public static void markDown(RichMarkdownTextView richMarkdownTextView, String markdown) { - String strippedText = PatternMatcher.removeTags(markdown); - Spanned markdownSpan = MarkDown.convert(strippedText, richMarkdownTextView.getContext(), richMarkdownTextView); + String strippedText = RegexUtil.removeTags(markdown); + Spanned markdownSpan = MarkDownUtil.convert(strippedText, richMarkdownTextView.getContext(), richMarkdownTextView); richMarkdownTextView.setText(markdownSpan, TextView.BufferType.SPANNABLE); } @BindingAdapter("textHtml") public static void htmlText(RichMarkdownTextView richMarkdownTextView, String html) { - Spanned markdownSpan = MarkDown.convert(html, richMarkdownTextView.getContext(), richMarkdownTextView); + Spanned markdownSpan = MarkDownUtil.convert(html, richMarkdownTextView.getContext(), richMarkdownTextView); richMarkdownTextView.setText(markdownSpan, TextView.BufferType.SPANNABLE); } @@ -76,21 +76,21 @@ public static void basicText(RichMarkdownTextView richMarkdownTextView, String h @BindingAdapter("textHtml") public static void htmlText(RichMarkdownTextView richMarkdownTextView, @StringRes int resId) { String text = richMarkdownTextView.getContext().getString(resId); - Spanned markdownSpan = MarkDown.convert(text, richMarkdownTextView.getContext(), richMarkdownTextView); + Spanned markdownSpan = MarkDownUtil.convert(text, richMarkdownTextView.getContext(), richMarkdownTextView); richMarkdownTextView.setText(markdownSpan, TextView.BufferType.SPANNABLE); } @BindingAdapter("richMarkDown") public static void richMarkDown(RichMarkdownTextView richMarkdownTextView, String markdown) { - RichText.from(PatternMatcher.convertToStandardMarkdown(markdown)) + RichText.from(RegexUtil.convertToStandardMarkdown(markdown)) .imageGetter(new DefaultImageGetter()) .bind(richMarkdownTextView.getContext()) .type(RichType.markdown).into(richMarkdownTextView); } public void setMarkDownText(String markDownText) { - String strippedText = PatternMatcher.removeTags(markDownText); - Spanned markdownSpan = MarkDown.convert(strippedText, getContext(), this); + String strippedText = RegexUtil.removeTags(markDownText); + Spanned markdownSpan = MarkDownUtil.convert(strippedText, getContext(), this); setText(markdownSpan, TextView.BufferType.SPANNABLE); } } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java index 326b8817f..d6d0c3a38 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java @@ -29,7 +29,7 @@ import com.mxt.anitrend.util.KeyUtil; import com.mxt.anitrend.util.LinearScaleHelper; import com.mxt.anitrend.util.NotifyUtil; -import com.mxt.anitrend.util.PatternMatcher; +import com.mxt.anitrend.util.RegexUtil; import com.mxt.anitrend.view.activity.base.ImagePreviewActivity; import com.mxt.anitrend.view.activity.base.VideoPlayerActivity; @@ -107,7 +107,7 @@ public void onViewRecycled() { private void findMediaAttachments(@Nullable String value) { if(!TextUtils.isEmpty(value)) { - Matcher matcher = PatternMatcher.findMedia(value); + Matcher matcher = RegexUtil.findMedia(value); contentLinks = new ArrayList<>(); contentTypes = new ArrayList<>(); while (matcher.find()) { @@ -115,8 +115,8 @@ private void findMediaAttachments(@Nullable String value) { String tag = matcher.group(gc - 1); String media = matcher.group(gc); contentTypes.add(tag); - if (tag.equals(PatternMatcher.KEY_YOU)) - contentLinks.add(PatternMatcher.buildYoutube(media.replace("(", "").replace(")", ""))); + if (tag.equals(RegexUtil.KEY_YOU)) + contentLinks.add(RegexUtil.buildYoutube(media.replace("(", "").replace(")", ""))); else contentLinks.add(media.replace("(", "").replace(")", "")); } @@ -166,19 +166,19 @@ public void onPageChanged(int currentPage) { public void onItemClick(View target, IntPair data) { Intent intent; switch (contentTypes.get(data.getFirst())) { - case PatternMatcher.KEY_IMG: + case RegexUtil.KEY_IMG: intent = new Intent(getContext(), ImagePreviewActivity.class); intent.putExtra(KeyUtil.arg_model, data.getSecond()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); break; - case PatternMatcher.KEY_WEB: + case RegexUtil.KEY_WEB: intent = new Intent(getContext(), VideoPlayerActivity.class); intent.putExtra(KeyUtil.arg_model, data.getSecond()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); break; - case PatternMatcher.KEY_YOU: + case RegexUtil.KEY_YOU: try { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(data.getSecond())); diff --git a/app/src/main/java/com/mxt/anitrend/base/interfaces/dao/BoxQuery.java b/app/src/main/java/com/mxt/anitrend/base/interfaces/dao/BoxQuery.java index a36a935d7..434c79f30 100644 --- a/app/src/main/java/com/mxt/anitrend/base/interfaces/dao/BoxQuery.java +++ b/app/src/main/java/com/mxt/anitrend/base/interfaces/dao/BoxQuery.java @@ -9,8 +9,24 @@ import java.util.List; +import io.objectbox.Box; + public interface BoxQuery { + /** + * Gets the object box from a requested class type. + * + *
+ * @param classType Type of class which must not be a list instance + * @return Box of type class requested + */ + Box getBoxStore(Class classType); + + /** + * Used when the application is logging out a user preferably + */ + void invalidateBoxStores(); + /** * Gets current authenticated user */ diff --git a/app/src/main/java/com/mxt/anitrend/data/DatabaseHelper.java b/app/src/main/java/com/mxt/anitrend/data/DatabaseHelper.java index 8fa329d9b..e2d829971 100644 --- a/app/src/main/java/com/mxt/anitrend/data/DatabaseHelper.java +++ b/app/src/main/java/com/mxt/anitrend/data/DatabaseHelper.java @@ -43,6 +43,7 @@ public DatabaseHelper(Context context) { * @param classType Type of class which must not be a list instance * @return Box of type class requested */ + @Override public Box getBoxStore(Class classType) { if(boxStore == null) boxStore = ((App)context.getApplicationContext()).getBoxStore(); @@ -50,8 +51,9 @@ public Box getBoxStore(Class classType) { } /** - * When logging out of the application + * Used when the application is logging out a user preferably */ + @Override public void invalidateBoxStores() { getBoxStore(WebToken.class).removeAll(); getBoxStore(AuthBase.class).removeAll(); diff --git a/app/src/main/java/com/mxt/anitrend/presenter/base/BasePresenter.java b/app/src/main/java/com/mxt/anitrend/presenter/base/BasePresenter.java index e72645c24..6b20dc8e4 100644 --- a/app/src/main/java/com/mxt/anitrend/presenter/base/BasePresenter.java +++ b/app/src/main/java/com/mxt/anitrend/presenter/base/BasePresenter.java @@ -8,7 +8,7 @@ import com.annimon.stream.Stream; import com.mxt.anitrend.base.custom.async.WebTokenRequest; import com.mxt.anitrend.base.custom.presenter.CommonPresenter; -import com.mxt.anitrend.data.DatabaseHelper; +import com.mxt.anitrend.base.interfaces.dao.BoxQuery; import com.mxt.anitrend.model.entity.anilist.UserStats; import com.mxt.anitrend.model.entity.anilist.meta.FormatStats; import com.mxt.anitrend.model.entity.anilist.meta.GenreStats; @@ -143,8 +143,8 @@ public boolean isCurrentUser(UserBase userBase) { public void checkValidAuth() { if(getApplicationPref().isAuthenticated()) { - DatabaseHelper databaseHelper = getDatabase(); - if(databaseHelper.getCurrentUser() == null) { + BoxQuery boxQuery = getDatabase(); + if(boxQuery.getCurrentUser() == null) { Log.e("checkValidAuth", "Last attempt to authenticate failed, refreshing session!"); WebTokenRequest.invalidateInstance(getContext()); } else diff --git a/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java b/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java index e718b7509..6f1df478e 100644 --- a/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java +++ b/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java @@ -9,7 +9,7 @@ import com.mxt.anitrend.base.custom.consumer.BaseConsumer; import com.mxt.anitrend.model.entity.anilist.User; import com.mxt.anitrend.util.KeyUtil; -import com.mxt.anitrend.util.NotificationDispatcher; +import com.mxt.anitrend.util.NotificationUtil; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; diff --git a/app/src/main/java/com/mxt/anitrend/util/ActionModeHelper.java b/app/src/main/java/com/mxt/anitrend/util/ActionModeUtil.java similarity index 97% rename from app/src/main/java/com/mxt/anitrend/util/ActionModeHelper.java rename to app/src/main/java/com/mxt/anitrend/util/ActionModeUtil.java index c8b7e9c3b..8d0f61c72 100644 --- a/app/src/main/java/com/mxt/anitrend/util/ActionModeHelper.java +++ b/app/src/main/java/com/mxt/anitrend/util/ActionModeUtil.java @@ -18,7 +18,7 @@ * Custom action mode holder class */ -public class ActionModeHelper { +public class ActionModeUtil { private boolean isEnabled; private ActionMode mActionMode; @@ -27,7 +27,7 @@ public class ActionModeHelper { private final List mSelectedItems; private final ActionModeListener modeListener; - public ActionModeHelper(ActionModeListener modeListener, boolean isEnabled) { + public ActionModeUtil(ActionModeListener modeListener, boolean isEnabled) { this.modeListener = modeListener; this.mSelectedItems = new ArrayList<>(); this.isEnabled = isEnabled; diff --git a/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java b/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java index 88ce5d555..a0e0bca84 100644 --- a/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java +++ b/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java @@ -4,6 +4,7 @@ import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.annotation.IdRes; +import android.support.annotation.IntRange; import android.support.annotation.Nullable; import android.support.annotation.StyleRes; @@ -29,7 +30,6 @@ public class ApplicationPref { /** Application Base Options */ public static final String _isLightTheme = "_isLightTheme"; public static final String _updateChannel = "_updateChannel"; - public static final String _isAmoledTheme = "_isAmoledTheme"; /** Api Keys */ private static final String _sortOrder = "_sortOrder"; @@ -77,7 +77,7 @@ public void toggleTheme() { } public boolean isAmoledEnabled() { - return sharedPreferences.getBoolean(_isAmoledTheme, false); + return sharedPreferences.getBoolean(context.getString(R.string.pref_key_amoled_theme), false); } // Returns the IDs of the startup page diff --git a/app/src/main/java/com/mxt/anitrend/util/ComparatorProvider.java b/app/src/main/java/com/mxt/anitrend/util/ComparatorUtil.java similarity index 89% rename from app/src/main/java/com/mxt/anitrend/util/ComparatorProvider.java rename to app/src/main/java/com/mxt/anitrend/util/ComparatorUtil.java index 9a981ab9e..e3a791910 100644 --- a/app/src/main/java/com/mxt/anitrend/util/ComparatorProvider.java +++ b/app/src/main/java/com/mxt/anitrend/util/ComparatorUtil.java @@ -7,7 +7,7 @@ * Created by Maxwell on 2/12/2017. * Comparator Provider returns comparators of various types */ -public final class ComparatorProvider { +public final class ComparatorUtil { public static Comparator> getKeyComparator() { return (o1, o2) -> o1.getKey().compareTo(o2.getKey()); diff --git a/app/src/main/java/com/mxt/anitrend/util/CompatUtil.java b/app/src/main/java/com/mxt/anitrend/util/CompatUtil.java index e39ad13f3..c90f2a651 100644 --- a/app/src/main/java/com/mxt/anitrend/util/CompatUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/CompatUtil.java @@ -454,10 +454,10 @@ public static Optional> findIndexOf(T[] collection, T target) { /** * Sorts a given map by the order of the of the keys in the map in descending order - * @see ComparatorProvider#getKeyComparator() for logic on how comparator handles this + * @see ComparatorUtil#getKeyComparator() for logic on how comparator handles this */ public static List> getKeyFilteredMap(Map map) { - return Stream.of(map).sorted(ComparatorProvider.getKeyComparator()).toList(); + return Stream.of(map).sorted(ComparatorUtil.getKeyComparator()).toList(); } public static boolean isLowRamDevice(Context context) { diff --git a/app/src/main/java/com/mxt/anitrend/util/DialogUtil.java b/app/src/main/java/com/mxt/anitrend/util/DialogUtil.java index d007a8170..61d757cb3 100644 --- a/app/src/main/java/com/mxt/anitrend/util/DialogUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/DialogUtil.java @@ -13,7 +13,6 @@ import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.Theme; -import com.annimon.stream.Stream; import com.mxt.anitrend.BuildConfig; import com.mxt.anitrend.R; import com.mxt.anitrend.base.custom.view.text.RichMarkdownTextView; @@ -50,7 +49,7 @@ public static void createDialogAttachMedia(@IdRes int action, final EditText edi if(editText != null) { if(!TextUtils.isEmpty(editText.getText())) { int start = editor.getSelectionStart(); - editor.getEditableText().insert(start, MarkDown.convertLink(editText.getText())); + editor.getEditableText().insert(start, MarkDownUtil.convertLink(editText.getText())); dialog.dismiss(); } else { NotifyUtil.makeText(context, R.string.input_empty_warning, Toast.LENGTH_SHORT).show(); @@ -75,7 +74,7 @@ public static void createDialogAttachMedia(@IdRes int action, final EditText edi if(editText != null) { if(!TextUtils.isEmpty(editText.getText())) { int start = editor.getSelectionStart(); - editor.getEditableText().insert(start, MarkDown.convertImage(editText.getText())); + editor.getEditableText().insert(start, MarkDownUtil.convertImage(editText.getText())); dialog.dismiss(); } else { NotifyUtil.makeText(context, R.string.input_empty_warning, Toast.LENGTH_SHORT).show(); @@ -100,7 +99,7 @@ public static void createDialogAttachMedia(@IdRes int action, final EditText edi if(editText != null) { if(!TextUtils.isEmpty(editText.getText())) { int start = editor.getSelectionStart(); - editor.getEditableText().insert(start, MarkDown.convertYoutube(editText.getText())); + editor.getEditableText().insert(start, MarkDownUtil.convertYoutube(editText.getText())); dialog.dismiss(); } else { NotifyUtil.makeText(context, R.string.input_empty_warning, Toast.LENGTH_SHORT).show(); @@ -125,7 +124,7 @@ public static void createDialogAttachMedia(@IdRes int action, final EditText edi if(editText != null) { if(!TextUtils.isEmpty(editText.getText())) { int start = editor.getSelectionStart(); - editor.getEditableText().insert(start, MarkDown.convertVideo(editText.getText())); + editor.getEditableText().insert(start, MarkDownUtil.convertVideo(editText.getText())); dialog.dismiss(); } else { NotifyUtil.makeText(context, R.string.input_empty_warning, Toast.LENGTH_SHORT).show(); @@ -166,7 +165,7 @@ public static void createMessage(Context context, String title, String content) createDefaultDialog(context).title(title) .positiveText(R.string.Close) .icon(CompatUtil.getTintedDrawable(context, R.drawable.ic_new_releases_white_24dp)) - .content(MarkDown.convert(content)) + .content(MarkDownUtil.convert(content)) .autoDismiss(true).show(); } @@ -176,7 +175,7 @@ public static void createMessage(Context context, String title, String content, .negativeText(negative) .neutralText(neutral) .icon(CompatUtil.getTintedDrawable(context, R.drawable.ic_new_releases_white_24dp)) - .content(MarkDown.convert(content)) + .content(MarkDownUtil.convert(content)) .autoDismiss(true).onAny(singleButtonCallback).show(); } @@ -185,7 +184,7 @@ public static void createMessage(Context context, String title, String content, .positiveText(positive) .negativeText(negative) .icon(CompatUtil.getTintedDrawable(context, R.drawable.ic_new_releases_white_24dp)) - .content(MarkDown.convert(content)) + .content(MarkDownUtil.convert(content)) .autoDismiss(true).onAny(singleButtonCallback).show(); } diff --git a/app/src/main/java/com/mxt/anitrend/util/EpisodeHelper.java b/app/src/main/java/com/mxt/anitrend/util/EpisodeUtil.java similarity index 97% rename from app/src/main/java/com/mxt/anitrend/util/EpisodeHelper.java rename to app/src/main/java/com/mxt/anitrend/util/EpisodeUtil.java index 126d8c27d..43db8b97b 100644 --- a/app/src/main/java/com/mxt/anitrend/util/EpisodeHelper.java +++ b/app/src/main/java/com/mxt/anitrend/util/EpisodeUtil.java @@ -10,7 +10,7 @@ * Episode list helper that check for crunchy feeds */ -public class EpisodeHelper { +public class EpisodeUtil { public static String episodeSupport(List links) { for (ExternalLink link : links) diff --git a/app/src/main/java/com/mxt/anitrend/util/GlideImageGetter.java b/app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java similarity index 88% rename from app/src/main/java/com/mxt/anitrend/util/GlideImageGetter.java rename to app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java index 17f18fe67..9d4e08148 100644 --- a/app/src/main/java/com/mxt/anitrend/util/GlideImageGetter.java +++ b/app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java @@ -17,18 +17,19 @@ import com.mxt.anitrend.R; /** + * Created by max * Uses glide to load images into an AppCompatTextView */ -public class GlideImageGetter implements Html.ImageGetter { +public class GlideImageUtil implements Html.ImageGetter { private Context context; private AppCompatTextView appCompatTextView; - public static GlideImageGetter create(Context context, AppCompatTextView appCompatTextView) { - return new GlideImageGetter(context, appCompatTextView); + public static GlideImageUtil create(Context context, AppCompatTextView appCompatTextView) { + return new GlideImageUtil(context, appCompatTextView); } - private GlideImageGetter(Context context, AppCompatTextView appCompatTextView) { + private GlideImageUtil(Context context, AppCompatTextView appCompatTextView) { this.context = context; this.appCompatTextView = appCompatTextView; } diff --git a/app/src/main/java/com/mxt/anitrend/util/HtmlTagHandler.java b/app/src/main/java/com/mxt/anitrend/util/HtmlTagUtil.java similarity index 64% rename from app/src/main/java/com/mxt/anitrend/util/HtmlTagHandler.java rename to app/src/main/java/com/mxt/anitrend/util/HtmlTagUtil.java index d1e6fbbe3..2ed7e98ea 100644 --- a/app/src/main/java/com/mxt/anitrend/util/HtmlTagHandler.java +++ b/app/src/main/java/com/mxt/anitrend/util/HtmlTagUtil.java @@ -6,15 +6,16 @@ import org.xml.sax.XMLReader; /** + * created by max * Helps us handle custom tags which may not be supported */ -public class HtmlTagHandler implements Html.TagHandler { +public class HtmlTagUtil implements Html.TagHandler { - public static HtmlTagHandler create() { - return new HtmlTagHandler(); + public static HtmlTagUtil create() { + return new HtmlTagUtil(); } - private HtmlTagHandler() { + private HtmlTagUtil() { } diff --git a/app/src/main/java/com/mxt/anitrend/util/IntentBundleUtil.java b/app/src/main/java/com/mxt/anitrend/util/IntentBundleUtil.java index d48c19b34..7c78bb9f8 100644 --- a/app/src/main/java/com/mxt/anitrend/util/IntentBundleUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/IntentBundleUtil.java @@ -24,7 +24,7 @@ public class IntentBundleUtil { public IntentBundleUtil(Intent intent, FragmentActivity context) { if(intent != null) { if(intent.hasExtra(KeyUtil.arg_shortcut_used) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) - ShortcutHelper.reportShortcutUsage(context, intent.getIntExtra(KeyUtil.arg_shortcut_used, KeyUtil.SHORTCUT_SEARCH)); + ShortcutUtil.reportShortcutUsage(context, intent.getIntExtra(KeyUtil.arg_shortcut_used, KeyUtil.SHORTCUT_SEARCH)); checkIntentData(intent, context); } } @@ -102,7 +102,7 @@ private void checkIntentData(Intent intent, FragmentActivity context) { sharedIntent = ShareCompat.IntentReader.from(context); else if ((INTENT_DATA = hasData(intent)) != null) - if((deepLinkMatcher = PatternMatcher.findIntentKeys(INTENT_DATA.getPath())) != null) + if((deepLinkMatcher = RegexUtil.findIntentKeys(INTENT_DATA.getPath())) != null) injectIntentParams(intent); } diff --git a/app/src/main/java/com/mxt/anitrend/util/LocaleHelper.java b/app/src/main/java/com/mxt/anitrend/util/LocaleUtil.java similarity index 98% rename from app/src/main/java/com/mxt/anitrend/util/LocaleHelper.java rename to app/src/main/java/com/mxt/anitrend/util/LocaleUtil.java index e6f5353a0..11d1a1d3d 100644 --- a/app/src/main/java/com/mxt/anitrend/util/LocaleHelper.java +++ b/app/src/main/java/com/mxt/anitrend/util/LocaleUtil.java @@ -15,7 +15,7 @@ * * Created by gunhansancar on 07/10/15. */ -public class LocaleHelper { +public class LocaleUtil { public static Context onAttach(Context context) { String language = new ApplicationPref(context).getUserLanguage(); diff --git a/app/src/main/java/com/mxt/anitrend/util/MarkDown.java b/app/src/main/java/com/mxt/anitrend/util/MarkDownUtil.java similarity index 66% rename from app/src/main/java/com/mxt/anitrend/util/MarkDown.java rename to app/src/main/java/com/mxt/anitrend/util/MarkDownUtil.java index cf9445c4b..3dc978dda 100644 --- a/app/src/main/java/com/mxt/anitrend/util/MarkDown.java +++ b/app/src/main/java/com/mxt/anitrend/util/MarkDownUtil.java @@ -10,6 +10,7 @@ import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; +import android.util.Log; import com.github.rjeschke.txtmark.Processor; @@ -17,7 +18,7 @@ * Created by max on 2017/03/26. * Moved markdown processor to global location */ -public final class MarkDown { +public final class MarkDownUtil { private static SpannableStringBuilder fromMD(@NonNull String content) { Spanned htmlConverted; @@ -34,11 +35,16 @@ public static Spanned convert(@Nullable String input) { if(TextUtils.isEmpty(input)) result = fromMD("No content available"); else - result = fromMD(PatternMatcher.findUserTags(input)); + result = fromMD(RegexUtil.findUserTags(input)); - if(result.length() > 0) - while (result.charAt(result.length() - 1) == '\n') - result = result.delete(result.length() - 1, result.length()); + try { + if(result.length() > 0) + while (result.charAt(result.length() - 1) == '\n') + result = result.delete(result.length() - 1, result.length()); + } catch (Exception e) { + e.printStackTrace(); + Log.e("convert(input)", e.getMessage()); + } return result; } @@ -46,9 +52,9 @@ public static Spanned convert(@Nullable String input) { /* private static SpannableStringBuilder fromMD(@NonNull String content, Context context, AppCompatTextView source) { Spanned htmlConverted; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) - htmlConverted = Html.fromHtml(Processor.process(content), Html.FROM_HTML_MODE_LEGACY, GlideImageGetter.create(context, source), HtmlTagHandler.create()); + htmlConverted = Html.fromHtml(Processor.process(content), Html.FROM_HTML_MODE_LEGACY, GlideImageUtil.create(context, source), HtmlTagUtil.create()); else - htmlConverted = Html.fromHtml(Processor.process(content), GlideImageGetter.create(context, source), HtmlTagHandler.create()); + htmlConverted = Html.fromHtml(Processor.process(content), GlideImageUtil.create(context, source), HtmlTagUtil.create()); return (SpannableStringBuilder) htmlConverted; }*/ @@ -57,12 +63,17 @@ public static Spanned convert(@Nullable String input, Context context, AppCompat if(TextUtils.isEmpty(input)) result = fromMD("No content available"); else - result = fromMD(PatternMatcher.findUserTags(input)); - // result = fromMD(PatternMatcher.findUserTags(input), context, source); - - if(result.length() > 0) - while (result.charAt(result.length() - 1) == '\n') - result = result.delete(result.length() - 1, result.length()); + result = fromMD(RegexUtil.findUserTags(input)); + // result = fromMD(RegexUtil.findUserTags(input), context, source); + + try { + if(result.length() > 0) + while (result.charAt(result.length() - 1) == '\n') + result = result.delete(result.length() - 1, result.length()); + } catch (Exception e) { + e.printStackTrace(); + Log.e("convert(input...)", e.getMessage()); + } return result; } @@ -84,18 +95,18 @@ static String convertVideo(Editable text) { } public static String convertLink(String text) { - return PatternMatcher.createLinkStandard(text); + return RegexUtil.createLinkStandard(text); } public static String convertImage(String text) { - return PatternMatcher.createImageStandard(text); + return RegexUtil.createImageStandard(text); } public static String convertYoutube(String text) { - return PatternMatcher.createYoutubeStandard(text); + return RegexUtil.createYoutubeStandard(text); } public static String convertVideo(String text) { - return PatternMatcher.createWebMStandard(text); + return RegexUtil.createWebMStandard(text); } } diff --git a/app/src/main/java/com/mxt/anitrend/util/MediaDialogUtil.java b/app/src/main/java/com/mxt/anitrend/util/MediaDialogUtil.java index f56eef367..d11194bed 100644 --- a/app/src/main/java/com/mxt/anitrend/util/MediaDialogUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/MediaDialogUtil.java @@ -185,7 +185,7 @@ private static CustomSeriesManageBase buildManagerType(Context context, @KeyUtil private static MaterialDialog.Builder createSeriesManageDialog(Context context, boolean isNewEntry, String title) { MaterialDialog.Builder materialBuilder = createDefaultDialog(context) .icon(CompatUtil.getDrawableTintAttr(context, isNewEntry ? R.drawable.ic_fiber_new_white_24dp : R.drawable.ic_border_color_white_24dp, R.attr.colorAccent)) - .title(MarkDown.convert(context.getString(isNewEntry? R.string.dialog_add_title : R.string.dialog_edit_title, title))) + .title(MarkDownUtil.convert(context.getString(isNewEntry? R.string.dialog_add_title : R.string.dialog_edit_title, title))) .positiveText(isNewEntry? R.string.Add: R.string.Update) .neutralText(R.string.Cancel) .autoDismiss(false); diff --git a/app/src/main/java/com/mxt/anitrend/util/NotificationDispatcher.java b/app/src/main/java/com/mxt/anitrend/util/NotificationUtil.java similarity index 96% rename from app/src/main/java/com/mxt/anitrend/util/NotificationDispatcher.java rename to app/src/main/java/com/mxt/anitrend/util/NotificationUtil.java index 2b42c7520..e03061dd2 100644 --- a/app/src/main/java/com/mxt/anitrend/util/NotificationDispatcher.java +++ b/app/src/main/java/com/mxt/anitrend/util/NotificationUtil.java @@ -14,10 +14,10 @@ /** * Created by max on 1/22/2017. - * NotificationDispatcher + * NotificationUtil */ -public final class NotificationDispatcher { +public final class NotificationUtil { private static final int NOTIFICATION_ID = 0x00000111; diff --git a/app/src/main/java/com/mxt/anitrend/util/PatternMatcher.java b/app/src/main/java/com/mxt/anitrend/util/RegexUtil.java similarity index 99% rename from app/src/main/java/com/mxt/anitrend/util/PatternMatcher.java rename to app/src/main/java/com/mxt/anitrend/util/RegexUtil.java index 6a451c78a..43d64c3c5 100644 --- a/app/src/main/java/com/mxt/anitrend/util/PatternMatcher.java +++ b/app/src/main/java/com/mxt/anitrend/util/RegexUtil.java @@ -11,7 +11,7 @@ * Created by max on 2017/04/08. * Pattern matcher uses regex to return possible matches for media types */ -public class PatternMatcher { +public class RegexUtil { public static final String KEY_IMG = "img"; public static final String KEY_WEB = "webm"; diff --git a/app/src/main/java/com/mxt/anitrend/util/ShortcutHelper.java b/app/src/main/java/com/mxt/anitrend/util/ShortcutUtil.java similarity index 99% rename from app/src/main/java/com/mxt/anitrend/util/ShortcutHelper.java rename to app/src/main/java/com/mxt/anitrend/util/ShortcutUtil.java index 6ff86e56b..f1bcd187d 100644 --- a/app/src/main/java/com/mxt/anitrend/util/ShortcutHelper.java +++ b/app/src/main/java/com/mxt/anitrend/util/ShortcutUtil.java @@ -28,7 +28,7 @@ @TargetApi(Build.VERSION_CODES.N_MR1) @RequiresApi(Build.VERSION_CODES.N_MR1) -public class ShortcutHelper { +public class ShortcutUtil { private static Intent createIntentAction(Context context, Class targetActivity, Bundle param) { Intent intent = new Intent(context, targetActivity); diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java index b9f99bfa7..e932feb2c 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java @@ -28,7 +28,7 @@ import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.DialogUtil; import com.mxt.anitrend.util.KeyUtil; -import com.mxt.anitrend.util.MarkDown; +import com.mxt.anitrend.util.MarkDownUtil; import com.mxt.anitrend.util.NotifyUtil; import com.mxt.anitrend.view.sheet.BottomSheetGiphy; @@ -192,16 +192,16 @@ public void getItemSelected() { @KeyUtil.ShareType int position = sharedResourceType.getSelectedItemPosition(); switch (position) { case KeyUtil.IMAGE_TYPE: - binding.composerWidget.setText(MarkDown.convertImage(text)); + binding.composerWidget.setText(MarkDownUtil.convertImage(text)); break; case KeyUtil.LINK_TYPE: - binding.composerWidget.setText(MarkDown.convertLink(text)); + binding.composerWidget.setText(MarkDownUtil.convertLink(text)); break; case KeyUtil.WEBM_TYPE: - binding.composerWidget.setText(MarkDown.convertVideo(text)); + binding.composerWidget.setText(MarkDownUtil.convertVideo(text)); break; case KeyUtil.YOUTUBE_TYPE: - binding.composerWidget.setText(MarkDown.convertYoutube(text)); + binding.composerWidget.setText(MarkDownUtil.convertYoutube(text)); break; case KeyUtil.PLAIN_TYPE: binding.composerWidget.setText(text); diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/detail/MediaBrowseActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/detail/MediaBrowseActivity.java index 9bc6a0706..c181b6bcd 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/detail/MediaBrowseActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/detail/MediaBrowseActivity.java @@ -13,7 +13,7 @@ import com.mxt.anitrend.presenter.base.BasePresenter; import com.mxt.anitrend.presenter.fragment.MediaPresenter; import com.mxt.anitrend.util.KeyUtil; -import com.mxt.anitrend.util.MarkDown; +import com.mxt.anitrend.util.MarkDownUtil; import com.mxt.anitrend.view.fragment.list.MediaBrowseFragment; import butterknife.BindView; @@ -42,7 +42,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onPostCreate(@Nullable Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); if(getIntent().hasExtra(KeyUtil.arg_activity_tag)) { - Spanned activityTitle = MarkDown.convert(getIntent().getStringExtra(KeyUtil.arg_activity_tag)); + Spanned activityTitle = MarkDownUtil.convert(getIntent().getStringExtra(KeyUtil.arg_activity_tag)); mActionBar.setTitle(activityTitle); } onActivityReady(); diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java index 5e55a213d..f6d5d939d 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java @@ -1,6 +1,5 @@ package com.mxt.anitrend.view.activity.index; -import android.annotation.TargetApi; import android.content.Intent; import android.databinding.DataBindingUtil; import android.net.Uri; @@ -26,7 +25,7 @@ import com.mxt.anitrend.util.JobSchedulerUtil; import com.mxt.anitrend.util.KeyUtil; import com.mxt.anitrend.util.NotifyUtil; -import com.mxt.anitrend.util.ShortcutHelper; +import com.mxt.anitrend.util.ShortcutUtil; /** * Created by max on 2017/11/03. @@ -100,19 +99,19 @@ private void createApplicationShortcuts() { Bundle SHORTCUT_PROFILE_BUNDLE = new Bundle(); SHORTCUT_PROFILE_BUNDLE.putString(KeyUtil.arg_userName, model.getName()); - ShortcutHelper.createShortcuts(LoginActivity.this, - new ShortcutHelper.ShortcutBuilder() + ShortcutUtil.createShortcuts(LoginActivity.this, + new ShortcutUtil.ShortcutBuilder() .setShortcutType(KeyUtil.SHORTCUT_NOTIFICATION) .build(), - new ShortcutHelper.ShortcutBuilder() + new ShortcutUtil.ShortcutBuilder() .setShortcutType(KeyUtil.SHORTCUT_MY_ANIME) .setShortcutParams(SHORTCUT_MY_ANIME_BUNDLE) .build(), - new ShortcutHelper.ShortcutBuilder() + new ShortcutUtil.ShortcutBuilder() .setShortcutType(KeyUtil.SHORTCUT_MY_MANGA) .setShortcutParams(SHORTCUT_MY_MANGA_BUNDLE) .build(), - new ShortcutHelper.ShortcutBuilder() + new ShortcutUtil.ShortcutBuilder() .setShortcutType(KeyUtil.SHORTCUT_PROFILE) .setShortcutParams(SHORTCUT_PROFILE_BUNDLE) .build()); diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/index/MainActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/index/MainActivity.java index 71e0b3fd0..3a537c2cc 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/index/MainActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/index/MainActivity.java @@ -47,7 +47,7 @@ import com.mxt.anitrend.util.DateUtil; import com.mxt.anitrend.util.DialogUtil; import com.mxt.anitrend.util.KeyUtil; -import com.mxt.anitrend.util.MarkDown; +import com.mxt.anitrend.util.MarkDownUtil; import com.mxt.anitrend.util.NotifyUtil; import com.mxt.anitrend.view.activity.base.AboutActivity; import com.mxt.anitrend.view.activity.base.SettingsActivity; @@ -406,7 +406,7 @@ protected void updateUI() { if(versionBase != null && versionBase.isNewerVersion()) { // If a new version of the application is available on GitHub TextView mAppUpdateWidget = menuItems.findItem(R.id.nav_check_update).getActionView().findViewById(R.id.app_update_info); - mAppUpdateWidget.setText(MarkDown.convert(getString(R.string.app_update, versionBase.getVersion()))); + mAppUpdateWidget.setText(MarkDownUtil.convert(getString(R.string.app_update, versionBase.getVersion()))); mAppUpdateWidget.setVisibility(View.VISIBLE); } checkNewInstallation(); diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/detail/NotificationFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/detail/NotificationFragment.java index 4d6fe7b2b..59a2abebb 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/detail/NotificationFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/detail/NotificationFragment.java @@ -15,7 +15,6 @@ import com.mxt.anitrend.adapter.recycler.detail.NotificationAdapter; import com.mxt.anitrend.base.custom.async.ThreadPool; import com.mxt.anitrend.base.custom.fragment.FragmentBaseList; -import com.mxt.anitrend.data.DatabaseHelper; import com.mxt.anitrend.model.entity.anilist.Notification; import com.mxt.anitrend.model.entity.anilist.User; import com.mxt.anitrend.model.entity.base.NotificationHistory; @@ -78,8 +77,8 @@ protected void updateUI() { //Testing notifications by forcing the notification dispatcher /*for (int i = 0; i < 3; i++) - NotificationDispatcher.createNotification(getContext(), new ArrayList<>(model.subList(i, i + 1)));*/ - // NotificationDispatcher.createNotification(getContext(), new ArrayList<>(model.subList(5, 6))); + NotificationUtil.createNotification(getContext(), new ArrayList<>(model.subList(i, i + 1)));*/ + // NotificationUtil.createNotification(getContext(), new ArrayList<>(model.subList(5, 6))); } @Override @@ -167,13 +166,11 @@ private void setItemAsRead(final Notification data) { * @see ThreadPool */ private void markAllNotificationsAsRead() { - DatabaseHelper databaseHelper = getPresenter().getDatabase(); - List notificationHistories = Stream.of(mAdapter.getData()) .map(notification -> new NotificationHistory(notification.getId())) .toList(); - databaseHelper.getBoxStore(NotificationHistory.class) + getPresenter().getDatabase().getBoxStore(NotificationHistory.class) .put(notificationHistories); if (getActivity() != null) diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java index 460b6f76e..60f1b2dd0 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java @@ -17,7 +17,7 @@ import com.mxt.anitrend.model.entity.container.body.ConnectionContainer; import com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder; import com.mxt.anitrend.presenter.widget.WidgetPresenter; -import com.mxt.anitrend.util.EpisodeHelper; +import com.mxt.anitrend.util.EpisodeUtil; import com.mxt.anitrend.util.ErrorUtil; import com.mxt.anitrend.util.GraphUtil; import com.mxt.anitrend.util.KeyUtil; @@ -116,7 +116,7 @@ public void onResponse(@NonNull Call>> ca if(!connectionContainer.isEmpty()) { externalLinks = connectionContainer.getConnection(); if(mAdapter.getItemCount() < 1 && externalLinks != null) - targetLink = EpisodeHelper.episodeSupport(externalLinks); + targetLink = EpisodeUtil.episodeSupport(externalLinks); if (targetLink == null) showEmpty(getString(R.string.waring_missing_episode_links)); else diff --git a/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetMessage.java b/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetMessage.java index d43c9c07c..1a665ced8 100644 --- a/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetMessage.java +++ b/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetMessage.java @@ -11,7 +11,6 @@ import com.mxt.anitrend.base.custom.sheet.BottomSheetBase; import com.mxt.anitrend.base.custom.view.text.RichMarkdownTextView; import com.mxt.anitrend.util.KeyUtil; -import com.mxt.anitrend.util.MarkDown; import butterknife.BindView; import butterknife.ButterKnife; diff --git a/app/src/test/java/com/mxt/anitrend/util/EpisodeHelperTests.java b/app/src/test/java/com/mxt/anitrend/util/EpisodeUtilTests.java similarity index 88% rename from app/src/test/java/com/mxt/anitrend/util/EpisodeHelperTests.java rename to app/src/test/java/com/mxt/anitrend/util/EpisodeUtilTests.java index c1cd51c1d..ad5c45e12 100644 --- a/app/src/test/java/com/mxt/anitrend/util/EpisodeHelperTests.java +++ b/app/src/test/java/com/mxt/anitrend/util/EpisodeUtilTests.java @@ -17,7 +17,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class EpisodeHelperTests { +public class EpisodeUtilTests { @Test @@ -28,7 +28,7 @@ public void episodeSupport_givenCrunchyrollUrl_shouldReturnTheFeedUrl() { List links = Collections.singletonList(link); - assertThat(EpisodeHelper.episodeSupport(links), equalTo(show + ".rss")); + assertThat(EpisodeUtil.episodeSupport(links), equalTo(show + ".rss")); } @@ -40,7 +40,7 @@ public void episodeSupport_givenFeedUrl_shouldReturnTheSameLink() { when(link.getUrl()).thenReturn(url); List links = Collections.singletonList(link); - assertThat(EpisodeHelper.episodeSupport(links), equalTo(url)); + assertThat(EpisodeUtil.episodeSupport(links), equalTo(url)); } @Test @@ -56,7 +56,7 @@ public void episodeSupport_givenCrunchyrollAndFeedUrl_shouldReturnEither() { when(link2.getUrl()).thenReturn(feedUrl); List links = Arrays.asList(link1, link2); - assertThat(EpisodeHelper.episodeSupport(links), + assertThat(EpisodeUtil.episodeSupport(links), is(anyOf( equalTo(show + ".rss"), equalTo(feedUrl) @@ -75,6 +75,6 @@ public void episodeSupport_notGivenASupportedLink_shouldReturnNull() { when(link2.getUrl()).thenReturn(twitter); List links = Arrays.asList(link1, link2); - assertThat(EpisodeHelper.episodeSupport(links), nullValue()); + assertThat(EpisodeUtil.episodeSupport(links), nullValue()); } } \ No newline at end of file diff --git a/app/src/test/java/com/mxt/anitrend/util/EpisodeHelper_GetActualTitleTest.java b/app/src/test/java/com/mxt/anitrend/util/EpisodeUtil_GetActualTitleTest.java similarity index 86% rename from app/src/test/java/com/mxt/anitrend/util/EpisodeHelper_GetActualTitleTest.java rename to app/src/test/java/com/mxt/anitrend/util/EpisodeUtil_GetActualTitleTest.java index 42696aad6..f173fd150 100644 --- a/app/src/test/java/com/mxt/anitrend/util/EpisodeHelper_GetActualTitleTest.java +++ b/app/src/test/java/com/mxt/anitrend/util/EpisodeUtil_GetActualTitleTest.java @@ -10,7 +10,7 @@ import static org.hamcrest.Matchers.equalTo; @RunWith(Parameterized.class) -public class EpisodeHelper_GetActualTitleTest { +public class EpisodeUtil_GetActualTitleTest { @Parameterized.Parameters public static Iterable data() { @@ -30,7 +30,7 @@ public static Iterable data() { @Test public void getActualTile() { - assertThat(EpisodeHelper.getActualTile(inputTitle), equalTo(actualTitle)); + assertThat(EpisodeUtil.getActualTile(inputTitle), equalTo(actualTitle)); } } From aa09990edc1266a8d0c5f8eaf83cf7843c3cb036 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 11 Aug 2018 22:58:42 +0200 Subject: [PATCH 02/69] Job Dispatcher Rescheduling Enabled - Enabled rescheduling of jobs even when the operation was a success --- .../java/com/mxt/anitrend/service/JobDispatcherService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java b/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java index 6f1df478e..b428cc5ee 100644 --- a/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java +++ b/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java @@ -72,8 +72,8 @@ public boolean onStopJob(JobParameters job) { @Override @Subscribe(threadMode = ThreadMode.MAIN_ORDERED) public void onModelChanged(BaseConsumer consumer) { if(consumer.getRequestMode() == KeyUtil.USER_CURRENT_REQ && consumer.getChangeModel() != null) { - NotificationDispatcher.createNotification(getApplicationContext(), consumer.getChangeModel().getUnreadNotificationCount()); - jobFinished(job, false); + NotificationUtil.createNotification(getApplicationContext(), consumer.getChangeModel().getUnreadNotificationCount()); + jobFinished(job, true); } else jobFinished(job, true); } From 7a9fe4e7faf701681484f60a41e337abec66cadf Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 11 Aug 2018 22:59:28 +0200 Subject: [PATCH 03/69] Updated All Translation Files --- app/src/main/res/values-ar/strings.xml | 16 ++++-- app/src/main/res/values-de/strings.xml | 16 ++++-- app/src/main/res/values-es/strings.xml | 24 ++++++--- app/src/main/res/values-fr/strings.xml | 16 ++++-- app/src/main/res/values-it/strings.xml | 17 +++++-- app/src/main/res/values-pl/strings.xml | 23 ++++++--- app/src/main/res/values/strings.xml | 69 +++++++++++++------------- 7 files changed, 113 insertions(+), 68 deletions(-) diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 01bfaf04f..d5e994bf7 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -926,13 +926,21 @@ Privacy Configure privacy settings + + Amoled Theme + Toggle Theme option will default to non amoled mode (requires restart) + Toggle Theme option will default to amoled mode (requires restart) + + + Application Language + Crash Reports - Enable Crash Reports (require app restart) - Disable Crash Reports (require app restart) + Don\'t allow crashes to be reported (requires restart) + Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) Usage Analytics - Enable Usage Analytics (require app restart) - Disable Usage Analytics (require app restart) + Don\'t send any information about usage or bug identification (requires restart) + Allow information like most used activity and user id to be attached to bug reports (requires restart) Start Date Finish Date diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 0f4ea3d38..17dbda623 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -926,13 +926,21 @@ Privacy Configure privacy settings + + Amoled Theme + Toggle Theme option will default to non amoled mode (requires restart) + Toggle Theme option will default to amoled mode (requires restart) + + + Application Language + Crash Reports - Enable Crash Reports (require app restart) - Disable Crash Reports (require app restart) + Don\'t allow crashes to be reported (requires restart) + Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) Usage Analytics - Enable Usage Analytics (require app restart) - Disable Usage Analytics (require app restart) + Don\'t send any information about usage or bug identification (requires restart) + Allow information like most used activity and user id to be attached to bug reports (requires restart) Start Date Finish Date diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 188019d87..58961941d 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -923,16 +923,24 @@ elementos de tus favoritos al presionar en el icono del corazón . Se recomienda Google Chrome - Privacidad - Configura los ajustes de privacidad + Privacy + Configure privacy settings - Informe de fallos - Habilita los informes de fallos (requiere reiniciar la app) - Inhabilita los informes de fallos (requiere reiniciar la app) + + Amoled Theme + Toggle Theme option will default to non amoled mode (requires restart) + Toggle Theme option will default to amoled mode (requires restart) - Análisis de uso - Habilita el análisis de uso (requiere reinicio de la app) - Inhabilita el análisis de uso (requiere reinicio de la app) + + Application Language + + Crash Reports + Don\'t allow crashes to be reported (requires restart) + Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) + + Usage Analytics + Don\'t send any information about usage or bug identification (requires restart) + Allow information like most used activity and user id to be attached to bug reports (requires restart) Start Date Finish Date diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 1a1e056f6..c3f46fd62 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -930,13 +930,21 @@ Privacy Configure privacy settings + + Amoled Theme + Toggle Theme option will default to non amoled mode (requires restart) + Toggle Theme option will default to amoled mode (requires restart) + + + Application Language + Crash Reports - Enable Crash Reports (require app restart) - Disable Crash Reports (require app restart) + Don\'t allow crashes to be reported (requires restart) + Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) Usage Analytics - Enable Usage Analytics (require app restart) - Disable Usage Analytics (require app restart) + Don\'t send any information about usage or bug identification (requires restart) + Allow information like most used activity and user id to be attached to bug reports (requires restart) Start Date Finish Date diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 9b887c5b1..06415e053 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -922,17 +922,24 @@ Google Chrome Recommended - Privacy Configure privacy settings + + Amoled Theme + Toggle Theme option will default to non amoled mode (requires restart) + Toggle Theme option will default to amoled mode (requires restart) + + + Application Language + Crash Reports - Enable Crash Reports (require app restart) - Disable Crash Reports (require app restart) + Don\'t allow crashes to be reported (requires restart) + Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) Usage Analytics - Enable Usage Analytics (require app restart) - Disable Usage Analytics (require app restart) + Don\'t send any information about usage or bug identification (requires restart) + Allow information like most used activity and user id to be attached to bug reports (requires restart) Start Date Finish Date diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index e34f0dece..fd5f1015a 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -926,17 +926,24 @@ Zalecane Google Chrome + Privacy + Configure privacy settings - Prywatność - Skonfiguruj ustawienia prywatności + + Amoled Theme + Toggle Theme option will default to non amoled mode (requires restart) + Toggle Theme option will default to amoled mode (requires restart) - Raporty o awariach - Włącz raporty awarii (wymagane ponowne uruchomienie aplikacji) - Wyłącz raporty awarii (wymagane ponowne uruchomienie aplikacji) + + Application Language - Analityka użytkowania - Włącz Analityke użytkowania (wymaga ponownego uruchomienia aplikacji) - Wyłącz Analityke użytkowania (wymaga ponownego uruchomienia aplikacji) + Crash Reports + Don\'t allow crashes to be reported (requires restart) + Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) + + Usage Analytics + Don\'t send any information about usage or bug identification (requires restart) + Allow information like most used activity and user id to be attached to bug reports (requires restart) Start Date Finish Date diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ec794c4f5..930a69b51 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -382,13 +382,6 @@ general_startup_page _updateChannel - - _isAmoledTheme - - Dark Theme (AMOLED) - Enable AMOLED Dark Theme - Disable AMOLED Dark Theme - Notifications Configure how notifications are handled @@ -428,30 +421,6 @@ 360 - - Application Language - selected_language - - - English - العربية - Deutsch - Español - Français - Italiano - Polski - - - - en - ar - de - es - fr - it - pl - - Do you want to create an account? @@ -988,12 +957,42 @@ Configure privacy settings Crash Reports - Enable Crash Reports (require app restart) - Disable Crash Reports (require app restart) + Don\'t allow crashes to be reported (requires restart) + Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) Usage Analytics - Enable Usage Analytics (require app restart) - Disable Usage Analytics (require app restart) + Don\'t send any information about usage or bug identification (requires restart) + Allow information like most used activity and user id to be attached to bug reports (requires restart) + + + _isAmoledTheme + Amoled Theme + Toggle Theme option will default to non amoled mode (requires restart) + Toggle Theme option will default to amoled mode (requires restart) + + + Application Language + selected_language + + + English + العربية + Deutsch + Español + Français + Italiano + Polski + + + + en + ar + de + es + fr + it + pl + Start Date Finish Date From 59d02e42d74726fc72b8c2f5b6cce8f833852b73 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 11 Aug 2018 22:59:39 +0200 Subject: [PATCH 04/69] Removed Blank Lines --- app/src/main/res/values/color.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/res/values/color.xml b/app/src/main/res/values/color.xml index 2d314e285..47b77f64e 100644 --- a/app/src/main/res/values/color.xml +++ b/app/src/main/res/values/color.xml @@ -72,6 +72,4 @@ #46000000 #1f000000 - - From ad659d7cac9566970fc752db8b8f88ccbf95f501 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 11 Aug 2018 23:02:03 +0200 Subject: [PATCH 05/69] Additional Null Checking For Notifications - Based on a crash report that was cause by a NPE on the user object when the notification type is not an airing type --- .../anitrend/adapter/recycler/detail/NotificationAdapter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java index eafd4e429..bff5c6bec 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java @@ -94,7 +94,8 @@ public void onBindViewHolder(Notification model) { binding.notificationTime.setText(DateUtil.getPrettyDateUnix(model.getCreatedAt())); if(!CompatUtil.equals(model.getType(), KeyUtil.AIRING)) - AspectImageView.setImage(binding.notificationImg, model.getUser().getAvatar().getLarge()); + if(model.getUser() != null && model.getUser().getAvatar() != null) + AspectImageView.setImage(binding.notificationImg, model.getUser().getAvatar().getLarge()); else AspectImageView.setImage(binding.notificationImg, model.getMedia().getCoverImage().getLarge()); From 64ec7f0df14ecd683ffec8ad5d4311903b65c874 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 11 Aug 2018 23:07:30 +0200 Subject: [PATCH 06/69] Dropping LinearScaleHelper & SpeedRecycler #69 - Attempt fix for issue #69 has led to the drop of old and necessary code for achieving snapping recycler views for images on feeds - New implementation makes use of PagerSnapHelper to achieve the same thing without the bloat code which was error prone - Changed the layout height of the view that hold feed images to fit parent since that already enforces the maximum height of the recycler children --- .../custom/recycler/SpeedRecyclerView.java | 71 -------- .../view/widget/StatusContentWidget.java | 19 +-- .../com/mxt/anitrend/util/CenterSnapUtil.java | 54 ++++++ .../mxt/anitrend/util/LinearScaleHelper.java | 155 ------------------ .../mxt/anitrend/util/LinearSnapHelper.java | 47 ------ .../main/res/layout/adapter_feed_slide.xml | 7 +- app/src/main/res/layout/widget_status.xml | 2 +- 7 files changed, 64 insertions(+), 291 deletions(-) delete mode 100644 app/src/main/java/com/mxt/anitrend/base/custom/recycler/SpeedRecyclerView.java create mode 100644 app/src/main/java/com/mxt/anitrend/util/CenterSnapUtil.java delete mode 100644 app/src/main/java/com/mxt/anitrend/util/LinearScaleHelper.java delete mode 100644 app/src/main/java/com/mxt/anitrend/util/LinearSnapHelper.java diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/recycler/SpeedRecyclerView.java b/app/src/main/java/com/mxt/anitrend/base/custom/recycler/SpeedRecyclerView.java deleted file mode 100644 index 04d5a8d18..000000000 --- a/app/src/main/java/com/mxt/anitrend/base/custom/recycler/SpeedRecyclerView.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.mxt.anitrend.base.custom.recycler; - -import android.content.Context; -import android.support.annotation.Nullable; -import android.support.v7.widget.RecyclerView; -import android.util.AttributeSet; - -import com.mxt.anitrend.base.interfaces.view.CustomView; -import com.mxt.anitrend.util.LinearSnapHelper; - -/** - * 控制fling速度的RecyclerView - * - * Created by jameson on 9/1/16. - */ -public class SpeedRecyclerView extends RecyclerView implements CustomView { - - private static final float FLING_SCALE_DOWN_FACTOR = 0.5f; // 减速因子 - private static final int FLING_MAX_VELOCITY = 8000; // 最大顺时滑动速度 - private final LinearSnapHelper mLinearSnapHelper = new LinearSnapHelper(); - - public SpeedRecyclerView(Context context) { - super(context); - onInit(); - } - - public SpeedRecyclerView(Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - onInit(); - } - - public SpeedRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - onInit(); - } - - @Override - public boolean fling(int velocityX, int velocityY) { - velocityX = solveVelocity(velocityX); - velocityY = solveVelocity(velocityY); - return super.fling(velocityX, velocityY); - } - - private int solveVelocity(int velocity) { - if (velocity > 0) - return Math.min(velocity, FLING_MAX_VELOCITY); - else - return Math.max(velocity, -FLING_MAX_VELOCITY); - } - - /** - * Optionally included when constructing custom views - */ - @Override - public void onInit() { - setOnFlingListener(null); - mLinearSnapHelper.attachToRecyclerView(this); - } - - /** - * Clean up any resources that won't be needed - */ - @Override - public void onViewRecycled() { - clearOnScrollListeners(); - } - - public LinearSnapHelper getSnapHelper() { - return mLinearSnapHelper; - } -} diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java index d6d0c3a38..b52a968fb 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java @@ -9,6 +9,7 @@ import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.SnapHelper; import android.text.TextUtils; import android.util.AttributeSet; import android.view.LayoutInflater; @@ -25,9 +26,9 @@ import com.mxt.anitrend.databinding.WidgetStatusBinding; import com.mxt.anitrend.model.entity.anilist.FeedList; import com.mxt.anitrend.model.entity.anilist.FeedReply; +import com.mxt.anitrend.util.CenterSnapUtil; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; -import com.mxt.anitrend.util.LinearScaleHelper; import com.mxt.anitrend.util.NotifyUtil; import com.mxt.anitrend.util.RegexUtil; import com.mxt.anitrend.view.activity.base.ImagePreviewActivity; @@ -41,11 +42,10 @@ * Created by max on 2017/11/25. */ -public class StatusContentWidget extends LinearLayout implements CustomView, LinearScaleHelper.PageChangeListener, ItemClickListener { +public class StatusContentWidget extends LinearLayout implements CustomView, ItemClickListener, CenterSnapUtil.PositionChangeListener { private List contentLinks, contentTypes; private WidgetStatusBinding binding; - private LinearScaleHelper linearScaleHelper; public StatusContentWidget(@NonNull Context context) { super(context); @@ -76,7 +76,8 @@ public void onInit() { binding = WidgetStatusBinding.inflate(LayoutInflater.from(getContext()), this, true); binding.widgetStatusRecycler.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); binding.widgetStatusRecycler.setNestedScrollingEnabled(true); - linearScaleHelper = new LinearScaleHelper(); + SnapHelper snapHelper = new CenterSnapUtil(this); + snapHelper.attachToRecyclerView(binding.widgetStatusRecycler); } public void setModel(FeedList model) { @@ -100,9 +101,6 @@ public void setTextData(String textData) { @Override public void onViewRecycled() { contentLinks = null; contentTypes = null; - binding.widgetStatusRecycler.onViewRecycled(); - if(linearScaleHelper != null) - linearScaleHelper.onViewRecycled(); } private void findMediaAttachments(@Nullable String value) { @@ -137,13 +135,6 @@ private void constructAdditionalViews() { binding.widgetStatusIndicator.setVisibility(VISIBLE); binding.widgetStatusIndicator.setMaximum(previewAdapter.getItemCount()); binding.widgetStatusIndicator.setCurrentPosition(1); - - linearScaleHelper.setPageChangeListener(this); - - linearScaleHelper.setScale(1.4f); - linearScaleHelper.setPagePadding(0); - linearScaleHelper.setShowLeftCardWidth(0); - linearScaleHelper.attachToRecyclerView(binding.widgetStatusRecycler); } binding.widgetSlideHolder.setVisibility(VISIBLE); } else diff --git a/app/src/main/java/com/mxt/anitrend/util/CenterSnapUtil.java b/app/src/main/java/com/mxt/anitrend/util/CenterSnapUtil.java new file mode 100644 index 000000000..c0616f418 --- /dev/null +++ b/app/src/main/java/com/mxt/anitrend/util/CenterSnapUtil.java @@ -0,0 +1,54 @@ +package com.mxt.anitrend.util; + +import android.support.annotation.NonNull; +import android.support.v7.widget.PagerSnapHelper; +import android.support.v7.widget.RecyclerView; +import android.view.View; + +import com.mxt.anitrend.base.interfaces.view.CustomView; + +/** + * Created by max on 2018/08/11. + */ + +public class CenterSnapUtil extends PagerSnapHelper implements CustomView { + + private PositionChangeListener positionChangeListener; + + public CenterSnapUtil(PositionChangeListener positionChangeListener) { + this.positionChangeListener = positionChangeListener; + } + + @Override + public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View targetView) { + return super.calculateDistanceToFinalSnap(layoutManager, targetView); + } + + @Override + public int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int velocityX, int velocityY) { + int position = super.findTargetSnapPosition(layoutManager, velocityX, velocityY); + if(positionChangeListener != null && position != RecyclerView.NO_POSITION) + positionChangeListener.onPageChanged(position + 1); + return position; + } + + /** + * Optionally included when constructing custom views + */ + @Override + public void onInit() { + + } + + /** + * Clean up any resources that won't be needed + */ + @Override + public void onViewRecycled() { + positionChangeListener = null; + } + + public interface PositionChangeListener { + void onPageChanged(int currentPage); + } +} diff --git a/app/src/main/java/com/mxt/anitrend/util/LinearScaleHelper.java b/app/src/main/java/com/mxt/anitrend/util/LinearScaleHelper.java deleted file mode 100644 index c81661790..000000000 --- a/app/src/main/java/com/mxt/anitrend/util/LinearScaleHelper.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.mxt.anitrend.util; - -import android.content.Context; -import android.support.v7.widget.RecyclerView; -import android.view.View; - -import com.mxt.anitrend.base.custom.recycler.SpeedRecyclerView; - -/** - * Created by jameson on 8/30/16. - */ -public class LinearScaleHelper extends RecyclerView.OnScrollListener { - - private SpeedRecyclerView speedRecyclerView; - private Context mContext; - - private float mScale = 0.9f; // 两边视图scale - private int mPagePadding = 15; // 卡片的padding, 卡片间的距离等于2倍的mPagePadding - private int mShowLeftCardWidth = 15; // 左边卡片显示大小 - - private int mCardWidth; // 卡片宽度 - private int mOnePageWidth; // 滑动一页的距离 - private int mCardGalleryWidth; - - private int mCurrentItemPos; - private int mCurrentItemOffset; - - private PageChangeListener pageChangeListener; - - public void attachToRecyclerView(SpeedRecyclerView mRecyclerView) { - mRecyclerView.addOnScrollListener(this); - speedRecyclerView = mRecyclerView; - mContext = mRecyclerView.getContext(); - initWidth(); - } - - public void setPageChangeListener(PageChangeListener pageChangeListener) { - this.pageChangeListener = pageChangeListener; - } - - @Override - public void onScrollStateChanged(RecyclerView recyclerView, int newState) { - super.onScrollStateChanged(recyclerView, newState); - LinearSnapHelper snapHelper = ((SpeedRecyclerView)recyclerView).getSnapHelper(); - if (newState == RecyclerView.SCROLL_STATE_IDLE) - snapHelper.mNoNeedToScroll = mCurrentItemOffset == 0 || mCurrentItemOffset == getDestItemOffset(recyclerView.getAdapter().getItemCount() - 1); - else - snapHelper.mNoNeedToScroll = false; - } - - @Override - public void onScrolled(RecyclerView recyclerView, int dx, int dy) { - super.onScrolled(recyclerView, dx, dy); - // dx>0则表示右滑, dx<0表示左滑, dy<0表示上滑, dy>0表示下滑 - mCurrentItemOffset += dx; - computeCurrentItemPos(); - onScrolledChangedCallback(); - } - - /** - * 初始化卡片宽度 - */ - private void initWidth() { - speedRecyclerView.post(() -> { - mCardGalleryWidth = speedRecyclerView.getWidth(); - mCardWidth = mCardGalleryWidth - CompatUtil.dipToPx(2 * (mPagePadding + mShowLeftCardWidth)); - mOnePageWidth = mCardWidth; - speedRecyclerView.smoothScrollToPosition(mCurrentItemPos); - onScrolledChangedCallback(); - }); - } - - public void setCurrentItemPos(int currentItemPos) { - this.mCurrentItemPos = currentItemPos; - } - - public int getCurrentItemPos() { - return mCurrentItemPos; - } - - private int getDestItemOffset(int destPos) { - return mOnePageWidth * destPos; - } - - /** - * 计算mCurrentItemOffset - */ - private void computeCurrentItemPos() { - if (mOnePageWidth <= 0) return; - boolean pageChanged = false; - // 滑动超过一页说明已翻页 - if (Math.abs(mCurrentItemOffset - mCurrentItemPos * mOnePageWidth) >= mOnePageWidth) { - pageChanged = true; - } - if (pageChanged) { - int tempPos = mCurrentItemPos; - mCurrentItemPos = mCurrentItemOffset / mOnePageWidth; - if(pageChangeListener != null) - pageChangeListener.onPageChanged(mCurrentItemPos + 1); - } - } - - /** - * RecyclerView位移事件监听, view大小随位移事件变化 - */ - private void onScrolledChangedCallback() { - int offset = mCurrentItemOffset - mCurrentItemPos * mOnePageWidth; - float percent = (float) Math.max(Math.abs(offset) * 1.0 / mOnePageWidth, 0.0001); - - View leftView = null; - View currentView; - View rightView = null; - if (mCurrentItemPos > 0) { - leftView = speedRecyclerView.getLayoutManager().findViewByPosition(mCurrentItemPos - 1); - } - currentView = speedRecyclerView.getLayoutManager().findViewByPosition(mCurrentItemPos); - if (mCurrentItemPos < speedRecyclerView.getAdapter().getItemCount() - 1) { - rightView = speedRecyclerView.getLayoutManager().findViewByPosition(mCurrentItemPos + 1); - } - - if (leftView != null) { - // y = (1 - mScale)x + mScale - leftView.setScaleY((1 - mScale) * percent + mScale); - } - if (currentView != null) { - // y = (mScale - 1)x + 1 - currentView.setScaleY((mScale - 1) * percent + 1); - } - if (rightView != null) { - // y = (1 - mScale)x + mScale - rightView.setScaleY((1 - mScale) * percent + mScale); - } - } - - public void setScale(float scale) { - mScale = scale; - } - - public void setPagePadding(int pagePadding) { - mPagePadding = pagePadding; - } - - public void setShowLeftCardWidth(int showLeftCardWidth) { - mShowLeftCardWidth = showLeftCardWidth; - } - - public void onViewRecycled() { - if(pageChangeListener != null) - pageChangeListener = null; - } - - public interface PageChangeListener { - void onPageChanged(int page); - } -} diff --git a/app/src/main/java/com/mxt/anitrend/util/LinearSnapHelper.java b/app/src/main/java/com/mxt/anitrend/util/LinearSnapHelper.java deleted file mode 100644 index b4da67f24..000000000 --- a/app/src/main/java/com/mxt/anitrend/util/LinearSnapHelper.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.mxt.anitrend.util; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.SnapHelper; -import android.view.View; - -/** - * 防止卡片在第一页和最后一页因无法"居中"而一直循环调用onScrollStateChanged-->SnapHelper.snapToTargetExistingView-->onScrollStateChanged - * Created by jameson on 9/3/16. - */ -public class LinearSnapHelper extends android.support.v7.widget.LinearSnapHelper { - - private boolean isAttached = false; - boolean mNoNeedToScroll = false; - - @Override - public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View targetView) { - if (mNoNeedToScroll) { - return new int[]{0, 0}; - } else { - return super.calculateDistanceToFinalSnap(layoutManager, targetView); - } - } - - /** - * Attaches the {@link SnapHelper} to the provided RecyclerView, by calling - * {@link RecyclerView#setOnFlingListener(RecyclerView.OnFlingListener)}. - * You can call this method with {@code null} to detach it from the current RecyclerView. - * - * @param recyclerView The RecyclerView instance to which you want to add this helper or - * {@code null} if you want to remove SnapHelper from the current - * RecyclerView. - * @throws IllegalArgumentException if there is already a {@link RecyclerView.OnFlingListener} - * attached to the provided {@link RecyclerView}. - */ - @Override - public void attachToRecyclerView(@Nullable RecyclerView recyclerView) throws IllegalStateException { - super.attachToRecyclerView(recyclerView); - isAttached = true; - } - - public boolean isAttached() { - return isAttached; - } -} diff --git a/app/src/main/res/layout/adapter_feed_slide.xml b/app/src/main/res/layout/adapter_feed_slide.xml index 9c37e5376..d61f305dd 100644 --- a/app/src/main/res/layout/adapter_feed_slide.xml +++ b/app/src/main/res/layout/adapter_feed_slide.xml @@ -9,12 +9,13 @@ + android:layout_height="match_parent" + tools:layout_height="wrap_content"> - - From 9071d5f936bfec7d09a62758fd1514093b3116e5 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 11 Aug 2018 23:07:48 +0200 Subject: [PATCH 07/69] Updated Change Log --- app/src/main/assets/changelog.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/assets/changelog.md b/app/src/main/assets/changelog.md index ed0449749..dff8b6bef 100644 --- a/app/src/main/assets/changelog.md +++ b/app/src/main/assets/changelog.md @@ -5,12 +5,15 @@ - Take a moment to give us your [feedback](https://poll.ly/#/PEA4x1Wg), thank you. ### Enhancements -- Amoled theme, find option in settings then use the toggle theme entry -- Changeable application language, find this option in settings +- New amoled theme: __Settings -> General__ +- New changeable application language: __Settings -> General__ +- New personalised score types based on your profile settings +- New start and end dates for your anime/manga lists ### Bug Fixes -- +- What??? Do you seriously expect us to fix any bugs!? Look just enjoy the app, they're all features! ### Current Issues - Clicking on @username shows mixed feed -- Emojis have been disabled. _New AniList site doesn't support them anymore_ \ No newline at end of file +- Sometimes image slide count doesn't change when you scroll slowly in feeds +- Notifications don't always work (We don't have an ETA for a fix at the moment, please bear with us) \ No newline at end of file From 457da59f2e6734a6cb1f310b6416ec0ff11c1a54 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 11 Aug 2018 23:08:03 +0200 Subject: [PATCH 08/69] Updated Release Version --- app/release/output.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/release/output.json b/app/release/output.json index 4263208a3..f36d630c8 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":85,"versionName":"1.1.2","enabled":true,"outputFile":"anitrend_v1.1.2_rc_85.apk","fullName":"release","baseName":"release"},"path":"anitrend_v1.1.2_rc_85.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":86,"versionName":"1.2.0","enabled":true,"outputFile":"anitrend_v1.2.0_rc_86.apk","fullName":"release","baseName":"release"},"path":"anitrend_v1.2.0_rc_86.apk","properties":{}}] \ No newline at end of file From e624c6ee2dc4d142900981fc1332247dc88acfda Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 13 Aug 2018 15:13:25 +0200 Subject: [PATCH 09/69] Fixed Number Format Exception in ScoreWidget - Number format exception that was being thrown when a period`.` was added into the field without any proceeding or preceding numbers --- .../mxt/anitrend/base/custom/view/widget/ScoreWidget.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ScoreWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ScoreWidget.java index bbf949243..99fe29417 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ScoreWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/ScoreWidget.java @@ -150,7 +150,12 @@ public void afterTextChanged(Editable editable) { if (isNotDirectInput) return; String currentChange = editable.toString(); - float temporaryValue = !TextUtils.isEmpty(currentChange) ? Float.parseFloat(currentChange) : 0; + float temporaryValue = 0; + try { + temporaryValue = !TextUtils.isEmpty(currentChange) ? Float.parseFloat(currentChange) : 0; + } catch (NumberFormatException e) { + e.printStackTrace(); + } if(boundCheck(temporaryValue)) scoreCurrent = temporaryValue; else From 0a16086eaa204385a96fe4d1af286f265da1719b Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 13 Aug 2018 15:17:20 +0200 Subject: [PATCH 10/69] Updated Video Player, Alerter & Tap Target Prompt Libraries --- app/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4e1443513..a9ce999bd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -146,7 +146,7 @@ dependencies { implementation 'com.annimon:stream:1.1.9' /** Highly Customizable Video Player */ - implementation 'cn.jzvd:jiaozivideoplayer:6.2.10' + implementation 'cn.jzvd:jiaozivideoplayer:6.2.12' /** Photo View */ implementation 'com.github.chrisbanes:PhotoView:2.1.3' @@ -155,13 +155,13 @@ dependencies { implementation 'com.github.XunMengWinter:CircularAnim:0.3.4' /** Alerter */ - implementation 'com.tapadoo.android:alerter:2.0.4' + implementation 'com.tapadoo.android:alerter:3.0.0' /** Rich Text Markdown Parser */ implementation 'com.zzhoujay.richtext:richtext:3.0.5' /** Tap Target Prompt */ - implementation 'uk.co.samuelwall:material-tap-target-prompt:2.7.0' + implementation 'uk.co.samuelwall:material-tap-target-prompt:2.12.1' /** Circular Progress View */ implementation 'com.github.rahatarmanahmed:circularprogressview:2.5.0' From 2a86c79ddaf1f381ecec71b72fd7c03d4dcd3054 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 13 Aug 2018 15:17:57 +0200 Subject: [PATCH 11/69] Updated TapTargetPrompt Functionality - New version of alerts added with no functional changes to the base code - New changes added to how TapTargetUtil and TutorialUtil work, with new functionality to add sequence prompts --- .../com/mxt/anitrend/util/TapTargetUtil.java | 16 ++++- .../com/mxt/anitrend/util/TutorialUtil.java | 67 +++++++++++++++++-- .../view/activity/detail/MediaActivity.java | 10 ++- .../view/activity/detail/ProfileActivity.java | 2 +- 4 files changed, 84 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/util/TapTargetUtil.java b/app/src/main/java/com/mxt/anitrend/util/TapTargetUtil.java index c3fb2efbf..3b1ba30a3 100644 --- a/app/src/main/java/com/mxt/anitrend/util/TapTargetUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/TapTargetUtil.java @@ -1,20 +1,22 @@ package com.mxt.anitrend.util; import android.support.annotation.IdRes; +import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.support.v4.app.FragmentActivity; import android.support.v4.graphics.ColorUtils; import android.support.v4.view.animation.FastOutSlowInInterpolator; +import android.util.Log; import android.view.View; +import com.annimon.stream.Stream; import com.mxt.anitrend.R; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt; +import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetSequence; /** * Created by max on 2018/03/01. MaterialTapTargetPrompt helper class, should not be used directly @@ -25,6 +27,16 @@ public class TapTargetUtil { private static List activePrompts = new ArrayList<>(); + public static void showMultiplePrompts(@Nullable MaterialTapTargetPrompt.Builder... tapTargetPrompts) { + if (tapTargetPrompts != null) { + MaterialTapTargetSequence materialTapTargetSequence = new MaterialTapTargetSequence(); + Stream.of(tapTargetPrompts).filter(it -> it != null) + .forEach(it -> materialTapTargetSequence.addPrompt(it.create())); + if(materialTapTargetSequence.size() > 0) + materialTapTargetSequence.show(); + } + } + public static MaterialTapTargetPrompt.Builder buildDefault(FragmentActivity context, @IdRes int resource) { return new MaterialTapTargetPrompt.Builder(context) .setTarget(context.findViewById(resource)) diff --git a/app/src/main/java/com/mxt/anitrend/util/TutorialUtil.java b/app/src/main/java/com/mxt/anitrend/util/TutorialUtil.java index 6daf06038..70401f725 100644 --- a/app/src/main/java/com/mxt/anitrend/util/TutorialUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/TutorialUtil.java @@ -24,7 +24,7 @@ * .setFocalColour(R.color.colorGrey600) * .setTapTarget(KeyUtil.KEY_NOTIFICATION_TIP) * .setApplicationPref(getPresenter().getApplicationPref()) - * .showTapTarget( + * .createTapTarget( * R.string.tip_notifications_title, * R.string.tip_notifications_text, * R.id.action_notification @@ -96,7 +96,65 @@ public TutorialUtil setApplicationPref(ApplicationPref applicationPref) { } /** - * Display a hint, highlighting a given a resource id + * Get the prompt you want to display, highlighting a given a resource id + *
+ * + * @param resource Item that should be focused on by the application tip + */ + public @Nullable MaterialTapTargetPrompt.Builder createTapTarget(@IdRes int resource) { + if(applicationPref == null) { + Log.e(toString(), "Did you forget to set the current application preferences?"); + return null; + } + if (!TapTargetUtil.isActive(tapTarget) && applicationPref.shouldShowTipFor(tapTarget)) + return TapTargetUtil.buildDefault(context, resource) + .setPromptStateChangeListener(defaultStateChangeListener) + .setFocalColour(CompatUtil.getColor(context, focalColour)); + return null; + } + + /** + * Get the prompt you want to display, highlighting a given a resource id, heading and subheading + *
+ * + * @param primary Heading for the tip that should be displayed + * @param secondary Sub Heading for the tip that should be displayed + * @param resource Item that should be focused on by the application tip + */ + public @Nullable MaterialTapTargetPrompt.Builder createTapTarget(@StringRes int primary, @StringRes int secondary, @IdRes int resource) { + if(applicationPref == null) { + Log.e(toString(), "Did you forget to set the current application preferences?"); + return null; + } + if (!TapTargetUtil.isActive(tapTarget) && applicationPref.shouldShowTipFor(tapTarget)) + return TapTargetUtil.buildDefault(context, primary, secondary, resource) + .setPromptStateChangeListener(defaultStateChangeListener) + .setFocalColour(CompatUtil.getColor(context, focalColour)); + return null; + } + + /** + * Get the prompt you want to display, highlighting a given a resource view + *
+ * + * @param primary Heading for the tip that should be displayed + * @param secondary Sub Heading for the tip that should be displayed + * @param resource Item that should be focused on by the application tip + */ + public @Nullable MaterialTapTargetPrompt.Builder createTapTarget(@StringRes int primary, @StringRes int secondary, View resource) { + if(applicationPref == null) { + Log.e(toString(), "Did you forget to set the current application preferences?"); + return null; + } + if (!TapTargetUtil.isActive(tapTarget) && applicationPref.shouldShowTipFor(tapTarget)) + return TapTargetUtil.buildDefault(context, primary, secondary, resource) + .setPromptStateChangeListener(defaultStateChangeListener) + .setFocalColour(CompatUtil.getColor(context, focalColour)); + return null; + } + + /** + * Display hint, highlighting a given a resource id *
* * @param resource Item that should be focused on by the application tip @@ -111,11 +169,10 @@ public void showTapTarget(@IdRes int resource) { .setPromptStateChangeListener(defaultStateChangeListener) .setFocalColour(CompatUtil.getColor(context, focalColour)) .show(); - } /** - * Display a hint, highlighting a given a resource id, heading and subheading + * Display hint, highlighting a given a resource id, heading and subheading *
* * @param primary Heading for the tip that should be displayed @@ -135,7 +192,7 @@ public void showTapTarget(@StringRes int primary, @StringRes int secondary, @IdR } /** - * Display a hint, highlighting a given a resource view + * Display hint, highlighting a given a resource view *
* * @param primary Heading for the tip that should be displayed diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/detail/MediaActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/detail/MediaActivity.java index a9c19200e..cfed51047 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/detail/MediaActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/detail/MediaActivity.java @@ -27,6 +27,7 @@ import com.mxt.anitrend.util.KeyUtil; import com.mxt.anitrend.util.MediaActionUtil; import com.mxt.anitrend.util.NotifyUtil; +import com.mxt.anitrend.util.TapTargetUtil; import com.mxt.anitrend.util.TutorialUtil; import com.mxt.anitrend.view.activity.base.ImagePreviewActivity; import com.ogaclejapan.smarttablayout.SmartTabLayout; @@ -35,6 +36,7 @@ import butterknife.BindView; import butterknife.ButterKnife; +import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt; /** * Created by max on 2017/12/01. @@ -152,13 +154,15 @@ protected void updateUI() { binding.setOnClickListener(this); WideImageView.setImage(binding.seriesBanner, model.getBannerImage()); setFavouriteWidgetMenuItemIcon(); setManageMenuItemIcon(); - if(getPresenter().getApplicationPref().isAuthenticated()) - new TutorialUtil().setContext(this) + if(getPresenter().getApplicationPref().isAuthenticated()) { + MaterialTapTargetPrompt.Builder favouritesPrompt = new TutorialUtil().setContext(this) .setFocalColour(R.color.colorGrey600) .setTapTarget(KeyUtil.KEY_DETAIL_TIP) .setApplicationPref(getPresenter().getApplicationPref()) - .showTapTarget(R.string.tip_series_options_title, + .createTapTarget(R.string.tip_series_options_title, R.string.tip_series_options_message, R.id.action_manage); + TapTargetUtil.showMultiplePrompts(favouritesPrompt); + } } } diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/detail/ProfileActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/detail/ProfileActivity.java index 89dd8025e..f6447349c 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/detail/ProfileActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/detail/ProfileActivity.java @@ -23,6 +23,7 @@ import com.mxt.anitrend.util.GraphUtil; import com.mxt.anitrend.util.KeyUtil; import com.mxt.anitrend.util.NotifyUtil; +import com.mxt.anitrend.util.TapTargetUtil; import com.mxt.anitrend.util.TutorialUtil; import com.mxt.anitrend.view.activity.base.ImagePreviewActivity; import com.mxt.anitrend.view.sheet.BottomSheetComposer; @@ -131,7 +132,6 @@ protected void updateUI() { binding.setOnClickListener(this); binding.profileStatsWidget.setParams(getIntent().getExtras()); WideImageView.setImage(binding.profileBanner, model.getBannerImage()); - if(getPresenter().isCurrentUser(model.getId())) { new TutorialUtil().setContext(this) .setFocalColour(R.color.colorGrey600) From 6b5cc03a9dda6f0e7226390fe23b99aca47a7a8c Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 13 Aug 2018 15:42:42 +0200 Subject: [PATCH 12/69] Fixed Incorrect Score Formatting - Custom scores was not converting 10 Point Decimal scores for media not in the users list correctly - Deprecated getScoreFormatted() method from MediaList --- .../anitrend/base/custom/view/text/RatingTextView.java | 10 +++++++--- .../mxt/anitrend/model/entity/anilist/MediaList.java | 4 ---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java index f8e95273e..c738a40c5 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java @@ -114,21 +114,25 @@ private void setRating(MediaBase mediaBase) { if(mediaListOptions != null) switch (mediaListOptions.getScoreFormat()) { case KeyUtil.POINT_10_DECIMAL: - mediaScoreDefault = (mediaBase.getMeanScore() / 10); + mediaScoreDefault = (mediaBase.getMeanScore() / 10f); binding.ratingValue.setText(String.format(Locale.getDefault(),"%.1f", mediaScoreDefault)); break; case KeyUtil.POINT_100: binding.ratingValue.setText(String.format(Locale.getDefault(),"%d", mediaBase.getMeanScore())); break; case KeyUtil.POINT_10: - binding.ratingValue.setText(String.format(Locale.getDefault(),"%d", mediaBase.getMeanScore() / 10)); + mediaScoreDefault = (mediaBase.getMeanScore() / 10); + binding.ratingValue.setText(String.format(Locale.getDefault(),"%d", (int) mediaScoreDefault)); break; case KeyUtil.POINT_5: binding.ratingValue.setText(String.format(Locale.getDefault(),"%d", (int) mediaScoreDefault)); break; case KeyUtil.POINT_3: binding.ratingValue.setText(""); - if(mediaBase.getMeanScore() >= 0 && mediaBase.getMeanScore() <= 33) + if(mediaBase.getMeanScore() == 0) + binding.ratingValue.setCompoundDrawablesWithIntrinsicBounds(CompatUtil.getDrawable(getContext(), + R.drawable.ic_face_white_18dp), null, null, null); + if(mediaBase.getMeanScore() > 0 && mediaBase.getMeanScore() <= 33) binding.ratingValue.setCompoundDrawablesWithIntrinsicBounds(CompatUtil.getDrawable(getContext(), R.drawable.ic_sentiment_dissatisfied_white_18dp), null, null, null); else if (mediaBase.getMeanScore() >= 34 && mediaBase.getMeanScore() <= 66) diff --git a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java index 01f1c1b23..8bba1eaed 100644 --- a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java +++ b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaList.java @@ -116,10 +116,6 @@ public float getScore() { return score; } - public String getScoreFormatted() { - return String.valueOf(score); - } - public int getProgress() { return progress; } From c11fb9ae570b0a9e97c36ed3d2fe007ca2b838e5 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Tue, 14 Aug 2018 10:47:41 +0200 Subject: [PATCH 13/69] Revert Alerter 3.0.0 -> 2.0.6 - New version of the library caused class not found exception: https://github.com/Tapadoo/Alerter/issues/138 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index a9ce999bd..d19cc7e13 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -155,7 +155,7 @@ dependencies { implementation 'com.github.XunMengWinter:CircularAnim:0.3.4' /** Alerter */ - implementation 'com.tapadoo.android:alerter:3.0.0' + implementation 'com.tapadoo.android:alerter:2.0.6' /** Rich Text Markdown Parser */ implementation 'com.zzhoujay.richtext:richtext:3.0.5' From 4a1569acffad3fa5f7e7edd0897c86ff737070ea Mon Sep 17 00:00:00 2001 From: Maxwell Date: Tue, 14 Aug 2018 10:51:42 +0200 Subject: [PATCH 14/69] Media Titles Fixes - Set the overview titles to single line and changed Japanese title to standard text view --- app/src/main/res/layout/section_series_description.xml | 2 +- app/src/main/res/layout/section_series_info.xml | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/layout/section_series_description.xml b/app/src/main/res/layout/section_series_description.xml index 9b2d5ced2..84239681a 100644 --- a/app/src/main/res/layout/section_series_description.xml +++ b/app/src/main/res/layout/section_series_description.xml @@ -35,7 +35,7 @@ android:layout_width="wrap_content" android:layout_height="@dimen/md_margin" /> - - - Date: Tue, 14 Aug 2018 11:08:52 +0200 Subject: [PATCH 15/69] Revert Alerter 2.0.6 -> 2.0.4 - New version of the library caused class not found exception: https://github.com/Tapadoo/Alerter/issues/138 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index d19cc7e13..c2cb8e11b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -155,7 +155,7 @@ dependencies { implementation 'com.github.XunMengWinter:CircularAnim:0.3.4' /** Alerter */ - implementation 'com.tapadoo.android:alerter:2.0.6' + implementation 'com.tapadoo.android:alerter:2.0.4' /** Rich Text Markdown Parser */ implementation 'com.zzhoujay.richtext:richtext:3.0.5' From 7d8d4d943ad4e43b448de5aaae158e0d3235b944 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:04:41 +0200 Subject: [PATCH 16/69] Case Insensitivity Fixes - Regex filtering for status feeds were designed under the assumption that the custom markdown is case sensitive --- app/src/main/java/com/mxt/anitrend/util/RegexUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/util/RegexUtil.java b/app/src/main/java/com/mxt/anitrend/util/RegexUtil.java index 43d64c3c5..74a16fbd0 100644 --- a/app/src/main/java/com/mxt/anitrend/util/RegexUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/RegexUtil.java @@ -34,7 +34,7 @@ public class RegexUtil { static { - pattern = Pattern.compile(PATTERN_MEDIA); + pattern = Pattern.compile(PATTERN_MEDIA, Pattern.CASE_INSENSITIVE); } /** @@ -45,7 +45,7 @@ public static Matcher findMedia(@NonNull String param) { } private static @NonNull Matcher findImages(@NonNull String param) { - return Pattern.compile("(img).*?(\\([^)]+\\))").matcher(param); + return Pattern.compile("(img|Img|IMG).*?(\\([^)]+\\))", Pattern.CASE_INSENSITIVE).matcher(param); } /** From c2df755c47df7e3ed56b4da1179a4fca138ef8c4 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:07:40 +0200 Subject: [PATCH 17/69] Additional Support For YouTube Videos - Adds additional support for YouTube trailers when no YouTube app is present, closes issue #51 --- .../detail/MediaOverviewFragment.java | 13 +- .../youtube/YouTubeEmbedFragment.java | 124 ++++++++++++++++++ 2 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YouTubeEmbedFragment.java diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/detail/MediaOverviewFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/detail/MediaOverviewFragment.java index c8c48b57f..b4160ccc1 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/detail/MediaOverviewFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/detail/MediaOverviewFragment.java @@ -10,6 +10,7 @@ import android.view.ViewGroup; import com.annimon.stream.IntPair; +import com.google.android.youtube.player.YouTubeIntents; import com.mxt.anitrend.R; import com.mxt.anitrend.adapter.recycler.detail.GenreAdapter; import com.mxt.anitrend.adapter.recycler.detail.TagAdapter; @@ -30,6 +31,7 @@ import com.mxt.anitrend.view.activity.base.ImagePreviewActivity; import com.mxt.anitrend.view.activity.detail.MediaBrowseActivity; import com.mxt.anitrend.view.activity.detail.StudioActivity; +import com.mxt.anitrend.view.fragment.youtube.YouTubeEmbedFragment; import com.mxt.anitrend.view.fragment.youtube.YoutubePlayerFragment; import butterknife.ButterKnife; @@ -97,12 +99,17 @@ public void onStart() { */ @Override protected void updateUI() { - if(model.getTrailer() != null && CompatUtil.equals(model.getTrailer().getSite(), "youtube")) { - if (youtubePlayerFragment == null) { - youtubePlayerFragment = YoutubePlayerFragment.newInstance(model.getTrailer()); + if(getActivity() != null && model.getTrailer() != null && CompatUtil.equals(model.getTrailer().getSite(), "youtube")) { + if(YouTubeIntents.canResolvePlayVideoIntent(getActivity())) { + if (youtubePlayerFragment == null) + youtubePlayerFragment = YoutubePlayerFragment.newInstance(model.getTrailer()); getChildFragmentManager().beginTransaction() .replace(R.id.youtube_view, youtubePlayerFragment) .commit(); + } else { + getChildFragmentManager().beginTransaction() + .replace(R.id.youtube_view, YouTubeEmbedFragment.newInstance(model.getTrailer())) + .commit(); } } else binding.youtubeView.setVisibility(View.GONE); diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YouTubeEmbedFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YouTubeEmbedFragment.java new file mode 100644 index 000000000..5d48bb4ec --- /dev/null +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YouTubeEmbedFragment.java @@ -0,0 +1,124 @@ +package com.mxt.anitrend.view.fragment.youtube; + +import android.content.ActivityNotFoundException; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions; +import com.bumptech.glide.request.RequestOptions; +import com.mxt.anitrend.R; +import com.mxt.anitrend.base.custom.fragment.FragmentBase; +import com.mxt.anitrend.databinding.AdapterFeedSlideBinding; +import com.mxt.anitrend.model.entity.anilist.meta.MediaTrailer; +import com.mxt.anitrend.presenter.base.BasePresenter; +import com.mxt.anitrend.util.KeyUtil; +import com.mxt.anitrend.util.NotifyUtil; +import com.mxt.anitrend.util.RegexUtil; + +import butterknife.ButterKnife; + +public class YouTubeEmbedFragment extends FragmentBase { + + private MediaTrailer mediaTrailer; + + private AdapterFeedSlideBinding binding; + + public static YouTubeEmbedFragment newInstance(MediaTrailer model) { + Bundle args = new Bundle(); + args.putParcelable(KeyUtil.arg_media_trailer, model); + YouTubeEmbedFragment fragment = new YouTubeEmbedFragment(); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if(getArguments() != null) + mediaTrailer = getArguments().getParcelable(KeyUtil.arg_media_trailer); + setPresenter(new BasePresenter(getContext())); + } + + /** + * Called to have the fragment instantiate its user interface view. + * This is optional, and non-graphical fragments can return null (which + * is the default implementation). This will be called between + * {@link #onCreate(Bundle)} and {@link #onActivityCreated(Bundle)}. + *

+ *

If you return a View from here, you will later be called in + * {@link #onDestroyView} when the view is being released. + * + * @param inflater The LayoutInflater object that can be used to inflate + * any views in the fragment, + * @param container If non-null, this is the parent view that the fragment's + * UI should be attached to. The fragment should not add the view itself, + * but this can be used to generate the LayoutParams of the view. + * @param savedInstanceState If non-null, this fragment is being re-constructed + * from a previous saved state as given here. + * @return Return the View for the fragment's UI, or null. + */ + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + binding = AdapterFeedSlideBinding.inflate(inflater, container, false); + unbinder = ButterKnife.bind(this, binding.getRoot()); + return binding.getRoot(); + } + + @Override + public void onResume() { + super.onResume(); + makeRequest(); + } + + /** + * Is automatically called in the @onStart Method if overridden in list implementation + */ + @Override + protected void updateUI() { + String youtubeLink = RegexUtil.buildYoutube(mediaTrailer.getId()); + String thumbnailUrl =RegexUtil.getYoutubeThumb(youtubeLink); + if (getActivity() != null) + Glide.with(getActivity()).load(thumbnailUrl) + .transition(DrawableTransitionOptions.withCrossFade(250)) + .apply(RequestOptions.centerCropTransform()) + .into(binding.feedStatusImage); + } + + /** + * All new or updated network requests should be handled in this method + */ + @Override + public void makeRequest() { + binding.setOnClickListener((v) -> { + try { + String youtubeLink = RegexUtil.buildYoutube(mediaTrailer.getId()); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(youtubeLink)); + startActivity(intent); + } catch (ActivityNotFoundException e) { + e.printStackTrace(); + NotifyUtil.makeText(getContext(), R.string.init_youtube_missing, Toast.LENGTH_SHORT).show(); + } + }); + updateUI(); + } + + /** + * Called when the model state is changed. + * + * @param model The new data + */ + @Override + public void onChanged(@Nullable MediaTrailer model) { + + } +} From fc6905b987a1cf476d44382799f28884de90defd Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:08:39 +0200 Subject: [PATCH 18/69] Updated GraphQL Queries - Prior to including bonus feature for release v1.2.0 --- app/src/main/assets/graphql/Browse/Query/MediaBrowse.graphql | 5 +++++ .../main/assets/graphql/Browse/Query/ReviewBrowse.graphql | 5 +++++ .../assets/graphql/Character/Query/CharacterActors.graphql | 5 +++++ .../assets/graphql/Character/Query/CharacterMedia.graphql | 5 +++++ app/src/main/assets/graphql/Feed/Query/FeedList.graphql | 5 +++++ app/src/main/assets/graphql/Feed/Query/FeedListReply.graphql | 5 +++++ .../main/assets/graphql/Media/Query/MediaRelations.graphql | 5 +++++ app/src/main/assets/graphql/Search/Query/MediaSearch.graphql | 5 +++++ app/src/main/assets/graphql/Staff/Query/StaffMedia.graphql | 5 +++++ app/src/main/assets/graphql/Staff/Query/StaffRoles.graphql | 5 +++++ app/src/main/assets/graphql/Studio/Query/StudioMedia.graphql | 5 +++++ 11 files changed, 55 insertions(+) diff --git a/app/src/main/assets/graphql/Browse/Query/MediaBrowse.graphql b/app/src/main/assets/graphql/Browse/Query/MediaBrowse.graphql index ac9d75627..195d3f363 100644 --- a/app/src/main/assets/graphql/Browse/Query/MediaBrowse.graphql +++ b/app/src/main/assets/graphql/Browse/Query/MediaBrowse.graphql @@ -58,6 +58,11 @@ query MediaBrowse($id: Int, $page: Int, $perPage: Int, $seasonYear: Int, $type: episode } } + mediaListEntry { + ... on MediaList { + status + } + } } } } diff --git a/app/src/main/assets/graphql/Browse/Query/ReviewBrowse.graphql b/app/src/main/assets/graphql/Browse/Query/ReviewBrowse.graphql index 4290c76ad..9c9cf705f 100644 --- a/app/src/main/assets/graphql/Browse/Query/ReviewBrowse.graphql +++ b/app/src/main/assets/graphql/Browse/Query/ReviewBrowse.graphql @@ -84,6 +84,11 @@ query ReviewBrowse($page: Int, $perPage: Int, $mediaId: Int, $type: MediaType, $ episode } } + mediaListEntry { + ... on MediaList { + status + } + } } } } diff --git a/app/src/main/assets/graphql/Character/Query/CharacterActors.graphql b/app/src/main/assets/graphql/Character/Query/CharacterActors.graphql index 984c131c4..80737a0e9 100644 --- a/app/src/main/assets/graphql/Character/Query/CharacterActors.graphql +++ b/app/src/main/assets/graphql/Character/Query/CharacterActors.graphql @@ -76,6 +76,11 @@ query CharacterActors($id: Int!, $page: Int, $perPage: Int, $sort: [StaffSort] = episode } } + mediaListEntry { + ... on MediaList { + status + } + } } } } diff --git a/app/src/main/assets/graphql/Character/Query/CharacterMedia.graphql b/app/src/main/assets/graphql/Character/Query/CharacterMedia.graphql index 240d4b2f6..6021fd996 100644 --- a/app/src/main/assets/graphql/Character/Query/CharacterMedia.graphql +++ b/app/src/main/assets/graphql/Character/Query/CharacterMedia.graphql @@ -59,6 +59,11 @@ query CharacterMedia($id: Int!, $page: Int, $perPage: Int, $sort: [MediaSort] = timeUntilAiring episode } + } + mediaListEntry { + ... on MediaList { + status + } } } } diff --git a/app/src/main/assets/graphql/Feed/Query/FeedList.graphql b/app/src/main/assets/graphql/Feed/Query/FeedList.graphql index 0ec07c2cc..f9aca2a62 100644 --- a/app/src/main/assets/graphql/Feed/Query/FeedList.graphql +++ b/app/src/main/assets/graphql/Feed/Query/FeedList.graphql @@ -91,6 +91,11 @@ query FeedList($page: Int, $perPage: Int, $id: Int, $isFollowing: Boolean, $user timeUntilAiring episode } + } + mediaListEntry { + ... on MediaList { + status + } } } } diff --git a/app/src/main/assets/graphql/Feed/Query/FeedListReply.graphql b/app/src/main/assets/graphql/Feed/Query/FeedListReply.graphql index 049c11b36..3daa5b448 100644 --- a/app/src/main/assets/graphql/Feed/Query/FeedListReply.graphql +++ b/app/src/main/assets/graphql/Feed/Query/FeedListReply.graphql @@ -105,6 +105,11 @@ query FeedListReply($id: Int, $asHtml: Boolean = false) { episode } } + mediaListEntry { + ... on MediaList { + status + } + } } } siteUrl diff --git a/app/src/main/assets/graphql/Media/Query/MediaRelations.graphql b/app/src/main/assets/graphql/Media/Query/MediaRelations.graphql index 54d44218d..e010b695d 100644 --- a/app/src/main/assets/graphql/Media/Query/MediaRelations.graphql +++ b/app/src/main/assets/graphql/Media/Query/MediaRelations.graphql @@ -63,6 +63,11 @@ query MediaRelations($id: Int!, $type: MediaType, $isAdult: Boolean = false) { episode } } + mediaListEntry { + ... on MediaList { + status + } + } } } } diff --git a/app/src/main/assets/graphql/Search/Query/MediaSearch.graphql b/app/src/main/assets/graphql/Search/Query/MediaSearch.graphql index 3c4c65c2e..54cbd6be5 100644 --- a/app/src/main/assets/graphql/Search/Query/MediaSearch.graphql +++ b/app/src/main/assets/graphql/Search/Query/MediaSearch.graphql @@ -58,6 +58,11 @@ query MediaSearch($id: Int, $page: Int, $perPage: Int, $search: String, $type: M episode } } + mediaListEntry { + ... on MediaList { + status + } + } } } } diff --git a/app/src/main/assets/graphql/Staff/Query/StaffMedia.graphql b/app/src/main/assets/graphql/Staff/Query/StaffMedia.graphql index 90bddacea..a0bea9d50 100644 --- a/app/src/main/assets/graphql/Staff/Query/StaffMedia.graphql +++ b/app/src/main/assets/graphql/Staff/Query/StaffMedia.graphql @@ -59,6 +59,11 @@ query StaffMedia($id: Int!, $page: Int, $perPage: Int, $sort: [MediaSort] = FORM episode } } + mediaListEntry { + ... on MediaList { + status + } + } } } } diff --git a/app/src/main/assets/graphql/Staff/Query/StaffRoles.graphql b/app/src/main/assets/graphql/Staff/Query/StaffRoles.graphql index d5c6f9fc8..fd9289b90 100644 --- a/app/src/main/assets/graphql/Staff/Query/StaffRoles.graphql +++ b/app/src/main/assets/graphql/Staff/Query/StaffRoles.graphql @@ -62,6 +62,11 @@ query StaffRoles($id: Int!, $page: Int, $perPage: Int, $sort: [MediaSort] = POPU episode } } + mediaListEntry { + ... on MediaList { + status + } + } } } } diff --git a/app/src/main/assets/graphql/Studio/Query/StudioMedia.graphql b/app/src/main/assets/graphql/Studio/Query/StudioMedia.graphql index 1f618e40f..994e76b5e 100644 --- a/app/src/main/assets/graphql/Studio/Query/StudioMedia.graphql +++ b/app/src/main/assets/graphql/Studio/Query/StudioMedia.graphql @@ -60,6 +60,11 @@ query StudioMedia($id: Int!, $page: Int, $perPage: Int, $sort: [MediaSort] = POP episode } } + mediaListEntry { + ... on MediaList { + status + } + } } } } From 0e5c3f8b7ce8e455291fde749cd086006657b7d1 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:11:52 +0200 Subject: [PATCH 19/69] Case Insensitivity For Embedded Status Content Type --- .../anitrend/adapter/recycler/detail/ImagePreviewAdapter.java | 2 +- .../anitrend/base/custom/view/widget/StatusContentWidget.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/ImagePreviewAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/ImagePreviewAdapter.java index 5433681df..951491a97 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/ImagePreviewAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/ImagePreviewAdapter.java @@ -68,7 +68,7 @@ public PreviewHolder(AdapterFeedSlideBinding binding) { public void onBindViewHolder(String model) { String targetModel; RequestOptions requestOptions = null; - switch (contentTypes.get(getAdapterPosition())) { + switch (contentTypes.get(getAdapterPosition()).toLowerCase()) { case RegexUtil.KEY_IMG: targetModel = model; ViewCompat.setTransitionName(binding.feedStatusImage, model); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java index b52a968fb..15eeeb537 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/StatusContentWidget.java @@ -156,7 +156,7 @@ public void onPageChanged(int currentPage) { @Override public void onItemClick(View target, IntPair data) { Intent intent; - switch (contentTypes.get(data.getFirst())) { + switch (contentTypes.get(data.getFirst()).toLowerCase()) { case RegexUtil.KEY_IMG: intent = new Intent(getContext(), ImagePreviewActivity.class); intent.putExtra(KeyUtil.arg_model, data.getSecond()); From 5c6357d8ee030baa1dee175d389c237ad9d5778f Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:15:47 +0200 Subject: [PATCH 20/69] Base Implementation Architecture Fixes - LayoutAdapter fixes for media episodes when using devices such as tablets --- .../base/custom/fragment/FragmentBaseList.java | 4 +++- .../base/custom/fragment/FragmentChannelBase.java | 6 ++++-- .../custom/view/image/AppCompatTintImageView.java | 11 +++++++++++ .../activity/base/AppCompatPreferenceActivity.java | 9 +++++++-- .../view/fragment/list/WatchListFragment.java | 9 ++++----- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBaseList.java b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBaseList.java index b5365380e..ce52d76b1 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBaseList.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBaseList.java @@ -273,7 +273,9 @@ public void setLimitReached() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if(getPresenter() != null && isFilterable && GraphUtil.isKeyFilter(key)) { - swipeRefreshLayout.setRefreshing(true); + showLoading(); + if(mAdapter != null) + mAdapter.clearDataSet(); onRefresh(); } } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java index 5d9130a2d..e12d87029 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java @@ -9,6 +9,7 @@ import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.StaggeredGridLayoutManager; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; @@ -63,7 +64,7 @@ public abstract class FragmentChannelBase extends FragmentBase externalLinks; protected RecyclerViewAdapter mAdapter; - private GridLayoutManager mLayoutManager; + private StaggeredGridLayoutManager mLayoutManager; private final View.OnClickListener stateLayoutOnClick = view -> { if(swipeRefreshLayout.isRefreshing()) @@ -95,6 +96,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { if(externalLinks != null) targetLink = EpisodeUtil.episodeSupport(externalLinks); } + mColumnSize = R.integer.single_list_x1; } /** @@ -108,7 +110,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c unbinder = ButterKnife.bind(this, root); recyclerView.setHasFixedSize(true); //originally set to fixed size true recyclerView.setNestedScrollingEnabled(true); //set to false if somethings fail to work properly - mLayoutManager = new GridLayoutManager(getContext(), getResources().getInteger(mColumnSize)); + mLayoutManager = new StaggeredGridLayoutManager(getResources().getInteger(mColumnSize), StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(mLayoutManager); swipeRefreshLayout.setOnRefreshAndLoadListener(this); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AppCompatTintImageView.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AppCompatTintImageView.java index 75a7aa06e..a8223ffd1 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AppCompatTintImageView.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AppCompatTintImageView.java @@ -2,6 +2,9 @@ import android.content.Context; import android.databinding.BindingAdapter; +import android.support.annotation.AttrRes; +import android.support.annotation.ColorInt; +import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatImageView; import android.util.AttributeSet; @@ -48,4 +51,12 @@ public void onInit() { public void onViewRecycled() { } + + public void setTintDrawable(@DrawableRes int drawable, @ColorRes int colorTint) { + setImageDrawable(CompatUtil.getDrawable(getContext(), drawable, colorTint)); + } + + public void setTintDrawableAttr(@DrawableRes int drawable, @AttrRes int colorAttribute) { + setImageDrawable(CompatUtil.getDrawableTintAttr(getContext(), drawable, colorAttribute)); + } } diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/AppCompatPreferenceActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/AppCompatPreferenceActivity.java index 81c158f2f..7bd712dcc 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/AppCompatPreferenceActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/AppCompatPreferenceActivity.java @@ -6,6 +6,7 @@ import android.preference.PreferenceActivity; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; +import android.support.annotation.StyleRes; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatDelegate; import android.support.v7.widget.Toolbar; @@ -26,9 +27,13 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity { private AppCompatDelegate mDelegate; protected void configureActivity() { - int style = new ApplicationPref(this).getTheme(); + ApplicationPref applicationPref = new ApplicationPref(this); + @StyleRes int style = applicationPref.getTheme(); + if(!CompatUtil.isLightTheme(style) && applicationPref.isAmoledEnabled()) + setTheme(R.style.AppThemeBlack); + else + setTheme(style); setNavigationStyle(style); - setTheme(style); } /** diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java index 60f1b2dd0..8e7f287a7 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java @@ -38,16 +38,16 @@ public class WatchListFragment extends FragmentChannelBase implements RetroCallb private long mediaId; private @KeyUtil.MediaType String mediaType; - public static Fragment newInstance(Bundle params, boolean popular) { + public static FragmentChannelBase newInstance(Bundle params, boolean popular) { Bundle args = new Bundle(params); - WatchListFragment fragment = new WatchListFragment(); + FragmentChannelBase fragment = new WatchListFragment(); args.putBoolean(KeyUtil.arg_popular, popular); fragment.setArguments(args); return fragment; } - public static Fragment newInstance(List externalLinks, boolean popular) { - WatchListFragment fragment = new WatchListFragment(); + public static FragmentChannelBase newInstance(List externalLinks, boolean popular) { + FragmentChannelBase fragment = new WatchListFragment(); Bundle args = new Bundle(); args.putParcelableArrayList(KeyUtil.arg_list_model, (ArrayList) externalLinks); args.putBoolean(KeyUtil.arg_popular, popular); @@ -71,7 +71,6 @@ public void onCreate(@Nullable Bundle savedInstanceState) { mAdapter.setClickListener(clickListener); setPresenter(new WidgetPresenter<>(getContext())); setViewModel(true); - mColumnSize = R.integer.single_list_x1; } /** From 74916d02471035d0e86d17c129504978881ec103 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:16:29 +0200 Subject: [PATCH 21/69] Default Value FuzzyDateWidget - Adds a default value to the start and end dates on the list editor --- .../anitrend/base/custom/view/widget/FuzzyDateWidget.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java index 7e836734c..3964f07dc 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java @@ -57,11 +57,9 @@ public void setDate( @Nullable FuzzyDate fuzzyDate) { } private void updateDate() { - if(fuzzyDate != null) { - String convertedDate = DateUtil.convertDate(fuzzyDate); - binding.setModel(convertedDate); - binding.executePendingBindings(); - } + String convertedDate = DateUtil.convertDate(fuzzyDate); + binding.setModel(convertedDate); + binding.executePendingBindings(); } public @Nullable FuzzyDate getDate() { From 6647eee09fe02d0ddbef02460d5d902ce8692b18 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:17:52 +0200 Subject: [PATCH 22/69] Updated About Page --- app/build.gradle | 2 +- .../com/mxt/anitrend/view/fragment/detail/AboutFragment.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index c2cb8e11b..ded6a162e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -173,7 +173,7 @@ dependencies { implementation'com.github.PhilJay:MPAndroidChart:v3.0.3' /** About Library */ - implementation 'com.github.medyo:android-about-page:1.2.2' + implementation 'com.github.medyo:android-about-page:1.2.4' } apply plugin: 'com.google.gms.google-services' diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/detail/AboutFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/detail/AboutFragment.java index dbdf0b26d..98c40ef9c 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/detail/AboutFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/detail/AboutFragment.java @@ -14,6 +14,7 @@ import com.mxt.anitrend.R; import com.mxt.anitrend.base.custom.fragment.FragmentBase; import com.mxt.anitrend.presenter.base.BasePresenter; +import com.mxt.anitrend.util.DialogUtil; import com.mxt.anitrend.util.NotifyUtil; import org.greenrobot.eventbus.Subscribe; @@ -46,6 +47,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c .addGroup("Additional Information") .addGitHub("AniTrend") .addWebsite("https://anitrend.co") + .addItem(new Element().setTitle(getString(R.string.text_what_is_new)) + .setOnClickListener((v) -> DialogUtil.createChangeLog(getActivity())) + .setIconDrawable(R.drawable.ic_fiber_new_white_24dp)) .addGroup("Legal Information") .addItem(new Element().setTitle("Terms & Conditions").setIconDrawable(R.drawable.ic_privacy_grey_600_24dp) .setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/AniTrend/anitrend-app/blob/develop/TERMS_OF_SERVICE.md")))) From ff8590c8ca940c8c131da10f193a8bb60f97b07b Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:20:14 +0200 Subject: [PATCH 23/69] Bonus Feature: Media List Status Indicator - Adds icons for list status in the rating widget and on list editor --- .../adapter/spinner/StatusArrayAdapter.java | 56 +++++++++++++++++++ .../base/custom/view/text/RatingTextView.java | 41 ++++++++++++++ .../view/widget/CustomSeriesAnimeManage.java | 11 ++-- .../view/widget/CustomSeriesMangaManage.java | 16 ++++-- .../main/res/drawable/ic_pause_white_18dp.xml | 4 ++ .../drawable/ic_remove_red_eye_white_18dp.xml | 4 ++ .../res/drawable/ic_repeat_white_18dp.xml | 4 ++ app/src/main/res/drawable/rating_bubble.xml | 4 +- .../main/res/layout/adapter_spinner_item.xml | 35 ++++++++++-- .../main/res/layout/custom_rating_widget.xml | 7 +++ 10 files changed, 164 insertions(+), 18 deletions(-) create mode 100644 app/src/main/java/com/mxt/anitrend/adapter/spinner/StatusArrayAdapter.java create mode 100644 app/src/main/res/drawable/ic_pause_white_18dp.xml create mode 100644 app/src/main/res/drawable/ic_remove_red_eye_white_18dp.xml create mode 100644 app/src/main/res/drawable/ic_repeat_white_18dp.xml diff --git a/app/src/main/java/com/mxt/anitrend/adapter/spinner/StatusArrayAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/spinner/StatusArrayAdapter.java new file mode 100644 index 000000000..103f2016b --- /dev/null +++ b/app/src/main/java/com/mxt/anitrend/adapter/spinner/StatusArrayAdapter.java @@ -0,0 +1,56 @@ +package com.mxt.anitrend.adapter.spinner; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; + +import com.mxt.anitrend.R; +import com.mxt.anitrend.base.custom.view.image.AppCompatTintImageView; +import com.mxt.anitrend.base.custom.view.text.SingleLineTextView; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class StatusArrayAdapter extends ArrayAdapter { + + private final Map titleIconList = new HashMap() {{ + put(0, R.drawable.ic_remove_red_eye_white_18dp); put(1, R.drawable.ic_bookmark_white_24dp); + put(2, R.drawable.ic_done_all_grey_600_24dp); put(3, R.drawable.ic_delete_red_600_18dp); + put(4, R.drawable.ic_pause_white_18dp); put(5, R.drawable.ic_repeat_white_18dp); + }}; + + public StatusArrayAdapter(@NonNull Context context, int resource, int textViewResourceId, @NonNull List objects) { + super(context, resource, textViewResourceId, objects); + } + + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + View view = super.getView(position, convertView, parent); + + SingleLineTextView title = view.findViewById(R.id.spinner_text); + AppCompatTintImageView icon = view.findViewById(R.id.spinner_icon); + + title.setText(getItem(position)); + icon.setTintDrawableAttr(titleIconList.get(position), R.attr.titleColor); + + return view; + } + + @Override + public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + View view = super.getDropDownView(position, convertView, parent); + + SingleLineTextView title = view.findViewById(R.id.spinner_text); + AppCompatTintImageView icon = view.findViewById(R.id.spinner_icon); + + title.setText(getItem(position)); + icon.setTintDrawableAttr(titleIconList.get(position), R.attr.titleColor); + + return view; + } +} diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java index c738a40c5..3ff89c7df 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java @@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.ColorRes; +import android.support.annotation.DrawableRes; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.util.AttributeSet; @@ -71,6 +72,44 @@ private void setFavourState(boolean isFavourite) { binding.ratingFavourState.setImageDrawable(drawable); } + private void setListStatus(MediaBase mediaBase) { + if(mediaBase.getMediaListEntry() != null) { + binding.ratingListStatus.setVisibility(VISIBLE); + switch (mediaBase.getMediaListEntry().getStatus()) { + case KeyUtil.CURRENT: + binding.ratingListStatus.setTintDrawable(R.drawable.ic_remove_red_eye_white_18dp, + R.color.white); + break; + case KeyUtil.PLANNING: + binding.ratingListStatus.setTintDrawable(R.drawable.ic_bookmark_white_24dp, + R.color.white); + break; + case KeyUtil.COMPLETED: + binding.ratingListStatus.setTintDrawable(R.drawable.ic_done_all_grey_600_24dp, + R.color.white); + break; + case KeyUtil.DROPPED: + binding.ratingListStatus.setTintDrawable(R.drawable.ic_delete_red_600_18dp, + R.color.white); + break; + case KeyUtil.PAUSED: + binding.ratingListStatus.setTintDrawable(R.drawable.ic_pause_white_18dp, + R.color.white); + break; + case KeyUtil.REPEATING: + binding.ratingListStatus.setTintDrawable(R.drawable.ic_repeat_white_18dp, + R.color.white); + break; + } + } + else + binding.ratingListStatus.setVisibility(GONE); + } + + private void setListStatus() { + binding.ratingListStatus.setVisibility(GONE); + } + private void setRating(MediaList mediaList) { if(mediaListOptions != null) switch (mediaListOptions.getScoreFormat()) { @@ -151,12 +190,14 @@ else if (mediaBase.getMeanScore() >= 67 && mediaBase.getMeanScore() <= 100) public static void setAverageRating(RatingTextView view, MediaBase mediaBase) { //float rating = (float) mediaBase.getAverageScore() * MAX / 100; view.setRating(mediaBase); + view.setListStatus(mediaBase); view.setFavourState(mediaBase.isFavourite()); } @BindingAdapter("rating") public static void setAverageRating(RatingTextView view, MediaList mediaList) { //float rating = (float) mediaList.getScore() * MAX / 100; + view.setListStatus(); view.setRating(mediaList); view.setFavourState(mediaList.getMedia().isFavourite()); } diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java index f3f702202..826781d95 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java @@ -12,6 +12,7 @@ import android.widget.Toast; import com.mxt.anitrend.R; +import com.mxt.anitrend.adapter.spinner.StatusArrayAdapter; import com.mxt.anitrend.databinding.CustomActionAnimeBinding; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; @@ -82,12 +83,12 @@ protected void populateFields() { @Override protected void bindFields() { - // Create an ArrayAdapter using the string array and a default spinner layout - ArrayAdapter adapter = ArrayAdapter.createFromResource(getContext(), R.array.media_list_status, R.layout.adapter_spinner_item); - // Specify the layout to use when the list of choices appears - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + ArrayAdapter listAdapter = new StatusArrayAdapter(getContext(), + R.layout.adapter_spinner_item, R.id.spinner_text, + CompatUtil.getStringList(getContext(), R.array.media_list_status)); + // Apply the adapter to the spinner - binding.diaCurrentStatus.setAdapter(adapter); + binding.diaCurrentStatus.setAdapter(listAdapter); if (!TextUtils.isEmpty(model.getStatus())) binding.diaCurrentStatus.setSelection(CompatUtil.constructListFrom(KeyUtil.MediaListStatus).indexOf(model.getStatus())); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java index ad7c57b98..70ddf1a9e 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java @@ -3,15 +3,21 @@ import android.content.Context; import android.os.Build; import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; +import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; +import android.widget.ListAdapter; import android.widget.Toast; +import com.annimon.stream.Stream; import com.mxt.anitrend.R; +import com.mxt.anitrend.adapter.spinner.StatusArrayAdapter; import com.mxt.anitrend.databinding.CustomActionMangaBinding; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; @@ -82,12 +88,12 @@ protected void populateFields() { @Override protected void bindFields() { - // Create an ArrayAdapter using the string array and a default spinner layout - ArrayAdapter adapter = ArrayAdapter.createFromResource(getContext(), R.array.media_list_status, R.layout.adapter_spinner_item); - // Specify the layout to use when the list of choices appears - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + ArrayAdapter listAdapter = new StatusArrayAdapter(getContext(), + R.layout.adapter_spinner_item, R.id.spinner_text, + CompatUtil.getStringList(getContext(), R.array.media_list_status)); + // Apply the adapter to the spinner - binding.diaCurrentStatus.setAdapter(adapter); + binding.diaCurrentStatus.setAdapter(listAdapter); if(!TextUtils.isEmpty(model.getStatus())) binding.diaCurrentStatus.setSelection(CompatUtil.constructListFrom(KeyUtil.MediaListStatus).indexOf(model.getStatus())); diff --git a/app/src/main/res/drawable/ic_pause_white_18dp.xml b/app/src/main/res/drawable/ic_pause_white_18dp.xml new file mode 100644 index 000000000..ae2846bd8 --- /dev/null +++ b/app/src/main/res/drawable/ic_pause_white_18dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/drawable/ic_remove_red_eye_white_18dp.xml b/app/src/main/res/drawable/ic_remove_red_eye_white_18dp.xml new file mode 100644 index 000000000..bdba796e2 --- /dev/null +++ b/app/src/main/res/drawable/ic_remove_red_eye_white_18dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/drawable/ic_repeat_white_18dp.xml b/app/src/main/res/drawable/ic_repeat_white_18dp.xml new file mode 100644 index 000000000..b469a7aa3 --- /dev/null +++ b/app/src/main/res/drawable/ic_repeat_white_18dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/drawable/rating_bubble.xml b/app/src/main/res/drawable/rating_bubble.xml index a0f8f658e..c0284c05f 100644 --- a/app/src/main/res/drawable/rating_bubble.xml +++ b/app/src/main/res/drawable/rating_bubble.xml @@ -3,7 +3,7 @@ - + @@ -11,7 +11,7 @@ - + diff --git a/app/src/main/res/layout/adapter_spinner_item.xml b/app/src/main/res/layout/adapter_spinner_item.xml index 72b600ce0..7e61cce19 100644 --- a/app/src/main/res/layout/adapter_spinner_item.xml +++ b/app/src/main/res/layout/adapter_spinner_item.xml @@ -1,10 +1,33 @@ - \ No newline at end of file + android:padding="@dimen/mg_margin" + android:orientation="horizontal"> + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/custom_rating_widget.xml b/app/src/main/res/layout/custom_rating_widget.xml index 46d0b9fa9..2cc2c54a2 100644 --- a/app/src/main/res/layout/custom_rating_widget.xml +++ b/app/src/main/res/layout/custom_rating_widget.xml @@ -28,6 +28,13 @@ android:layout_height="12dp" tools:srcCompat="@drawable/ic_star_yellow_700_24dp"/> + + \ No newline at end of file From 62e8a08c8520395fdb853ee186c83c4debf642eb Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:21:27 +0200 Subject: [PATCH 24/69] Fragment Life Cycle Fixes - Fix YouTube fragment life cycle issue that potentially cause initialization errors --- .../view/fragment/youtube/YoutubePlayerFragment.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YoutubePlayerFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YoutubePlayerFragment.java index abeb0d867..a83f31ddd 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YoutubePlayerFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YoutubePlayerFragment.java @@ -2,6 +2,7 @@ import android.arch.lifecycle.Lifecycle; import android.os.Bundle; +import android.util.Log; import com.google.android.youtube.player.YouTubeInitializationResult; import com.google.android.youtube.player.YouTubePlayer; @@ -37,8 +38,8 @@ public void onCreate(Bundle bundle) { } @Override - public void onStart() { - super.onStart(); + public void onResume() { + super.onResume(); if(isAlive()) initialize(BuildConfig.API_KEY, this); } @@ -52,7 +53,7 @@ public void onDestroyView() { @Override public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) { - if(getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) { + if(getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) { this.youTubePlayer = youTubePlayer; if (!wasRestored) this.youTubePlayer.cueVideo(mediaTrailer.getId()); @@ -69,6 +70,6 @@ public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInit * @return true if the fragment is still valid otherwise false */ private boolean isAlive() { - return isVisible() || !isDetached() || !isRemoving(); + return isVisible() || !isDetached() || !isRemoving() && getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED); } } From c00cc0667768b48bd6807178404f44152ad6c23e Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:23:18 +0200 Subject: [PATCH 25/69] Fix Deeplinking Intent Util - Issues related with how links in web front end are handled, ending with '/' --- .../main/java/com/mxt/anitrend/util/IntentBundleUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/util/IntentBundleUtil.java b/app/src/main/java/com/mxt/anitrend/util/IntentBundleUtil.java index 7c78bb9f8..413d6778e 100644 --- a/app/src/main/java/com/mxt/anitrend/util/IntentBundleUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/IntentBundleUtil.java @@ -52,8 +52,11 @@ private void injectIntentParams(Intent intent) { case KeyUtil.DEEP_LINK_USER: if(TextUtils.isDigitsOnly(lastKey)) intent.putExtra(KeyUtil.arg_id, Long.valueOf(lastKey)); - else + else { + if (lastKey.contains("/")) + lastKey = lastKey.replace("/", ""); intent.putExtra(KeyUtil.arg_userName, lastKey); + } break; case KeyUtil.DEEP_LINK_MANGA: if ((splitKeys = hasDepth(lastKey)) != null) From cc36c519ffb0f90a5c0fafa6f4143da4d4f3c508 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:27:12 +0200 Subject: [PATCH 26/69] Media Pages Minor Changes - Added selectable text view attributes on character and staff overview fragments - Redecorated media overview fragments based on @TrickRoom and community suggestions - Removed maximum number of lines on series titles - Collapsed series type to save space --- .../base/custom/view/text/SeriesTypeView.java | 29 +++++++++++++++++++ .../layout/fragment_character_overview.xml | 2 ++ .../res/layout/fragment_series_overview.xml | 24 +++++++-------- .../res/layout/fragment_staff_overview.xml | 2 ++ .../res/layout/section_series_description.xml | 11 ------- .../res/layout/section_series_details.xml | 5 +++- .../main/res/layout/section_series_info.xml | 17 ++++------- 7 files changed, 55 insertions(+), 35 deletions(-) create mode 100644 app/src/main/java/com/mxt/anitrend/base/custom/view/text/SeriesTypeView.java diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/SeriesTypeView.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/SeriesTypeView.java new file mode 100644 index 000000000..0d35a4c85 --- /dev/null +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/SeriesTypeView.java @@ -0,0 +1,29 @@ +package com.mxt.anitrend.base.custom.view.text; + +import android.content.Context; +import android.databinding.BindingAdapter; +import android.util.AttributeSet; + +import com.mxt.anitrend.R; + +public class SeriesTypeView extends SingleLineTextView { + + + public SeriesTypeView(Context context) { + super(context); + } + + public SeriesTypeView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public SeriesTypeView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @BindingAdapter("seriesType") + public static void setSeriesType(SeriesTypeView view, String seriesType) { + String attribute = view.getContext().getString(R.string.title_series_type); + view.setText(String.format("%s %s", attribute, seriesType)); + } +} diff --git a/app/src/main/res/layout/fragment_character_overview.xml b/app/src/main/res/layout/fragment_character_overview.xml index 03470af3f..688d5fb6e 100644 --- a/app/src/main/res/layout/fragment_character_overview.xml +++ b/app/src/main/res/layout/fragment_character_overview.xml @@ -57,6 +57,7 @@ android:ellipsize="end" android:textStyle="bold" android:text="@{model.name.fullName}" + android:textIsSelectable="true" tools:text="Gintoki Sakata"/> diff --git a/app/src/main/res/layout/fragment_series_overview.xml b/app/src/main/res/layout/fragment_series_overview.xml index daa47f201..f684d8db4 100644 --- a/app/src/main/res/layout/fragment_series_overview.xml +++ b/app/src/main/res/layout/fragment_series_overview.xml @@ -35,6 +35,18 @@ + + + + + + - - - - - - diff --git a/app/src/main/res/layout/fragment_staff_overview.xml b/app/src/main/res/layout/fragment_staff_overview.xml index 80ffce5a0..5d68532d0 100644 --- a/app/src/main/res/layout/fragment_staff_overview.xml +++ b/app/src/main/res/layout/fragment_staff_overview.xml @@ -58,6 +58,7 @@ android:maxLines="2" android:ellipsize="end" android:textStyle="bold" + android:textIsSelectable="true" android:text="@{model.name.fullName}" tools:text="Tomokazu Sugita"/> @@ -87,6 +88,7 @@ android:fontFamily="sans-serif-light" android:maxLines="2" android:ellipsize="end" + android:textIsSelectable="true" tools:text="Japanese" /> diff --git a/app/src/main/res/layout/section_series_description.xml b/app/src/main/res/layout/section_series_description.xml index 84239681a..8d2c019d5 100644 --- a/app/src/main/res/layout/section_series_description.xml +++ b/app/src/main/res/layout/section_series_description.xml @@ -14,17 +14,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - + android:orientation="vertical" + android:clickable="true" + android:focusable="true" + android:foreground="?selectableItemBackground"> - - - - - + tools:text="Series Type: TV"/> Date: Sat, 25 Aug 2018 15:27:48 +0200 Subject: [PATCH 27/69] Updated Version --- app/release/output.json | 2 +- app/src/main/assets/changelog.md | 5 ++++- build.gradle | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/release/output.json b/app/release/output.json index f36d630c8..832fd8236 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":86,"versionName":"1.2.0","enabled":true,"outputFile":"anitrend_v1.2.0_rc_86.apk","fullName":"release","baseName":"release"},"path":"anitrend_v1.2.0_rc_86.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":87,"versionName":"1.2.0","enabled":true,"outputFile":"anitrend_v1.2.0_rc_87.apk","fullName":"release","baseName":"release"},"path":"anitrend_v1.2.0_rc_87.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/assets/changelog.md b/app/src/main/assets/changelog.md index dff8b6bef..fed095b43 100644 --- a/app/src/main/assets/changelog.md +++ b/app/src/main/assets/changelog.md @@ -9,9 +9,12 @@ - New changeable application language: __Settings -> General__ - New personalised score types based on your profile settings - New start and end dates for your anime/manga lists +- Media list status icons for media in your list +- Additional support for trailers when a device doesn't have the YouTube app ### Bug Fixes -- What??? Do you seriously expect us to fix any bugs!? Look just enjoy the app, they're all features! +- Crash issue with Android Pie devices when viewing status feeds +- 404 on profile links that end with / ### Current Issues - Clicking on @username shows mixed feed diff --git a/build.gradle b/build.gradle index c461fd868..9c762608f 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { compileSdk = 28 targetSdk = 28 minSdk = 17 - versionCode = 86 + versionCode = 87 versionName = '1.2.0' butterKnife = '8.8.1' glide = '4.7.1' From 6f2a6c334c36f93b5ec58118e12bcac29b49ef77 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 15:48:46 +0200 Subject: [PATCH 28/69] Styled Share Bottom Sheet --- .../adapter/spinner/ShareArrayAdapter.java | 56 +++++++++++++++++++ .../activity/base/SharedContentActivity.java | 9 ++- app/src/main/res/values-fr/strings.xml | 10 ++-- app/src/main/res/values-it/strings.xml | 10 ++-- app/src/main/res/values-pl/strings.xml | 8 +-- app/src/main/res/values/strings.xml | 8 +-- 6 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 app/src/main/java/com/mxt/anitrend/adapter/spinner/ShareArrayAdapter.java diff --git a/app/src/main/java/com/mxt/anitrend/adapter/spinner/ShareArrayAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/spinner/ShareArrayAdapter.java new file mode 100644 index 000000000..9bb7eddea --- /dev/null +++ b/app/src/main/java/com/mxt/anitrend/adapter/spinner/ShareArrayAdapter.java @@ -0,0 +1,56 @@ +package com.mxt.anitrend.adapter.spinner; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; + +import com.mxt.anitrend.R; +import com.mxt.anitrend.base.custom.view.image.AppCompatTintImageView; +import com.mxt.anitrend.base.custom.view.text.SingleLineTextView; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ShareArrayAdapter extends ArrayAdapter { + + private final Map titleIconList = new HashMap() {{ + put(0, R.drawable.ic_textsms_white_24dp); + put(1, R.drawable.ic_link_white_24dp); put(2, R.drawable.ic_crop_original_white_24dp); + put(3, R.drawable.ic_youtube); put(4, R.drawable.ic_slow_motion_video_white_24dp); + }}; + + public ShareArrayAdapter(@NonNull Context context, int resource, int textViewResourceId, @NonNull List objects) { + super(context, resource, textViewResourceId, objects); + } + + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + View view = super.getView(position, convertView, parent); + + SingleLineTextView title = view.findViewById(R.id.spinner_text); + AppCompatTintImageView icon = view.findViewById(R.id.spinner_icon); + + title.setText(getItem(position)); + icon.setTintDrawableAttr(titleIconList.get(position), R.attr.titleColor); + + return view; + } + + @Override + public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + View view = super.getDropDownView(position, convertView, parent); + + SingleLineTextView title = view.findViewById(R.id.spinner_text); + AppCompatTintImageView icon = view.findViewById(R.id.spinner_icon); + + title.setText(getItem(position)); + icon.setTintDrawableAttr(titleIconList.get(position), R.attr.titleColor); + + return view; + } +} diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java index e932feb2c..54cfab457 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java @@ -15,6 +15,8 @@ import com.annimon.stream.IntPair; import com.mxt.anitrend.R; +import com.mxt.anitrend.adapter.spinner.ShareArrayAdapter; +import com.mxt.anitrend.adapter.spinner.StatusArrayAdapter; import com.mxt.anitrend.base.custom.activity.ActivityBase; import com.mxt.anitrend.base.custom.consumer.BaseConsumer; import com.mxt.anitrend.base.custom.view.image.AppCompatTintImageView; @@ -110,9 +112,10 @@ protected void onPostCreate(@Nullable Bundle savedInstanceState) { bottomSheetBehavior.setPeekHeight(CompatUtil.dipToPx(KeyUtil.PEEK_HEIGHT)); bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); - ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.post_share_types, R.layout.adapter_spinner_item); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - sharedResourceType.setAdapter(adapter); + ArrayAdapter listAdapter = new ShareArrayAdapter(this, + R.layout.adapter_spinner_item, R.id.spinner_text, + CompatUtil.getStringList(this, R.array.post_share_types)); + sharedResourceType.setAdapter(listAdapter); onActivityReady(); } diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index c3f46fd62..cfabd207d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -788,11 +788,11 @@ - Insert Plain Text - @string/attach_link_title - @string/attach_image_title - @string/attach_youtube_title - @string/attach_webm_title + Plain Text + Website + Picture + YouTube + Video diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 06415e053..5806c7b69 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -783,11 +783,11 @@ - Insert Plain Text - @string/attach_link_title - @string/attach_image_title - @string/attach_youtube_title - @string/attach_webm_title + Plain Text + Website + Picture + YouTube + Video diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index fd5f1015a..a0c308912 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -788,10 +788,10 @@ Zwykły tekst - Link - Link do zdjęcia - Link do YouTube - Link do Wideo + Website + zdjęcia + YouTube + Video diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 930a69b51..2f69bae95 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -812,10 +812,10 @@ Plain Text - Website Url - Picture Url - YouTube Url - Video Url + Website + Picture + YouTube + Video From 4ffc17b9005bd85c1f7de13ab4ea4ff7bc8b1c41 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 17:17:15 +0200 Subject: [PATCH 29/69] RegexUtil Tests - Most tests for regex util, only for methods that are not using context tools like TextUtil classes which are not mocked and need to be ran from a context --- .../com/mxt/anitrend/util/RegexUtilTests.java | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 app/src/test/java/com/mxt/anitrend/util/RegexUtilTests.java diff --git a/app/src/test/java/com/mxt/anitrend/util/RegexUtilTests.java b/app/src/test/java/com/mxt/anitrend/util/RegexUtilTests.java new file mode 100644 index 000000000..3e58d0520 --- /dev/null +++ b/app/src/test/java/com/mxt/anitrend/util/RegexUtilTests.java @@ -0,0 +1,96 @@ +package com.mxt.anitrend.util; +import org.junit.Test; + +import java.util.regex.Matcher; + +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertNull; + +public class RegexUtilTests { + + @Test + public void findMedia() { + String testStatus = "MAL is back\\n\\nand i no longer give a shit\\n\\nimg220(https:\\/\\/static1.fjcdn.com\\/thumbnails\\/comments\\/Go+talk+to+our+friendly+fellows+on+the+anime+board+_496f62c2f231bc1c8a9b77a449bf628f.gif)\\nThis place is nice, i like it."; + Matcher matcher = RegexUtil.findMedia(testStatus); + assertNotNull(matcher); + int expectedCount = 1, current = 0; + while (matcher.find()) { + int gc = matcher.groupCount(); + String tag = matcher.group(gc - 1); + assertEquals(RegexUtil.KEY_IMG, tag); + String media = matcher.group(gc); + assertEquals("(https:\\/\\/static1.fjcdn.com\\/thumbnails\\/comments\\/Go+talk+to+our+friendly+fellows+on+the+anime+board+_496f62c2f231bc1c8a9b77a449bf628f.gif)", media); + current += 1; + } + assertEquals(expectedCount, current); + } + + @Test + public void findIntentKeys() { + Matcher matcher = RegexUtil.findIntentKeys("https://anitrend.gitbook.io/project/architecture"); + assertNull(matcher); + + matcher = RegexUtil.findIntentKeys("https://anilist.co/anime/100483/Yuragisou-no-Yuunasan/"); + assertNotNull(matcher); + String type = matcher.group(1); + assertEquals(KeyUtil.DEEP_LINK_ANIME, type); + + matcher = RegexUtil.findIntentKeys("https://anilist.co/manga/87213/Yuragisou-no-Yuunasan/"); + assertNotNull(matcher); + type = matcher.group(1); + assertEquals(KeyUtil.DEEP_LINK_MANGA, type); + + /* This is deprecated in the new front end */ + matcher = RegexUtil.findIntentKeys("https://anilist.co/actor/102263/Youko-Hikasa"); + assertNull(matcher); + + matcher = RegexUtil.findIntentKeys("https://anilist.co/character/88573/Subaru-Natsuki"); + assertNotNull(matcher); + type = matcher.group(1); + assertEquals(KeyUtil.DEEP_LINK_CHARACTER, type); + + matcher = RegexUtil.findIntentKeys("https://anilist.co/staff/102263/Youko-Hikasa"); + assertNotNull(matcher); + type = matcher.group(1); + assertEquals(KeyUtil.DEEP_LINK_STAFF, type); + + matcher = RegexUtil.findIntentKeys("https://anilist.co/studio/18/Toei-Animation"); + assertNotNull(matcher); + type = matcher.group(1); + assertEquals(KeyUtil.DEEP_LINK_STUDIO, type); + + matcher = RegexUtil.findIntentKeys("https://anilist.co/user/wax911/"); + assertNotNull(matcher); + type = matcher.group(1); + assertEquals(KeyUtil.DEEP_LINK_USER, type); + } + + @Test + public void buildYoutube() { + String expected = "https://www.youtube.com/watch?v=8a0gn8mmnaY"; + String result = RegexUtil.buildYoutube("https://www.youtube.com/watch?v=8a0gn8mmnaY"); + assertEquals(expected, result); + result = RegexUtil.buildYoutube("https://youtu.be/8a0gn8mmnaY"); + assertEquals(expected, result); + result = RegexUtil.buildYoutube("8a0gn8mmnaY"); + assertEquals(expected, result); + } + + @Test + public void createYoutubeStandard() { + String expected = "youtube(8a0gn8mmnaY)"; + String result = RegexUtil.createYoutubeStandard("https://youtu.be/8a0gn8mmnaY"); + assertEquals(expected, result); + } + + @Test + public void getYoutubeThumb() { + String expected = "https://img.youtube.com/vi/8a0gn8mmnaY/hqdefault.jpg"; + String result = RegexUtil.getYoutubeThumb("https://www.youtube.com/watch?v=8a0gn8mmnaY"); + assertEquals(expected, result); + + result = RegexUtil.getYoutubeThumb("https://data.whicdn.com/images/107659661/original.gif"); + assertEquals(RegexUtil.NO_THUMBNAIL, result); + } +} \ No newline at end of file From 9676e40b6b8ba1da45f87cf0faae295fe2db92cc Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 25 Aug 2018 17:19:06 +0200 Subject: [PATCH 30/69] Bug Fix From RegexUtil - Building of invalid links for youtube videos was invalid --- app/src/main/java/com/mxt/anitrend/util/RegexUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/util/RegexUtil.java b/app/src/main/java/com/mxt/anitrend/util/RegexUtil.java index 74a16fbd0..8ecc14ac4 100644 --- a/app/src/main/java/com/mxt/anitrend/util/RegexUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/RegexUtil.java @@ -128,7 +128,7 @@ public static String getYoutubeThumb(String link) { if(matcher.find()) temp = matcher.group(matcher.groupCount()); else - temp = NO_THUMBNAIL; + return NO_THUMBNAIL; return String.format(VID_THUMB, temp); } From 2cb8b0d4ad113c9b7fa951632a089a8f87155507 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sun, 26 Aug 2018 11:11:41 +0200 Subject: [PATCH 31/69] Shared Array Adapter - Used a shared array adapter for ShareConentActivity and List Editors --- ...rrayAdapter.java => IconArrayAdapter.java} | 22 +++++--- .../adapter/spinner/StatusArrayAdapter.java | 56 ------------------- .../view/widget/CustomSeriesAnimeManage.java | 7 +-- .../view/widget/CustomSeriesManageBase.java | 21 +++++++ .../view/widget/CustomSeriesMangaManage.java | 12 +--- .../activity/base/SharedContentActivity.java | 17 ++++-- 6 files changed, 49 insertions(+), 86 deletions(-) rename app/src/main/java/com/mxt/anitrend/adapter/spinner/{ShareArrayAdapter.java => IconArrayAdapter.java} (66%) delete mode 100644 app/src/main/java/com/mxt/anitrend/adapter/spinner/StatusArrayAdapter.java diff --git a/app/src/main/java/com/mxt/anitrend/adapter/spinner/ShareArrayAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/spinner/IconArrayAdapter.java similarity index 66% rename from app/src/main/java/com/mxt/anitrend/adapter/spinner/ShareArrayAdapter.java rename to app/src/main/java/com/mxt/anitrend/adapter/spinner/IconArrayAdapter.java index 9bb7eddea..3a984f6df 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/spinner/ShareArrayAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/spinner/IconArrayAdapter.java @@ -15,18 +15,22 @@ import java.util.List; import java.util.Map; -public class ShareArrayAdapter extends ArrayAdapter { +public class IconArrayAdapter extends ArrayAdapter { - private final Map titleIconList = new HashMap() {{ - put(0, R.drawable.ic_textsms_white_24dp); - put(1, R.drawable.ic_link_white_24dp); put(2, R.drawable.ic_crop_original_white_24dp); - put(3, R.drawable.ic_youtube); put(4, R.drawable.ic_slow_motion_video_white_24dp); - }}; + private Map indexIconMap; - public ShareArrayAdapter(@NonNull Context context, int resource, int textViewResourceId, @NonNull List objects) { + public IconArrayAdapter(@NonNull Context context, int resource, int textViewResourceId, @NonNull List objects) { super(context, resource, textViewResourceId, objects); } + /** + * Set a map containing the index relative to the title containing a drawable int res + * @param indexIconMap map of signature (position, R.drawable) + */ + public void setIndexIconMap(Map indexIconMap) { + this.indexIconMap = indexIconMap; + } + @NonNull @Override public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { @@ -36,7 +40,7 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup AppCompatTintImageView icon = view.findViewById(R.id.spinner_icon); title.setText(getItem(position)); - icon.setTintDrawableAttr(titleIconList.get(position), R.attr.titleColor); + icon.setTintDrawableAttr(indexIconMap.get(position), R.attr.titleColor); return view; } @@ -49,7 +53,7 @@ public View getDropDownView(int position, @Nullable View convertView, @NonNull V AppCompatTintImageView icon = view.findViewById(R.id.spinner_icon); title.setText(getItem(position)); - icon.setTintDrawableAttr(titleIconList.get(position), R.attr.titleColor); + icon.setTintDrawableAttr(indexIconMap.get(position), R.attr.titleColor); return view; } diff --git a/app/src/main/java/com/mxt/anitrend/adapter/spinner/StatusArrayAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/spinner/StatusArrayAdapter.java deleted file mode 100644 index 103f2016b..000000000 --- a/app/src/main/java/com/mxt/anitrend/adapter/spinner/StatusArrayAdapter.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.mxt.anitrend.adapter.spinner; - -import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; - -import com.mxt.anitrend.R; -import com.mxt.anitrend.base.custom.view.image.AppCompatTintImageView; -import com.mxt.anitrend.base.custom.view.text.SingleLineTextView; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class StatusArrayAdapter extends ArrayAdapter { - - private final Map titleIconList = new HashMap() {{ - put(0, R.drawable.ic_remove_red_eye_white_18dp); put(1, R.drawable.ic_bookmark_white_24dp); - put(2, R.drawable.ic_done_all_grey_600_24dp); put(3, R.drawable.ic_delete_red_600_18dp); - put(4, R.drawable.ic_pause_white_18dp); put(5, R.drawable.ic_repeat_white_18dp); - }}; - - public StatusArrayAdapter(@NonNull Context context, int resource, int textViewResourceId, @NonNull List objects) { - super(context, resource, textViewResourceId, objects); - } - - @NonNull - @Override - public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { - View view = super.getView(position, convertView, parent); - - SingleLineTextView title = view.findViewById(R.id.spinner_text); - AppCompatTintImageView icon = view.findViewById(R.id.spinner_icon); - - title.setText(getItem(position)); - icon.setTintDrawableAttr(titleIconList.get(position), R.attr.titleColor); - - return view; - } - - @Override - public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { - View view = super.getDropDownView(position, convertView, parent); - - SingleLineTextView title = view.findViewById(R.id.spinner_text); - AppCompatTintImageView icon = view.findViewById(R.id.spinner_icon); - - title.setText(getItem(position)); - icon.setTintDrawableAttr(titleIconList.get(position), R.attr.titleColor); - - return view; - } -} diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java index 826781d95..bea9f8f18 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java @@ -12,7 +12,6 @@ import android.widget.Toast; import com.mxt.anitrend.R; -import com.mxt.anitrend.adapter.spinner.StatusArrayAdapter; import com.mxt.anitrend.databinding.CustomActionAnimeBinding; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; @@ -83,12 +82,8 @@ protected void populateFields() { @Override protected void bindFields() { - ArrayAdapter listAdapter = new StatusArrayAdapter(getContext(), - R.layout.adapter_spinner_item, R.id.spinner_text, - CompatUtil.getStringList(getContext(), R.array.media_list_status)); - // Apply the adapter to the spinner - binding.diaCurrentStatus.setAdapter(listAdapter); + binding.diaCurrentStatus.setAdapter(getIconArrayAdapter()); if (!TextUtils.isEmpty(model.getStatus())) binding.diaCurrentStatus.setSelection(CompatUtil.constructListFrom(KeyUtil.MediaListStatus).indexOf(model.getStatus())); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java index b800fef08..238635d28 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java @@ -8,13 +8,20 @@ import android.util.AttributeSet; import android.view.View; import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.RelativeLayout; +import com.mxt.anitrend.R; +import com.mxt.anitrend.adapter.spinner.IconArrayAdapter; import com.mxt.anitrend.base.interfaces.view.CustomView; import com.mxt.anitrend.model.entity.anilist.MediaList; import com.mxt.anitrend.model.entity.anilist.meta.MediaListOptions; import com.mxt.anitrend.model.entity.base.MediaBase; import com.mxt.anitrend.presenter.fragment.MediaPresenter; +import com.mxt.anitrend.util.CompatUtil; + +import java.util.HashMap; +import java.util.Map; /** * Created by max on 2018/01/20. @@ -27,6 +34,12 @@ public abstract class CustomSeriesManageBase extends RelativeLayout implements C protected MediaList model; + protected final Map indexIconMap = new HashMap() {{ + put(0, R.drawable.ic_remove_red_eye_white_18dp); put(1, R.drawable.ic_bookmark_white_24dp); + put(2, R.drawable.ic_done_all_grey_600_24dp); put(3, R.drawable.ic_delete_red_600_18dp); + put(4, R.drawable.ic_pause_white_18dp); put(5, R.drawable.ic_repeat_white_18dp); + }}; + public CustomSeriesManageBase(Context context) { super(context); onInit(); @@ -56,6 +69,14 @@ public void onInit() { presenter = new MediaPresenter(getContext()); } + protected IconArrayAdapter getIconArrayAdapter() { + IconArrayAdapter iconArrayAdapter = new IconArrayAdapter(getContext(), + R.layout.adapter_spinner_item, R.id.spinner_text, + CompatUtil.getStringList(getContext(), R.array.media_list_status)); + iconArrayAdapter.setIndexIconMap(indexIconMap); + return iconArrayAdapter; + } + public void setModel(MediaBase mediaBase) { if(mediaBase.getMediaListEntry() != null) { this.model = mediaBase.getMediaListEntry(); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java index 70ddf1a9e..7d55d50bb 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java @@ -3,21 +3,15 @@ import android.content.Context; import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; -import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; -import android.widget.ListAdapter; import android.widget.Toast; -import com.annimon.stream.Stream; import com.mxt.anitrend.R; -import com.mxt.anitrend.adapter.spinner.StatusArrayAdapter; import com.mxt.anitrend.databinding.CustomActionMangaBinding; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; @@ -88,12 +82,8 @@ protected void populateFields() { @Override protected void bindFields() { - ArrayAdapter listAdapter = new StatusArrayAdapter(getContext(), - R.layout.adapter_spinner_item, R.id.spinner_text, - CompatUtil.getStringList(getContext(), R.array.media_list_status)); - // Apply the adapter to the spinner - binding.diaCurrentStatus.setAdapter(listAdapter); + binding.diaCurrentStatus.setAdapter(getIconArrayAdapter()); if(!TextUtils.isEmpty(model.getStatus())) binding.diaCurrentStatus.setSelection(CompatUtil.constructListFrom(KeyUtil.MediaListStatus).indexOf(model.getStatus())); diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java index 54cfab457..faba3e54f 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java @@ -15,8 +15,7 @@ import com.annimon.stream.IntPair; import com.mxt.anitrend.R; -import com.mxt.anitrend.adapter.spinner.ShareArrayAdapter; -import com.mxt.anitrend.adapter.spinner.StatusArrayAdapter; +import com.mxt.anitrend.adapter.spinner.IconArrayAdapter; import com.mxt.anitrend.base.custom.activity.ActivityBase; import com.mxt.anitrend.base.custom.consumer.BaseConsumer; import com.mxt.anitrend.base.custom.view.image.AppCompatTintImageView; @@ -38,6 +37,9 @@ import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import java.util.HashMap; +import java.util.Map; + import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -84,6 +86,12 @@ public void onSlide(@NonNull View bottomSheet, float slideOffset) { protected @BindView(R.id.sheet_share_post_type) Spinner sharedResourceType; protected @BindView(R.id.sheet_share_post_type_approve) AppCompatTintImageView sharedResourceApprove; + private Map indexIconMap = new HashMap() {{ + put(0, R.drawable.ic_textsms_white_24dp); + put(1, R.drawable.ic_link_white_24dp); put(2, R.drawable.ic_crop_original_white_24dp); + put(3, R.drawable.ic_youtube); put(4, R.drawable.ic_slow_motion_video_white_24dp); + }}; + /** * Some activities may have custom themes and if that's the case * override this method and set your own theme style, also if you wish @@ -112,10 +120,11 @@ protected void onPostCreate(@Nullable Bundle savedInstanceState) { bottomSheetBehavior.setPeekHeight(CompatUtil.dipToPx(KeyUtil.PEEK_HEIGHT)); bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); - ArrayAdapter listAdapter = new ShareArrayAdapter(this, + IconArrayAdapter iconArrayAdapter = new IconArrayAdapter(this, R.layout.adapter_spinner_item, R.id.spinner_text, CompatUtil.getStringList(this, R.array.post_share_types)); - sharedResourceType.setAdapter(listAdapter); + iconArrayAdapter.setIndexIconMap(indexIconMap); + sharedResourceType.setAdapter(iconArrayAdapter); onActivityReady(); } From 4697c14f025a4e14c567bb16467096e37c1bae04 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sun, 26 Aug 2018 11:16:06 +0200 Subject: [PATCH 32/69] Removed Unused Imports --- .../anitrend/adapter/recycler/detail/CommentAdapter.java | 4 ---- .../mxt/anitrend/adapter/recycler/detail/GenreAdapter.java | 3 --- .../mxt/anitrend/adapter/recycler/detail/GiphyAdapter.java | 2 -- .../mxt/anitrend/adapter/recycler/detail/LinkAdapter.java | 3 --- .../adapter/recycler/detail/NotificationAdapter.java | 2 -- .../mxt/anitrend/adapter/recycler/detail/RankAdapter.java | 2 -- .../mxt/anitrend/adapter/recycler/detail/TagAdapter.java | 2 -- .../anitrend/adapter/recycler/index/EpisodeAdapter.java | 4 ---- .../mxt/anitrend/adapter/recycler/index/FeedAdapter.java | 2 -- .../mxt/anitrend/adapter/recycler/index/MediaAdapter.java | 5 ----- .../mxt/anitrend/adapter/recycler/index/ReviewAdapter.java | 2 -- .../mxt/anitrend/adapter/recycler/index/StaffAdapter.java | 2 -- .../mxt/anitrend/adapter/recycler/index/StudioAdapter.java | 2 -- .../com/mxt/anitrend/adapter/spinner/IconArrayAdapter.java | 1 - .../anitrend/base/custom/fragment/FragmentChannelBase.java | 1 - .../mxt/anitrend/base/custom/sheet/BottomSheetList.java | 1 - .../base/custom/view/container/NotificationCardView.java | 3 --- .../base/custom/view/image/AppCompatTintImageView.java | 1 - .../mxt/anitrend/base/custom/view/text/RatingTextView.java | 2 -- .../base/custom/view/widget/CustomSeriesAnimeManage.java | 1 - .../base/custom/view/widget/CustomSeriesManageBase.java | 2 -- .../base/custom/view/widget/CustomSeriesMangaManage.java | 1 - .../mxt/anitrend/model/api/converter/GraphQLConverter.java | 1 - .../mxt/anitrend/model/api/retro/anilist/BrowseModel.java | 2 -- .../anitrend/model/entity/anilist/MediaListCollection.java | 4 +++- .../main/java/com/mxt/anitrend/util/ApplicationPref.java | 1 - app/src/main/java/com/mxt/anitrend/util/GroupingUtil.java | 2 +- app/src/main/java/com/mxt/anitrend/util/LocaleUtil.java | 2 -- app/src/main/java/com/mxt/anitrend/util/TapTargetUtil.java | 1 - .../mxt/anitrend/view/activity/base/SettingsActivity.java | 7 ------- .../anitrend/view/activity/base/SharedContentActivity.java | 1 - .../mxt/anitrend/view/activity/detail/ProfileActivity.java | 1 - .../mxt/anitrend/view/activity/detail/StaffActivity.java | 1 - .../mxt/anitrend/view/activity/index/LoginActivity.java | 1 + .../mxt/anitrend/view/fragment/detail/AboutFragment.java | 2 -- .../mxt/anitrend/view/fragment/list/MediaListFragment.java | 1 - .../mxt/anitrend/view/fragment/list/WatchListFragment.java | 1 - .../view/fragment/youtube/YoutubePlayerFragment.java | 1 - .../com/mxt/anitrend/view/sheet/BottomSheetComposer.java | 1 - .../java/com/mxt/anitrend/view/sheet/BottomSheetUsers.java | 1 - 40 files changed, 5 insertions(+), 74 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/CommentAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/CommentAdapter.java index 0b014fe29..31804d347 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/CommentAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/CommentAdapter.java @@ -6,19 +6,15 @@ import android.view.ViewGroup; import android.widget.Filter; -import com.annimon.stream.IntPair; import com.bumptech.glide.Glide; import com.mxt.anitrend.R; import com.mxt.anitrend.base.custom.recycler.RecyclerViewAdapter; import com.mxt.anitrend.base.custom.recycler.RecyclerViewHolder; import com.mxt.anitrend.databinding.AdapterCommentBinding; -import com.mxt.anitrend.model.entity.anilist.FeedList; import com.mxt.anitrend.model.entity.anilist.FeedReply; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; -import java.util.List; - import butterknife.OnClick; /** diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/GenreAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/GenreAdapter.java index cc0a13155..1bbafc365 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/GenreAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/GenreAdapter.java @@ -6,7 +6,6 @@ import android.view.ViewGroup; import android.widget.Filter; -import com.annimon.stream.IntPair; import com.bumptech.glide.Glide; import com.mxt.anitrend.R; import com.mxt.anitrend.base.custom.recycler.RecyclerViewAdapter; @@ -15,8 +14,6 @@ import com.mxt.anitrend.model.entity.anilist.Genre; import com.mxt.anitrend.util.CompatUtil; -import java.util.List; - import butterknife.OnClick; import butterknife.OnLongClick; diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/GiphyAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/GiphyAdapter.java index 9c228677b..265276290 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/GiphyAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/GiphyAdapter.java @@ -6,7 +6,6 @@ import android.view.ViewGroup; import android.widget.Filter; -import com.annimon.stream.IntPair; import com.bumptech.glide.Glide; import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions; import com.bumptech.glide.request.RequestOptions; @@ -20,7 +19,6 @@ import com.mxt.anitrend.util.KeyUtil; import java.util.HashMap; -import java.util.List; import butterknife.OnClick; import butterknife.OnLongClick; diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/LinkAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/LinkAdapter.java index 59ec81a95..fffcf977d 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/LinkAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/LinkAdapter.java @@ -6,7 +6,6 @@ import android.view.ViewGroup; import android.widget.Filter; -import com.annimon.stream.IntPair; import com.bumptech.glide.Glide; import com.mxt.anitrend.R; import com.mxt.anitrend.base.custom.recycler.RecyclerViewAdapter; @@ -15,8 +14,6 @@ import com.mxt.anitrend.model.entity.anilist.ExternalLink; import com.mxt.anitrend.util.CompatUtil; -import java.util.List; - import butterknife.OnClick; import butterknife.OnLongClick; diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java index bff5c6bec..02e2ba084 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java @@ -20,8 +20,6 @@ import com.mxt.anitrend.util.DateUtil; import com.mxt.anitrend.util.KeyUtil; -import java.util.List; - import butterknife.OnClick; import butterknife.OnLongClick; import io.objectbox.Box; diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/RankAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/RankAdapter.java index 62e65c618..8dafc94a9 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/RankAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/RankAdapter.java @@ -15,8 +15,6 @@ import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; -import java.util.List; - import butterknife.OnClick; import butterknife.OnLongClick; diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/TagAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/TagAdapter.java index 4f7b11161..4afcf1650 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/TagAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/TagAdapter.java @@ -14,8 +14,6 @@ import com.mxt.anitrend.model.entity.anilist.MediaTag; import com.mxt.anitrend.util.CompatUtil; -import java.util.List; - import butterknife.OnClick; import butterknife.OnLongClick; diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/EpisodeAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/EpisodeAdapter.java index d73cba365..1838fda53 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/EpisodeAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/EpisodeAdapter.java @@ -7,7 +7,6 @@ import android.view.ViewGroup; import android.widget.Filter; -import com.annimon.stream.Stream; import com.bumptech.glide.Glide; import com.mxt.anitrend.R; import com.mxt.anitrend.base.custom.recycler.RecyclerViewAdapter; @@ -15,9 +14,6 @@ import com.mxt.anitrend.databinding.AdapterEpisodeBinding; import com.mxt.anitrend.model.entity.crunchy.Episode; -import java.util.ArrayList; -import java.util.List; - import butterknife.OnClick; import butterknife.OnLongClick; diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/FeedAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/FeedAdapter.java index 709b11d20..83bfa9073 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/FeedAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/FeedAdapter.java @@ -21,8 +21,6 @@ import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; -import java.util.List; - import butterknife.OnClick; import butterknife.OnLongClick; diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/MediaAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/MediaAdapter.java index 7d6a53024..5c5139676 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/MediaAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/MediaAdapter.java @@ -7,7 +7,6 @@ import android.view.ViewGroup; import android.widget.Filter; -import com.annimon.stream.Stream; import com.bumptech.glide.Glide; import com.mxt.anitrend.R; import com.mxt.anitrend.base.custom.recycler.RecyclerViewAdapter; @@ -20,10 +19,6 @@ import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.KeyUtil; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - import butterknife.ButterKnife; import butterknife.OnClick; import butterknife.OnLongClick; diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/ReviewAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/ReviewAdapter.java index 0acb7ecda..37c816a93 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/ReviewAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/ReviewAdapter.java @@ -15,8 +15,6 @@ import com.mxt.anitrend.databinding.AdapterSeriesReviewBinding; import com.mxt.anitrend.model.entity.anilist.Review; -import java.util.List; - import butterknife.OnClick; import butterknife.OnLongClick; diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/StaffAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/StaffAdapter.java index 7480057d9..f13ac4775 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/StaffAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/StaffAdapter.java @@ -14,8 +14,6 @@ import com.mxt.anitrend.model.entity.base.StaffBase; import com.mxt.anitrend.util.CompatUtil; -import java.util.List; - import butterknife.OnClick; /** diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/StudioAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/StudioAdapter.java index c1515d6fd..0ec672fe5 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/StudioAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/index/StudioAdapter.java @@ -14,8 +14,6 @@ import com.mxt.anitrend.model.entity.base.StudioBase; import com.mxt.anitrend.util.CompatUtil; -import java.util.List; - import butterknife.OnClick; /** diff --git a/app/src/main/java/com/mxt/anitrend/adapter/spinner/IconArrayAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/spinner/IconArrayAdapter.java index 3a984f6df..269d5a177 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/spinner/IconArrayAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/spinner/IconArrayAdapter.java @@ -11,7 +11,6 @@ import com.mxt.anitrend.base.custom.view.image.AppCompatTintImageView; import com.mxt.anitrend.base.custom.view.text.SingleLineTextView; -import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java index e12d87029..282dc80f6 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentChannelBase.java @@ -8,7 +8,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; -import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.StaggeredGridLayoutManager; import android.text.TextUtils; import android.view.LayoutInflater; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetList.java b/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetList.java index b26ff9b9a..4480565ff 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetList.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetList.java @@ -17,7 +17,6 @@ import com.mxt.anitrend.base.interfaces.event.ItemClickListener; import com.mxt.anitrend.base.interfaces.event.RecyclerLoadListener; import com.mxt.anitrend.util.CompatUtil; -import com.mxt.anitrend.util.KeyUtil; import com.nguyenhoanglam.progresslayout.ProgressLayout; import java.util.List; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/container/NotificationCardView.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/container/NotificationCardView.java index 1238bdf46..de05ec630 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/container/NotificationCardView.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/container/NotificationCardView.java @@ -5,9 +5,6 @@ import android.support.annotation.Nullable; import android.util.AttributeSet; -import com.mxt.anitrend.R; -import com.mxt.anitrend.util.CompatUtil; - public class NotificationCardView extends CardViewBase { public NotificationCardView(@NonNull Context context) { diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AppCompatTintImageView.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AppCompatTintImageView.java index a8223ffd1..b051e1a60 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AppCompatTintImageView.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/image/AppCompatTintImageView.java @@ -3,7 +3,6 @@ import android.content.Context; import android.databinding.BindingAdapter; import android.support.annotation.AttrRes; -import android.support.annotation.ColorInt; import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatImageView; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java index 3ff89c7df..9dad6070a 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/text/RatingTextView.java @@ -1,12 +1,10 @@ package com.mxt.anitrend.base.custom.view.text; import android.content.Context; -import android.content.Intent; import android.databinding.BindingAdapter; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.ColorRes; -import android.support.annotation.DrawableRes; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.util.AttributeSet; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java index bea9f8f18..36697c8dd 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesAnimeManage.java @@ -8,7 +8,6 @@ import android.util.AttributeSet; import android.view.View; import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.Toast; import com.mxt.anitrend.R; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java index 238635d28..ce73123a2 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesManageBase.java @@ -6,9 +6,7 @@ import android.support.annotation.NonNull; import android.support.annotation.RequiresApi; import android.util.AttributeSet; -import android.view.View; import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.RelativeLayout; import com.mxt.anitrend.R; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java index 7d55d50bb..1dbc1bd8a 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/CustomSeriesMangaManage.java @@ -8,7 +8,6 @@ import android.util.AttributeSet; import android.view.View; import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.Toast; import com.mxt.anitrend.R; diff --git a/app/src/main/java/com/mxt/anitrend/model/api/converter/GraphQLConverter.java b/app/src/main/java/com/mxt/anitrend/model/api/converter/GraphQLConverter.java index ce165a432..9cd776fb8 100644 --- a/app/src/main/java/com/mxt/anitrend/model/api/converter/GraphQLConverter.java +++ b/app/src/main/java/com/mxt/anitrend/model/api/converter/GraphQLConverter.java @@ -7,7 +7,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.mxt.anitrend.base.custom.annotation.processor.GraphProcessor; -import com.mxt.anitrend.model.api.retro.WebFactory; import com.mxt.anitrend.model.entity.container.attribute.GraphError; import com.mxt.anitrend.model.entity.container.body.DataContainer; import com.mxt.anitrend.model.entity.container.body.GraphContainer; diff --git a/app/src/main/java/com/mxt/anitrend/model/api/retro/anilist/BrowseModel.java b/app/src/main/java/com/mxt/anitrend/model/api/retro/anilist/BrowseModel.java index ac564838f..084fea786 100644 --- a/app/src/main/java/com/mxt/anitrend/model/api/retro/anilist/BrowseModel.java +++ b/app/src/main/java/com/mxt/anitrend/model/api/retro/anilist/BrowseModel.java @@ -5,9 +5,7 @@ import com.mxt.anitrend.model.entity.anilist.MediaListCollection; import com.mxt.anitrend.model.entity.anilist.Review; import com.mxt.anitrend.model.entity.anilist.meta.DeleteState; -import com.mxt.anitrend.model.entity.anilist.meta.MediaListOptions; import com.mxt.anitrend.model.entity.base.MediaBase; -import com.mxt.anitrend.model.entity.container.body.DataContainer; import com.mxt.anitrend.model.entity.container.body.GraphContainer; import com.mxt.anitrend.model.entity.container.body.PageContainer; import com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder; diff --git a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaListCollection.java b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaListCollection.java index 5ffa6331f..b0b008165 100644 --- a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaListCollection.java +++ b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaListCollection.java @@ -1,9 +1,11 @@ package com.mxt.anitrend.model.entity.anilist; -import java.util.List; import android.os.Parcel; + import com.mxt.anitrend.model.entity.base.MediaListCollectionBase; +import java.util.List; + public class MediaListCollection extends MediaListCollectionBase { private List entries; diff --git a/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java b/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java index a0e0bca84..766ec1b89 100644 --- a/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java +++ b/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java @@ -4,7 +4,6 @@ import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.annotation.IdRes; -import android.support.annotation.IntRange; import android.support.annotation.Nullable; import android.support.annotation.StyleRes; diff --git a/app/src/main/java/com/mxt/anitrend/util/GroupingUtil.java b/app/src/main/java/com/mxt/anitrend/util/GroupingUtil.java index f550e236d..17e028ea5 100644 --- a/app/src/main/java/com/mxt/anitrend/util/GroupingUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/GroupingUtil.java @@ -12,8 +12,8 @@ import com.mxt.anitrend.model.entity.base.MediaBase; import com.mxt.anitrend.model.entity.base.StaffBase; import com.mxt.anitrend.model.entity.container.body.EdgeContainer; -import com.mxt.anitrend.model.entity.group.RecyclerItem; import com.mxt.anitrend.model.entity.group.RecyclerHeaderItem; +import com.mxt.anitrend.model.entity.group.RecyclerItem; import com.mxt.anitrend.view.fragment.group.CharacterActorsFragment; import java.util.ArrayList; diff --git a/app/src/main/java/com/mxt/anitrend/util/LocaleUtil.java b/app/src/main/java/com/mxt/anitrend/util/LocaleUtil.java index 11d1a1d3d..228586aa9 100644 --- a/app/src/main/java/com/mxt/anitrend/util/LocaleUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/LocaleUtil.java @@ -2,11 +2,9 @@ import android.annotation.TargetApi; import android.content.Context; -import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; -import android.preference.PreferenceManager; import java.util.Locale; diff --git a/app/src/main/java/com/mxt/anitrend/util/TapTargetUtil.java b/app/src/main/java/com/mxt/anitrend/util/TapTargetUtil.java index 3b1ba30a3..7dffc615f 100644 --- a/app/src/main/java/com/mxt/anitrend/util/TapTargetUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/TapTargetUtil.java @@ -6,7 +6,6 @@ import android.support.v4.app.FragmentActivity; import android.support.v4.graphics.ColorUtils; import android.support.v4.view.animation.FastOutSlowInInterpolator; -import android.util.Log; import android.view.View; import com.annimon.stream.Stream; diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java index c150d0fba..b8c7e9259 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java @@ -4,7 +4,6 @@ import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.content.res.Configuration; import android.media.Ringtone; import android.media.RingtoneManager; @@ -17,18 +16,12 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.preference.RingtonePreference; -import android.preference.SwitchPreference; import android.support.v4.app.NavUtils; import android.support.v7.app.ActionBar; import android.text.TextUtils; -import android.util.Log; import android.view.MenuItem; import com.mxt.anitrend.R; -import com.mxt.anitrend.data.DatabaseHelper; -import com.mxt.anitrend.model.entity.base.VersionBase; -import com.mxt.anitrend.util.ApplicationPref; -import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.JobSchedulerUtil; import java.util.List; diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java index faba3e54f..da9712510 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/SharedContentActivity.java @@ -9,7 +9,6 @@ import android.support.v4.app.ShareCompat; import android.support.v7.widget.AppCompatImageView; import android.view.View; -import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/detail/ProfileActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/detail/ProfileActivity.java index f6447349c..3c9abf388 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/detail/ProfileActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/detail/ProfileActivity.java @@ -23,7 +23,6 @@ import com.mxt.anitrend.util.GraphUtil; import com.mxt.anitrend.util.KeyUtil; import com.mxt.anitrend.util.NotifyUtil; -import com.mxt.anitrend.util.TapTargetUtil; import com.mxt.anitrend.util.TutorialUtil; import com.mxt.anitrend.view.activity.base.ImagePreviewActivity; import com.mxt.anitrend.view.sheet.BottomSheetComposer; diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/detail/StaffActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/detail/StaffActivity.java index 51eb58ac1..f1e40c874 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/detail/StaffActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/detail/StaffActivity.java @@ -19,7 +19,6 @@ import com.mxt.anitrend.presenter.base.BasePresenter; import com.mxt.anitrend.util.GraphUtil; import com.mxt.anitrend.util.KeyUtil; -import com.mxt.anitrend.util.MediaActionUtil; import com.mxt.anitrend.util.NotifyUtil; import com.ogaclejapan.smarttablayout.SmartTabLayout; diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java index f6d5d939d..ca482070a 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java @@ -10,6 +10,7 @@ import android.util.Log; import android.view.View; import android.widget.Toast; + import com.mxt.anitrend.R; import com.mxt.anitrend.base.custom.activity.ActivityBase; import com.mxt.anitrend.base.custom.async.WebTokenRequest; diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/detail/AboutFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/detail/AboutFragment.java index 98c40ef9c..6333e3805 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/detail/AboutFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/detail/AboutFragment.java @@ -8,14 +8,12 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Toast; import com.mxt.anitrend.BuildConfig; import com.mxt.anitrend.R; import com.mxt.anitrend.base.custom.fragment.FragmentBase; import com.mxt.anitrend.presenter.base.BasePresenter; import com.mxt.anitrend.util.DialogUtil; -import com.mxt.anitrend.util.NotifyUtil; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaListFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaListFragment.java index 0d1ba9558..e51297cac 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaListFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaListFragment.java @@ -6,7 +6,6 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.text.TextUtils; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java index 8e7f287a7..7171dffff 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/list/WatchListFragment.java @@ -5,7 +5,6 @@ import android.os.Parcelable; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; import android.util.Log; import com.mxt.anitrend.BuildConfig; diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YoutubePlayerFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YoutubePlayerFragment.java index a83f31ddd..d2ed6f382 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YoutubePlayerFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/youtube/YoutubePlayerFragment.java @@ -2,7 +2,6 @@ import android.arch.lifecycle.Lifecycle; import android.os.Bundle; -import android.util.Log; import com.google.android.youtube.player.YouTubeInitializationResult; import com.google.android.youtube.player.YouTubePlayer; diff --git a/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetComposer.java b/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetComposer.java index d5ca75dd3..ba13088b4 100644 --- a/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetComposer.java +++ b/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetComposer.java @@ -6,7 +6,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; -import android.widget.Toast; import com.annimon.stream.IntPair; import com.mxt.anitrend.R; diff --git a/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetUsers.java b/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetUsers.java index be2fff9c3..8a512ff04 100644 --- a/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetUsers.java +++ b/app/src/main/java/com/mxt/anitrend/view/sheet/BottomSheetUsers.java @@ -25,7 +25,6 @@ import com.mxt.anitrend.view.activity.detail.ProfileActivity; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import butterknife.ButterKnife; From 621b09c20e3fbf373b8c6772ca55b67aa5654b56 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sun, 26 Aug 2018 11:50:47 +0200 Subject: [PATCH 33/69] Added Attribute Setter - Prior to a fix that requires this setter to be accessible --- .../anitrend/model/entity/container/attribute/PageInfo.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/com/mxt/anitrend/model/entity/container/attribute/PageInfo.java b/app/src/main/java/com/mxt/anitrend/model/entity/container/attribute/PageInfo.java index fbb4f3ff8..4afc7d5b2 100644 --- a/app/src/main/java/com/mxt/anitrend/model/entity/container/attribute/PageInfo.java +++ b/app/src/main/java/com/mxt/anitrend/model/entity/container/attribute/PageInfo.java @@ -65,4 +65,8 @@ public boolean hasNextPage() { public void setTotal(int total) { this.total = total; } + + public void setPerPage(int perPage) { + this.perPage = perPage; + } } From 71a7158b36a77dca0487de1921fc2be103e51dd5 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sun, 26 Aug 2018 11:51:56 +0200 Subject: [PATCH 34/69] Patch For Unable To Resolve Content - Fixes #80 which led to unresolved content for public status feeds --- .../java/com/mxt/anitrend/util/GraphUtil.java | 19 +++++++++++++++++++ .../view/fragment/list/FeedListFragment.java | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/util/GraphUtil.java b/app/src/main/java/com/mxt/anitrend/util/GraphUtil.java index 2a2ae7d9e..1d83e7871 100644 --- a/app/src/main/java/com/mxt/anitrend/util/GraphUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/GraphUtil.java @@ -1,6 +1,13 @@ package com.mxt.anitrend.util; +import android.text.TextUtils; + +import com.annimon.stream.Stream; +import com.mxt.anitrend.model.entity.anilist.FeedList; import com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder; +import com.mxt.anitrend.presenter.base.BasePresenter; + +import java.util.List; /** * Created by max on 2018/03/22. @@ -35,4 +42,16 @@ public static boolean isKeyFilter(String preferenceKey) { return !CompatUtil.equals(preferenceKey, ApplicationPref._isLightTheme) && !CompatUtil.equals(preferenceKey, ApplicationPref._updateChannel); } + + /** + * Remove empty json object responses, to resolve undefined content errors + */ + public static List filterFeedList(BasePresenter presenter, List feedLists) { + List filteredList = Stream.of(feedLists) + .filter(f -> f != null && !TextUtils.isEmpty(f.getType())) + .toList(); + if(presenter.getPageInfo() != null) + presenter.getPageInfo().setPerPage(filteredList.size()); + return filteredList; + } } diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/list/FeedListFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/list/FeedListFragment.java index 879717be7..14970d621 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/list/FeedListFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/list/FeedListFragment.java @@ -22,6 +22,7 @@ import com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder; import com.mxt.anitrend.presenter.base.BasePresenter; import com.mxt.anitrend.util.CompatUtil; +import com.mxt.anitrend.util.GraphUtil; import com.mxt.anitrend.util.KeyUtil; import com.mxt.anitrend.util.MediaActionUtil; import com.mxt.anitrend.util.NotifyUtil; @@ -168,7 +169,7 @@ public void onChanged(@Nullable PageContainer content) { if(content.hasPageInfo()) getPresenter().setPageInfo(content.getPageInfo()); if(!content.isEmpty()) - onPostProcessed(content.getPageData()); + onPostProcessed(GraphUtil.filterFeedList(getPresenter(), content.getPageData())); else onPostProcessed(Collections.emptyList()); } else From dae1b5f72b708c77b0f266ad85cf1992fc579801 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sun, 26 Aug 2018 13:59:50 +0200 Subject: [PATCH 35/69] Empty Constructor Required For Object Box --- .../java/com/mxt/anitrend/model/entity/anilist/Genre.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/Genre.java b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/Genre.java index f604944f4..6b81fd8cb 100644 --- a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/Genre.java +++ b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/Genre.java @@ -21,6 +21,10 @@ public class Genre implements Parcelable { private String genre; private boolean isSelected; + public Genre() { + + } + public Genre(String genre) { this.genre = genre; } From f58b8b3b27b56551232639cf05ae5964da5c6cf9 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Wed, 29 Aug 2018 21:49:44 +0200 Subject: [PATCH 36/69] Extended Date Range For Media Filter --- .../mxt/anitrend/view/fragment/list/MediaBrowseFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java index 780d1d198..987d15e3a 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java @@ -138,7 +138,7 @@ public boolean onOptionsItemSelected(MenuItem item) { }); return true; case R.id.action_year: - final List yearRanges = DateUtil.getYearRanges(1980, 1); + final List yearRanges = DateUtil.getYearRanges(1950, 1); DialogUtil.createSelection(getContext(), R.string.app_filter_year, CompatUtil.getIndexOf(yearRanges, getPresenter().getApplicationPref().getSeasonYear()), yearRanges, (dialog, which) -> { if(which == DialogAction.POSITIVE) From e84622dbf17087cc829c8ed3f1b0ab5695f9ecb8 Mon Sep 17 00:00:00 2001 From: Mehul Mittal Date: Thu, 30 Aug 2018 01:21:54 +0530 Subject: [PATCH 37/69] Set End Date With Auto Increment Widget (#81) - Set CompletedAt and StartedAt upon auto-increment, also set Current if initial value was 1 - Fix incorrect parameters being sent to getCurrentDate --- .../view/widget/AutoIncrementWidget.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java index 745050879..dfb1410e0 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java @@ -17,6 +17,7 @@ import com.mxt.anitrend.base.interfaces.view.CustomView; import com.mxt.anitrend.databinding.WidgetAutoIncrementerBinding; import com.mxt.anitrend.model.entity.anilist.MediaList; +import com.mxt.anitrend.model.entity.anilist.meta.FuzzyDate; import com.mxt.anitrend.presenter.widget.WidgetPresenter; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.ErrorUtil; @@ -25,6 +26,8 @@ import com.mxt.anitrend.util.MediaUtil; import com.mxt.anitrend.util.NotifyUtil; +import java.util.Calendar; + import retrofit2.Call; import retrofit2.Response; @@ -145,13 +148,24 @@ public void onFailure(@NonNull Call call, @NonNull Throwable throwabl } } + private void updateModelState() { + if(model.getProgress() == 0) { + model.setStatus(KeyUtil.CURRENT); + model.setStartedAt(getCurrentDate()); + } model.setProgress(model.getProgress() + 1); - if(MediaUtil.isIncrementLimitReached(model)) + if(MediaUtil.isIncrementLimitReached(model)) { model.setStatus(KeyUtil.COMPLETED); - + model.setCompletedAt(getCurrentDate()); + } presenter.setParams(MediaListUtil.getMediaListParams(model, presenter.getDatabase() .getCurrentUser().getMediaListOptions().getScoreFormat())); presenter.requestData(requestType, getContext(), this); } + + private FuzzyDate getCurrentDate(){ + Calendar calendar = Calendar.getInstance(); + return new FuzzyDate(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.YEAR)); + } } From 1e08b5a54866aadc773fa1e5b74c89dd6bd14fd1 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Wed, 29 Aug 2018 23:01:59 +0200 Subject: [PATCH 38/69] Refactored Current Date For Fuzzy Date - Moved getCurrentDate() to DateUtil.java out of AutoIncrementWidget.java --- .../custom/view/widget/AutoIncrementWidget.java | 10 +++------- .../main/java/com/mxt/anitrend/util/DateUtil.java | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java index dfb1410e0..d8e1f8063 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java @@ -20,6 +20,7 @@ import com.mxt.anitrend.model.entity.anilist.meta.FuzzyDate; import com.mxt.anitrend.presenter.widget.WidgetPresenter; import com.mxt.anitrend.util.CompatUtil; +import com.mxt.anitrend.util.DateUtil; import com.mxt.anitrend.util.ErrorUtil; import com.mxt.anitrend.util.KeyUtil; import com.mxt.anitrend.util.MediaListUtil; @@ -152,20 +153,15 @@ public void onFailure(@NonNull Call call, @NonNull Throwable throwabl private void updateModelState() { if(model.getProgress() == 0) { model.setStatus(KeyUtil.CURRENT); - model.setStartedAt(getCurrentDate()); + model.setStartedAt(DateUtil.getCurrentDate()); } model.setProgress(model.getProgress() + 1); if(MediaUtil.isIncrementLimitReached(model)) { model.setStatus(KeyUtil.COMPLETED); - model.setCompletedAt(getCurrentDate()); + model.setCompletedAt(DateUtil.getCurrentDate()); } presenter.setParams(MediaListUtil.getMediaListParams(model, presenter.getDatabase() .getCurrentUser().getMediaListOptions().getScoreFormat())); presenter.requestData(requestType, getContext(), this); } - - private FuzzyDate getCurrentDate(){ - Calendar calendar = Calendar.getInstance(); - return new FuzzyDate(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.YEAR)); - } } diff --git a/app/src/main/java/com/mxt/anitrend/util/DateUtil.java b/app/src/main/java/com/mxt/anitrend/util/DateUtil.java index 7a35796ec..c5dd7b8e6 100644 --- a/app/src/main/java/com/mxt/anitrend/util/DateUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/DateUtil.java @@ -42,7 +42,7 @@ public class DateUtil { * * @return Season name */ - public static @KeyUtil.MediaSeason String getCurrentSeason(){ + public static @KeyUtil.MediaSeason String getCurrentSeason() { int month = Calendar.getInstance().get(Calendar.MONTH); return seasons[month]; } @@ -70,7 +70,7 @@ public static String getMediaSeason(FuzzyDate fuzzyDate){ * * @return Season name */ - public static int getMenuSelect(){ + public static int getMenuSelect() { String value = seasons[Calendar.getInstance().get(Calendar.MONTH)]; return CompatUtil.constructListFrom(KeyUtil.MediaSeason).indexOf(value); } @@ -82,7 +82,7 @@ public static int getMenuSelect(){ * * @return current year with a given delta */ - public static int getCurrentYear(int delta){ + public static int getCurrentYear(int delta) { if(Calendar.getInstance().get(Calendar.MONTH) >= 11 && getCurrentSeason().equals(KeyUtil.WINTER)) return Calendar.getInstance().get(Calendar.YEAR) + delta; return Calendar.getInstance().get(Calendar.YEAR) + delta; @@ -212,6 +212,15 @@ public static int getDate() { return Calendar.getInstance().get(Calendar.DATE); } + + /** + * Get the current fuzzy date + */ + public static @NonNull FuzzyDate getCurrentDate() { + Calendar calendar = Calendar.getInstance(); + return new FuzzyDate(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.YEAR)); + } + /** * Checks if the time given has a difference greater than or equal to the target time *
From 6b0bb3c3497665ebf19c936fe6203659b77edf84 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 1 Sep 2018 16:37:40 +0200 Subject: [PATCH 39/69] Media Genres & Tags Filters #71 - Adds additional Json converter for storing selected genres and filters as plain text --- .../model/entity/anilist/MediaTag.java | 5 ++ .../mxt/anitrend/util/ApplicationPref.java | 31 +++++++++ .../mxt/anitrend/util/SelectedFilterUtil.java | 68 +++++++++++++++++++ .../fragment/list/MediaBrowseFragment.java | 60 ++++++++++++++-- 4 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/mxt/anitrend/util/SelectedFilterUtil.java diff --git a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaTag.java b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaTag.java index 76dce83d1..6906d7b40 100644 --- a/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaTag.java +++ b/app/src/main/java/com/mxt/anitrend/model/entity/anilist/MediaTag.java @@ -106,4 +106,9 @@ public boolean isSelected() { public void setId(long id) { this.id = id; } + + @Override + public String toString() { + return name; + } } diff --git a/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java b/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java index 766ec1b89..7ac24f3d1 100644 --- a/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java +++ b/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java @@ -4,13 +4,16 @@ import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.annotation.IdRes; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StyleRes; import com.mxt.anitrend.BuildConfig; import com.mxt.anitrend.R; +import java.util.List; import java.util.Locale; +import java.util.Map; /** * Created by max on 2017/09/16. @@ -31,6 +34,8 @@ public class ApplicationPref { public static final String _updateChannel = "_updateChannel"; /** Api Keys */ + private static final String _genreFilter = "_genreFilter"; + private static final String _tagFilter = "_tagFilter"; private static final String _sortOrder = "_sortOrder"; private static final String _mediaStatus = "_mediaStatus"; private static final String _mediaFormat = "_mediaFormat"; @@ -300,4 +305,30 @@ public void setUpdated() { editor.putInt(_versionCode, BuildConfig.VERSION_CODE); editor.apply(); } + + public void setSelectedGenres(@Nullable Map selectedIndices) { + String selected = new SelectedFilterUtil() + .convertToDatabaseValue(selectedIndices); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(_genreFilter, selected); + editor.apply(); + } + + public @NonNull Map getSelectedGenres() { + String selected = sharedPreferences.getString(_genreFilter, null); + return new SelectedFilterUtil().convertToEntityProperty(selected); + } + + public void setSelectedTags(@Nullable Map selectedIndices) { + String selected = new SelectedFilterUtil() + .convertToDatabaseValue(selectedIndices); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(_tagFilter, selected); + editor.apply(); + } + + public @NonNull Map getSelectedTags() { + String selected = sharedPreferences.getString(_tagFilter, null); + return new SelectedFilterUtil().convertToEntityProperty(selected); + } } diff --git a/app/src/main/java/com/mxt/anitrend/util/SelectedFilterUtil.java b/app/src/main/java/com/mxt/anitrend/util/SelectedFilterUtil.java new file mode 100644 index 000000000..837f06c4c --- /dev/null +++ b/app/src/main/java/com/mxt/anitrend/util/SelectedFilterUtil.java @@ -0,0 +1,68 @@ +package com.mxt.anitrend.util; + +import android.support.annotation.NonNull; + +import com.annimon.stream.Stream; +import com.google.gson.reflect.TypeToken; +import com.mxt.anitrend.model.api.retro.WebFactory; +import com.mxt.anitrend.model.entity.anilist.Genre; +import com.mxt.anitrend.model.entity.anilist.MediaTag; + +import java.lang.reflect.Type; +import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; + +import javax.annotation.Nullable; + +import io.objectbox.converter.PropertyConverter; + +/** + * Created by max on 2018/09/01. + * Converter for genres and tags selection preference + */ + +public class SelectedFilterUtil implements PropertyConverter, String> { + + @Override + public @NonNull Map convertToEntityProperty(@Nullable String databaseValue) { + if(databaseValue == null) + return new WeakHashMap<>(); + Type targetType = new TypeToken>(){}.getType(); + return WebFactory.gson.fromJson(databaseValue, targetType); + } + + @Override + public @NonNull String convertToDatabaseValue(@Nullable Map entityProperty) { + if(entityProperty == null) + WebFactory.gson.toJson(new WeakHashMap<>()); + return WebFactory.gson.toJson(entityProperty); + } + + public static @Nullable Map createTagSelectionMap(@NonNull List mediaTags, @Nullable Integer[] selectedIndices) { + if (selectedIndices != null) { + Map tagMap = new WeakHashMap<>(); + for (Integer index: selectedIndices) + tagMap.put(index, mediaTags.get(index).getName()); + return tagMap; + } + return null; + } + + public static @Nullable Map createGenreSelectionMap(@NonNull List genres, @Nullable Integer[] selectedIndices) { + if (selectedIndices != null) { + Map genreMap = new WeakHashMap<>(); + for (Integer index: selectedIndices) + genreMap.put(index, genres.get(index).getGenre()); + return genreMap; + } + return null; + } + + public static @Nullable List getMappedValues(@Nullable Map selectedItems) { + if (selectedItems != null && selectedItems.size() > 0) + return Stream.of(selectedItems).map(Map.Entry::getValue) + .toList(); + return null; + } +} diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java index 987d15e3a..cba8c4e32 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java @@ -11,6 +11,7 @@ import com.afollestad.materialdialogs.DialogAction; import com.annimon.stream.IntPair; +import com.annimon.stream.Stream; import com.mxt.anitrend.R; import com.mxt.anitrend.adapter.recycler.index.MediaAdapter; import com.mxt.anitrend.base.custom.fragment.FragmentBaseList; @@ -28,11 +29,14 @@ import com.mxt.anitrend.util.MediaActionUtil; import com.mxt.anitrend.util.MediaBrowseUtil; import com.mxt.anitrend.util.NotifyUtil; +import com.mxt.anitrend.util.SelectedFilterUtil; import com.mxt.anitrend.view.activity.detail.MediaActivity; import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.Map; +import java.util.WeakHashMap; /** * Created by max on 2018/02/03. @@ -88,9 +92,9 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.findItem(R.id.action_type).setVisible(false); menu.findItem(R.id.action_year).setVisible(false); menu.findItem(R.id.action_status).setVisible(false); + menu.findItem(R.id.action_genre).setVisible(false); + menu.findItem(R.id.action_tag).setVisible(false); } - menu.findItem(R.id.action_genre).setVisible(false); - menu.findItem(R.id.action_tag).setVisible(false); } @Override @@ -118,15 +122,61 @@ public boolean onOptionsItemSelected(MenuItem item) { if(CompatUtil.isEmpty(genres)) { NotifyUtil.makeText(getContext(), R.string.app_splash_loading, R.drawable.ic_warning_white_18dp, Toast.LENGTH_SHORT).show(); getPresenter().checkGenresAndTags(getActivity()); + } else { + Map genresIndexMap = getPresenter() + .getApplicationPref().getSelectedGenres(); + + Integer[] selectedGenres = Stream.of(genresIndexMap) + .map(Map.Entry::getKey) + .toArray(Integer[]::new); + + DialogUtil.createCheckList(getContext(), R.string.app_filter_genres, genres, selectedGenres, + (dialog, which, text) -> false, (dialog, which) -> { + switch (which) { + case POSITIVE: + Map selectedIndices = SelectedFilterUtil + .createGenreSelectionMap(genres, dialog.getSelectedIndices()); + + getPresenter().getApplicationPref() + .setSelectedGenres(selectedIndices); + break; + case NEGATIVE: + getPresenter().getApplicationPref() + .setSelectedGenres(new WeakHashMap<>()); + break; + } + }); } - // pending implementation : - // https://github.com/AniTrend/anitrend-app/blob/aac381ad369d372bf03688c9fc8e6bb27c78c323/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBase.java return true; case R.id.action_tag: List tagList = getPresenter().getDatabase().getMediaTags(); if(CompatUtil.isEmpty(tagList)) { NotifyUtil.makeText(getContext(), R.string.app_splash_loading, R.drawable.ic_warning_white_18dp, Toast.LENGTH_SHORT).show(); getPresenter().checkGenresAndTags(getActivity()); + } else { + Map tagsIndexMap = getPresenter() + .getApplicationPref().getSelectedTags(); + + Integer[] selectedTags = Stream.of(tagsIndexMap) + .map(Map.Entry::getKey) + .toArray(Integer[]::new); + + DialogUtil.createCheckList(getContext(), R.string.app_filter_tags, tagList, selectedTags, + (dialog, which, text) -> false, (dialog, which) -> { + switch (which) { + case POSITIVE: + Map selectedIndices = SelectedFilterUtil + .createTagSelectionMap(tagList, dialog.getSelectedIndices()); + + getPresenter().getApplicationPref() + .setSelectedTags(selectedIndices); + break; + case NEGATIVE: + getPresenter().getApplicationPref() + .setSelectedTags(new WeakHashMap<>()); + break; + } + }); } return true; case R.id.action_type: @@ -177,6 +227,8 @@ public void makeRequest() { queryContainer.putVariable(KeyUtil.arg_seasonYear, getPresenter().getApplicationPref().getSeasonYear()); queryContainer.putVariable(KeyUtil.arg_status, pref.getMediaStatus()) + .putVariable(KeyUtil.arg_genres, SelectedFilterUtil.getMappedValues(pref.getSelectedGenres())) + .putVariable(KeyUtil.arg_tags, SelectedFilterUtil.getMappedValues(pref.getSelectedTags())) .putVariable(KeyUtil.arg_format, pref.getMediaFormat()); } queryContainer.putVariable(KeyUtil.arg_sort, pref.getMediaSort() + pref.getSortOrder()); From 41f27bc0eb18b6d8ac78c6a40630f3f32be11a24 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 1 Sep 2018 18:29:26 +0200 Subject: [PATCH 40/69] Updated Version Code --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9c762608f..c2879d67b 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { compileSdk = 28 targetSdk = 28 minSdk = 17 - versionCode = 87 + versionCode = 88 versionName = '1.2.0' butterKnife = '8.8.1' glide = '4.7.1' From 7910f29688dfa455ae50412eb4acb27fa94eadd6 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 1 Sep 2018 18:29:36 +0200 Subject: [PATCH 41/69] Updated Changelog --- app/src/main/assets/changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/assets/changelog.md b/app/src/main/assets/changelog.md index fed095b43..b6b6d7ece 100644 --- a/app/src/main/assets/changelog.md +++ b/app/src/main/assets/changelog.md @@ -5,12 +5,14 @@ - Take a moment to give us your [feedback](https://poll.ly/#/PEA4x1Wg), thank you. ### Enhancements +- New genre and tags filters - New amoled theme: __Settings -> General__ - New changeable application language: __Settings -> General__ - New personalised score types based on your profile settings - New start and end dates for your anime/manga lists - Media list status icons for media in your list - Additional support for trailers when a device doesn't have the YouTube app +- Many other minor enhancement and improvements ### Bug Fixes - Crash issue with Android Pie devices when viewing status feeds From e1ee16dddb7afa4a9613f9ac7f4d2134df0e982e Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 11:05:25 +0200 Subject: [PATCH 42/69] Updated Changelog --- app/src/main/assets/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/changelog.md b/app/src/main/assets/changelog.md index b6b6d7ece..c0d6f2bbd 100644 --- a/app/src/main/assets/changelog.md +++ b/app/src/main/assets/changelog.md @@ -10,7 +10,7 @@ - New changeable application language: __Settings -> General__ - New personalised score types based on your profile settings - New start and end dates for your anime/manga lists -- Media list status icons for media in your list +- Media list status icons for your list - Additional support for trailers when a device doesn't have the YouTube app - Many other minor enhancement and improvements From a0a24e8b0b9ede50a78e920f2fbcd844fd4d76f5 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 11:07:36 +0200 Subject: [PATCH 43/69] Disabled Tag Filter For Suggestions --- .../mxt/anitrend/view/fragment/list/SuggestionListFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/list/SuggestionListFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/list/SuggestionListFragment.java index 9ad82c6c6..dea47effb 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/list/SuggestionListFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/list/SuggestionListFragment.java @@ -17,7 +17,6 @@ * Created by max on 2017/11/04. * Suggestions adapter */ -// TODO: 2018/04/07 Hide genres from filter list public class SuggestionListFragment extends MediaBrowseFragment { public static SuggestionListFragment newInstance(Bundle params) { @@ -46,6 +45,7 @@ public void makeRequest() { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); menu.findItem(R.id.action_genre).setVisible(false); + menu.findItem(R.id.action_tag).setVisible(false); menu.findItem(R.id.action_type).setVisible(false); menu.findItem(R.id.action_year).setVisible(false); menu.findItem(R.id.action_status).setVisible(false); From 0ea211f6fdaf07977878f26807ad50f5db171247 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 11:07:58 +0200 Subject: [PATCH 44/69] Fixed TODOs --- .../mxt/anitrend/base/custom/view/editor/ComposerWidget.java | 1 - app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/ComposerWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/ComposerWidget.java index c8c35d50e..622cfb745 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/ComposerWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/editor/ComposerWidget.java @@ -167,7 +167,6 @@ public void onViewRecycled() { itemClickListener = null; } - // TODO: 2018/03/25 Check how parameters are being passed @SuppressLint("SwitchIntDef") public void startRequestData() { if (binding.widgetFlipper.getDisplayedChild() == WidgetPresenter.CONTENT_STATE) { diff --git a/app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java b/app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java index 9d4e08148..4cc26b0f6 100644 --- a/app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java @@ -64,7 +64,7 @@ public void draw(Canvas canvas) { } public void setDrawable(Drawable drawable) { - // TODO: 2018/04/28 Check image bounds and make sure the maximum widgth is not more than device screen width + // TODO: 2018/04/28 Check image bounds and make sure the maximum width is not more than device screen width this.drawable = drawable; int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); From ad32f19ef4bd4cce2d6a9f9d641a95ad9f9ce115 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 11:41:34 +0200 Subject: [PATCH 45/69] Preference Value Converter --- .../interfaces/base/PreferenceConverter.java | 17 ++++++++ .../mxt/anitrend/util/ApplicationPref.java | 13 +++---- ...ectedFilterUtil.java => GenreTagUtil.java} | 39 +++++++++---------- .../fragment/list/MediaBrowseFragment.java | 10 ++--- 4 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 app/src/main/java/com/mxt/anitrend/base/interfaces/base/PreferenceConverter.java rename app/src/main/java/com/mxt/anitrend/util/{SelectedFilterUtil.java => GenreTagUtil.java} (76%) diff --git a/app/src/main/java/com/mxt/anitrend/base/interfaces/base/PreferenceConverter.java b/app/src/main/java/com/mxt/anitrend/base/interfaces/base/PreferenceConverter.java new file mode 100644 index 000000000..65f5340b0 --- /dev/null +++ b/app/src/main/java/com/mxt/anitrend/base/interfaces/base/PreferenceConverter.java @@ -0,0 +1,17 @@ +package com.mxt.anitrend.base.interfaces.base; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +/** + * Created by max on 2018/09/01. + * Convert objects to json values and back. + */ +public interface PreferenceConverter { + + @NonNull + T convertToEntity(@Nullable String json); + + @NonNull + String convertToJson(@Nullable T entity); +} diff --git a/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java b/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java index 7ac24f3d1..520a849b2 100644 --- a/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java +++ b/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java @@ -11,7 +11,6 @@ import com.mxt.anitrend.BuildConfig; import com.mxt.anitrend.R; -import java.util.List; import java.util.Locale; import java.util.Map; @@ -307,8 +306,8 @@ public void setUpdated() { } public void setSelectedGenres(@Nullable Map selectedIndices) { - String selected = new SelectedFilterUtil() - .convertToDatabaseValue(selectedIndices); + String selected = new GenreTagUtil() + .convertToJson(selectedIndices); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(_genreFilter, selected); editor.apply(); @@ -316,12 +315,12 @@ public void setSelectedGenres(@Nullable Map selectedIndices) { public @NonNull Map getSelectedGenres() { String selected = sharedPreferences.getString(_genreFilter, null); - return new SelectedFilterUtil().convertToEntityProperty(selected); + return new GenreTagUtil().convertToEntity(selected); } public void setSelectedTags(@Nullable Map selectedIndices) { - String selected = new SelectedFilterUtil() - .convertToDatabaseValue(selectedIndices); + String selected = new GenreTagUtil() + .convertToJson(selectedIndices); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(_tagFilter, selected); editor.apply(); @@ -329,6 +328,6 @@ public void setSelectedTags(@Nullable Map selectedIndices) { public @NonNull Map getSelectedTags() { String selected = sharedPreferences.getString(_tagFilter, null); - return new SelectedFilterUtil().convertToEntityProperty(selected); + return new GenreTagUtil().convertToEntity(selected); } } diff --git a/app/src/main/java/com/mxt/anitrend/util/SelectedFilterUtil.java b/app/src/main/java/com/mxt/anitrend/util/GenreTagUtil.java similarity index 76% rename from app/src/main/java/com/mxt/anitrend/util/SelectedFilterUtil.java rename to app/src/main/java/com/mxt/anitrend/util/GenreTagUtil.java index 837f06c4c..2e410b71b 100644 --- a/app/src/main/java/com/mxt/anitrend/util/SelectedFilterUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/GenreTagUtil.java @@ -1,9 +1,12 @@ package com.mxt.anitrend.util; + import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.annimon.stream.Stream; import com.google.gson.reflect.TypeToken; +import com.mxt.anitrend.base.interfaces.base.PreferenceConverter; import com.mxt.anitrend.model.api.retro.WebFactory; import com.mxt.anitrend.model.entity.anilist.Genre; import com.mxt.anitrend.model.entity.anilist.MediaTag; @@ -13,31 +16,12 @@ import java.util.Map; import java.util.WeakHashMap; -import javax.annotation.Nullable; - -import io.objectbox.converter.PropertyConverter; - /** * Created by max on 2018/09/01. * Converter for genres and tags selection preference */ -public class SelectedFilterUtil implements PropertyConverter, String> { - - @Override - public @NonNull Map convertToEntityProperty(@Nullable String databaseValue) { - if(databaseValue == null) - return new WeakHashMap<>(); - Type targetType = new TypeToken>(){}.getType(); - return WebFactory.gson.fromJson(databaseValue, targetType); - } - - @Override - public @NonNull String convertToDatabaseValue(@Nullable Map entityProperty) { - if(entityProperty == null) - WebFactory.gson.toJson(new WeakHashMap<>()); - return WebFactory.gson.toJson(entityProperty); - } +public class GenreTagUtil implements PreferenceConverter> { public static @Nullable Map createTagSelectionMap(@NonNull List mediaTags, @Nullable Integer[] selectedIndices) { if (selectedIndices != null) { @@ -65,4 +49,19 @@ public class SelectedFilterUtil implements PropertyConverter convertToEntity(@Nullable String json) { + if(json == null) + return new WeakHashMap<>(); + Type targetType = new TypeToken>(){}.getType(); + return WebFactory.gson.fromJson(json, targetType); + } + + @Override + public @NonNull String convertToJson(@Nullable Map entity) { + if(entity == null) + WebFactory.gson.toJson(new WeakHashMap<>()); + return WebFactory.gson.toJson(entity); + } } diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java index cba8c4e32..0c14e79af 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java @@ -29,7 +29,7 @@ import com.mxt.anitrend.util.MediaActionUtil; import com.mxt.anitrend.util.MediaBrowseUtil; import com.mxt.anitrend.util.NotifyUtil; -import com.mxt.anitrend.util.SelectedFilterUtil; +import com.mxt.anitrend.util.GenreTagUtil; import com.mxt.anitrend.view.activity.detail.MediaActivity; import java.util.Collections; @@ -134,7 +134,7 @@ public boolean onOptionsItemSelected(MenuItem item) { (dialog, which, text) -> false, (dialog, which) -> { switch (which) { case POSITIVE: - Map selectedIndices = SelectedFilterUtil + Map selectedIndices = GenreTagUtil .createGenreSelectionMap(genres, dialog.getSelectedIndices()); getPresenter().getApplicationPref() @@ -165,7 +165,7 @@ public boolean onOptionsItemSelected(MenuItem item) { (dialog, which, text) -> false, (dialog, which) -> { switch (which) { case POSITIVE: - Map selectedIndices = SelectedFilterUtil + Map selectedIndices = GenreTagUtil .createTagSelectionMap(tagList, dialog.getSelectedIndices()); getPresenter().getApplicationPref() @@ -227,8 +227,8 @@ public void makeRequest() { queryContainer.putVariable(KeyUtil.arg_seasonYear, getPresenter().getApplicationPref().getSeasonYear()); queryContainer.putVariable(KeyUtil.arg_status, pref.getMediaStatus()) - .putVariable(KeyUtil.arg_genres, SelectedFilterUtil.getMappedValues(pref.getSelectedGenres())) - .putVariable(KeyUtil.arg_tags, SelectedFilterUtil.getMappedValues(pref.getSelectedTags())) + .putVariable(KeyUtil.arg_genres, GenreTagUtil.getMappedValues(pref.getSelectedGenres())) + .putVariable(KeyUtil.arg_tags, GenreTagUtil.getMappedValues(pref.getSelectedTags())) .putVariable(KeyUtil.arg_format, pref.getMediaFormat()); } queryContainer.putVariable(KeyUtil.arg_sort, pref.getMediaSort() + pref.getSortOrder()); From ec0402b29816b7b5c7e93c6d44409eed7d2ae9e3 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 13:07:30 +0200 Subject: [PATCH 46/69] Updated JobDispatcher Service - Added smart min sync time calculator - Reverted job param for need to reschedule when work is completed --- .../com/mxt/anitrend/service/JobDispatcherService.java | 2 +- .../java/com/mxt/anitrend/util/JobSchedulerUtil.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java b/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java index b428cc5ee..ea8609bbc 100644 --- a/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java +++ b/app/src/main/java/com/mxt/anitrend/service/JobDispatcherService.java @@ -73,7 +73,7 @@ public boolean onStopJob(JobParameters job) { public void onModelChanged(BaseConsumer consumer) { if(consumer.getRequestMode() == KeyUtil.USER_CURRENT_REQ && consumer.getChangeModel() != null) { NotificationUtil.createNotification(getApplicationContext(), consumer.getChangeModel().getUnreadNotificationCount()); - jobFinished(job, true); + jobFinished(job, false); } else jobFinished(job, true); } diff --git a/app/src/main/java/com/mxt/anitrend/util/JobSchedulerUtil.java b/app/src/main/java/com/mxt/anitrend/util/JobSchedulerUtil.java index 3e3e15aee..4dac73969 100644 --- a/app/src/main/java/com/mxt/anitrend/util/JobSchedulerUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/JobSchedulerUtil.java @@ -18,9 +18,15 @@ */ public final class JobSchedulerUtil { - private static final int MINIMUM_SYNC_TIME = 5 * 60; private static final String JOB_DISPATCHER = "anitrend_job_service_18602_0589"; + /** + * Gets the 45% of the current set sync time from preferences + */ + private static int getMinimumSyncTime(ApplicationPref applicationPref) { + return (int) (0.45 * applicationPref.getSyncTime()); + } + /** * Schedules a new job service or replaces the existing job if one * exists. @@ -41,7 +47,7 @@ public static void scheduleJob(Context context) { // The Job should be preserved until the next boot. .setLifetime(Lifetime.UNTIL_NEXT_BOOT) // start between 5 to e.g. XX minutes set in our sync preferences - .setTrigger(Trigger.executionWindow(MINIMUM_SYNC_TIME, applicationPref.getSyncTime())) + .setTrigger(Trigger.executionWindow(getMinimumSyncTime(applicationPref), applicationPref.getSyncTime())) // overwrite an existing job with the same tag .setReplaceCurrent(true) // retry with exponential backoff From 0e49d471831aac0f0022d1ce29325bb174653347 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 13:08:44 +0200 Subject: [PATCH 47/69] Renamed Amoled Preference Getter Name --- .../com/mxt/anitrend/base/custom/activity/ActivityBase.java | 2 +- app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java index fde8d8353..c548bbd15 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java @@ -92,7 +92,7 @@ public abstract class ActivityBase extends AppComp */ protected void configureActivity() { ApplicationPref applicationPref = new ApplicationPref(this); - if(!CompatUtil.isLightTheme((style = applicationPref.getTheme())) && applicationPref.isAmoledEnabled()) + if(!CompatUtil.isLightTheme((style = applicationPref.getTheme())) && applicationPref.isBlackThemeEnabled()) setTheme(R.style.AppThemeBlack); else setTheme(style); diff --git a/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java b/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java index 520a849b2..d48a61fba 100644 --- a/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java +++ b/app/src/main/java/com/mxt/anitrend/util/ApplicationPref.java @@ -79,8 +79,8 @@ public void toggleTheme() { return style; } - public boolean isAmoledEnabled() { - return sharedPreferences.getBoolean(context.getString(R.string.pref_key_amoled_theme), false); + public boolean isBlackThemeEnabled() { + return sharedPreferences.getBoolean(context.getString(R.string.pref_key_black_theme), false); } // Returns the IDs of the startup page From 2b4dbffcd23004c8a1363c9186e5a54de40b71bd Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 13:11:03 +0200 Subject: [PATCH 48/69] Added Preference Change Listener --- .../base/AppCompatPreferenceActivity.java | 6 ++-- .../view/activity/base/SettingsActivity.java | 34 +++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/AppCompatPreferenceActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/AppCompatPreferenceActivity.java index 7bd712dcc..1e3511d29 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/AppCompatPreferenceActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/AppCompatPreferenceActivity.java @@ -26,10 +26,11 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity { private AppCompatDelegate mDelegate; + protected ApplicationPref applicationPref; + protected void configureActivity() { - ApplicationPref applicationPref = new ApplicationPref(this); @StyleRes int style = applicationPref.getTheme(); - if(!CompatUtil.isLightTheme(style) && applicationPref.isAmoledEnabled()) + if(!CompatUtil.isLightTheme(style) && applicationPref.isBlackThemeEnabled()) setTheme(R.style.AppThemeBlack); else setTheme(style); @@ -54,6 +55,7 @@ protected void setNavigationStyle(int style) { protected void onCreate(Bundle savedInstanceState) { getDelegate().installViewFactory(); getDelegate().onCreate(savedInstanceState); + applicationPref = new ApplicationPref(this); configureActivity(); super.onCreate(savedInstanceState); } diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java index b8c7e9259..cbb20e562 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java @@ -4,6 +4,7 @@ import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.content.res.Configuration; import android.media.Ringtone; import android.media.RingtoneManager; @@ -20,9 +21,12 @@ import android.support.v7.app.ActionBar; import android.text.TextUtils; import android.view.MenuItem; +import android.widget.Toast; import com.mxt.anitrend.R; +import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.JobSchedulerUtil; +import com.mxt.anitrend.util.NotifyUtil; import java.util.List; @@ -39,6 +43,20 @@ */ public class SettingsActivity extends AppCompatPreferenceActivity { + private SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener = (sharedPreferences, key) -> { + if (CompatUtil.equals(key, getString(R.string.pref_key_crash_reports)) || CompatUtil.equals(key, getString(R.string.pref_key_usage_analytics)) || + CompatUtil.equals(key, getString(R.string.pref_key_selected_Language)) || CompatUtil.equals(key, getString(R.string.pref_key_black_theme))) { + // Change the application theme if the current theme is not in dark mode + if (CompatUtil.equals(key, getString(R.string.pref_key_black_theme))) + if(applicationPref != null && CompatUtil.isLightTheme(getApplicationContext())) + applicationPref.toggleTheme(); + NotifyUtil.makeText(getApplicationContext(), R.string.text_application_restart_required, Toast.LENGTH_LONG).show(); + } else if (CompatUtil.equals(key, getString(R.string.pref_key_sync_frequency))) { + JobSchedulerUtil.cancelJob(getApplicationContext()); + JobSchedulerUtil.scheduleJob(getApplicationContext()); + } + }; + /** * A preference value change listener that updates the preference's summary * to reflect its new value. @@ -289,8 +307,18 @@ public boolean onOptionsItemSelected(MenuItem item) { } @Override - protected void onDestroy() { - JobSchedulerUtil.scheduleJob(getApplicationContext()); - super.onDestroy(); + protected void onPostResume() { + super.onPostResume(); + if (applicationPref != null) + applicationPref.getSharedPreferences() + .registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener); + } + + @Override + protected void onPause() { + if (applicationPref != null) + applicationPref.getSharedPreferences() + .unregisterOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener); + super.onPause(); } } From 39a6fda74148cbb2be1ff6a161701ee58dc1a0fc Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 13:12:04 +0200 Subject: [PATCH 49/69] Fixed & Updated Translations - Removed invalid strings and added new strings --- app/src/main/res/values-ar/strings.xml | 22 ++++++++------ app/src/main/res/values-de/strings.xml | 22 ++++++++------ app/src/main/res/values-es/strings.xml | 22 ++++++++------ app/src/main/res/values-fr/strings.xml | 42 ++++++++++++++------------ app/src/main/res/values-it/strings.xml | 22 ++++++++------ app/src/main/res/values-pl/strings.xml | 16 +++++----- app/src/main/res/values/strings.xml | 24 +++++++++------ 7 files changed, 98 insertions(+), 72 deletions(-) diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index d5e994bf7..57da4ef74 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -926,22 +926,26 @@ Privacy Configure privacy settings - - Amoled Theme - Toggle Theme option will default to non amoled mode (requires restart) - Toggle Theme option will default to amoled mode (requires restart) + + _isBlackTheme + Black Theme + Use black theme for devices that LED displays to save power - Application Language + Application Language + Override system language and set your own application specific language Crash Reports - Don\'t allow crashes to be reported (requires restart) - Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) + Application will not send crash reports, please enable this option to make bug discovery and fixing easier + Application will automatically send crash reports Usage Analytics - Don\'t send any information about usage or bug identification (requires restart) - Allow information like most used activity and user id to be attached to bug reports (requires restart) + Application will not send any anonymous statistics on most used features, please consider enabling this option for better design choices in future + Application will only send anonymous statistics like most used features Start Date Finish Date + Customize + Customize application behavior + Please restart the application for changes to take effect diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 17dbda623..b4b1b0b8b 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -926,22 +926,26 @@ Privacy Configure privacy settings - - Amoled Theme - Toggle Theme option will default to non amoled mode (requires restart) - Toggle Theme option will default to amoled mode (requires restart) + + _isBlackTheme + Black Theme + Use black theme for devices that LED displays to save power - Application Language + Application Language + Override system language and set your own application specific language Crash Reports - Don\'t allow crashes to be reported (requires restart) - Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) + Application will not send crash reports, please enable this option to make bug discovery and fixing easier + Application will automatically send crash reports Usage Analytics - Don\'t send any information about usage or bug identification (requires restart) - Allow information like most used activity and user id to be attached to bug reports (requires restart) + Application will not send any anonymous statistics on most used features, please consider enabling this option for better design choices in future + Application will only send anonymous statistics like most used features Start Date Finish Date + Customize + Customize application behavior + Please restart the application for changes to take effect \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 58961941d..fe0951348 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -926,22 +926,26 @@ elementos de tus favoritos al presionar en el icono del corazón . Privacy Configure privacy settings - - Amoled Theme - Toggle Theme option will default to non amoled mode (requires restart) - Toggle Theme option will default to amoled mode (requires restart) + + _isBlackTheme + Black Theme + Use black theme for devices that LED displays to save power - Application Language + Application Language + Override system language and set your own application specific language Crash Reports - Don\'t allow crashes to be reported (requires restart) - Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) + Application will not send crash reports, please enable this option to make bug discovery and fixing easier + Application will automatically send crash reports Usage Analytics - Don\'t send any information about usage or bug identification (requires restart) - Allow information like most used activity and user id to be attached to bug reports (requires restart) + Application will not send any anonymous statistics on most used features, please consider enabling this option for better design choices in future + Application will only send anonymous statistics like most used features Start Date Finish Date + Customize + Customize application behavior + Please restart the application for changes to take effect diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index cfabd207d..749de6cde 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -166,10 +166,10 @@ Impossible de se connecter au serveur :( Glisser vers le bas pour réessayer ! L\'authentification a échoué. Glisser vers le bas pour réessayer ! - Authentification... - En attente de donnée supplémentaire... - Chargement du Profil... - Initialisation de l\'Application... + Authentification… + En attente de donnée supplémentaire… + Chargement du Profil… + Initialisation de l\'Application… Appuyez à nouveau sur "Retour" pour quitter l\'application - Application des Modifications... + Application des Modifications… Les Filtres ne sont pas applicables sur cette page ! @@ -530,9 +530,9 @@ Pas assez de genre pour le moment ! - Recherche dans vos données... + Recherche dans vos données… - Requête en Traitement... + Requête en Traitement… AniTrend n\'a pas reçu la permission ! Lire plus @@ -553,7 +553,7 @@ Annulé par l\'utilisateur ! - En Traitement... + En Traitement… Vous êtes déjà connecté ! @@ -575,7 +575,7 @@ Quelque chose a échoué en essayant de vous connecter ! Connexion complète mais annulée. - Émoticônes : Glisser sur le côté... + Émoticônes : Glisser sur le côté… Publier les Informations @@ -606,7 +606,7 @@ Quoi de Neuf ! Entrez du texte ici - Impossible de publier le texte... + Impossible de publier le texte… Editer la publication Modifier votre publication ! Créer une publication @@ -930,22 +930,26 @@ Privacy Configure privacy settings - - Amoled Theme - Toggle Theme option will default to non amoled mode (requires restart) - Toggle Theme option will default to amoled mode (requires restart) + + _isBlackTheme + Black Theme + Use black theme for devices that LED displays to save power - Application Language + Application Language + Override system language and set your own application specific language Crash Reports - Don\'t allow crashes to be reported (requires restart) - Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) + Application will not send crash reports, please enable this option to make bug discovery and fixing easier + Application will automatically send crash reports Usage Analytics - Don\'t send any information about usage or bug identification (requires restart) - Allow information like most used activity and user id to be attached to bug reports (requires restart) + Application will not send any anonymous statistics on most used features, please consider enabling this option for better design choices in future + Application will only send anonymous statistics like most used features Start Date Finish Date + Customize + Customize application behavior + Please restart the application for changes to take effect \ No newline at end of file diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 5806c7b69..2bffc43d1 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -925,22 +925,26 @@ Privacy Configure privacy settings - - Amoled Theme - Toggle Theme option will default to non amoled mode (requires restart) - Toggle Theme option will default to amoled mode (requires restart) + + _isBlackTheme + Black Theme + Use black theme for devices that LED displays to save power - Application Language + Application Language + Override system language and set your own application specific language Crash Reports - Don\'t allow crashes to be reported (requires restart) - Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) + Application will not send crash reports, please enable this option to make bug discovery and fixing easier + Application will automatically send crash reports Usage Analytics - Don\'t send any information about usage or bug identification (requires restart) - Allow information like most used activity and user id to be attached to bug reports (requires restart) + Application will not send any anonymous statistics on most used features, please consider enabling this option for better design choices in future + Application will only send anonymous statistics like most used features Start Date Finish Date + Customize + Customize application behavior + Please restart the application for changes to take effect diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index a0c308912..9cc59aaa1 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -470,7 +470,7 @@ Naciśnij ponownie, aby zamknąć aplikację - Stosowanie zmian ... + Stosowanie zmian… Filtry nie mają zastosowania na tej stronie @@ -756,7 +756,6 @@ propozycje najbardziej popularne - playlista @@ -929,13 +928,14 @@ Privacy Configure privacy settings - - Amoled Theme - Toggle Theme option will default to non amoled mode (requires restart) - Toggle Theme option will default to amoled mode (requires restart) + + _isBlackTheme + Black Theme + Use black theme for devices that LED displays to save power - Application Language + Application Language + Set application specific language Crash Reports Don\'t allow crashes to be reported (requires restart) @@ -947,4 +947,6 @@ Start Date Finish Date + Customize + Customize application behavior diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2f69bae95..147a6f273 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -957,21 +957,21 @@ Configure privacy settings Crash Reports - Don\'t allow crashes to be reported (requires restart) - Allow AniTrend to crashes to be reported, this will not include any sensitive information (requires restart) + Application will not send crash reports, please enable this option to make bug discovery and fixing easier + Application will automatically send crash reports Usage Analytics - Don\'t send any information about usage or bug identification (requires restart) - Allow information like most used activity and user id to be attached to bug reports (requires restart) + Application will not send any anonymous statistics on most used features, please consider enabling this option for better design choices in future + Application will only send anonymous statistics like most used features - - _isAmoledTheme - Amoled Theme - Toggle Theme option will default to non amoled mode (requires restart) - Toggle Theme option will default to amoled mode (requires restart) + + _isBlackTheme + Black Theme + Use black theme for devices that LED displays to save power - Application Language + Application Language + Override system language and set your own application specific language selected_language @@ -996,4 +996,8 @@ Start Date Finish Date + + Customize + Customize application behavior + Please restart the application for changes to take effect From 8827acdc2fea959e20c3219e358c699439a8c7c1 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 13:12:47 +0200 Subject: [PATCH 50/69] Moved Personalization Settings - Created new preference fragment for customization based settings --- .../view/activity/base/SettingsActivity.java | 30 +++++++++++++++++-- .../ic_format_color_fill_grey_600_24dp.xml | 5 ++++ app/src/main/res/xml/pref_customize.xml | 17 +++++++++++ app/src/main/res/xml/pref_general.xml | 16 ---------- app/src/main/res/xml/pref_headers.xml | 7 +++++ 5 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 app/src/main/res/drawable/ic_format_color_fill_grey_600_24dp.xml create mode 100644 app/src/main/res/xml/pref_customize.xml diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java index cbb20e562..023c1b272 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java @@ -187,12 +187,40 @@ public void onBuildHeaders(List

target) { */ protected boolean isValidFragment(String fragmentName) { return PreferenceFragment.class.getName().equals(fragmentName) + || CustomizePreferenceFragment.class.getName().equals(fragmentName) || GeneralPreferenceFragment.class.getName().equals(fragmentName) || DataSyncPreferenceFragment.class.getName().equals(fragmentName) || PrivacyPreferenceFragment.class.getName().equals(fragmentName) || NotificationPreferenceFragment.class.getName().equals(fragmentName); } + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public static class CustomizePreferenceFragment extends PreferenceFragment { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.pref_customize); + setHasOptionsMenu(true); + + // Bind the summaries of EditText/List/Dialog/Ringtone preferences + // to their values. When their values change, their summaries are + // updated to reflect the new value, per the Android Design + // guidelines. + // bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_key_amoled_theme))); + bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_key_selected_Language))); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == android.R.id.home) { + startActivity(new Intent(getActivity(), SettingsActivity.class)); + return true; + } + return super.onOptionsItemSelected(item); + } + } + @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static class GeneralPreferenceFragment extends PreferenceFragment { @Override @@ -207,8 +235,6 @@ public void onCreate(Bundle savedInstanceState) { // guidelines. bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_key_startup_page))); bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_key_update_channel))); - //bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_key_amoled_theme))); - bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_key_selected_Language))); } @Override diff --git a/app/src/main/res/drawable/ic_format_color_fill_grey_600_24dp.xml b/app/src/main/res/drawable/ic_format_color_fill_grey_600_24dp.xml new file mode 100644 index 000000000..7df78795a --- /dev/null +++ b/app/src/main/res/drawable/ic_format_color_fill_grey_600_24dp.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/xml/pref_customize.xml b/app/src/main/res/xml/pref_customize.xml new file mode 100644 index 000000000..8e70a7db7 --- /dev/null +++ b/app/src/main/res/xml/pref_customize.xml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 8fa4527ef..0f176efdc 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -16,20 +16,4 @@ android:key="@string/pref_key_update_channel" android:title="@string/pref_title_update_channel" /> - - - - - - \ No newline at end of file diff --git a/app/src/main/res/xml/pref_headers.xml b/app/src/main/res/xml/pref_headers.xml index 93bdc5d19..7b4589484 100644 --- a/app/src/main/res/xml/pref_headers.xml +++ b/app/src/main/res/xml/pref_headers.xml @@ -1,6 +1,13 @@ +
+
Date: Mon, 3 Sep 2018 13:30:47 +0200 Subject: [PATCH 51/69] Minor Settings Notification Fix --- .../com/mxt/anitrend/view/activity/base/SettingsActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java index 023c1b272..c42b08ed2 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java @@ -50,7 +50,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { if (CompatUtil.equals(key, getString(R.string.pref_key_black_theme))) if(applicationPref != null && CompatUtil.isLightTheme(getApplicationContext())) applicationPref.toggleTheme(); - NotifyUtil.makeText(getApplicationContext(), R.string.text_application_restart_required, Toast.LENGTH_LONG).show(); + Toast.makeText(getApplicationContext(), R.string.text_application_restart_required, Toast.LENGTH_LONG).show(); } else if (CompatUtil.equals(key, getString(R.string.pref_key_sync_frequency))) { JobSchedulerUtil.cancelJob(getApplicationContext()); JobSchedulerUtil.scheduleJob(getApplicationContext()); From 97c85aa5aebb400aef554075fe0222af07f420b4 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 13:38:25 +0200 Subject: [PATCH 52/69] Fixed Missing Media Image --- .../adapter/recycler/detail/NotificationAdapter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java index 02e2ba084..29a058f94 100644 --- a/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java +++ b/app/src/main/java/com/mxt/anitrend/adapter/recycler/detail/NotificationAdapter.java @@ -91,9 +91,10 @@ public void onBindViewHolder(Notification model) { binding.notificationTime.setText(DateUtil.getPrettyDateUnix(model.getCreatedAt())); - if(!CompatUtil.equals(model.getType(), KeyUtil.AIRING)) - if(model.getUser() != null && model.getUser().getAvatar() != null) + if(!CompatUtil.equals(model.getType(), KeyUtil.AIRING)) { + if (model.getUser() != null && model.getUser().getAvatar() != null) AspectImageView.setImage(binding.notificationImg, model.getUser().getAvatar().getLarge()); + } else AspectImageView.setImage(binding.notificationImg, model.getMedia().getCoverImage().getLarge()); From 2f3b7ed8be6d316e520e978b98984d4bcbe66c2a Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 13:39:05 +0200 Subject: [PATCH 53/69] Patched Analytics & Crash Analytics --- app/src/main/java/com/mxt/anitrend/App.java | 36 ++++++++++--------- .../com/mxt/anitrend/util/AnalyticsUtil.java | 18 ++++++---- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/App.java b/app/src/main/java/com/mxt/anitrend/App.java index a6c4144dc..586505263 100644 --- a/app/src/main/java/com/mxt/anitrend/App.java +++ b/app/src/main/java/com/mxt/anitrend/App.java @@ -3,6 +3,7 @@ import android.app.Application; import android.content.Context; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.crashlytics.android.core.CrashlyticsCore; import com.google.firebase.analytics.FirebaseAnalytics; @@ -23,9 +24,9 @@ public class App extends Application { - private FirebaseAnalytics analytics; + private @Nullable FirebaseAnalytics analytics; private BoxStore boxStore; - private Fabric fabric; + private @Nullable Fabric fabric; private void setupBoxStore() { boxStore = MyObjectBox.builder() @@ -36,15 +37,16 @@ private void setupBoxStore() { } private void setCrashAnalytics(ApplicationPref pref) { - CrashlyticsCore crashlyticsCore = new CrashlyticsCore.Builder() - .disabled(BuildConfig.DEBUG || !pref.isCrashReportsEnabled()) - .build(); - - fabric = Fabric.with(new Fabric.Builder(this) - .kits(crashlyticsCore) - .debuggable(BuildConfig.DEBUG) - .appIdentifier(BuildConfig.BUILD_TYPE) - .build()); + if (!BuildConfig.DEBUG) + if (pref.isCrashReportsEnabled()) { + CrashlyticsCore crashlyticsCore = new CrashlyticsCore.Builder() + .build(); + + fabric = Fabric.with(new Fabric.Builder(this) + .kits(crashlyticsCore) + .appIdentifier(BuildConfig.BUILD_TYPE) + .build()); + } } private void initApp(ApplicationPref pref) { @@ -53,9 +55,11 @@ private void initApp(ApplicationPref pref) { .sendSubscriberExceptionEvent(BuildConfig.DEBUG) .throwSubscriberException(BuildConfig.DEBUG) .installDefaultEventBus(); - analytics = FirebaseAnalytics.getInstance(this); - analytics.setAnalyticsCollectionEnabled(pref.isUsageAnalyticsEnabled()); - analytics.setMinimumSessionDuration(5000L); + if (pref.isUsageAnalyticsEnabled()) { + analytics = FirebaseAnalytics.getInstance(this); + analytics.setAnalyticsCollectionEnabled(pref.isUsageAnalyticsEnabled()); + analytics.setMinimumSessionDuration(5000L); + } } @Override @@ -88,7 +92,7 @@ protected void attachBaseContext(Context base) { * * @see com.mxt.anitrend.util.AnalyticsUtil */ - public @NonNull Fabric getFabric() { + public @Nullable Fabric getFabric() { return fabric; } @@ -97,7 +101,7 @@ protected void attachBaseContext(Context base) { * * @see com.mxt.anitrend.util.AnalyticsUtil */ - public @NonNull FirebaseAnalytics getAnalytics() { + public @Nullable FirebaseAnalytics getAnalytics() { return analytics; } } diff --git a/app/src/main/java/com/mxt/anitrend/util/AnalyticsUtil.java b/app/src/main/java/com/mxt/anitrend/util/AnalyticsUtil.java index 4ba883f90..370635114 100644 --- a/app/src/main/java/com/mxt/anitrend/util/AnalyticsUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/AnalyticsUtil.java @@ -1,6 +1,5 @@ package com.mxt.anitrend.util; -import android.content.Context; import android.support.annotation.NonNull; import android.support.v4.app.FragmentActivity; @@ -15,10 +14,12 @@ public final class AnalyticsUtil { public static void logCurrentScreen(FragmentActivity fragmentActivity, @NonNull String tag) { - if(fragmentActivity != null && new ApplicationPref(fragmentActivity).isUsageAnalyticsEnabled()) { + if(fragmentActivity != null) { App app = ((App) fragmentActivity.getApplicationContext()); - app.getAnalytics().setCurrentScreen(fragmentActivity, tag, null); - app.getFabric().setCurrentActivity(fragmentActivity); + if (app.getFabric() != null) + app.getFabric().setCurrentActivity(fragmentActivity); + if (app.getAnalytics() != null) + app.getAnalytics().setCurrentScreen(fragmentActivity, tag, null); } } @@ -30,8 +31,11 @@ public static void clearSession() { Crashlytics.setUserIdentifier(""); } - public static void setCrashAnalyticsUser(Context context, String userName) { - if(new ApplicationPref(context).isCrashReportsEnabled()) - Crashlytics.setUserIdentifier(userName); + public static void setCrashAnalyticsUser(FragmentActivity fragmentActivity, String userName) { + if(fragmentActivity != null) { + App app = ((App) fragmentActivity.getApplicationContext()); + if (app.getFabric() != null) + Crashlytics.setUserIdentifier(userName); + } } } From 645efedde8fa669940a2c8648fb71a37cd25ddbb Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 13:39:38 +0200 Subject: [PATCH 54/69] Conditional Checking For Crash Reporting --- .../com/mxt/anitrend/base/custom/activity/ActivityBase.java | 3 ++- .../com/mxt/anitrend/base/custom/fragment/FragmentBase.java | 3 ++- .../com/mxt/anitrend/view/activity/index/LoginActivity.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java index c548bbd15..0835fac9e 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java @@ -387,7 +387,8 @@ public void showError(String error) { if(!TextUtils.isEmpty(error)) Log.e(TAG, error); if(isAlive()) { - AnalyticsUtil.reportException(TAG, error); + if (getPresenter() != null && getPresenter().getApplicationPref().isCrashReportsEnabled()) + AnalyticsUtil.reportException(TAG, error); NotifyUtil.createAlerter(this, getString(R.string.text_error_request), error, R.drawable.ic_warning_white_18dp, R.color.colorStateOrange, KeyUtil.DURATION_MEDIUM); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBase.java index d3ba1d800..06d45da33 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/fragment/FragmentBase.java @@ -333,7 +333,8 @@ public void onDestroyActionMode(ActionMode mode) { public void showError(String error) { if(!TextUtils.isEmpty(error)) { Log.e(TAG, error); - AnalyticsUtil.reportException(TAG, error); + if (getPresenter() != null && getPresenter().getApplicationPref().isCrashReportsEnabled()) + AnalyticsUtil.reportException(TAG, error); } } diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java index ca482070a..0a4388f03 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/index/LoginActivity.java @@ -157,7 +157,8 @@ public void showError(String error) { if(error == null) error = getString(R.string.text_error_auth_login); NotifyUtil.createAlerter(this, getString(R.string.login_error_title), error, R.drawable.ic_warning_white_18dp, R.color.colorStateRed, KeyUtil.DURATION_LONG); - AnalyticsUtil.reportException(this.toString(), error); + if (getPresenter() != null && getPresenter().getApplicationPref().isCrashReportsEnabled()) + AnalyticsUtil.reportException(TAG, error); binding.widgetFlipper.showPrevious(); Log.e(this.toString(), error); } From a0f9769b0d1fd3b5926ae9b4cb4539f5b99a4815 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 3 Sep 2018 13:56:13 +0200 Subject: [PATCH 55/69] Fixed On Demand Notification Change --- .../mxt/anitrend/view/activity/base/SettingsActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java index c42b08ed2..5b4cc0c45 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java @@ -48,12 +48,17 @@ public class SettingsActivity extends AppCompatPreferenceActivity { CompatUtil.equals(key, getString(R.string.pref_key_selected_Language)) || CompatUtil.equals(key, getString(R.string.pref_key_black_theme))) { // Change the application theme if the current theme is not in dark mode if (CompatUtil.equals(key, getString(R.string.pref_key_black_theme))) - if(applicationPref != null && CompatUtil.isLightTheme(getApplicationContext())) + if(CompatUtil.isLightTheme(getApplicationContext())) applicationPref.toggleTheme(); Toast.makeText(getApplicationContext(), R.string.text_application_restart_required, Toast.LENGTH_LONG).show(); } else if (CompatUtil.equals(key, getString(R.string.pref_key_sync_frequency))) { JobSchedulerUtil.cancelJob(getApplicationContext()); JobSchedulerUtil.scheduleJob(getApplicationContext()); + } else if (CompatUtil.equals(key, getString(R.string.pref_key_new_message_notifications))) { + if (applicationPref.isNotificationEnabled()) + JobSchedulerUtil.scheduleJob(getApplicationContext()); + else + JobSchedulerUtil.cancelJob(getApplicationContext()); } }; From f2f9afabb6ec3e30aba9f019697361664ed667d3 Mon Sep 17 00:00:00 2001 From: Mehul Mittal Date: Wed, 5 Sep 2018 21:24:59 +0530 Subject: [PATCH 56/69] Added Clear Option in DatePickerDialog (#83) - Add clear option in DatePickerDialog - Make the Clear string a String resource - Send values of FuzzyDate as null instead of setting them - Stop using nulls as 0 works - Remove unused imports - Add Whitespace --- .../anitrend/base/custom/view/widget/FuzzyDateWidget.java | 8 ++++++++ .../main/java/com/mxt/anitrend/util/MediaListUtil.java | 6 +++--- app/src/main/res/values/strings.xml | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java index 3964f07dc..3dbce834c 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/FuzzyDateWidget.java @@ -3,6 +3,7 @@ import android.annotation.TargetApi; import android.app.DatePickerDialog; import android.content.Context; +import android.content.DialogInterface; import android.os.Build; import android.support.annotation.Nullable; import android.util.AttributeSet; @@ -10,6 +11,7 @@ import android.widget.DatePicker; import android.widget.FrameLayout; +import com.mxt.anitrend.R; import com.mxt.anitrend.base.interfaces.view.CustomView; import com.mxt.anitrend.databinding.WidgetFuzzyDateBinding; import com.mxt.anitrend.model.entity.anilist.meta.FuzzyDate; @@ -83,6 +85,12 @@ public void onClick(View v) { calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); } + datePickerDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getContext().getText(R.string.dialog_button_clear), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + onDateSet(datePickerDialog.getDatePicker(), 0, -1, 0); + } + }); datePickerDialog.show(); } diff --git a/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java b/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java index ce85bad5a..7e72c4b74 100644 --- a/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/MediaListUtil.java @@ -26,7 +26,7 @@ public static Bundle getMediaListParams(@NonNull MediaList model, @KeyUtil.Score QueryContainerBuilder queryContainer = GraphUtil.getDefaultQuery(false) .putVariable(KeyUtil.arg_scoreFormat, scoreFormat); - if(model.getId() > 0) + if (model.getId() > 0) queryContainer.putVariable(KeyUtil.arg_id, model.getId()); queryContainer.putVariable(KeyUtil.arg_mediaId, model.getMediaId()); queryContainer.putVariable(KeyUtil.arg_listStatus, model.getStatus()); @@ -38,10 +38,10 @@ public static Bundle getMediaListParams(@NonNull MediaList model, @KeyUtil.Score queryContainer.putVariable(KeyUtil.arg_startedAt, model.getStartedAt()); queryContainer.putVariable(KeyUtil.arg_completedAt, model.getCompletedAt()); - if(model.getAdvancedScores() != null) + if (model.getAdvancedScores() != null) queryContainer.putVariable(KeyUtil.arg_listAdvancedScore, model.getAdvancedScores()); - if(!CompatUtil.isEmpty(model.getCustomLists())) { + if (!CompatUtil.isEmpty(model.getCustomLists())) { List enabledCustomLists = Stream.of(model.getCustomLists()) .filter(CustomList::isEnabled) .map(CustomList::getName) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 147a6f273..62ccf45ad 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -996,6 +996,7 @@ Start Date Finish Date + Clear Customize Customize application behavior From b4ba73120caf62ad66647fc7cec1561a1979f683 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sat, 8 Sep 2018 17:52:13 +0200 Subject: [PATCH 57/69] Experimental Material Design 2 - Added some curved designs as material design 2 suggests --- .../com/mxt/anitrend/base/custom/sheet/BottomSheetBase.java | 5 +++-- .../anitrend/base/custom/view/container/CardViewBase.java | 2 +- app/src/main/res/drawable/material_curve.xml | 5 +++++ app/src/main/res/layout/activity_login.xml | 3 ++- app/src/main/res/layout/adapter_anime.xml | 2 +- app/src/main/res/layout/adapter_character.xml | 2 +- app/src/main/res/layout/adapter_series.xml | 2 +- app/src/main/res/layout/adapter_series_airing.xml | 2 +- app/src/main/res/layout/adapter_staff.xml | 2 +- 9 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 app/src/main/res/drawable/material_curve.xml diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetBase.java index 791d959af..9284720b7 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetBase.java @@ -11,6 +11,7 @@ import android.support.v7.widget.AppCompatImageView; import android.util.Log; import android.view.View; +import android.widget.FrameLayout; import com.miguelcatalan.materialsearchview.MaterialSearchView; import com.mxt.anitrend.R; @@ -79,7 +80,7 @@ public void onSlide(@NonNull View bottomSheet, float slideOffset) { } }; - + /** * Set up your custom bottom sheet and check for arguments if any */ @@ -157,7 +158,7 @@ protected void createBottomSheetBehavior(View contentView) { CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams(); CoordinatorLayout.Behavior coordinatorBehavior = layoutParams.getBehavior(); - if (coordinatorBehavior != null && coordinatorBehavior instanceof BottomSheetBehavior) { + if (coordinatorBehavior instanceof BottomSheetBehavior) { bottomSheetBehavior = (BottomSheetBehavior) coordinatorBehavior; bottomSheetBehavior.setPeekHeight(CompatUtil.dipToPx(KeyUtil.PEEK_HEIGHT)); bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback); diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/container/CardViewBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/container/CardViewBase.java index 4ef49a3bb..f1a1a99ef 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/container/CardViewBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/container/CardViewBase.java @@ -47,7 +47,7 @@ public void onInit() { } protected void applyStyle(int contentPadding) { - setRadius(getResources().getDimensionPixelSize(R.dimen.xs_margin)); + setRadius(getResources().getDimensionPixelSize(R.dimen.xl_margin)); setUseCompatPadding(true); setPreventCornerOverlap(false); setContentPadding(contentPadding, contentPadding, contentPadding, contentPadding); diff --git a/app/src/main/res/drawable/material_curve.xml b/app/src/main/res/drawable/material_curve.xml new file mode 100644 index 000000000..451459e48 --- /dev/null +++ b/app/src/main/res/drawable/material_curve.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 3cb8886b7..289588ee1 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -23,7 +23,7 @@ android:orientation="vertical" android:layout_gravity="center" android:elevation="@dimen/md_margin" - android:background="?colorPrimary"> + android:background="@drawable/material_curve"> Date: Wed, 12 Sep 2018 19:41:16 +0200 Subject: [PATCH 58/69] Updated Dependencies - Firebase 16.0.1 -> 16.0.3 - Constraint Layout 1.1.2 -> 1.1.3 --- app/build.gradle | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ded6a162e..7bd8de9e1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -86,7 +86,7 @@ dependencies { implementation "android.arch.lifecycle:extensions:${rootProject.architecture}" /** Android Support Libraries */ - implementation 'com.android.support.constraint:constraint-layout:1.1.2' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation "com.android.support:appcompat-v7:${rootProject.supportLibrary}" implementation "com.android.support:support-v4:${rootProject.supportLibrary}" implementation "com.android.support:design:${rootProject.supportLibrary}" diff --git a/build.gradle b/build.gradle index c2879d67b..d1d9b7577 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { glide = '4.7.1' retrofit = '2.4.0' supportLibrary = '27.1.1' - firebase = '16.0.1' + firebase = '16.0.3' objectBox = '2.0.0' architecture = '1.1.1' emojify = '0.1.7' From 43d0044f71e69757b33783e1e321521b8232192a Mon Sep 17 00:00:00 2001 From: Maxwell Date: Wed, 12 Sep 2018 22:12:36 +0200 Subject: [PATCH 59/69] Reduced Eager Loading For Glide --- .../java/com/mxt/anitrend/base/custom/glide/GlideAppModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/glide/GlideAppModule.java b/app/src/main/java/com/mxt/anitrend/base/custom/glide/GlideAppModule.java index e7efc2316..699ca5069 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/glide/GlideAppModule.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/glide/GlideAppModule.java @@ -39,7 +39,7 @@ public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder boolean isLowRamDevice = CompatUtil.isLowRamDevice(context); MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context) - .setMemoryCacheScreens(isLowRamDevice? 2 : 3).build(); + .setMemoryCacheScreens(isLowRamDevice? 1 : 2).build(); // Increasing cache & pool by 25% - default is 250MB int memoryCacheSize = (int) (1.25 * calculator.getMemoryCacheSize()); From 3565374bbaddb61cba5824f37e77405cc85f9039 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Wed, 12 Sep 2018 22:12:52 +0200 Subject: [PATCH 60/69] Material Curve Fixes --- .../res/drawable/material_curve_black.xml | 5 +++ app/src/main/res/layout/adapter_anime.xml | 2 +- app/src/main/res/layout/adapter_character.xml | 2 +- app/src/main/res/layout/adapter_manga.xml | 2 +- .../main/res/layout/adapter_media_header.xml | 18 +++++--- .../main/res/layout/adapter_notification.xml | 34 ++++++--------- app/src/main/res/layout/adapter_series.xml | 2 +- .../main/res/layout/adapter_series_airing.xml | 2 +- app/src/main/res/layout/adapter_staff.xml | 2 +- .../layout/fragment_character_overview.xml | 36 +++++++++------- .../res/layout/fragment_series_overview.xml | 37 +++------------- .../res/layout/fragment_staff_overview.xml | 18 +++++--- .../res/layout/section_series_description.xml | 43 ++++++++++++++++++- .../res/layout/section_series_details.xml | 11 ++++- .../main/res/layout/section_series_info.xml | 42 +++++++----------- .../res/layout/widget_auto_incrementer.xml | 8 ++-- app/src/main/res/values-v21/style.xml | 4 +- 17 files changed, 147 insertions(+), 121 deletions(-) create mode 100644 app/src/main/res/drawable/material_curve_black.xml diff --git a/app/src/main/res/drawable/material_curve_black.xml b/app/src/main/res/drawable/material_curve_black.xml new file mode 100644 index 000000000..f6efc3da6 --- /dev/null +++ b/app/src/main/res/drawable/material_curve_black.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/adapter_anime.xml b/app/src/main/res/layout/adapter_anime.xml index 4f6ee43da..b3e505778 100644 --- a/app/src/main/res/layout/adapter_anime.xml +++ b/app/src/main/res/layout/adapter_anime.xml @@ -18,7 +18,7 @@ app:cardPreventCornerOverlap="false" app:cardBackgroundColor="?cardColor" app:cardElevation="@dimen/sm_margin" - app:cardCornerRadius="@dimen/lg_margin" + app:cardCornerRadius="@dimen/xl_margin" tools:layout_width="@dimen/series_image_lg"> - + app:cardPreventCornerOverlap="false" + app:cardBackgroundColor="?cardColor" + app:cardElevation="@dimen/sm_margin" + app:cardCornerRadius="@dimen/lg_margin"> @@ -34,8 +38,8 @@ android:layout_height="wrap_content" /> @@ -82,6 +86,6 @@ - + diff --git a/app/src/main/res/layout/adapter_notification.xml b/app/src/main/res/layout/adapter_notification.xml index 1fe0bd121..4de95f927 100644 --- a/app/src/main/res/layout/adapter_notification.xml +++ b/app/src/main/res/layout/adapter_notification.xml @@ -3,10 +3,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> - - - - + android:layout_height="wrap_content" + android:orientation="horizontal"> + + @@ -80,7 +75,7 @@ @@ -88,7 +83,4 @@ - - - \ No newline at end of file diff --git a/app/src/main/res/layout/adapter_series.xml b/app/src/main/res/layout/adapter_series.xml index 6f6e1ae3f..5393aa308 100644 --- a/app/src/main/res/layout/adapter_series.xml +++ b/app/src/main/res/layout/adapter_series.xml @@ -18,7 +18,7 @@ app:cardPreventCornerOverlap="false" app:cardBackgroundColor="?cardColor" app:cardElevation="@dimen/sm_margin" - app:cardCornerRadius="@dimen/lg_margin" + app:cardCornerRadius="@dimen/xl_margin" tools:layout_width="@dimen/series_image_lg"> - + - - @@ -93,14 +97,14 @@ - + - + - + diff --git a/app/src/main/res/layout/fragment_series_overview.xml b/app/src/main/res/layout/fragment_series_overview.xml index f684d8db4..4bff11ee0 100644 --- a/app/src/main/res/layout/fragment_series_overview.xml +++ b/app/src/main/res/layout/fragment_series_overview.xml @@ -25,27 +25,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - - - - - - - + - + - - - - - + - + app:cardPreventCornerOverlap="false" + app:cardBackgroundColor="?cardColor" + app:cardElevation="@dimen/sm_margin" + app:cardCornerRadius="@dimen/xl_margin"> - - @@ -95,7 +99,7 @@ - + - + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/section_series_details.xml b/app/src/main/res/layout/section_series_details.xml index c163f6893..5355474a4 100644 --- a/app/src/main/res/layout/section_series_details.xml +++ b/app/src/main/res/layout/section_series_details.xml @@ -8,7 +8,14 @@ - + + @@ -317,4 +324,6 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/section_series_info.xml b/app/src/main/res/layout/section_series_info.xml index 96fdd24c7..3a3805e84 100644 --- a/app/src/main/res/layout/section_series_info.xml +++ b/app/src/main/res/layout/section_series_info.xml @@ -8,7 +8,19 @@ - + + @@ -23,11 +35,9 @@ app:imageUrl="@{model.coverImage}" tools:src="@drawable/sample_img"/> - @@ -83,30 +93,10 @@ android:layout_width="wrap_content" android:layout_height="@dimen/md_margin" /> - - - - - - + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_auto_incrementer.xml b/app/src/main/res/layout/widget_auto_incrementer.xml index 23d1f7345..f7476ecdd 100644 --- a/app/src/main/res/layout/widget_auto_incrementer.xml +++ b/app/src/main/res/layout/widget_auto_incrementer.xml @@ -11,19 +11,21 @@ android:id="@+id/widget_flipper" android:clickable="true" android:focusable="true" + android:layout_margin="@dimen/md_margin" android:inAnimation="@android:anim/slide_in_left" android:outAnimation="@android:anim/slide_out_right" android:foreground="?selectableItemBackground" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClickListener="@{onClickEvent}" - android:background="@color/black_transparent_image"> + android:background="@drawable/material_curve_black"> diff --git a/app/src/main/res/values-v21/style.xml b/app/src/main/res/values-v21/style.xml index 2e452e732..2985e1769 100644 --- a/app/src/main/res/values-v21/style.xml +++ b/app/src/main/res/values-v21/style.xml @@ -31,8 +31,8 @@ true - @color/colorRootDark - @color/colorRootDark + @color/colorLineDark + @color/colorLineDark @style/PopupThemeLight From 0b358bd1933b07b6d44fb977c709538a72d598a0 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 13 Sep 2018 11:33:43 +0200 Subject: [PATCH 61/69] Removed Unused Classes & Methods --- .../decorator/GridItemDividerDecoration.java | 54 ------------- .../data/converter/FuzzyDateConverter.java | 28 ------- .../data/converter/ListConverter.java | 33 -------- .../data/converter/MediaBaseConverter.java | 28 ------- .../com/mxt/anitrend/util/GlideImageUtil.java | 77 ------------------- .../com/mxt/anitrend/util/HtmlTagUtil.java | 26 ------- .../com/mxt/anitrend/util/MarkDownUtil.java | 9 --- 7 files changed, 255 deletions(-) delete mode 100644 app/src/main/java/com/mxt/anitrend/base/custom/recycler/decorator/GridItemDividerDecoration.java delete mode 100644 app/src/main/java/com/mxt/anitrend/data/converter/FuzzyDateConverter.java delete mode 100644 app/src/main/java/com/mxt/anitrend/data/converter/ListConverter.java delete mode 100644 app/src/main/java/com/mxt/anitrend/data/converter/MediaBaseConverter.java delete mode 100644 app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java delete mode 100644 app/src/main/java/com/mxt/anitrend/util/HtmlTagUtil.java diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/recycler/decorator/GridItemDividerDecoration.java b/app/src/main/java/com/mxt/anitrend/base/custom/recycler/decorator/GridItemDividerDecoration.java deleted file mode 100644 index f7a0af758..000000000 --- a/app/src/main/java/com/mxt/anitrend/base/custom/recycler/decorator/GridItemDividerDecoration.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.mxt.anitrend.base.custom.recycler.decorator; - -import android.graphics.Canvas; -import android.graphics.Paint; -import android.support.annotation.ColorInt; -import android.support.annotation.Dimension; -import android.support.v7.widget.RecyclerView; -import android.view.View; - -import com.mxt.anitrend.base.custom.recycler.RecyclerViewHolder; - -/** - * Created by max on 2017/12/10. - * A {@link RecyclerView.ItemDecoration} which draws dividers (along the right & bottom) - * for {@link RecyclerView.ViewHolder}s which implement {@link RecyclerViewHolder}. - * credits @plaid - */ - -public class GridItemDividerDecoration extends RecyclerView.ItemDecoration { - - private final int dividerSize; - private final Paint paint; - - public GridItemDividerDecoration(@Dimension int dividerSize, @ColorInt int dividerColor) { - this.dividerSize = dividerSize; - paint = new Paint(); - paint.setColor(dividerColor); - paint.setStyle(Paint.Style.FILL); - } - - @Override - public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { - if (parent.isAnimating()) return; - - final int childCount = parent.getChildCount(); - final RecyclerView.LayoutManager lm = parent.getLayoutManager(); - for (int i = 0; i < childCount; i++) { - final View child = parent.getChildAt(i); - RecyclerView.ViewHolder viewHolder = parent.getChildViewHolder(child); - - if (viewHolder instanceof RecyclerViewHolder) { - final int right = lm.getDecoratedRight(child); - final int bottom = lm.getDecoratedBottom(child); - // draw the bottom divider - canvas.drawRect(lm.getDecoratedLeft(child), bottom - dividerSize, - right, bottom, paint); - // draw the right edge divider - canvas.drawRect(right - dividerSize, lm.getDecoratedTop(child), - right, bottom - dividerSize, paint); - } - } - } - -} diff --git a/app/src/main/java/com/mxt/anitrend/data/converter/FuzzyDateConverter.java b/app/src/main/java/com/mxt/anitrend/data/converter/FuzzyDateConverter.java deleted file mode 100644 index 90dbdb2a0..000000000 --- a/app/src/main/java/com/mxt/anitrend/data/converter/FuzzyDateConverter.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mxt.anitrend.data.converter; - -import com.mxt.anitrend.model.api.retro.WebFactory; -import com.mxt.anitrend.model.entity.anilist.meta.FuzzyDate; - -import io.objectbox.converter.PropertyConverter; - -/** - * Created by max on 2018/03/21. - * Fuzzy Date converter - */ - -public class FuzzyDateConverter implements PropertyConverter { - - @Override - public FuzzyDate convertToEntityProperty(String databaseValue) { - if(databaseValue == null) - return null; - return WebFactory.gson.fromJson(databaseValue, FuzzyDate.class); - } - - @Override - public String convertToDatabaseValue(FuzzyDate entityProperty) { - if(entityProperty == null) - return null; - return WebFactory.gson.toJson(entityProperty); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/mxt/anitrend/data/converter/ListConverter.java b/app/src/main/java/com/mxt/anitrend/data/converter/ListConverter.java deleted file mode 100644 index 463425ed4..000000000 --- a/app/src/main/java/com/mxt/anitrend/data/converter/ListConverter.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.mxt.anitrend.data.converter; - -import com.google.gson.reflect.TypeToken; -import com.mxt.anitrend.model.api.retro.WebFactory; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; - -import io.objectbox.converter.PropertyConverter; - -/** - * Created by max on 2017/11/04. - * Entity Converter - */ - -public class ListConverter implements PropertyConverter, String> { - - @Override - public synchronized List convertToEntityProperty(String databaseValue) { - if(databaseValue == null) - return new ArrayList<>(); - Type targetType = new TypeToken>(){}.getType(); - return WebFactory.gson.fromJson(databaseValue, targetType); - } - - @Override - public synchronized String convertToDatabaseValue(List entityProperty) { - if(entityProperty == null) - return null; - return WebFactory.gson.toJson(entityProperty); - } -} diff --git a/app/src/main/java/com/mxt/anitrend/data/converter/MediaBaseConverter.java b/app/src/main/java/com/mxt/anitrend/data/converter/MediaBaseConverter.java deleted file mode 100644 index 3dfcd686f..000000000 --- a/app/src/main/java/com/mxt/anitrend/data/converter/MediaBaseConverter.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mxt.anitrend.data.converter; - -import com.mxt.anitrend.model.api.retro.WebFactory; -import com.mxt.anitrend.model.entity.base.MediaBase; - -import io.objectbox.converter.PropertyConverter; - -/** - * Created by max on 2017/11/04. - * Media small entity converter - */ - -public class MediaBaseConverter implements PropertyConverter { - - @Override - public MediaBase convertToEntityProperty(String databaseValue) { - if(databaseValue == null) - return null; - return WebFactory.gson.fromJson(databaseValue, MediaBase.class); - } - - @Override - public String convertToDatabaseValue(MediaBase entityProperty) { - if(entityProperty == null) - return null; - return WebFactory.gson.toJson(entityProperty); - } -} diff --git a/app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java b/app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java deleted file mode 100644 index 4cc26b0f6..000000000 --- a/app/src/main/java/com/mxt/anitrend/util/GlideImageUtil.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.mxt.anitrend.util; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.widget.AppCompatTextView; -import android.text.Html; - -import com.bumptech.glide.Glide; -import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions; -import com.bumptech.glide.request.RequestOptions; -import com.bumptech.glide.request.target.SimpleTarget; -import com.bumptech.glide.request.transition.Transition; -import com.mxt.anitrend.R; - -/** - * Created by max - * Uses glide to load images into an AppCompatTextView - */ -public class GlideImageUtil implements Html.ImageGetter { - - private Context context; - private AppCompatTextView appCompatTextView; - - public static GlideImageUtil create(Context context, AppCompatTextView appCompatTextView) { - return new GlideImageUtil(context, appCompatTextView); - } - - private GlideImageUtil(Context context, AppCompatTextView appCompatTextView) { - this.context = context; - this.appCompatTextView = appCompatTextView; - } - - @Override - public Drawable getDrawable(String source) { - final DrawablePlaceHolder drawablePlaceHolder = new DrawablePlaceHolder(); - Glide.with(context).load(source).apply(RequestOptions.centerCropTransform()) - .transition(DrawableTransitionOptions.withCrossFade(150)) - .into(new SimpleTarget() { - @Override - public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) { - drawablePlaceHolder.setDrawable(resource); - } - }); - return drawablePlaceHolder; - } - - @SuppressWarnings("deprecation") - private class DrawablePlaceHolder extends BitmapDrawable { - - protected Drawable drawable; - - public DrawablePlaceHolder() { - setDrawable(CompatUtil.getDrawable(context, R.drawable.empty_icon)); - } - - @Override - public void draw(Canvas canvas) { - if (drawable != null) - drawable.draw(canvas); - } - - public void setDrawable(Drawable drawable) { - // TODO: 2018/04/28 Check image bounds and make sure the maximum width is not more than device screen width - this.drawable = drawable; - int width = drawable.getIntrinsicWidth(); - int height = drawable.getIntrinsicHeight(); - drawable.setBounds(0, 0, width, height); - setBounds(0, 0, width, height); - if (appCompatTextView != null) - appCompatTextView.setText(appCompatTextView.getText()); - } - } -} diff --git a/app/src/main/java/com/mxt/anitrend/util/HtmlTagUtil.java b/app/src/main/java/com/mxt/anitrend/util/HtmlTagUtil.java deleted file mode 100644 index 2ed7e98ea..000000000 --- a/app/src/main/java/com/mxt/anitrend/util/HtmlTagUtil.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mxt.anitrend.util; - -import android.text.Editable; -import android.text.Html; - -import org.xml.sax.XMLReader; - -/** - * created by max - * Helps us handle custom tags which may not be supported - */ -public class HtmlTagUtil implements Html.TagHandler { - - public static HtmlTagUtil create() { - return new HtmlTagUtil(); - } - - private HtmlTagUtil() { - - } - - @Override - public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) { - - } -} diff --git a/app/src/main/java/com/mxt/anitrend/util/MarkDownUtil.java b/app/src/main/java/com/mxt/anitrend/util/MarkDownUtil.java index 3dc978dda..1ba9165b5 100644 --- a/app/src/main/java/com/mxt/anitrend/util/MarkDownUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/MarkDownUtil.java @@ -49,15 +49,6 @@ public static Spanned convert(@Nullable String input) { return result; } -/* private static SpannableStringBuilder fromMD(@NonNull String content, Context context, AppCompatTextView source) { - Spanned htmlConverted; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) - htmlConverted = Html.fromHtml(Processor.process(content), Html.FROM_HTML_MODE_LEGACY, GlideImageUtil.create(context, source), HtmlTagUtil.create()); - else - htmlConverted = Html.fromHtml(Processor.process(content), GlideImageUtil.create(context, source), HtmlTagUtil.create()); - return (SpannableStringBuilder) htmlConverted; - }*/ - public static Spanned convert(@Nullable String input, Context context, AppCompatTextView source) { SpannableStringBuilder result; if(TextUtils.isEmpty(input)) From a1716556fc36f45993d1c58e51bdace2275c038b Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 13 Sep 2018 11:35:20 +0200 Subject: [PATCH 62/69] Optimised Unused Imports --- .../com/mxt/anitrend/base/custom/sheet/BottomSheetBase.java | 1 - .../anitrend/base/custom/view/widget/AutoIncrementWidget.java | 3 --- .../com/mxt/anitrend/view/activity/base/SettingsActivity.java | 1 - .../mxt/anitrend/view/fragment/list/MediaBrowseFragment.java | 2 +- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetBase.java index 9284720b7..be153724f 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/sheet/BottomSheetBase.java @@ -11,7 +11,6 @@ import android.support.v7.widget.AppCompatImageView; import android.util.Log; import android.view.View; -import android.widget.FrameLayout; import com.miguelcatalan.materialsearchview.MaterialSearchView; import com.mxt.anitrend.R; diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java index d8e1f8063..b0d296348 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/view/widget/AutoIncrementWidget.java @@ -17,7 +17,6 @@ import com.mxt.anitrend.base.interfaces.view.CustomView; import com.mxt.anitrend.databinding.WidgetAutoIncrementerBinding; import com.mxt.anitrend.model.entity.anilist.MediaList; -import com.mxt.anitrend.model.entity.anilist.meta.FuzzyDate; import com.mxt.anitrend.presenter.widget.WidgetPresenter; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.DateUtil; @@ -27,8 +26,6 @@ import com.mxt.anitrend.util.MediaUtil; import com.mxt.anitrend.util.NotifyUtil; -import java.util.Calendar; - import retrofit2.Call; import retrofit2.Response; diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java index 5b4cc0c45..ab941ad17 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/base/SettingsActivity.java @@ -26,7 +26,6 @@ import com.mxt.anitrend.R; import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.JobSchedulerUtil; -import com.mxt.anitrend.util.NotifyUtil; import java.util.List; diff --git a/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java b/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java index 0c14e79af..45370ce91 100644 --- a/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java +++ b/app/src/main/java/com/mxt/anitrend/view/fragment/list/MediaBrowseFragment.java @@ -25,11 +25,11 @@ import com.mxt.anitrend.util.CompatUtil; import com.mxt.anitrend.util.DateUtil; import com.mxt.anitrend.util.DialogUtil; +import com.mxt.anitrend.util.GenreTagUtil; import com.mxt.anitrend.util.KeyUtil; import com.mxt.anitrend.util.MediaActionUtil; import com.mxt.anitrend.util.MediaBrowseUtil; import com.mxt.anitrend.util.NotifyUtil; -import com.mxt.anitrend.util.GenreTagUtil; import com.mxt.anitrend.view.activity.detail.MediaActivity; import java.util.Collections; From 9ad2b595c88119f9f031ed81a38fba2070a1f839 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 13 Sep 2018 11:36:13 +0200 Subject: [PATCH 63/69] API Rate Limit Message Handling - Human readable API rate limit exception display message for users --- .../java/com/mxt/anitrend/util/ErrorUtil.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/util/ErrorUtil.java b/app/src/main/java/com/mxt/anitrend/util/ErrorUtil.java index b2cd8a369..3646b317c 100644 --- a/app/src/main/java/com/mxt/anitrend/util/ErrorUtil.java +++ b/app/src/main/java/com/mxt/anitrend/util/ErrorUtil.java @@ -13,6 +13,7 @@ import java.lang.reflect.Type; import java.util.List; +import okhttp3.Headers; import okhttp3.ResponseBody; import retrofit2.Response; @@ -23,7 +24,12 @@ public class ErrorUtil { + private static final int HTTP_LIMIT_REACHED = 429; + private static final String TAG = "ErrorUtil"; + private static final String Retry_After = "Retry-After"; + private static final String RateLimit_Limit = "X-RateLimit-Limit"; + private static final String RateLimit_Remaining = "X-RateLimit-Remaining"; /** * Converts the response error response into an object. @@ -34,11 +40,18 @@ public class ErrorUtil { public static @NonNull String getError(@Nullable Response response) { try { if(response != null) { + Headers headers = response.headers(); ResponseBody responseBody = response.errorBody(); String message, error; - if (responseBody != null && !TextUtils.isEmpty(message = responseBody.string())) - if(!TextUtils.isEmpty(error = getGraphQLError(message))) - return error; + if (response.code() != HTTP_LIMIT_REACHED) { + if (responseBody != null && !TextUtils.isEmpty(message = responseBody.string())) + if (!TextUtils.isEmpty(error = getGraphQLError(message))) + return error; + } else { + error = String.format("%s of %s requests remaining, please retry after %s seconds", + headers.get(RateLimit_Remaining), headers.get(RateLimit_Limit), headers.get(Retry_After)); + return error; + } } } catch (Exception ex) { ex.printStackTrace(); From 710d74b5860188d1e1c39ef4e0d6145991e716b5 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 13 Sep 2018 11:36:35 +0200 Subject: [PATCH 64/69] Updated Translation Strings --- app/src/main/res/values-ar/strings.xml | 2 +- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-fr/strings.xml | 2 +- app/src/main/res/values-it/strings.xml | 2 +- app/src/main/res/values-pl/strings.xml | 3 ++- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 57da4ef74..618f4963f 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -927,7 +927,6 @@ Configure privacy settings - _isBlackTheme Black Theme Use black theme for devices that LED displays to save power @@ -948,4 +947,5 @@ Customize Customize application behavior Please restart the application for changes to take effect + Clear diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index b4b1b0b8b..5b2b1b5b3 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -927,7 +927,6 @@ Configure privacy settings - _isBlackTheme Black Theme Use black theme for devices that LED displays to save power @@ -948,4 +947,5 @@ Customize Customize application behavior Please restart the application for changes to take effect + Clear \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index fe0951348..dbba89169 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -927,7 +927,6 @@ elementos de tus favoritos al presionar en el icono del corazón . Configure privacy settings - _isBlackTheme Black Theme Use black theme for devices that LED displays to save power @@ -948,4 +947,5 @@ elementos de tus favoritos al presionar en el icono del corazón . Customize Customize application behavior Please restart the application for changes to take effect + Clear diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 749de6cde..5d8f90e6a 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -931,7 +931,6 @@ Configure privacy settings - _isBlackTheme Black Theme Use black theme for devices that LED displays to save power @@ -952,4 +951,5 @@ Customize Customize application behavior Please restart the application for changes to take effect + Clear \ No newline at end of file diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 2bffc43d1..0c5c22d04 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -926,7 +926,6 @@ Configure privacy settings - _isBlackTheme Black Theme Use black theme for devices that LED displays to save power @@ -947,4 +946,5 @@ Customize Customize application behavior Please restart the application for changes to take effect + Clear diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 9cc59aaa1..33aabb23a 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -929,7 +929,6 @@ Configure privacy settings - _isBlackTheme Black Theme Use black theme for devices that LED displays to save power @@ -949,4 +948,6 @@ Finish Date Customize Customize application behavior + Please restart the application for changes to take effect + Clear From 4cbe00f308359909ac51117ce613e0d43959f79f Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 13 Sep 2018 11:37:15 +0200 Subject: [PATCH 65/69] Revert Firebase Dependency Version - Updating to v16.0.3 causes the application to require multi-dex --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d1d9b7577..c2879d67b 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { glide = '4.7.1' retrofit = '2.4.0' supportLibrary = '27.1.1' - firebase = '16.0.3' + firebase = '16.0.1' objectBox = '2.0.0' architecture = '1.1.1' emojify = '0.1.7' From 735118123bf983d8152281a3ccaed72bccbfdbe2 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 13 Sep 2018 13:38:09 +0200 Subject: [PATCH 66/69] Permission Grant Callback - Added Permission grant method --- .../base/custom/activity/ActivityBase.java | 15 +++++++++++---- .../view/activity/index/MainActivity.java | 12 ++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java b/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java index 0835fac9e..d7050dfcb 100644 --- a/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java +++ b/app/src/main/java/com/mxt/anitrend/base/custom/activity/ActivityBase.java @@ -252,16 +252,23 @@ protected boolean isAlive() { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode == REQUEST_PERMISSION) { for (int i = 0; i < permissions.length; i++) { - if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { - NotifyUtil.makeText(this, R.string.completed_success, Toast.LENGTH_SHORT).show(); - Log.i(TAG, "Granted " + permissions[i]); - } + if (grantResults[i] == PackageManager.PERMISSION_GRANTED) + onPermissionGranted(permissions[i]); else NotifyUtil.makeText(this, R.string.text_permission_required, R.drawable.ic_warning_white_18dp, Toast.LENGTH_SHORT).show(); } } } + /** + * Called for each of the requested permissions as they are granted + * + * @param permission the current permission granted + */ + protected void onPermissionGranted(@NonNull String permission) { + Log.i(TAG, "Granted " + permission); + } + /** * Dispatch onPause() to fragments. */ diff --git a/app/src/main/java/com/mxt/anitrend/view/activity/index/MainActivity.java b/app/src/main/java/com/mxt/anitrend/view/activity/index/MainActivity.java index 3a537c2cc..5b2df402c 100644 --- a/app/src/main/java/com/mxt/anitrend/view/activity/index/MainActivity.java +++ b/app/src/main/java/com/mxt/anitrend/view/activity/index/MainActivity.java @@ -382,6 +382,18 @@ public void onNegativeButton() { } } + /** + * Called for each of the requested permissions as they are granted + * + * @param permission the current permission granted + */ + @Override + protected void onPermissionGranted(@NonNull String permission) { + super.onPermissionGranted(permission); + if (permission.equals(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) + onNavigate(R.id.nav_check_update); + } + @Override protected void updateUI() { VersionBase versionBase = getPresenter().getDatabase().getRemoteVersion(); From 2366e66549b8b5fe52f8980e55a44c97392ea2f2 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 13 Sep 2018 13:43:03 +0200 Subject: [PATCH 67/69] Updated Version Code --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c2879d67b..ecd8f11bf 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { compileSdk = 28 targetSdk = 28 minSdk = 17 - versionCode = 88 + versionCode = 90 versionName = '1.2.0' butterKnife = '8.8.1' glide = '4.7.1' From e8ec6d189f732407d0682d446e3a53560a92cc13 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 13 Sep 2018 13:44:06 +0200 Subject: [PATCH 68/69] Updated Release Information --- app/.meta/version.json | 4 ++-- app/release/output.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/.meta/version.json b/app/.meta/version.json index a0bc0f489..144b81319 100644 --- a/app/.meta/version.json +++ b/app/.meta/version.json @@ -1,7 +1,7 @@ { - "code": 85, + "code": 90, "migration": false, "releaseNotes": "", - "version": "1.1.2", + "version": "1.2.0", "appId": "com.mxt.anitrend" } diff --git a/app/release/output.json b/app/release/output.json index 832fd8236..dd2119e79 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":87,"versionName":"1.2.0","enabled":true,"outputFile":"anitrend_v1.2.0_rc_87.apk","fullName":"release","baseName":"release"},"path":"anitrend_v1.2.0_rc_87.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":90,"versionName":"1.2.0","enabled":true,"outputFile":"anitrend_v1.2.0_rc_90.apk","fullName":"release","baseName":"release"},"path":"anitrend_v1.2.0_rc_90.apk","properties":{}}] \ No newline at end of file From 28aafca1afd695f94002626f718118154f59f95f Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 13 Sep 2018 13:50:08 +0200 Subject: [PATCH 69/69] Updated README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ad291dbc5..32a6ee44a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ Big shout out to all the testers, translators and donators on the [AniTrend Disc - Find all issues, feature requests, bugs and project road map [here](https://waffle.io/AniTrend/anitrend-app) +## Documentation + +Development documentation for AniTrend is still a work in progress so for the time bieng on the essentials are available and can be found over at: __[anitrend.gitbook.io](https://anitrend.gitbook.io/project/)__ + # Screenshots ### Dual Application Themes