aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java24
-rw-r--r--app/src/main/res/layout/fragment_view_reddit_gallery_image_or_gif.xml2
6 files changed, 34 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
index 13f40f63..636e4615 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
@@ -59,6 +59,7 @@ public abstract class BaseActivity extends AppCompatActivity {
private int systemVisibilityToolbarExpanded = 0;
private int systemVisibilityToolbarCollapsed = 0;
private CustomThemeWrapper customThemeWrapper;
+ private int appliedTheme;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -98,15 +99,18 @@ public abstract class BaseActivity extends AppCompatActivity {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
getTheme().applyStyle(R.style.Theme_Normal, true);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.LIGHT);
+ setAppliedTheme(R.style.Theme_Normal);
break;
case 1:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED);
+ setAppliedTheme(R.style.Theme_Normal_AmoledDark);
} else {
getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK);
+ setAppliedTheme(R.style.Theme_Normal_NormalDark);
}
break;
case 2:
@@ -117,14 +121,17 @@ public abstract class BaseActivity extends AppCompatActivity {
}
if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
getTheme().applyStyle(R.style.Theme_Normal, true);
+ setAppliedTheme(R.style.Theme_Normal);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.LIGHT);
} else {
if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.AMOLED);
+ setAppliedTheme(R.style.Theme_Normal_AmoledDark);
} else {
getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.DARK);
+ setAppliedTheme(R.style.Theme_Normal_NormalDark);
}
}
}
@@ -227,6 +234,8 @@ public abstract class BaseActivity extends AppCompatActivity {
return systemVisibilityToolbarCollapsed;
}
+ public int getAppliedTheme() { return appliedTheme; }
+
public boolean isImmersiveInterface() {
return immersiveInterface;
}
@@ -297,6 +306,8 @@ public abstract class BaseActivity extends AppCompatActivity {
isImmersiveInterfaceApplicable = false;
}
+ public void setAppliedTheme(int appliedStyle) { this.appliedTheme = appliedStyle; }
+
protected void applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(AppBarLayout appBarLayout, @Nullable CollapsingToolbarLayout collapsingToolbarLayout, Toolbar toolbar) {
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar, true);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
index 8b477c34..3c016a2c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
@@ -48,6 +48,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
public static final String EXTRA_REDDIT_GALLERY = "ERG";
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
+ public static final String EXTRA_APPLIED_THEME = "EAS";
@BindView(R.id.hauler_view_view_reddit_gallery_activity)
HaulerView haulerView;
@@ -69,7 +70,8 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
((Infinity) getApplication()).getAppComponent().inject(this);
- getTheme().applyStyle(R.style.Theme_Normal, true);
+ int theme = getIntent().getIntExtra(EXTRA_APPLIED_THEME, R.style.Theme_Normal);
+ getTheme().applyStyle(theme <= 0 ? R.style.Theme_Normal : theme, true);
getTheme().applyStyle(FontStyle.valueOf(sharedPreferences
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index 9857e421..dba26de7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -87,6 +87,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.VoteThing;
+import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
@@ -2268,6 +2269,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, mPost.getGallery());
intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName());
+ intent.putExtra(ViewRedditGalleryActivity.EXTRA_APPLIED_THEME, ((BaseActivity)mActivity).getAppliedTheme());
mActivity.startActivity(intent);
}
}
@@ -2378,6 +2380,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, mPost.getGallery());
intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName());
+ intent.putExtra(ViewRedditGalleryActivity.EXTRA_APPLIED_THEME, ((BaseActivity)mActivity).getAppliedTheme());
mActivity.startActivity(intent);
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 2c23649e..bc9931a7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -72,8 +72,10 @@ import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.VoteThing;
+import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
+import ml.docilealligator.infinityforreddit.activities.SearchResultActivity;
import ml.docilealligator.infinityforreddit.activities.ViewImageOrGifActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity;
@@ -1970,6 +1972,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, post.getGallery());
intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, post.getSubredditName());
+ intent.putExtra(ViewRedditGalleryActivity.EXTRA_APPLIED_THEME, ((BaseActivity)mActivity).getAppliedTheme());
mActivity.startActivity(intent);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
index 97ae2a7c..9c652a51 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
@@ -4,12 +4,14 @@ import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -52,6 +54,7 @@ import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
+import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.BuildConfig;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
@@ -268,17 +271,18 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
}
if(!captionUrlIsEmpty)
{
- captionUrlTextView.setOnLongClickListener(view -> {
- UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
- Bundle bundle = new Bundle();
- bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, captionUrl);
- urlMenuBottomSheetFragment.setArguments(bundle);
- urlMenuBottomSheetFragment.show(activity.getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag());
- return true;
- });
-
- captionUrlTextView.setVisibility(View.VISIBLE);
captionUrlTextView.setText(captionUrl);
+ if (!activity.isDestroyed() && !activity.isFinishing()) {
+ BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, captionUrlTextView).setOnLinkLongClickListener((textView, url) -> {
+ UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
+ urlMenuBottomSheetFragment.setArguments(bundle);
+ urlMenuBottomSheetFragment.show(activity.getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag());
+ return true;
+ });
+ }
+ captionUrlTextView.setVisibility(View.VISIBLE);
}
}
diff --git a/app/src/main/res/layout/fragment_view_reddit_gallery_image_or_gif.xml b/app/src/main/res/layout/fragment_view_reddit_gallery_image_or_gif.xml
index 986b86c6..23fc50b0 100644
--- a/app/src/main/res/layout/fragment_view_reddit_gallery_image_or_gif.xml
+++ b/app/src/main/res/layout/fragment_view_reddit_gallery_image_or_gif.xml
@@ -77,11 +77,9 @@
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
- android:autoLink="web"
android:ellipsize="end"
android:fontFamily="?attr/content_font_family"
android:gravity="center_vertical"
- android:nestedScrollingEnabled="false"
android:textColor="#FFFFFF"
android:textColorLink="#FFFFFF"
android:textSize="?attr/content_font_default"