Search in sources :

Example 11 with SwitchCompat

use of android.support.v7.widget.SwitchCompat in project LeafPic by HoraApps.

the class SettingsActivity method customizePictureViewer.

private void customizePictureViewer() {
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
    View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_media_viewer_theme, null);
    final SwitchCompat swApplyTheme_Viewer = (SwitchCompat) dialogLayout.findViewById(R.id.apply_theme_3th_act_enabled);
    ((CardView) dialogLayout.findViewById(R.id.third_act_theme_card)).setCardBackgroundColor(getCardBackgroundColor());
    //or GetPrimary
    dialogLayout.findViewById(R.id.third_act_theme_title).setBackgroundColor(getPrimaryColor());
    ((TextView) dialogLayout.findViewById(R.id.apply_theme_3thAct_title)).setTextColor(getTextColor());
    ((TextView) dialogLayout.findViewById(R.id.apply_theme_3thAct_title_Sub)).setTextColor(getSubTextColor());
    ((IconicsImageView) dialogLayout.findViewById(R.id.ll_apply_theme_3thAct_icon)).setColor(getIconColor());
    swApplyTheme_Viewer.setChecked(isApplyThemeOnImgAct());
    swApplyTheme_Viewer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateSwitchColor(swApplyTheme_Viewer, getAccentColor());
        }
    });
    updateSwitchColor(swApplyTheme_Viewer, getAccentColor());
    final LineColorPicker transparencyColorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.pickerTransparent);
    transparencyColorPicker.setColors(ColorPalette.getTransparencyShadows(getPrimaryColor()));
    transparencyColorPicker.setSelectedColor(ColorPalette.getTransparentColor(getPrimaryColor(), getTransparency()));
    /**TEXT VIEWS**/
    ((TextView) dialogLayout.findViewById(R.id.seek_bar_alpha_title)).setTextColor(getTextColor());
    ((TextView) dialogLayout.findViewById(R.id.seek_bar_alpha_title_Sub)).setTextColor(getSubTextColor());
    dialogBuilder.setView(dialogLayout);
    dialogBuilder.setNeutralButton(getString(R.string.cancel).toUpperCase(), null);
    dialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            SharedPreferences.Editor editor = SP.getEditor();
            editor.putBoolean(getString(R.string.preference_apply_theme_pager), swApplyTheme_Viewer.isChecked());
            int c = Color.alpha(transparencyColorPicker.getColor());
            editor.putInt(getString(R.string.preference_transparency), 255 - c);
            editor.commit();
            updateTheme();
        }
    });
    dialogBuilder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) CardView(android.support.v7.widget.CardView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) LineColorPicker(uz.shift.colorpicker.LineColorPicker) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 12 with SwitchCompat

use of android.support.v7.widget.SwitchCompat in project AndroidChromium by JackyAndroid.

the class DataReductionProxyFirstRunFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final SwitchCompat enableDataSaverSwitch = (SwitchCompat) view.findViewById(R.id.enable_data_saver_switch);
    Button nextButton = (Button) view.findViewById(R.id.next_button);
    enableDataSaverSwitch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            DataReductionProxySettings.getInstance().setDataReductionProxyEnabled(v.getContext(), enableDataSaverSwitch.isChecked());
            if (enableDataSaverSwitch.isChecked()) {
                enableDataSaverSwitch.setText(R.string.data_reduction_enabled_switch);
            } else {
                enableDataSaverSwitch.setText(R.string.data_reduction_disabled_switch);
            }
        }
    });
    nextButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            advanceToNextPage();
        }
    });
    enableDataSaverSwitch.setChecked(true);
    DataReductionProxySettings.getInstance().setDataReductionProxyEnabled(view.getContext(), enableDataSaverSwitch.isChecked());
}
Also used : Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) View(android.view.View) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 13 with SwitchCompat

use of android.support.v7.widget.SwitchCompat in project AndroidChromium by JackyAndroid.

the class InfoBarControlLayout method addSwitch.

/**
     * Creates a standard toggle switch and adds it to the layout.
     *
     * -------------------------------------------------
     * | ICON | MESSAGE                       | TOGGLE |
     * -------------------------------------------------
     * If an icon is not provided, the ImageView that would normally show it is hidden.
     *
     * @param iconResourceId ID of the drawable to use for the icon, or 0 to hide the ImageView.
     * @param iconColorId    ID of the tint color for the icon, or 0 for default.
     * @param toggleMessage  Message to display for the toggle.
     * @param toggleId       ID to use for the toggle.
     * @param isChecked      Whether the toggle should start off checked.
     */
public View addSwitch(int iconResourceId, int iconColorId, CharSequence toggleMessage, int toggleId, boolean isChecked) {
    LinearLayout switchLayout = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.infobar_control_toggle, this, false);
    addView(switchLayout, new ControlLayoutParams());
    ImageView iconView = (ImageView) switchLayout.findViewById(R.id.control_icon);
    if (iconResourceId == 0) {
        switchLayout.removeView(iconView);
    } else {
        iconView.setImageResource(iconResourceId);
        if (iconColorId != 0) {
            iconView.setColorFilter(ApiCompatibilityUtils.getColor(getResources(), iconColorId));
        }
    }
    TextView messageView = (TextView) switchLayout.findViewById(R.id.control_message);
    messageView.setText(toggleMessage);
    SwitchCompat switchView = (SwitchCompat) switchLayout.findViewById(R.id.control_toggle_switch);
    switchView.setId(toggleId);
    switchView.setChecked(isChecked);
    return switchLayout;
}
Also used : TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 14 with SwitchCompat

use of android.support.v7.widget.SwitchCompat in project wire-android by wireapp.

the class CustomMatchers method otrSwitchWithId.

public static Matcher<View> otrSwitchWithId(final int id) {
    return new TypeSafeMatcher<View>() {

        Resources resources = null;

        @Override
        public void describeTo(Description description) {
            String idDescription = Integer.toString(id);
            if (resources != null) {
                try {
                    idDescription = resources.getResourceName(id);
                } catch (Resources.NotFoundException e) {
                    // No big deal, will just use the int value.
                    idDescription = String.format("%s (resource name not found)", id);
                }
            }
            description.appendText("with id: " + idDescription);
        }

        @Override
        public boolean matchesSafely(View view) {
            resources = view.getResources();
            ViewParent parent = view.getParent();
            return parent != null && parent instanceof OtrSwitch && id == ((OtrSwitch) parent).getId() && view instanceof SwitchCompat;
        }
    };
}
Also used : TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Description(org.hamcrest.Description) ViewParent(android.view.ViewParent) Resources(android.content.res.Resources) OtrSwitch(com.waz.zclient.ui.views.e2ee.OtrSwitch) View(android.view.View) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 15 with SwitchCompat

use of android.support.v7.widget.SwitchCompat in project ahbottomnavigation by aurelhubert.

the class DemoFragment method initDemoSettings.

/**
	 * Init demo settings
	 */
private void initDemoSettings(View view) {
    final DemoActivity demoActivity = (DemoActivity) getActivity();
    final SwitchCompat switchColored = (SwitchCompat) view.findViewById(R.id.fragment_demo_switch_colored);
    final SwitchCompat switchFiveItems = (SwitchCompat) view.findViewById(R.id.fragment_demo_switch_five_items);
    final SwitchCompat showHideBottomNavigation = (SwitchCompat) view.findViewById(R.id.fragment_demo_show_hide);
    final SwitchCompat showSelectedBackground = (SwitchCompat) view.findViewById(R.id.fragment_demo_selected_background);
    final SwitchCompat switchForceTitleHide = (SwitchCompat) view.findViewById(R.id.fragment_demo_force_title_hide);
    final SwitchCompat switchTranslucentNavigation = (SwitchCompat) view.findViewById(R.id.fragment_demo_translucent_navigation);
    switchColored.setChecked(demoActivity.isBottomNavigationColored());
    switchFiveItems.setChecked(demoActivity.getBottomNavigationNbItems() == 5);
    switchTranslucentNavigation.setChecked(getActivity().getSharedPreferences("shared", Context.MODE_PRIVATE).getBoolean("translucentNavigation", false));
    switchTranslucentNavigation.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? View.VISIBLE : View.GONE);
    switchTranslucentNavigation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            getActivity().getSharedPreferences("shared", Context.MODE_PRIVATE).edit().putBoolean("translucentNavigation", isChecked).apply();
            demoActivity.reload();
        }
    });
    switchColored.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            demoActivity.updateBottomNavigationColor(isChecked);
        }
    });
    switchFiveItems.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            demoActivity.updateBottomNavigationItems(isChecked);
        }
    });
    showHideBottomNavigation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            demoActivity.showOrHideBottomNavigation(isChecked);
        }
    });
    showSelectedBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            demoActivity.updateSelectedBackgroundVisibility(isChecked);
        }
    });
    switchForceTitleHide.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            demoActivity.setForceTitleHide(isChecked);
        }
    });
}
Also used : CompoundButton(android.widget.CompoundButton) SwitchCompat(android.support.v7.widget.SwitchCompat)

Aggregations

SwitchCompat (android.support.v7.widget.SwitchCompat)29 TextView (android.widget.TextView)20 View (android.view.View)19 CompoundButton (android.widget.CompoundButton)19 Intent (android.content.Intent)7 ImageView (android.widget.ImageView)7 AlertDialog (android.support.v7.app.AlertDialog)6 ScrollView (android.widget.ScrollView)6 DialogInterface (android.content.DialogInterface)5 SearchView (android.support.v7.widget.SearchView)4 MenuItem (android.view.MenuItem)4 CheckerBoardDrawable (com.facebook.fresco.samples.showcase.misc.CheckerBoardDrawable)4 CardView (android.support.v7.widget.CardView)3 LayoutInflater (android.view.LayoutInflater)3 ViewGroup (android.view.ViewGroup)3 AdapterView (android.widget.AdapterView)3 LinearLayout (android.widget.LinearLayout)3 Spinner (android.widget.Spinner)3 ArrayList (java.util.ArrayList)3 ClipData (android.content.ClipData)2