Search in sources :

Example 1 with SecurityHelper

use of org.horaapps.leafpic.util.SecurityHelper in project LeafPic by HoraApps.

the class SettingsActivity method onPostCreate.

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    SP = PreferenceUtil.getInstance(getApplicationContext());
    securityObj = new SecurityHelper(SettingsActivity.this);
    txtTT = (TextView) findViewById(R.id.theme_setting_title);
    txtGT = (TextView) findViewById(R.id.general_setting_title);
    txtPT = (TextView) findViewById(R.id.picture_setting_title);
    txtVT = (TextView) findViewById(R.id.video_setting_title);
    txtAT = (TextView) findViewById(R.id.advanced_setting_title);
    scr = (ScrollView) findViewById(R.id.settingAct_scrollView);
    /*** BASIC THEME ***/
    findViewById(R.id.ll_basic_theme).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            baseThemeDialog();
        }
    });
    /*** SECURITY ***/
    findViewById(R.id.ll_security).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!securityObj.isActiveSecurity())
                startActivity(new Intent(getApplicationContext(), SecurityActivity.class));
            else
                askPasswordDialog();
        }
    });
    /*** PRIMARY COLOR PIKER ***/
    findViewById(R.id.ll_primaryColor).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            primaryColorPiker();
        }
    });
    /*** ACCENT COLOR PIKER ***/
    findViewById(R.id.ll_accentColor).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            accentColorPiker();
        }
    });
    /*** EXCLUDED ALBUMS INTENT ***/
    findViewById(R.id.ll_excluded_album).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(SettingsActivity.this, ExcludedAlbumsActivity.class));
        }
    });
    /*** CUSTOMIZE PICTURE VIEWER DIALOG ***/
    findViewById(R.id.ll_custom_thirdAct).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            customizePictureViewer();
        }
    });
    /*** MAP PROVIDER DIALOG ***/
    findViewById(R.id.ll_map_provider).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mapProviderDialog();
        }
    });
    /*** MULTI COLUMN DIALOG ***/
    findViewById(R.id.ll_n_columns).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            multiColumnsDialog();
        }
    });
    /*** SW Show Fab ***/
    swShowFab = (SwitchCompat) findViewById(R.id.sw_show_fab);
    swShowFab.setChecked(SP.getBoolean(getString(R.string.preference_show_fab), false));
    swShowFab.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_show_fab), isChecked);
            updateSwitchColor(swShowFab, getAccentColor());
        }
    });
    /*** SW Show Fab ***/
    swSubScaling = (SwitchCompat) findViewById(R.id.sw_sub_scaling);
    swSubScaling.setChecked(SP.getBoolean(getString(R.string.preference_sub_scaling), false));
    swSubScaling.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_sub_scaling), isChecked);
            updateSwitchColor(swSubScaling, getAccentColor());
        }
    });
    /*** SW Internal Player ***/
    swInternalBrowser = (SwitchCompat) findViewById(R.id.set_internal_player);
    swInternalBrowser.setChecked(SP.getBoolean(getString(R.string.preference_internal_player), false));
    swInternalBrowser.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_internal_player), isChecked);
            new Thread(new Runnable() {

                @Override
                public void run() {
                    ((MyApplication) getApplicationContext()).updateAlbums();
                }
            }).start();
            updateSwitchColor(swInternalBrowser, getAccentColor());
        }
    });
    /*** SW INCLUDE VIDEO ***/
    swIncludeVideo = (SwitchCompat) findViewById(R.id.set_include_video);
    swIncludeVideo.setChecked(SP.getBoolean(getString(R.string.preference_include_video), true));
    swIncludeVideo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_include_video), isChecked);
            updateSwitchColor(swIncludeVideo, getAccentColor());
        }
    });
    /*** SW SWIPE DIRECTION ***/
    swSwipeDirection = (SwitchCompat) findViewById(R.id.Set_media_viewer_swipe_direction);
    swSwipeDirection.setChecked(SP.getBoolean(getString(R.string.preference_swipe_direction_inverted), false));
    swSwipeDirection.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_swipe_direction_inverted), isChecked);
            updateSwitchColor(swSwipeDirection, getAccentColor());
        }
    });
    /*** SW AUTO UPDATE MEDIA ***/
    swAutoUpdate = (SwitchCompat) findViewById(R.id.SetAutoUpdateMedia);
    swAutoUpdate.setChecked(SP.getBoolean(getString(R.string.preference_auto_update_media), false));
    swAutoUpdate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_auto_update_media), isChecked);
            updateSwitchColor(swAutoUpdate, getAccentColor());
        }
    });
    /*** SW MEDIA STORE ***/
    swUseMediaStore = (SwitchCompat) findViewById(R.id.sw_use_media_mediastore);
    swUseMediaStore.setChecked(SP.getBoolean(getString(R.string.preference_use_alternative_provider), false));
    swUseMediaStore.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_use_alternative_provider), isChecked);
            updateSwitchColor(swUseMediaStore, getAccentColor());
        }
    });
    /*** SW DELAY FULL-SIZE IMAGE ***/
    swDelayFullImage = (SwitchCompat) findViewById(R.id.set_full_resolution);
    swDelayFullImage.setChecked(SP.getBoolean(getString(R.string.preference_delay_full_image), true));
    swDelayFullImage.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_delay_full_image), isChecked);
            updateSwitchColor(swDelayFullImage, getAccentColor());
        }
    });
    /*** SW PICTURE ORIENTATION ***/
    swPictureOrientation = (SwitchCompat) findViewById(R.id.set_picture_orientation);
    swPictureOrientation.setChecked(SP.getBoolean(getString(R.string.preference_auto_rotate), false));
    swPictureOrientation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_auto_rotate), isChecked);
            updateSwitchColor(swPictureOrientation, getAccentColor());
        }
    });
    /*** SW MAX LUMINOSITY ***/
    swMaxLuminosity = (SwitchCompat) findViewById(R.id.set_max_luminosity);
    swMaxLuminosity.setChecked(SP.getBoolean(getString(R.string.preference_max_brightness), false));
    swMaxLuminosity.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_max_brightness), isChecked);
            updateSwitchColor(swMaxLuminosity, getAccentColor());
        }
    });
    /*** SW TRANSLUCENT STATUS BAR ***/
    swStatusBar = (SwitchCompat) findViewById(R.id.SetTraslucentStatusBar);
    swStatusBar.setChecked(SP.getBoolean(getString(R.string.preference_translucent_status_bar), true));
    swStatusBar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_translucent_status_bar), isChecked);
            updateTheme();
            setStatusBarColor();
            updateSwitchColor(swStatusBar, getAccentColor());
        }
    });
    /*** SW COLORED NAV BAR ***/
    swNavBar = (SwitchCompat) findViewById(R.id.SetColoredNavBar);
    swNavBar.setChecked(SP.getBoolean(getString(R.string.preference_colored_nav_bar), false));
    swNavBar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SP.putBoolean(getString(R.string.preference_colored_nav_bar), isChecked);
            updateTheme();
            updateSwitchColor(swNavBar, getAccentColor());
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                getWindow().setNavigationBarColor(isNavigationBarColored() ? getPrimaryColor() : ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
        }
    });
}
Also used : Intent(android.content.Intent) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) CompoundButton(android.widget.CompoundButton) SecurityHelper(org.horaapps.leafpic.util.SecurityHelper)

Aggregations

Intent (android.content.Intent)1 CardView (android.support.v7.widget.CardView)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 IconicsImageView (com.mikepenz.iconics.view.IconicsImageView)1 SecurityHelper (org.horaapps.leafpic.util.SecurityHelper)1