com.afollestad.materialdialogs.color.ColorChooserDialog Java Examples

The following examples show how to use com.afollestad.materialdialogs.color.ColorChooserDialog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SettingsActivity.java    From EdXposedManager with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int color) {
    int colorFrom = XposedApp.getColor(this);

    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, color);
    colorAnimation.addUpdateListener(animator -> {
        int color1 = (int) animator.getAnimatedValue();

        toolbar.setBackgroundColor(color1);

        int darkenColor = XposedApp.darkenColor(color1, getDarkenFactor());

        getWindow().setStatusBarColor(darkenColor);

        if (navBar != null && navBar.isChecked()) {
            getWindow().setNavigationBarColor(darkenColor);
        }
    });
    colorAnimation.setDuration(750);
    colorAnimation.start();

    if (!dialog.isAccentMode()) {
        XposedApp.getPreferences().edit().putInt("colors", color).apply();
    }
}
 
Example #2
Source File: ScrollingActivity.java    From recycler-fast-scroll with Apache License 2.0 6 votes vote down vote up
void customizeColors(int title) {
    int colorChooserDialogTitle = 0;
    int preselectColor = 0;
    switch (title) {
        case R.string.handle_normal_color:
            colorChooserDialogTitle = R.string.handle_normal_color;
            preselectColor = mRecyclerFastScroller.getHandleNormalColor();
            break;
        case R.string.handle_pressed_color:
            colorChooserDialogTitle = R.string.handle_pressed_color;
            preselectColor = mRecyclerFastScroller.getHandlePressedColor();
            break;
        case R.string.scrollbar_color:
            colorChooserDialogTitle = R.string.scrollbar_color;
            preselectColor = mRecyclerFastScroller.getBarColor();
            break;
    }
    new ColorChooserDialog.Builder(this, colorChooserDialogTitle)
            .accentMode(title == R.string.handle_pressed_color)
            .preselect(preselectColor)
            .show();
}
 
Example #3
Source File: SettingActivity.java    From Toutiao with Apache License 2.0 6 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    if (getSupportActionBar() != null)
        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(selectedColor));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // 状态栏上色
        getWindow().setStatusBarColor(CircleView.shiftColorDown(selectedColor));
        // 最近任务栏上色
        ActivityManager.TaskDescription tDesc = new ActivityManager.TaskDescription(
                getString(R.string.app_name),
                BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_rect),
                selectedColor);
        setTaskDescription(tDesc);
        // 导航栏上色
        if (SettingUtil.getInstance().getNavBar()) {
            getWindow().setNavigationBarColor(CircleView.shiftColorDown(selectedColor));
        } else {
            getWindow().setNavigationBarColor(Color.BLACK);
        }
    }
    if (!dialog.isAccentMode()) {
        SettingUtil.getInstance().setColor(selectedColor);
    }
}
 
Example #4
Source File: FindGenerateCodeAty.java    From myapplication with Apache License 2.0 6 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog,
                             @ColorInt int selectedColor) {

    Log.d(LOG_TAG, "onColorSelection: " + selectedColor);
    switch (mPalette) {
        // 前景色
        case 0:
            mForeColor = selectedColor;
            operateColor(selectedColor, AbsentMConstants.FORE_COLOR);
            break;
        // 背景色
        case 1:
            mBackColor = selectedColor;
            operateColor(selectedColor, AbsentMConstants.BACK_COLOR);
            break;
    }

}
 
Example #5
Source File: SettingsFragment.java    From Pasta-Music with Apache License 2.0 6 votes vote down vote up
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    switch (dialog.getTitle()) {
        case R.string.primary_color:
            if (PreferenceUtils.getPrimaryColor(getContext()) == selectedColor) return;
            prefs.edit().putInt(PreferenceUtils.PRIMARY, selectedColor).apply();
            primary.transition(new ColorDrawable(selectedColor));
            break;
        case R.string.accent_color:
            if (PreferenceUtils.getAccentColor(getContext()) == selectedColor) return;
            prefs.edit().putInt(PreferenceUtils.ACCENT, selectedColor).apply();
            accent.transition(new ColorDrawable(selectedColor));
            break;
        default:
            return;
    }
    pasta.showToast(getString(R.string.restart_msg));
}
 
Example #6
Source File: SettingsActivity.java    From VinylMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    switch (dialog.getTitle()) {
        case R.string.primary_color:
            ThemeStore.editTheme(this)
                    .primaryColor(selectedColor)
                    .commit();
            break;
        case R.string.accent_color:
            ThemeStore.editTheme(this)
                    .accentColor(selectedColor)
                    .commit();
            break;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        new DynamicShortcutManager(this).updateDynamicShortcuts();
    }
    recreate();
}
 
Example #7
Source File: SettingsActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    switch (dialog.getTitle()) {
        case R.string.primary_color:
            ThemeStore.editTheme(this).primaryColor(selectedColor).commit();
            break;
        case R.string.accent_color:
            ThemeStore.editTheme(this).accentColor(selectedColor).commit();
            break;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        new DynamicShortcutManager(this).updateDynamicShortcuts();
    }
    recreate();
}
 
Example #8
Source File: SettingsActivity.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    switch (dialog.getTitle()) {
        case R.string.primary_color:
            ThemeStore.editTheme(this)
                    .primaryColor(selectedColor)
                    .commit();
            break;
        case R.string.accent_color:
            ThemeStore.editTheme(this)
                    .accentColor(selectedColor)
                    .commit();
            break;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        new DynamicShortcutManager(this).updateDynamicShortcuts();
    }
    recreate();
}
 
Example #9
Source File: SettingsActivity.java    From Music-Player with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    switch (dialog.getTitle()) {
        case R.string.primary_color:
                Arrays.sort(NonProAllowedColors.PRIMARY_COLORS);
                if (Arrays.binarySearch(NonProAllowedColors.PRIMARY_COLORS, selectedColor) < 0) {
            }
            ThemeStore.editTheme(this)
                    .primaryColor(selectedColor)
                    .commit();
            break;
        case R.string.accent_color:
                Arrays.sort(NonProAllowedColors.ACCENT_COLORS);
                if (Arrays.binarySearch(NonProAllowedColors.ACCENT_COLORS, selectedColor) < 0) {
                }
            ThemeStore.editTheme(this)
                    .accentColor(selectedColor)
                    .commit();
            break;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        new DynamicShortcutManager(this).updateDynamicShortcuts();
    }
    recreate();
}
 
Example #10
Source File: Draw.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    drawView.setPaintStrokeColor(selectedColor);
    color.getBackground().setColorFilter(selectedColor, PorterDuff.Mode.MULTIPLY);

    Reddit.colors.edit().putInt("drawColor", selectedColor).commit();
}
 
Example #11
Source File: BaseModelFragment.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void showColorPickerDialog(int titleRes) {
    if (!(getActivity() instanceof ContentActivity)) {
        throw new IllegalArgumentException("The associated activity must be content!");
    }
    new ColorChooserDialog.Builder((ContentActivity) getActivity(), titleRes)
            .preselect(primaryColor())
            .accentMode(false)
            .titleSub(titleRes)
            .backButton(R.string.text_back)
            .doneButton(R.string.done_label)
            .cancelButton(R.string.text_cancel)
            .show();
}
 
Example #12
Source File: SettingsActivity.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    switch (dialog.getTitle()) {
        case R.string.primary_color:
            if (!App.isProVersion()) {
                Arrays.sort(NonProAllowedColors.PRIMARY_COLORS);
                if (Arrays.binarySearch(NonProAllowedColors.PRIMARY_COLORS, selectedColor) < 0) {
                    // color wasn't found
                    Toast.makeText(this, R.string.only_the_first_5_colors_available, Toast.LENGTH_LONG).show();
                    startActivity(new Intent(this, PurchaseActivity.class));
                    return;
                }
            }
            ThemeStore.editTheme(this)
                    .primaryColor(selectedColor)
                    .commit();
            break;
        case R.string.accent_color:
            if (!App.isProVersion()) {
                Arrays.sort(NonProAllowedColors.ACCENT_COLORS);
                if (Arrays.binarySearch(NonProAllowedColors.ACCENT_COLORS, selectedColor) < 0) {
                    // color wasn't found
                    Toast.makeText(this, R.string.only_the_first_5_colors_available, Toast.LENGTH_LONG).show();
                    startActivity(new Intent(this, PurchaseActivity.class));
                    return;
                }
            }
            ThemeStore.editTheme(this)
                    .accentColor(selectedColor)
                    .commit();
            break;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        new DynamicShortcutManager(this).updateDynamicShortcuts();
    }
    recreate();
}
 
Example #13
Source File: SettingsFragment.java    From Pasta-Music with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.accent)
public void setAccent() {
    new ColorChooserDialog.Builder((HomeActivity) getActivity(), R.string.accent_color)
            .titleSub(R.string.accent_color)
            .doneButton(R.string.save)
            .cancelButton(R.string.cancel)
            .backButton(R.string.md_back_label)
            .accentMode(true)
            .preselect(PreferenceUtils.getAccentColor(getContext()))
            .show();
}
 
Example #14
Source File: SettingsFragment.java    From Pasta-Music with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.primary)
public void setPrimary() {
    new ColorChooserDialog.Builder((HomeActivity) getActivity(), R.string.primary_color)
            .titleSub(R.string.primary_color)
            .doneButton(R.string.save)
            .cancelButton(R.string.cancel)
            .backButton(R.string.md_back_label)
            .preselect(PreferenceUtils.getPrimaryColor(getContext()))
            .show();
}
 
Example #15
Source File: PrefsSettings.java    From Calculator with Apache License 2.0 5 votes vote down vote up
@Override
public void onColorSelection(ColorChooserDialog dialog, int color) {
    int title = dialog.getTitle();
    if (title == R.string.actionbr) {
        actionbar = color;
    } else if (title == R.string.navbr) {
        navbar = color;
    } else if (title == R.string.txt) {
        text = color;
    }
    refresh();
}
 
Example #16
Source File: MainActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, int selectedColor) {
    if (categoryEditDialog != null) {
        categoryEditDialog.updateUIBySelectedColor(selectedColor);
    }
    Fragment currentFragment = getCurrentFragment();
    if (currentFragment instanceof CategoriesFragment) {
        ((CategoriesFragment) currentFragment).setSelectedColor(selectedColor);
    }
}
 
Example #17
Source File: CreateEditActivity.java    From recurrence with GNU General Public License v3.0 5 votes vote down vote up
@OnClick(R.id.colour_select)
public void colourSelector() {
    DatabaseHelper database = DatabaseHelper.getInstance(this);
    int[] colours = database.getColoursArray();
    database.close();

    new ColorChooserDialog.Builder(this, R.string.select_colour)
            .allowUserColorInputAlpha(false)
            .customColors(colours, null)
            .preselect(Color.parseColor(colour))
            .show();
}
 
Example #18
Source File: SettingsActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, int selectedColor) {
    if (getString(R.string.key_accent_color).equals(keyForColor)) {
        setupTheme(selectedColor);
        if (isSettingsFragment()) {
            ((SettingsFragment) getCurrentFragment()).notifyAccentColorChanged(selectedColor);
        }
    }
}
 
Example #19
Source File: SettingFragment.java    From FakeWeather with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceClick(Preference preference) {
    if (preference == cleanCache) {
        Observable
                .just(FileUtil.delete(FileUtil.getInternalCacheDir(App.getContext())))
                .map(new Func1<Boolean, Boolean>() {
                    @Override
                    public Boolean call(Boolean result) {
                        return result && FileUtil.delete(FileUtil.getExternalCacheDir(App.getContext()));
                    }
                })
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SimpleSubscriber<Boolean>() {
                    @Override
                    public void onNext(Boolean aBoolean) {
                        cleanCache.setSummary(FileSizeUtil.getAutoFileOrFilesSize(FileUtil.getInternalCacheDir(App.getContext()), FileUtil.getExternalCacheDir(App.getContext())));
                        Snackbar.make(getView(), "缓存已清除 (*^__^*)", Snackbar.LENGTH_SHORT).show();
                    }
                });
    } else if (preference == theme) {
        new ColorChooserDialog.Builder((SettingActivity) getActivity(), R.string.theme)
                .customColors(R.array.colors, null)
                .doneButton(R.string.done)
                .cancelButton(R.string.cancel)
                .allowUserColorInput(false)
                .allowUserColorInputAlpha(false)
                .show(((SettingActivity) getActivity()).getSupportFragmentManager());
    } else if (preference == moduleManage) {
        getActivity().startActivity(new Intent(getActivity(), ModuleManageActivity.class));
    }
    return true;
}
 
Example #20
Source File: CreateEditActivity.java    From recurrence with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColour) {
    colour = String.format("#%06X", (0xFFFFFF & selectedColour));
    imageColourSelect.setColorFilter(selectedColour);
    colourText.setText(colour);
    DatabaseHelper database = DatabaseHelper.getInstance(this);
    database.addColour(new Colour(selectedColour, DateAndTimeUtil.toStringDateTimeWithSeconds(Calendar.getInstance())));
    database.close();
}
 
Example #21
Source File: SettingActivity.java    From FakeWeather with Apache License 2.0 5 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    if (selectedColor == ThemeUtil.getThemeColor(this, R.attr.colorPrimary))
        return;
    toolbar.setBackgroundColor(selectedColor);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(selectedColor);
    }
    if (selectedColor == getResources().getColor(R.color.lapis_blue)) {
        setTheme(R.style.LapisBlueTheme);
        SettingsUtil.setTheme(0);
    } else if (selectedColor == getResources().getColor(R.color.pale_dogwood)) {
        setTheme(R.style.PaleDogwoodTheme);
        SettingsUtil.setTheme(1);
    } else if (selectedColor == getResources().getColor(R.color.greenery)) {
        setTheme(R.style.GreeneryTheme);
        SettingsUtil.setTheme(2);
    } else if (selectedColor == getResources().getColor(R.color.primrose_yellow)) {
        setTheme(R.style.PrimroseYellowTheme);
        SettingsUtil.setTheme(3);
    } else if (selectedColor == getResources().getColor(R.color.flame)) {
        setTheme(R.style.FlameTheme);
        SettingsUtil.setTheme(4);
    } else if (selectedColor == getResources().getColor(R.color.island_paradise)) {
        setTheme(R.style.IslandParadiseTheme);
        SettingsUtil.setTheme(5);
    } else if (selectedColor == getResources().getColor(R.color.kale)) {
        setTheme(R.style.KaleTheme);
        SettingsUtil.setTheme(6);
    } else if (selectedColor == getResources().getColor(R.color.pink_yarrow)) {
        setTheme(R.style.PinkYarrowTheme);
        SettingsUtil.setTheme(7);
    } else if (selectedColor == getResources().getColor(R.color.niagara)) {
        setTheme(R.style.NiagaraTheme);
        SettingsUtil.setTheme(8);
    }
    getFragmentManager().beginTransaction().replace(R.id.contentLayout, new SettingFragment()).commit();
    EventBus.getDefault().post(new ThemeChangedEvent(selectedColor));
}
 
Example #22
Source File: ScrollingActivity.java    From recycler-fast-scroll with Apache License 2.0 5 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog colorChooserDialog, int color) {
    switch (colorChooserDialog.getTitle()) {
        case R.string.handle_normal_color:
            mRecyclerFastScroller.setHandleNormalColor(color);
            break;
        case R.string.handle_pressed_color:
            mRecyclerFastScroller.setHandlePressedColor(color);
            break;
        case R.string.scrollbar_color:
            mRecyclerFastScroller.setBarColor(color);
            break;
    }
}
 
Example #23
Source File: SettingsActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
private void showAccentColorPicker() {
    new ColorChooserDialog.Builder(this, R.string.select_accent_color)
            .allowUserColorInput(false)
            .preselect(ColorUtils.accentColor())
            .allowUserColorInputAlpha(false)
            .titleSub(R.string.select_accent_color)
            .accentMode(true)
            .backButton(R.string.text_back)
            .doneButton(R.string.done_label)
            .cancelButton(R.string.text_cancel)
            .show();
}
 
Example #24
Source File: SettingsActivity.java    From Phonograph with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onColorChooserDismissed(@NonNull ColorChooserDialog dialog) {
}
 
Example #25
Source File: SettingsFragment.java    From EdXposedManager with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onPreferenceClick(Preference preference) {
    SettingsActivity act = (SettingsActivity) getActivity();
    if (act == null)
        return false;

    if (preference.getKey().equals("colors")) {
        new ColorChooserDialog.Builder(act, R.string.choose_color)
                .backButton(R.string.back)
                .allowUserColorInput(false)
                .customColors(PRIMARY_COLORS, null)
                .doneButton(R.string.ok)
                .preselect(XposedApp.getColor(act)).show();
    } else if (preference.getKey().equals(downloadLocation.getKey())) {
        if (checkPermissions()) {
            mClickedPreference = downloadLocation;
            return false;
        }

        new FolderChooserDialog.Builder(act)
                .cancelButton(android.R.string.cancel)
                .initialPath(XposedApp.getDownloadPath())
                .show();
    } else if (preference.getKey().equals(stopVerboseLog.getKey())) {
        new Runnable() {
            @Override
            public void run() {
                BaseFragment.areYouSure(requireActivity(), getString(R.string.settings_summary_stop_log), (d, w) -> Shell.su("pkill -P $(cat " + mVerboseLogProcessID.getAbsolutePath() + ")").exec(), (d, w) -> {
                });
            }
        };
    } else if (preference.getKey().equals(stopLog.getKey())) {
        new Runnable() {
            @Override
            public void run() {
                BaseFragment.areYouSure(requireActivity(), getString(R.string.settings_summary_stop_log), (d, w) -> Shell.su("pkill -P $(cat " + mModulesLogProcessID.getAbsolutePath() + ")").exec(), (d, w) -> {
                });
            }
        };
    }
    return true;
}
 
Example #26
Source File: CommonActivity.java    From OmniList with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void onColorChooserDismissed(@NonNull ColorChooserDialog dialog) {}
 
Example #27
Source File: GeneralPreferenceFragment.java    From Toutiao with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_general);
    context = (SettingActivity) getActivity();
    setHasOptionsMenu(true);
    setText();

    findPreference("auto_nightMode").setOnPreferenceClickListener(preference -> {
        context.startWithFragment(AutoNightModeFragment.class.getName(), null, null, 0, null);
        return true;
    });

    findPreference("text_size").setOnPreferenceClickListener(preference -> {
        context.startWithFragment(TextSizeFragment.class.getName(), null, null, 0, null);
        return true;
    });

    findPreference("custom_icon").setOnPreferenceChangeListener((preference, newValue) -> {

        int selectValue = Integer.parseInt((String) newValue);
        int drawable = Constant.ICONS_DRAWABLES[selectValue];

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ActivityManager.TaskDescription tDesc = new ActivityManager.TaskDescription(
                    getString(R.string.app_name),
                    BitmapFactory.decodeResource(getResources(), drawable),
                    SettingUtil.getInstance().getColor());
            context.setTaskDescription(tDesc);
        }

        return true;
    });

    findPreference("color").setOnPreferenceClickListener(preference -> {
        new ColorChooserDialog.Builder(context, R.string.choose_theme_color)
                .backButton(R.string.back)
                .cancelButton(R.string.cancel)
                .doneButton(R.string.done)
                .customButton(R.string.custom)
                .presetsButton(R.string.back)
                .allowUserColorInputAlpha(false)
                .show(context);
        return false;
    });

    colorPreview = (IconPreference) findPreference("color");

    findPreference("nav_bar").setOnPreferenceClickListener(preference -> {
        int color = SettingUtil.getInstance().getColor();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (SettingUtil.getInstance().getNavBar()) {
                context.getWindow().setNavigationBarColor(CircleView.shiftColorDown(CircleView.shiftColorDown(color)));
            } else {
                context.getWindow().setNavigationBarColor(Color.BLACK);
            }
        }
        return false;
    });

    findPreference("clearCache").setOnPreferenceClickListener(preference -> {
        CacheDataManager.clearAllCache(context);
        Snackbar.make(getView(), R.string.clear_cache_successfully, Snackbar.LENGTH_SHORT).show();
        setText();
        return false;
    });

    try {
        String version = "当前版本 " + context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        findPreference("version").setSummary(version);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    findPreference("changelog").setOnPreferenceClickListener(preference -> {
        context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.changelog_url))));
        return false;
    });

    findPreference("licenses").setOnPreferenceClickListener(preference -> {
        createLicenseDialog();
        return false;
    });

    findPreference("sourceCode").setOnPreferenceClickListener(preference -> {
        context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.source_code_url))));
        return false;
    });

    findPreference("copyRight").setOnPreferenceClickListener(preference -> {
        new AlertDialog.Builder(context)
                .setTitle(R.string.copyright)
                .setMessage(R.string.copyright_content)
                .setCancelable(true)
                .show();
        return false;
    });
}
 
Example #28
Source File: PreferencesActivity.java    From always-on-amoled with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    Utils.logDebug(ContextConstatns.MAIN_SERVICE_LOG_TAG, String.valueOf(selectedColor));
    prefs.setInt(Prefs.KEYS.TEXT_COLOR.toString(), selectedColor);
}
 
Example #29
Source File: PreferencesActivity.java    From always-on-amoled with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    prefs = new Prefs(getApplicationContext());
    prefs.apply();
    DonateActivity.resetPaymentService(this);
    if (!prefs.permissionGranting) {
        startActivity(new Intent(getApplicationContext(), Intro.class));
        finish();
    } else {
        setContentView(R.layout.activity_main);
        getFragmentManager().beginTransaction()
                .replace(R.id.preferences_holder, new SettingsFragment())
                .commitAllowingStateLoss();

        handlePermissions();

        Intent starterServiceIntent = new Intent(getApplicationContext(), StarterService.class);

        donateButtonSetup();

        findViewById(R.id.preview).setOnClickListener(view -> {
            demo = true;
            Intent demoService = new Intent(getApplicationContext(), MainService.class);
            demoService.putExtra("demo", true);
            startService(demoService);
        });

        appRate();

        stopService(starterServiceIntent);
        startService(starterServiceIntent);

        Globals.colorDialog = new ColorChooserDialog.Builder(this, R.string.settings_text_color)
                .titleSub(R.string.settings_text_color_desc)
                .doneButton(R.string.md_done_label)
                .cancelButton(R.string.md_cancel_label)
                .backButton(R.string.md_back_label)
                .preselect(-1)
                .accentMode(true)
                .dynamicButtonColor(false);
    }
}
 
Example #30
Source File: CommonActivity.java    From OmniList with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, int selectedColor) {}