Search in sources :

Example 16 with ColorPreferences

use of me.ccrama.redditslide.Visuals.ColorPreferences in project Slide by ccrama.

the class SortingUtil method createSortingSpannableStrings.

private static Spannable[] createSortingSpannableStrings(String[] sortingStrings, int sortingId, String sub) {
    ArrayList<Spannable> spannables = new ArrayList<>();
    for (int i = 0; i < sortingStrings.length; i++) {
        SpannableString spanString = new SpannableString(sortingStrings[i]);
        if (i == sortingId) {
            spanString.setSpan(new ForegroundColorSpan(new ColorPreferences(Reddit.getAppContext()).getColor(sub)), 0, spanString.length(), 0);
            spanString.setSpan(new StyleSpan(Typeface.BOLD), 0, spanString.length(), 0);
        }
        spannables.add(spanString);
    }
    return spannables.toArray(new Spannable[0]);
}
Also used : SpannableString(android.text.SpannableString) ForegroundColorSpan(android.text.style.ForegroundColorSpan) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) StyleSpan(android.text.style.StyleSpan) ArrayList(java.util.ArrayList) Spannable(android.text.Spannable)

Example 17 with ColorPreferences

use of me.ccrama.redditslide.Visuals.ColorPreferences in project Slide by ccrama.

the class CommentPage method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = this.getArguments();
    subreddit = bundle.getString("subreddit", "");
    fullname = bundle.getString("id", "");
    page = bundle.getInt("page", 0);
    single = bundle.getBoolean("single", false);
    context = bundle.getString("context", "");
    contextNumber = bundle.getInt("contextNumber", 5);
    np = bundle.getBoolean("np", false);
    archived = bundle.getBoolean("archived", false);
    locked = bundle.getBoolean("locked", false);
    contest = bundle.getBoolean("contest", false);
    loadMore = (!context.isEmpty() && !context.equals(Reddit.EMPTY_STRING));
    if (!single)
        loadMore = false;
    int subredditStyle = new ColorPreferences(getActivity()).getThemeSubreddit(subreddit);
    contextThemeWrapper = new ContextThemeWrapper(getActivity(), subredditStyle);
    mLayoutManager = new PreCachingLayoutManagerComments(getActivity());
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) Bundle(android.os.Bundle) PreCachingLayoutManagerComments(me.ccrama.redditslide.Views.PreCachingLayoutManagerComments) TextPaint(android.text.TextPaint)

Example 18 with ColorPreferences

use of me.ccrama.redditslide.Visuals.ColorPreferences in project Slide by ccrama.

the class Album method onCreate.

public void onCreate(Bundle savedInstanceState) {
    overrideSwipeFromAnywhere();
    super.onCreate(savedInstanceState);
    getTheme().applyStyle(new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE), true);
    setContentView(R.layout.album);
    // Keep the screen on
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    if (getIntent().hasExtra(SUBREDDIT)) {
        this.subreddit = getIntent().getExtras().getString(SUBREDDIT);
    }
    if (getIntent().hasExtra(EXTRA_SUBMISSION_TITLE)) {
        this.submissionTitle = getIntent().getExtras().getString(EXTRA_SUBMISSION_TITLE);
    }
    final ViewPager pager = (ViewPager) findViewById(R.id.images);
    album = new AlbumPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(album);
    pager.setCurrentItem(1);
    pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (position == 0 && positionOffsetPixels == 0) {
                finish();
            }
            if (position == 0 && ((AlbumPagerAdapter) pager.getAdapter()).blankPage != null) {
                if (((AlbumPagerAdapter) pager.getAdapter()).blankPage != null) {
                    ((AlbumPagerAdapter) pager.getAdapter()).blankPage.doOffset(positionOffset);
                }
                ((AlbumPagerAdapter) pager.getAdapter()).blankPage.realBack.setBackgroundColor(Palette.adjustAlpha(positionOffset * 0.7f));
            }
        }
    });
    if (!Reddit.appRestart.contains("tutorialSwipe")) {
        startActivityForResult(new Intent(this, SwipeTutorial.class), 3);
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Intent(android.content.Intent) ViewPager(androidx.viewpager.widget.ViewPager)

Example 19 with ColorPreferences

use of me.ccrama.redditslide.Visuals.ColorPreferences in project Slide by ccrama.

the class AlbumPager method onCreate.

public void onCreate(Bundle savedInstanceState) {
    overrideSwipeFromAnywhere();
    super.onCreate(savedInstanceState);
    getTheme().applyStyle(new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE), true);
    setContentView(R.layout.album_pager);
    // Keep the screen on
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    if (getIntent().hasExtra(SUBREDDIT)) {
        this.subreddit = getIntent().getStringExtra(SUBREDDIT);
    }
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle(R.string.type_album);
    ToolbarColorizeHelper.colorizeToolbar(mToolbar, Color.WHITE, this);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mToolbar.setPopupTheme(new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE));
    adapterPosition = getIntent().getIntExtra(MediaView.ADAPTER_POSITION, -1);
    String url = getIntent().getExtras().getString("url", "");
    setShareUrl(url);
    pagerLoad = new LoadIntoPager(url, this);
    pagerLoad.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    if (!Reddit.appRestart.contains("tutorialSwipe")) {
        startActivityForResult(new Intent(this, SwipeTutorial.class), 3);
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Intent(android.content.Intent)

Example 20 with ColorPreferences

use of me.ccrama.redditslide.Visuals.ColorPreferences in project Slide by ccrama.

the class BaseActivity method applyDarkColorTheme.

/**
 * Applies the activity's base color theme based on the theme of a specific subreddit. Should be
 * called before inflating any layouts.
 * <p/>
 * This will take the accent colors from the sub theme but return the AMOLED with contrast base
 * theme.
 *
 * @param subreddit The subreddit to base the theme on
 */
protected void applyDarkColorTheme(String subreddit) {
    getTheme().applyStyle(new FontPreferences(this).getPostFontStyle().getResId(), true);
    getTheme().applyStyle(new ColorPreferences(this).getDarkThemeSubreddit(subreddit), true);
    getTheme().applyStyle(new FontPreferences(this).getCommentFontStyle().getResId(), true);
}
Also used : FontPreferences(me.ccrama.redditslide.Visuals.FontPreferences) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences)

Aggregations

ColorPreferences (me.ccrama.redditslide.Visuals.ColorPreferences)55 View (android.view.View)25 TextView (android.widget.TextView)21 Intent (android.content.Intent)18 AlertDialog (androidx.appcompat.app.AlertDialog)15 ArrayList (java.util.ArrayList)15 SpoilerRobotoTextView (me.ccrama.redditslide.SpoilerRobotoTextView)13 Context (android.content.Context)12 LayoutInflater (android.view.LayoutInflater)12 ContextThemeWrapper (androidx.appcompat.view.ContextThemeWrapper)12 RecyclerView (androidx.recyclerview.widget.RecyclerView)11 SubmissionsView (me.ccrama.redditslide.Fragments.SubmissionsView)11 ImageView (android.widget.ImageView)10 HorizontalScrollView (android.widget.HorizontalScrollView)9 ViewPager (androidx.viewpager.widget.ViewPager)9 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)9 Snackbar (com.google.android.material.snackbar.Snackbar)8 LinearInterpolator (android.view.animation.LinearInterpolator)7 Dialog (android.app.Dialog)6 AutoCompleteTextView (android.widget.AutoCompleteTextView)6