Search in sources :

Example 36 with ColorPreferences

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

the class SettingsSubAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    View convertView = holder.itemView;
    final TextView t = convertView.findViewById(R.id.name);
    t.setText(objects.get(position));
    final String subreddit = objects.get(position);
    final View colorView = convertView.findViewById(R.id.color);
    colorView.setBackgroundResource(R.drawable.circle);
    BlendModeUtil.tintDrawableAsModulate(colorView.getBackground(), Palette.getColor(subreddit));
    final String DELETE_SUB_SETTINGS_TITLE = (subreddit.contains("/m/")) ? subreddit : ("/r/" + subreddit);
    convertView.findViewById(R.id.remove).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new AlertDialog.Builder(context).setTitle(context.getString(R.string.settings_delete_sub_settings, DELETE_SUB_SETTINGS_TITLE)).setPositiveButton(R.string.btn_yes, (dialog, which) -> {
                Palette.removeColor(subreddit);
                // Remove layout settings
                SettingValues.prefs.edit().remove(Reddit.PREF_LAYOUT + subreddit).apply();
                // Remove accent / font color settings
                new ColorPreferences(context).removeFontStyle(subreddit);
                SettingValues.resetPicsEnabled(subreddit);
                SettingValues.resetSelftextEnabled(subreddit);
                dialog.dismiss();
                objects.remove(subreddit);
                notifyDataSetChanged();
            }).setNegativeButton(R.string.btn_no, (dialog, which) -> dialog.dismiss()).show();
        }
    });
    convertView.findViewById(R.id.edit).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            prepareAndShowSubEditor(subreddit);
        }
    });
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Context(android.content.Context) OnColorChangedListener(uz.shift.colorpicker.OnColorChangedListener) SettingValues(me.ccrama.redditslide.SettingValues) AlertDialog(androidx.appcompat.app.AlertDialog) R(me.ccrama.redditslide.R) SwitchCompat(androidx.appcompat.widget.SwitchCompat) LayoutInflater(android.view.LayoutInflater) MainActivity(me.ccrama.redditslide.Activities.MainActivity) Reddit(me.ccrama.redditslide.Reddit) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Palette(me.ccrama.redditslide.Visuals.Palette) BlendModeUtil(me.ccrama.redditslide.util.BlendModeUtil) LogUtil(me.ccrama.redditslide.util.LogUtil) ViewGroup(android.view.ViewGroup) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) ArrayList(java.util.ArrayList) TextView(android.widget.TextView) SubredditView(me.ccrama.redditslide.Activities.SubredditView) View(android.view.View) LineColorPicker(uz.shift.colorpicker.LineColorPicker) RecyclerView(androidx.recyclerview.widget.RecyclerView) Activity(android.app.Activity) ContextCompat(androidx.core.content.ContextCompat) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) TextView(android.widget.TextView) TextView(android.widget.TextView) SubredditView(me.ccrama.redditslide.Activities.SubredditView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 37 with ColorPreferences

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

the class SettingsSubreddit method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    applyColorTheme();
    setContentView(R.layout.activity_settings_subreddit);
    SettingsThemeFragment.changed = true;
    setupAppBar(R.id.toolbar, R.string.title_subreddit_settings, true, true);
    recycler = ((RecyclerView) findViewById(R.id.subslist));
    recycler.setLayoutManager(new LinearLayoutManager(this));
    reloadSubList();
    findViewById(R.id.reset).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new AlertDialog.Builder(SettingsSubreddit.this).setTitle(R.string.clear_all_sub_themes).setMessage(R.string.clear_all_sub_themes_msg).setPositiveButton(R.string.btn_yes, (dialog, which) -> {
                for (String s : changedSubs) {
                    Palette.removeColor(s);
                    SettingValues.prefs.edit().remove(Reddit.PREF_LAYOUT + s).apply();
                    new ColorPreferences(SettingsSubreddit.this).removeFontStyle(s);
                    SettingValues.resetPicsEnabled(s);
                }
                reloadSubList();
            }).setNegativeButton(R.string.btn_no, null).show();
        }
    });
    findViewById(R.id.post_floating_action_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final ArrayList<String> subs = UserSubscriptions.sort(UserSubscriptions.getSubscriptions(SettingsSubreddit.this));
            final CharSequence[] subsAsChar = subs.toArray(new CharSequence[0]);
            MaterialDialog.Builder builder = new MaterialDialog.Builder(SettingsSubreddit.this);
            builder.title(R.string.dialog_choose_subreddits_to_edit).items(subsAsChar).itemsCallbackMultiChoice(null, new MaterialDialog.ListCallbackMultiChoice() {

                @Override
                public boolean onSelection(MaterialDialog dialog, Integer[] which, CharSequence[] text) {
                    ArrayList<String> selectedSubs = new ArrayList<>();
                    for (int i : which) {
                        selectedSubs.add(subsAsChar[i].toString());
                    }
                    if (mSettingsSubAdapter != null)
                        mSettingsSubAdapter.prepareAndShowSubEditor(selectedSubs);
                    return true;
                }
            }).positiveText(R.string.btn_select).negativeText(R.string.btn_cancel).show();
        }
    });
    findViewById(R.id.color).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (Authentication.isLoggedIn) {
                new AlertDialog.Builder(SettingsSubreddit.this).setTitle(R.string.dialog_color_sync_title).setMessage(R.string.dialog_color_sync_message).setPositiveButton(R.string.misc_continue, (dialog, which) -> {
                    final MaterialDialog d = new MaterialDialog.Builder(SettingsSubreddit.this).title(R.string.general_sub_sync).content(R.string.misc_please_wait).progress(false, 100).cancelable(false).show();
                    new AsyncTask<Void, Void, Void>() {

                        @Override
                        protected Void doInBackground(Void... params) {
                            ArrayList<Subreddit> subColors = UserSubscriptions.syncSubredditsGetObject();
                            d.setMaxProgress(subColors.size());
                            int i = 0;
                            done = 0;
                            for (Subreddit s : subColors) {
                                if (s.getDataNode().has("key_color") && !s.getDataNode().get("key_color").asText().isEmpty() && Palette.getColor(s.getDisplayName().toLowerCase(Locale.ENGLISH)) == Palette.getDefaultColor()) {
                                    Palette.setColor(s.getDisplayName().toLowerCase(Locale.ENGLISH), GetClosestColor.getClosestColor(s.getDataNode().get("key_color").asText(), SettingsSubreddit.this));
                                    done++;
                                }
                                d.setProgress(i);
                                i++;
                                if (i == d.getMaxProgress()) {
                                    d.dismiss();
                                }
                            }
                            return null;
                        }

                        @Override
                        protected void onPostExecute(Void aVoid) {
                            reloadSubList();
                            Resources res = getResources();
                            new AlertDialog.Builder(SettingsSubreddit.this).setTitle(R.string.color_sync_complete).setMessage(res.getQuantityString(R.plurals.color_sync_colored, done, done)).setPositiveButton(R.string.btn_ok, null).show();
                        }
                    }.execute();
                    d.show();
                }).setNegativeButton(R.string.btn_cancel, null).show();
            } else {
                Snackbar s = Snackbar.make(mToolbar, R.string.err_color_sync_login, Snackbar.LENGTH_SHORT);
                LayoutUtils.showSnackbar(s);
            }
        }
    });
}
Also used : LayoutUtils(me.ccrama.redditslide.util.LayoutUtils) SettingValues(me.ccrama.redditslide.SettingValues) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) R(me.ccrama.redditslide.R) Intent(android.content.Intent) ArrayList(java.util.ArrayList) Locale(java.util.Locale) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) View(android.view.View) UserSubscriptions(me.ccrama.redditslide.UserSubscriptions) RecyclerView(androidx.recyclerview.widget.RecyclerView) AsyncTask(android.os.AsyncTask) Reddit(me.ccrama.redditslide.Reddit) Authentication(me.ccrama.redditslide.Authentication) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Palette(me.ccrama.redditslide.Visuals.Palette) GetClosestColor(me.ccrama.redditslide.Visuals.GetClosestColor) BaseActivityAnim(me.ccrama.redditslide.Activities.BaseActivityAnim) List(java.util.List) Subreddit(net.dean.jraw.models.Subreddit) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Snackbar(com.google.android.material.snackbar.Snackbar) Resources(android.content.res.Resources) ArrayList(java.util.ArrayList) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) AsyncTask(android.os.AsyncTask) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerView(androidx.recyclerview.widget.RecyclerView) Resources(android.content.res.Resources) Subreddit(net.dean.jraw.models.Subreddit) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 38 with ColorPreferences

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

the class SettingsSubreddit method reloadSubList.

public void reloadSubList() {
    changedSubs.clear();
    List<String> allSubs = UserSubscriptions.sort(UserSubscriptions.getAllUserSubreddits(this));
    // Check which subreddits are different
    ColorPreferences colorPrefs = new ColorPreferences(SettingsSubreddit.this);
    int defaultFont = colorPrefs.getFontStyle().getColor();
    for (String s : allSubs) {
        if (Palette.getColor(s) != Palette.getDefaultColor() || SettingValues.prefs.contains(Reddit.PREF_LAYOUT + s) || colorPrefs.getFontStyleSubreddit(s).getColor() != defaultFont || SettingValues.prefs.contains("picsenabled" + s.toLowerCase(Locale.ENGLISH))) {
            changedSubs.add(s);
        }
    }
    mSettingsSubAdapter = new SettingsSubAdapter(this, changedSubs);
    recycler.setAdapter(mSettingsSubAdapter);
    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.post_floating_action_button);
    recycler.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (dy <= 0 && fab.getId() != 0) {
                fab.show();
            } else {
                fab.hide();
            }
        }

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
        }
    });
    fab.show();
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 39 with ColorPreferences

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

the class MainActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    inNightMode = SettingValues.isNight();
    disableSwipeBackLayout();
    super.onCreate(savedInstanceState);
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
        // Activity was brought to front and not created
        finish();
        return;
    }
    if (!Slide.hasStarted) {
        Slide.hasStarted = true;
    }
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        requestPermission();
    }
    boolean first = false;
    if (Reddit.colors != null && !Reddit.colors.contains("firstStart53")) {
        new AlertDialog.Builder(this).setTitle("Content settings have moved!").setMessage("NSFW content is now disabled by default. If you are over the age of 18, to re-enable NSFW content, visit Settings > Content settings").setPositiveButton(R.string.btn_ok, null).setCancelable(false).show();
        Reddit.colors.edit().putBoolean("firstStart53", true).apply();
    }
    if (Reddit.colors != null && !Reddit.colors.contains("Tutorial")) {
        first = true;
        if (Reddit.appRestart == null) {
            Reddit.appRestart = getSharedPreferences("appRestart", 0);
        }
        Reddit.appRestart.edit().putBoolean("firststart52", true).apply();
        Intent i = new Intent(this, Tutorial.class);
        doForcePrefs();
        startActivity(i);
    } else {
        if (Authentication.didOnline && NetworkUtil.isConnected(MainActivity.this) && !checkedPopups) {
            runAfterLoad = new Runnable() {

                @Override
                public void run() {
                    runAfterLoad = null;
                    if (Authentication.isLoggedIn) {
                        new AsyncNotificationBadge().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    }
                    if (!Reddit.appRestart.getString(CheckForMail.SUBS_TO_GET, "").isEmpty()) {
                        new CheckForMail.AsyncGetSubs(MainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    }
                    new AsyncTask<Void, Void, Submission>() {

                        @Override
                        protected Submission doInBackground(Void... params) {
                            if (Authentication.isLoggedIn)
                                UserSubscriptions.doOnlineSyncing();
                            try {
                                SubredditPaginator p = new SubredditPaginator(Authentication.reddit, "slideforreddit");
                                p.setLimit(2);
                                ArrayList<Submission> posts = new ArrayList<>(p.next());
                                for (Submission s : posts) {
                                    String version = BuildConfig.VERSION_NAME;
                                    if (version.length() > 5) {
                                        version = version.substring(0, version.lastIndexOf("."));
                                    }
                                    if (s.isStickied() && s.getSubmissionFlair().getText() != null && s.getSubmissionFlair().getText().equalsIgnoreCase("Announcement") && !Reddit.appRestart.contains("announcement" + s.getFullName()) && s.getTitle().contains(version)) {
                                        Reddit.appRestart.edit().putBoolean("announcement" + s.getFullName(), true).apply();
                                        return s;
                                    } else if (BuildConfig.VERSION_NAME.contains("alpha") && s.isStickied() && s.getSubmissionFlair().getText() != null && s.getSubmissionFlair().getText().equalsIgnoreCase("Alpha") && !Reddit.appRestart.contains("announcement" + s.getFullName()) && s.getTitle().contains(BuildConfig.VERSION_NAME)) {
                                        Reddit.appRestart.edit().putBoolean("announcement" + s.getFullName(), true).apply();
                                        return s;
                                    } else if (s.isStickied() && s.getSubmissionFlair().getText().equalsIgnoreCase("PRO") && !SettingValues.isPro && !Reddit.appRestart.contains("announcement" + s.getFullName())) {
                                        Reddit.appRestart.edit().putBoolean("announcement" + s.getFullName(), true).apply();
                                        return s;
                                    }
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            return null;
                        }

                        @Override
                        protected void onPostExecute(final Submission s) {
                            checkedPopups = true;
                            if (s != null) {
                                Reddit.appRestart.edit().putString("page", s.getDataNode().get("selftext_html").asText()).apply();
                                Reddit.appRestart.edit().putString("title", s.getTitle()).apply();
                                Reddit.appRestart.edit().putString("url", s.getUrl()).apply();
                                String title;
                                if (s.getTitle().toLowerCase(Locale.ENGLISH).contains("release")) {
                                    title = getString(R.string.btn_changelog);
                                } else {
                                    title = getString(R.string.btn_view);
                                }
                                Snackbar snack = Snackbar.make(pager, s.getTitle(), Snackbar.LENGTH_INDEFINITE).setAction(title, new OnSingleClickListener() {

                                    @Override
                                    public void onSingleClick(View v) {
                                        Intent i = new Intent(MainActivity.this, Announcement.class);
                                        startActivity(i);
                                    }
                                });
                                LayoutUtils.showSnackbar(snack);
                            }
                        }
                    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                // todo this  new AsyncStartNotifSocket().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                }
            };
        }
    }
    if (savedInstanceState != null && !changed) {
        Authentication.isLoggedIn = savedInstanceState.getBoolean(LOGGED_IN);
        Authentication.name = savedInstanceState.getString(USERNAME, "LOGGEDOUT");
        Authentication.didOnline = savedInstanceState.getBoolean(IS_ONLINE);
    } else {
        changed = false;
    }
    if (getIntent().getBooleanExtra("EXIT", false))
        finish();
    applyColorTheme();
    setContentView(R.layout.activity_overview);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
    setSupportActionBar(mToolbar);
    if (getIntent() != null && getIntent().hasExtra(EXTRA_PAGE_TO)) {
        toGoto = getIntent().getIntExtra(EXTRA_PAGE_TO, 0);
    }
    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);
    // Gets the height of the header
    if (header != null) {
        header.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

            @Override
            public void onGlobalLayout() {
                headerHeight = header.getHeight();
                header.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });
    }
    pager = (ToggleSwipeViewPager) findViewById(R.id.content_view);
    singleMode = SettingValues.single;
    if (singleMode) {
        commentPager = SettingValues.commentPager;
    }
    // Inflate tabs if single mode is disabled
    if (!singleMode) {
        mTabLayout = (TabLayout) ((ViewStub) findViewById(R.id.stub_tabs)).inflate();
    }
    // Disable swiping if single mode is enabled
    if (singleMode) {
        pager.setSwipingEnabled(false);
    }
    sidebarBody = (SpoilerRobotoTextView) findViewById(R.id.sidebar_text);
    sidebarOverflow = (CommentOverflow) findViewById(R.id.commentOverflow);
    if (!Reddit.appRestart.getBoolean("isRestarting", false) && Reddit.colors.contains("Tutorial")) {
        LogUtil.v("Starting main " + Authentication.name);
        Authentication.isLoggedIn = Reddit.appRestart.getBoolean("loggedin", false);
        Authentication.name = Reddit.appRestart.getString("name", "LOGGEDOUT");
        UserSubscriptions.doMainActivitySubs(this);
    } else if (!first) {
        LogUtil.v("Starting main 2 " + Authentication.name);
        Authentication.isLoggedIn = Reddit.appRestart.getBoolean("loggedin", false);
        Authentication.name = Reddit.appRestart.getString("name", "LOGGEDOUT");
        Reddit.appRestart.edit().putBoolean("isRestarting", false).commit();
        Reddit.isRestarting = false;
        UserSubscriptions.doMainActivitySubs(this);
    }
    final SharedPreferences seen = getSharedPreferences("SEEN", 0);
    if (!seen.contains("isCleared") && !seen.getAll().isEmpty() || !Reddit.appRestart.contains("hasCleared")) {
        new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... params) {
                KVManger m = KVStore.getInstance();
                Map<String, ?> values = seen.getAll();
                for (Map.Entry<String, ?> entry : values.entrySet()) {
                    if (entry.getKey().length() == 6 && entry.getValue() instanceof Boolean) {
                        m.insert(entry.getKey(), "true");
                    } else if (entry.getValue() instanceof Long) {
                        m.insert(entry.getKey(), String.valueOf(seen.getLong(entry.getKey(), 0)));
                    }
                }
                seen.edit().clear().putBoolean("isCleared", true).apply();
                if (getSharedPreferences("HIDDEN_POSTS", 0).getAll().size() != 0) {
                    getSharedPreferences("HIDDEN", 0).edit().clear().apply();
                    getSharedPreferences("HIDDEN_POSTS", 0).edit().clear().apply();
                }
                if (!Reddit.appRestart.contains("hasCleared")) {
                    SharedPreferences.Editor e = Reddit.appRestart.edit();
                    Map<String, ?> toClear = Reddit.appRestart.getAll();
                    for (Map.Entry<String, ?> entry : toClear.entrySet()) {
                        if (entry.getValue() instanceof String && ((String) entry.getValue()).length() > 300) {
                            e.remove(entry.getKey());
                        }
                    }
                    e.putBoolean("hasCleared", true);
                    e.apply();
                }
                return null;
            }

            @Override
            protected void onPostExecute(Void aVoid) {
                dismissProgressDialog();
            }

            @Override
            protected void onPreExecute() {
                d = new MaterialDialog.Builder(MainActivity.this).title(R.string.misc_setting_up).content(R.string.misc_setting_up_message).progress(true, 100).cancelable(false).build();
                d.show();
            }
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
    if (!BuildConfig.isFDroid && Authentication.isLoggedIn && NetworkUtil.isConnected(MainActivity.this)) {
        // Display an snackbar that asks the user to rate the app after this
        // activity was created 6 times, never again when once clicked or with a maximum of
        // two times.
        SnackEngage.from(MainActivity.this).withSnack(new RateSnack().withConditions(new NeverAgainWhenClickedOnce(), new AfterNumberOfOpportunities(10), new WithLimitedNumberOfTimes(2)).overrideActionText(getString(R.string.misc_rate_msg)).overrideTitleText(getString(R.string.misc_rate_title)).withDuration(BaseSnack.DURATION_LONG)).build().engageWhenAppropriate();
    }
    if (SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_TOOLBAR || SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) {
        setupSubredditSearchToolbar();
    }
    /**
     * 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) {
    }
    LogUtil.v("Installed browsers");
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("http://ccrama.me/"));
    List<ResolveInfo> allApps = getPackageManager().queryIntentActivities(intent, PackageManager.GET_DISABLED_COMPONENTS);
    for (ResolveInfo i : allApps) {
        if (i.activityInfo.isEnabled())
            LogUtil.v(i.activityInfo.packageName);
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) RateSnack(org.ligi.snackengage.snacks.RateSnack) NeverAgainWhenClickedOnce(org.ligi.snackengage.conditions.NeverAgainWhenClickedOnce) OnSingleClickListener(me.ccrama.redditslide.util.OnSingleClickListener) ArrayList(java.util.ArrayList) CaseInsensitiveArrayList(me.ccrama.redditslide.CaseInsensitiveArrayList) AfterNumberOfOpportunities(org.ligi.snackengage.conditions.AfterNumberOfOpportunities) ResolveInfo(android.content.pm.ResolveInfo) SubredditPaginator(net.dean.jraw.paginators.SubredditPaginator) WithLimitedNumberOfTimes(org.ligi.snackengage.conditions.WithLimitedNumberOfTimes) ViewTreeObserver(android.view.ViewTreeObserver) Window(android.view.Window) IntentFilter(android.content.IntentFilter) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Submission(net.dean.jraw.models.Submission) ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) SharedPreferences(android.content.SharedPreferences) AsyncTask(android.os.AsyncTask) Intent(android.content.Intent) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) CardView(androidx.cardview.widget.CardView) AutoCompleteTextView(android.widget.AutoCompleteTextView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) ApiException(net.dean.jraw.ApiException) NetworkException(net.dean.jraw.http.NetworkException) ViewStub(android.view.ViewStub) KVManger(com.lusfold.androidkeyvaluestore.core.KVManger) Map(java.util.Map) HashMap(java.util.HashMap) NetworkStateReceiver(me.ccrama.redditslide.util.NetworkStateReceiver) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 40 with ColorPreferences

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

the class MainActivity method setDataSet.

public void setDataSet(List<String> data) {
    if (data != null && !data.isEmpty()) {
        usedArray = new CaseInsensitiveArrayList(data);
        if (adapter == null) {
            if (commentPager && singleMode) {
                adapter = new MainPagerAdapterComment(getSupportFragmentManager());
            } else {
                adapter = new MainPagerAdapter(getSupportFragmentManager());
            }
        } else {
            adapter.notifyDataSetChanged();
        }
        pager.setAdapter(adapter);
        pager.setOffscreenPageLimit(1);
        if (toGoto == -1) {
            toGoto = 0;
        }
        if (toGoto >= usedArray.size()) {
            toGoto -= 1;
        }
        shouldLoad = usedArray.get(toGoto);
        selectedSub = (usedArray.get(toGoto));
        themeSystemBars(usedArray.get(toGoto));
        final String USEDARRAY_0 = usedArray.get(0);
        header.setBackgroundColor(Palette.getColor(USEDARRAY_0));
        if (hea != null) {
            hea.setBackgroundColor(Palette.getColor(USEDARRAY_0));
            if (accountsArea != null) {
                accountsArea.setBackgroundColor(Palette.getDarkerColor(USEDARRAY_0));
            }
        }
        if (!SettingValues.single) {
            mTabLayout.setSelectedTabIndicatorColor(new ColorPreferences(MainActivity.this).getColor(USEDARRAY_0));
            pager.setCurrentItem(toGoto);
            mTabLayout.setupWithViewPager(pager);
            if (mTabLayout != null) {
                mTabLayout.setupWithViewPager(pager);
                LayoutUtils.scrollToTabAfterLayout(mTabLayout, toGoto);
            }
        } else {
            getSupportActionBar().setTitle(usedArray.get(toGoto));
            pager.setCurrentItem(toGoto);
        }
        setToolbarClick();
        setRecentBar(usedArray.get(toGoto));
        doSubSidebarNoLoad(usedArray.get(toGoto));
    } else if (NetworkUtil.isConnected(this)) {
        UserSubscriptions.doMainActivitySubs(this);
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) CaseInsensitiveArrayList(me.ccrama.redditslide.CaseInsensitiveArrayList)

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