Search in sources :

Example 46 with ColorPreferences

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

the class SubredditListView method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), new ColorPreferences(inflater.getContext()).getThemeSubreddit(where));
    View v = ((LayoutInflater) contextThemeWrapper.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.fragment_verticalcontent, container, false);
    rv = ((RecyclerView) v.findViewById(R.id.vertical_content));
    final RecyclerView.LayoutManager mLayoutManager = new PreCachingLayoutManager(getActivity());
    rv.setLayoutManager(mLayoutManager);
    rv.setItemAnimator(new SlideUpAlphaAnimator());
    mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors("no sub", getContext()));
    // 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.TAB_HEADER_VIEW_OFFSET - Constants.PTR_OFFSET_TOP, Constants.TAB_HEADER_VIEW_OFFSET + Constants.PTR_OFFSET_BOTTOM);
    v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE);
    doAdapter();
    return v;
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) ColorPreferences(me.ccrama.redditslide.ColorPreferences) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView) PreCachingLayoutManager(me.ccrama.redditslide.Views.PreCachingLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SlideUpAlphaAnimator(com.mikepenz.itemanimators.SlideUpAlphaAnimator)

Example 47 with ColorPreferences

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

the class Inbox method onCreate.

@Override
public void onCreate(Bundle savedInstance) {
    overrideSwipeFromAnywhere();
    if (Authentication.reddit == null || !Authentication.reddit.isAuthenticated() || Authentication.me == null) {
        LogUtil.v("Reauthenticating");
        new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... params) {
                if (Authentication.reddit == null) {
                    new Authentication(getApplicationContext());
                }
                try {
                    Authentication.me = Authentication.reddit.me();
                    Authentication.mod = Authentication.me.isMod();
                    Authentication.authentication.edit().putBoolean(Reddit.SHARED_PREF_IS_MOD, Authentication.mod).apply();
                    if (Reddit.notificationTime != -1) {
                        Reddit.notifications = new NotificationJobScheduler(Inbox.this);
                        Reddit.notifications.start(getApplicationContext());
                    }
                    if (Reddit.cachedData.contains("toCache")) {
                        Reddit.autoCache = new AutoCacheScheduler(Inbox.this);
                        Reddit.autoCache.start(getApplicationContext());
                    }
                    final String name = Authentication.me.getFullName();
                    Authentication.name = name;
                    LogUtil.v("AUTHENTICATED");
                    UserSubscriptions.doCachedModSubs();
                    if (Authentication.reddit.isAuthenticated()) {
                        final Set<String> accounts = Authentication.authentication.getStringSet("accounts", new HashSet<String>());
                        if (accounts.contains(name)) {
                            // convert to new system
                            accounts.remove(name);
                            accounts.add(name + ":" + Authentication.refresh);
                            Authentication.authentication.edit().putStringSet("accounts", accounts).apply();
                        }
                        Authentication.isLoggedIn = true;
                        Reddit.notFirst = true;
                    }
                } catch (Exception ignored) {
                }
                return null;
            }
        }.execute();
    }
    super.onCreate(savedInstance);
    last = SettingValues.prefs.getLong("lastInbox", System.currentTimeMillis() - (60 * 1000 * 60));
    SettingValues.prefs.edit().putLong("lastInbox", System.currentTimeMillis()).apply();
    applyColorTheme("");
    setContentView(R.layout.activity_inbox);
    setupAppBar(R.id.toolbar, R.string.title_inbox, true, true);
    mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
    tabs = (TabLayout) findViewById(R.id.sliding_tabs);
    tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
    tabs.setSelectedTabIndicatorColor(new ColorPreferences(Inbox.this).getColor("no sub"));
    pager = (ViewPager) findViewById(R.id.content_view);
    findViewById(R.id.header).setBackgroundColor(Palette.getDefaultColor());
    adapter = new OverviewPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);
    if (getIntent() != null && getIntent().hasExtra(EXTRA_UNREAD)) {
        pager.setCurrentItem(1);
    }
    tabs.setupWithViewPager(pager);
    pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            findViewById(R.id.header).animate().translationY(0).setInterpolator(new LinearInterpolator()).setDuration(180);
            if (position == 3 && findViewById(R.id.read) != null) {
                findViewById(R.id.read).setVisibility(View.GONE);
            } else if (findViewById(R.id.read) != null) {
                findViewById(R.id.read).setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) AutoCacheScheduler(me.ccrama.redditslide.Autocache.AutoCacheScheduler) ColorPreferences(me.ccrama.redditslide.ColorPreferences) NotificationJobScheduler(me.ccrama.redditslide.Notifications.NotificationJobScheduler) ViewPager(android.support.v4.view.ViewPager) LinearInterpolator(android.view.animation.LinearInterpolator) Authentication(me.ccrama.redditslide.Authentication) HashSet(java.util.HashSet)

Example 48 with ColorPreferences

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

the class BaseActivity method applyColorTheme.

/**
 * Applies the activity's base color theme. Should be called before inflating any layouts.
 */
protected void applyColorTheme() {
    getTheme().applyStyle(new FontPreferences(this).getCommentFontStyle().getResId(), true);
    getTheme().applyStyle(new FontPreferences(this).getPostFontStyle().getResId(), true);
    getTheme().applyStyle(new ColorPreferences(this).getFontStyle().getBaseId(), true);
}
Also used : FontPreferences(me.ccrama.redditslide.Visuals.FontPreferences) ColorPreferences(me.ccrama.redditslide.ColorPreferences)

Example 49 with ColorPreferences

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

the class Discover method onCreate.

@Override
public void onCreate(Bundle savedInstance) {
    overrideSwipeFromAnywhere();
    super.onCreate(savedInstance);
    applyColorTheme("");
    setContentView(R.layout.activity_multireddits);
    ((DrawerLayout) findViewById(R.id.drawer_layout)).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    setupAppBar(R.id.toolbar, R.string.discover_title, true, false);
    mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
    findViewById(R.id.header).setBackgroundColor(Palette.getDefaultColor());
    TabLayout tabs = (TabLayout) findViewById(R.id.sliding_tabs);
    tabs.setTabMode(TabLayout.MODE_FIXED);
    tabs.setSelectedTabIndicatorColor(new ColorPreferences(Discover.this).getColor("no sub"));
    ViewPager pager = (ViewPager) findViewById(R.id.content_view);
    pager.setAdapter(new OverviewPagerAdapter(getSupportFragmentManager()));
    tabs.setupWithViewPager(pager);
    pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            findViewById(R.id.header).animate().translationY(0).setInterpolator(new LinearInterpolator()).setDuration(180);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
}
Also used : ColorPreferences(me.ccrama.redditslide.ColorPreferences) LinearInterpolator(android.view.animation.LinearInterpolator) TabLayout(android.support.design.widget.TabLayout) DrawerLayout(android.support.v4.widget.DrawerLayout) ViewPager(android.support.v4.view.ViewPager)

Example 50 with ColorPreferences

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

the class Announcement method setViews.

private void setViews(String rawHTML, String subredditName, SpoilerRobotoTextView firstTextView, CommentOverflow commentOverflow) {
    if (rawHTML.isEmpty()) {
        return;
    }
    List<String> blocks = SubmissionParser.getBlocks(rawHTML);
    int startIndex = 0;
    // the <div class="md"> case is when the body contains a table or code block first
    if (!blocks.get(0).equals("<div class=\"md\">")) {
        firstTextView.setVisibility(View.VISIBLE);
        firstTextView.setTextHtml(blocks.get(0), subredditName);
        firstTextView.setLinkTextColor(new ColorPreferences(this).getColor(subredditName));
        startIndex = 1;
    } else {
        firstTextView.setText("");
        firstTextView.setVisibility(View.GONE);
    }
    if (blocks.size() > 1) {
        if (startIndex == 0) {
            commentOverflow.setViews(blocks, subredditName);
        } else {
            commentOverflow.setViews(blocks.subList(startIndex, blocks.size()), subredditName);
        }
        SidebarLayout sidebar = (SidebarLayout) findViewById(R.id.drawer_layout);
        for (int i = 0; i < commentOverflow.getChildCount(); i++) {
            View maybeScrollable = commentOverflow.getChildAt(i);
            if (maybeScrollable instanceof HorizontalScrollView) {
                sidebar.addScrollable(maybeScrollable);
            }
        }
    } else {
        commentOverflow.removeAllViews();
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.ColorPreferences) SidebarLayout(me.ccrama.redditslide.Views.SidebarLayout) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) HorizontalScrollView(android.widget.HorizontalScrollView) TitleTextView(me.ccrama.redditslide.Views.TitleTextView) View(android.view.View) HorizontalScrollView(android.widget.HorizontalScrollView)

Aggregations

ColorPreferences (me.ccrama.redditslide.ColorPreferences)50 View (android.view.View)23 TextView (android.widget.TextView)22 Intent (android.content.Intent)16 DialogInterface (android.content.DialogInterface)14 AlertDialogWrapper (com.afollestad.materialdialogs.AlertDialogWrapper)14 ArrayList (java.util.ArrayList)14 SpoilerRobotoTextView (me.ccrama.redditslide.SpoilerRobotoTextView)13 LayoutInflater (android.view.LayoutInflater)12 RecyclerView (android.support.v7.widget.RecyclerView)10 ImageView (android.widget.ImageView)10 SubmissionsView (me.ccrama.redditslide.Fragments.SubmissionsView)10 Context (android.content.Context)9 ContextThemeWrapper (android.support.v7.view.ContextThemeWrapper)9 HorizontalScrollView (android.widget.HorizontalScrollView)9 Snackbar (android.support.design.widget.Snackbar)8 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)8 CaseInsensitiveArrayList (me.ccrama.redditslide.CaseInsensitiveArrayList)8 LinearInterpolator (android.view.animation.LinearInterpolator)7 Dialog (android.app.Dialog)6