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]);
}
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());
}
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);
}
}
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);
}
}
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);
}
Aggregations