Search in sources :

Example 6 with ColorPreferences

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

the class RedditGalleryPager 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);
    }
    if (getIntent().hasExtra(EXTRA_SUBMISSION_TITLE)) {
        this.submissionTitle = getIntent().getExtras().getString(EXTRA_SUBMISSION_TITLE);
    }
    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);
    if (!Reddit.appRestart.contains("tutorialSwipe")) {
        startActivityForResult(new Intent(this, SwipeTutorial.class), 3);
    }
    findViewById(R.id.progress).setVisibility(View.GONE);
    images = (ArrayList<GalleryImage>) getIntent().getSerializableExtra(RedditGallery.GALLERY_URLS);
    p = (ViewPager) findViewById(R.id.images_horizontal);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setSubtitle(1 + "/" + images.size());
    }
    GalleryViewPagerAdapter adapter = new GalleryViewPagerAdapter(getSupportFragmentManager());
    p.setAdapter(adapter);
    p.setCurrentItem(1);
    findViewById(R.id.grid).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            LayoutInflater l = getLayoutInflater();
            View body = l.inflate(R.layout.album_grid_dialog, null, false);
            GridView gridview = body.findViewById(R.id.images);
            gridview.setAdapter(new ImageGridAdapter(RedditGalleryPager.this, true, images));
            final AlertDialog.Builder builder = new AlertDialog.Builder(RedditGalleryPager.this).setView(body);
            final Dialog d = builder.create();
            gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                    p.setCurrentItem(position + 1);
                    d.dismiss();
                }
            });
            d.show();
        }
    });
    p.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (position != 0) {
                if (getSupportActionBar() != null) {
                    getSupportActionBar().setSubtitle((position) + "/" + images.size());
                }
            }
            if (position == 0 && positionOffset < 0.2) {
                finish();
            }
        }
    });
    adapter.notifyDataSetChanged();
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) ImageGridAdapter(me.ccrama.redditslide.Adapters.ImageGridAdapter) Intent(android.content.Intent) GridView(android.widget.GridView) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) View(android.view.View) AdapterView(android.widget.AdapterView) ViewPager(androidx.viewpager.widget.ViewPager) AlertDialog(androidx.appcompat.app.AlertDialog) Dialog(android.app.Dialog) LayoutInflater(android.view.LayoutInflater) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView)

Example 7 with ColorPreferences

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

the class Related method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    overrideSwipeFromAnywhere();
    super.onCreate(savedInstanceState);
    applyColorTheme("");
    setContentView(R.layout.activity_search);
    Intent intent = getIntent();
    if (intent.hasExtra(Intent.EXTRA_TEXT) && !intent.getExtras().getString(Intent.EXTRA_TEXT, "").isEmpty()) {
        url = intent.getStringExtra(Intent.EXTRA_TEXT);
    }
    if (intent.hasExtra(EXTRA_URL)) {
        url = intent.getStringExtra(EXTRA_URL);
    }
    if (url == null || url.isEmpty()) {
        new AlertDialog.Builder(this).setTitle("URL is empty").setMessage("Try again with a different link!").setCancelable(false).setPositiveButton(R.string.btn_ok, (dialogInterface, i) -> finish()).show();
    }
    setupAppBar(R.id.toolbar, "Related links", true, true);
    // it won't be, trust me
    assert mToolbar != null;
    mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
    final RecyclerView rv = ((RecyclerView) findViewById(R.id.vertical_content));
    final PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(this);
    rv.setLayoutManager(mLayoutManager);
    rv.addOnScrollListener(new ToolbarScrollHideHandler(mToolbar, findViewById(R.id.header)) {

        @Override
        public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            visibleItemCount = rv.getLayoutManager().getChildCount();
            totalItemCount = rv.getLayoutManager().getItemCount();
            if (rv.getLayoutManager() instanceof PreCachingLayoutManager) {
                pastVisiblesItems = ((PreCachingLayoutManager) rv.getLayoutManager()).findFirstVisibleItemPosition();
            } else {
                int[] firstVisibleItems = null;
                firstVisibleItems = ((CatchStaggeredGridLayoutManager) rv.getLayoutManager()).findFirstVisibleItemPositions(firstVisibleItems);
                if (firstVisibleItems != null && firstVisibleItems.length > 0) {
                    pastVisiblesItems = firstVisibleItems[0];
                }
            }
            if (!posts.loading && (visibleItemCount + pastVisiblesItems) + 5 >= totalItemCount) {
                posts.loading = true;
                posts.loadMore(adapter, "", "url:" + url, false);
            }
        }
    });
    final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.activity_main_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors("", this));
    // If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned.
    // So, we estimate the height of the header in dp.
    mSwipeRefreshLayout.setProgressViewOffset(false, Constants.SINGLE_HEADER_VIEW_OFFSET - Constants.PTR_OFFSET_TOP, Constants.SINGLE_HEADER_VIEW_OFFSET + Constants.PTR_OFFSET_BOTTOM);
    mSwipeRefreshLayout.post(new Runnable() {

        @Override
        public void run() {
            mSwipeRefreshLayout.setRefreshing(true);
        }
    });
    posts = new SubredditSearchPosts("", "url:" + url, this, false);
    adapter = new ContributionAdapter(this, posts, rv);
    rv.setAdapter(adapter);
    posts.bindAdapter(adapter, mSwipeRefreshLayout);
    // TODO catch errors
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            posts.loadMore(adapter, "", "url:" + url, true);
        // TODO catch errors
        }
    });
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) R(me.ccrama.redditslide.R) NonNull(androidx.annotation.NonNull) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) Intent(android.content.Intent) Constants(me.ccrama.redditslide.Constants) PreCachingLayoutManager(me.ccrama.redditslide.Views.PreCachingLayoutManager) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Palette(me.ccrama.redditslide.Visuals.Palette) SubredditSearchPosts(me.ccrama.redditslide.Adapters.SubredditSearchPosts) ToolbarScrollHideHandler(me.ccrama.redditslide.handler.ToolbarScrollHideHandler) CatchStaggeredGridLayoutManager(me.ccrama.redditslide.Views.CatchStaggeredGridLayoutManager) MenuItem(android.view.MenuItem) ContributionAdapter(me.ccrama.redditslide.Adapters.ContributionAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) CatchStaggeredGridLayoutManager(me.ccrama.redditslide.Views.CatchStaggeredGridLayoutManager) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Intent(android.content.Intent) SubredditSearchPosts(me.ccrama.redditslide.Adapters.SubredditSearchPosts) PreCachingLayoutManager(me.ccrama.redditslide.Views.PreCachingLayoutManager) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) ContributionAdapter(me.ccrama.redditslide.Adapters.ContributionAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) ToolbarScrollHideHandler(me.ccrama.redditslide.handler.ToolbarScrollHideHandler)

Example 8 with ColorPreferences

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

the class SetupWidget method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    disableSwipeBackLayout();
    getTheme().applyStyle(new FontPreferences(this).getCommentFontStyle().getResId(), true);
    getTheme().applyStyle(new FontPreferences(this).getPostFontStyle().getResId(), true);
    getTheme().applyStyle(new ColorPreferences(this).getFontStyle().getBaseId(), true);
    super.onCreate(savedInstanceState);
    assignAppWidgetId();
    doShortcut();
}
Also used : FontPreferences(me.ccrama.redditslide.Visuals.FontPreferences) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences)

Example 9 with ColorPreferences

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

the class ModQueue method onCreate.

@Override
public void onCreate(Bundle savedInstance) {
    overrideSwipeFromAnywhere();
    super.onCreate(savedInstance);
    applyColorTheme("");
    setContentView(R.layout.activity_inbox);
    setupAppBar(R.id.toolbar, R.string.drawer_moderation, true, true);
    TabLayout tabs = (TabLayout) findViewById(R.id.sliding_tabs);
    tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
    tabs.setSelectedTabIndicatorColor(new ColorPreferences(ModQueue.this).getColor("no sub"));
    final View header = findViewById(R.id.header);
    ViewPager pager = (ViewPager) findViewById(R.id.content_view);
    pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            header.animate().translationY(0).setInterpolator(new LinearInterpolator()).setDuration(180);
        }
    });
    findViewById(R.id.header).setBackgroundColor(Palette.getDefaultColor());
    pager.setAdapter(new ModQueuePagerAdapter(getSupportFragmentManager()));
    tabs.setupWithViewPager(pager);
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) LinearInterpolator(android.view.animation.LinearInterpolator) TabLayout(com.google.android.material.tabs.TabLayout) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager)

Example 10 with ColorPreferences

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

the class NewsActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    inNightMode = SettingValues.isNight();
    disableSwipeBackLayout();
    super.onCreate(savedInstanceState);
    applyColorTheme();
    setContentView(R.layout.activity_news);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
    setSupportActionBar(mToolbar);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = this.getWindow();
        window.setStatusBarColor(Palette.getDarkerColor(Palette.getDarkerColor(Palette.getDefaultColor())));
    }
    mTabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    header = findViewById(R.id.header);
    pager = (ToggleSwipeViewPager) findViewById(R.id.content_view);
    mTabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    UserSubscriptions.doNewsSubs(NewsActivity.this);
    /**
     * int for the current base theme selected.
     * 0 = Dark, 1 = Light, 2 = AMOLED, 3 = Dark blue, 4 = AMOLED with contrast, 5 = Sepia
     */
    SettingValues.currentTheme = new ColorPreferences(this).getFontStyle().getThemeType();
    networkStateReceiver = new NetworkStateReceiver();
    networkStateReceiver.addListener(this);
    try {
        this.registerReceiver(networkStateReceiver, new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION));
    } catch (Exception e) {
    }
}
Also used : Window(android.view.Window) IntentFilter(android.content.IntentFilter) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) NetworkStateReceiver(me.ccrama.redditslide.util.NetworkStateReceiver)

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