Search in sources :

Example 1 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 2 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 3 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)

Example 4 with ColorPreferences

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);
}
Also used : FontPreferences(me.ccrama.redditslide.Visuals.FontPreferences) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences)

Example 5 with ColorPreferences

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);
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) DownloadListener(android.webkit.DownloadListener) CookieSyncManager(android.webkit.CookieSyncManager) WebSettings(android.webkit.WebSettings) Intent(android.content.Intent) CookieManager(android.webkit.CookieManager)

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