mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Fix bottom url menu not being themed accordingly
Use linkify for in-gallery caption url
This commit is contained in:
parent
91c457bfe3
commit
17df9d41ca
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user