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);
}
use of me.ccrama.redditslide.Visuals.ColorPreferences in project Slide by ccrama.
the class BaseActivity method applyColorTheme.
/**
* Applies the activity's base color theme based on the theme of a specific subreddit. Should be
* called before inflating any layouts.
*
* @param subreddit The subreddit to base the theme on
*/
protected void applyColorTheme(String subreddit) {
getTheme().applyStyle(new FontPreferences(this).getPostFontStyle().getResId(), true);
getTheme().applyStyle(new ColorPreferences(this).getThemeSubreddit(subreddit), true);
getTheme().applyStyle(new FontPreferences(this).getCommentFontStyle().getResId(), true);
}
use of me.ccrama.redditslide.Visuals.ColorPreferences in project Slide by ccrama.
the class Website method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
overrideSwipeFromAnywhere();
super.onCreate(savedInstanceState);
applyColorTheme("");
setContentView(R.layout.activity_web);
url = getIntent().getExtras().getString(LinkUtil.EXTRA_URL, "");
subredditColor = getIntent().getExtras().getInt(LinkUtil.EXTRA_COLOR, Palette.getDefaultColor());
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
setupAppBar(R.id.toolbar, "", true, subredditColor, R.id.appbar);
mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
p = (ProgressBar) findViewById(R.id.progress);
v = (WebView) findViewById(R.id.web);
client = new MyWebViewClient();
webClient = new AdBlockWebViewClient();
if (!SettingValues.cookies) {
final CookieManager cookieManager = CookieManager.getInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.removeAllCookies(null);
cookieManager.flush();
} else {
final CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(this);
cookieSyncMngr.startSync();
cookieManager.removeAllCookie();
cookieManager.removeSessionCookie();
cookieSyncMngr.stopSync();
cookieSyncMngr.sync();
}
cookieManager.setAcceptCookie(false);
WebSettings ws = v.getSettings();
ws.setSaveFormData(false);
ws.setSavePassword(false);
}
/* todo in the future, drag left and right to go back and forward in history
IOverScrollDecor decor = new HorizontalOverScrollBounceEffectDecorator(new WebViewOverScrollDecoratorAdapter(v));
decor.setOverScrollStateListener(new IOverScrollStateListener() {
@Override
public void onOverScrollStateChange(IOverScrollDecor decor, int oldState, int newState) {
switch (newState) {
case IOverScrollState.STATE_IDLE:
// No over-scroll is in effect.
break;
case IOverScrollState.STATE_DRAG_START_SIDE:
break;
case IOverScrollState.STATE_DRAG_END_SIDE:
break;
case IOverScrollState.STATE_BOUNCE_BACK:
if (oldState == IOverScrollState.STATE_DRAG_START_SIDE) {
if(v.canGoBack())
v.goBack();
} else { // i.e. (oldState == STATE_DRAG_END_SIDE)
if(v.canGoForward())
v.goForward();
}
break;
}
}
});
*/
v.setWebChromeClient(client);
v.setWebViewClient(webClient);
v.getSettings().setBuiltInZoomControls(true);
v.getSettings().setDisplayZoomControls(false);
v.getSettings().setJavaScriptEnabled(true);
v.getSettings().setLoadWithOverviewMode(true);
v.getSettings().setUseWideViewPort(true);
v.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
// Downloads using download manager on default browser
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
v.loadUrl(url);
}
Aggregations