Java Code Examples for android.widget.Switch#setVisibility()

The following examples show how to use android.widget.Switch#setVisibility() . 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: SeekBarForm.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
@SuppressLint("InflateParams")
public View inflate(Context context) {
	LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	View view = inflater.inflate(R.layout.dialog_seek_bar_preference, null);
	((TextView) view.findViewById(R.id.min_value)).setText(Integer.toString((int) (minValue * multipler)));
	((TextView) view.findViewById(R.id.max_value)).setText(Integer.toString((int) (maxValue * multipler)));
	seekBar = view.findViewById(R.id.seek_bar);
	seekBar.setMax((maxValue - minValue) / step);
	seekBar.setProgress((currentValue - minValue) / step);
	seekBar.setOnSeekBarChangeListener(this);
	Switch switchView = view.findViewById(R.id.switch_view);
	if (!showSwitch) {
		switchView.setVisibility(View.GONE);
	} else {
		switchView.setChecked(switchValue);
		switchView.setOnCheckedChangeListener(this);
		if (C.API_LOLLIPOP) {
			((ViewGroup.MarginLayoutParams) switchView.getLayoutParams()).rightMargin = 0;
		}
	}
	valueText = view.findViewById(R.id.current_value);
	updateCurrentValueText();
	return view;
}
 
Example 2
Source File: main_activity.java    From telegram-sms with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void set_privacy_mode_checkbox(TextView chat_id, Switch chat_command, Switch privacy_mode_switch) {
    if (!chat_command.isChecked()) {
        privacy_mode_switch.setVisibility(View.GONE);
        privacy_mode_switch.setChecked(false);
        return;
    }
    if (public_func.parse_long(chat_id.getText().toString()) < 0) {
        privacy_mode_switch.setVisibility(View.VISIBLE);
    } else {
        privacy_mode_switch.setVisibility(View.GONE);
        privacy_mode_switch.setChecked(false);
    }
}
 
Example 3
Source File: Misc.java    From SystemUITuner2 with MIT License 5 votes vote down vote up
private void setupSwitches() {
    Switch show_full_zen = view.findViewById(R.id.show_full_zen);
    Switch hu_notif = view.findViewById(R.id.hu_notif);
    Switch vol_warn = view.findViewById(R.id.vol_warn);
    Switch power_notifs = view.findViewById(R.id.power_notifications);
    Switch clock_seconds = view.findViewById(R.id.clock_seconds);
    Switch battery_percent = view.findViewById(R.id.battery_percent);
    CardView power_notif_controls = view.findViewById(R.id.power_notification_controls_card);

    //noinspection deprecation
    battery_percent.setText(Html.fromHtml(getResources().getText(R.string.battery_percentage) + "<br /><small> <font color=\"#777777\">" + getResources().getText(R.string.reboot_required) + "</font></small>"));

    if (Build.VERSION.SDK_INT > 23) {
        clock_seconds.setVisibility(View.VISIBLE); //only show switch if user is on Nougat or later
        power_notif_controls.setVisibility(View.VISIBLE); //this is a Nougat feature; only show it on Nougat devices
    } else {
        clock_seconds.setVisibility(View.GONE);
        power_notif_controls.setVisibility(View.GONE);
    }

    activity.setThings.switches(show_full_zen, SHOW_FULL_ZEN, SECURE, view); //switch listener
    activity.setThings.switches(hu_notif, HUN_ENABLED, GLOBAL, view);
    activity.setThings.switches(vol_warn, SAFE_AUDIO, GLOBAL, view);

    activity.setThings.switches(clock_seconds, CLOCK_SECONDS, SECURE, view);
    activity.setThings.switches(battery_percent, BATTERY_PERCENT, SYSTEM, view);

    activity.setThings.switches(power_notifs, POW_NOTIFS, SECURE, view);
}
 
Example 4
Source File: BaseSet.java    From MainScreenShow with GNU General Public License v2.0 5 votes vote down vote up
/**
 * show Switch 事件开关
 *
 * @param convertView
 * @param title
 */
protected void showEventStart(View convertView, String title) {

    TextView title1 = (TextView) convertView
            .findViewById(R.id.tv_msseventset_title);
    Switch sw = (Switch) convertView.findViewById(R.id.sw_msseventset);
    title1.setText(title);
    sw.setVisibility(View.VISIBLE);
    if (sp_date.getString("state" + VALUE, "").equals(getString(R.string.action_started)))

        sw.setChecked(true);
    else
        sw.setChecked(false);
    sw.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView,
                                     boolean isChecked) {

            if (isChecked) {
                sp_date.edit().putString("state" + VALUE, getString(R.string.action_started)).commit();
                listLength = setLenght + baseLenght + animationLenght;
                adapter.notifyDataSetChanged();
            } else {
                sp_date.edit().putString("state" + VALUE, getString(R.string.action_stoped)).commit();
                listLength = baseLenght;
                adapter.notifyDataSetChanged();
            }
        }
    });
}
 
Example 5
Source File: BaseSet.java    From MainScreenShow with GNU General Public License v2.0 5 votes vote down vote up
/**
 * show Switch Bubble 变色
 *
 * @param convertView
 */
protected void showBubble_Color(View convertView) {

    if (sp_date
            .getString("animation" + VALUE, "")
            .equals(PropertiesUtils.getAnimationInfo(BaseSet.this)[C.ANIMATION_BUBBLE])) {
        TextView title_ = (TextView) convertView
                .findViewById(R.id.tv_msseventset_title_);
        TextView tip = (TextView) convertView
                .findViewById(R.id.tv_msseventset_tip);
        Switch sw = (Switch) convertView.findViewById(R.id.sw_msseventset);
        title_.setText(R.string.setting_bubble_changeColor);
        tip.setText(R.string.tip_bubble_color);
        sp_setA = getSharedPreferences(
                eventName
                        + PropertiesUtils.getAnimationInfo(BaseSet.this)[C.ANIMATION_BUBBLE],
                0);

        sw.setVisibility(View.VISIBLE);
        sw.setChecked(sp_setA.getBoolean("color", true));
        sw.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView,
                                         boolean isChecked) {

                sp_setA.edit().putBoolean("color", isChecked).commit();

            }
        });
    }
}
 
Example 6
Source File: BaseSet.java    From MainScreenShow with GNU General Public License v2.0 5 votes vote down vote up
/**
 * show Switch SharsShine 流星开关
 *
 * @param convertView
 */
protected void showStarsShine_StaemeteorSwitch(View convertView) {

    if (sp_date.getString("animation" + VALUE, "")
            .equals(PropertiesUtils
                    .getAnimationInfo(BaseSet.this)[C.ANIMATION_STARSHINE])) {

        TextView title_ = (TextView) convertView
                .findViewById(R.id.tv_msseventset_title_);
        TextView tip = (TextView) convertView
                .findViewById(R.id.tv_msseventset_tip);
        Switch sw = (Switch) convertView.findViewById(R.id.sw_msseventset);
        title_.setText(R.string.setting_starShine_meteor);
        tip.setText(R.string.tip_starshine_starmeteorswitch);
        sp_setA = getSharedPreferences(
                eventName
                        + PropertiesUtils
                        .getAnimationInfo(BaseSet.this)[C.ANIMATION_STARSHINE],
                0);
        sw.setVisibility(View.VISIBLE);
        sw.setChecked(sp_setA.getBoolean("starmeteorswitch",
                true));
        sw.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(
                    CompoundButton buttonView, boolean isChecked) {

                sp_setA.edit()
                        .putBoolean("starmeteorswitch",
                                isChecked).commit();

            }
        });
    }
}
 
Example 7
Source File: ShareActivity.java    From Shaarlier with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Open a dialog for the user to change the description of the share
 */
private void openDialog() {
    setContentView(R.layout.activity_share);

    initAccountSpinner();

    if (NetworkUtils.isUrl(defaults.getUrl())) {
        prefetchLink(defaults);
        autoLoadTitleAndDescription(defaults);
        updateLoadersVisibility();
    }

    ((EditText) findViewById(R.id.url)).setText(defaults.getUrl());


    MultiAutoCompleteTextView textView = findViewById(R.id.tags);
    ((EditText) findViewById(R.id.tags)).setText(defaults.getTags());
    new AutoCompleteWrapper(textView, this);

    ((Checkable) findViewById(R.id.private_share)).setChecked(defaults.isPrivate());

    // Init the tweet button if necessary:
    Switch tweetCheckBox = findViewById(R.id.tweet);
    tweetCheckBox.setChecked(userPrefs.isTweet());
    if (!userPrefs.isTweet()) {
        tweetCheckBox.setVisibility(View.GONE);
    } else {
        tweetCheckBox.setVisibility(View.VISIBLE);
    }

    // Init the toot button if necessary:
    Switch tootCheckBox = findViewById(R.id.toot);
    tootCheckBox.setChecked(userPrefs.isToot());
    if (!userPrefs.isToot()) {
        tootCheckBox.setVisibility(View.GONE);
    } else {
        tootCheckBox.setVisibility(View.VISIBLE);
    }
}
 
Example 8
Source File: SettingsPinnedHeaderAdapter.java    From Trebuchet with GNU General Public License v3.0 4 votes vote down vote up
private void setStateText(TextView stateView, Switch settingSwitch, String state) {
    stateView.setText(state);
    stateView.setVisibility(View.VISIBLE);
    settingSwitch.setVisibility(View.INVISIBLE);
}
 
Example 9
Source File: SettingsPinnedHeaderAdapter.java    From Trebuchet with GNU General Public License v3.0 4 votes vote down vote up
private void setSettingSwitch(TextView stateView, Switch settingSwitch, boolean isChecked) {
    settingSwitch.setChecked(isChecked);
    settingSwitch.setVisibility(View.VISIBLE);
    stateView.setVisibility(View.INVISIBLE);
}
 
Example 10
Source File: SettingsPinnedHeaderAdapter.java    From Trebuchet with GNU General Public License v3.0 4 votes vote down vote up
private void hideStates(TextView stateView, Switch settingSwitch) {
    settingSwitch.setVisibility(View.INVISIBLE);
    stateView.setVisibility(View.INVISIBLE);
}
 
Example 11
Source File: BaseSet.java    From MainScreenShow with GNU General Public License v2.0 4 votes vote down vote up
/**
 * show Switch 事件开关
 *
 * @param convertView
 * @param title
 */
protected void showEventStartForDesktop(View convertView, String title,boolean isStart) {

    TextView title1 = (TextView) convertView
            .findViewById(R.id.tv_msseventset_title);
    final Switch sw = (Switch) convertView.findViewById(R.id.sw_msseventset);
    title1.setText(title);
    sw.setVisibility(View.VISIBLE);
    if(isStart){
        sw.setChecked(true);
    }else{
        sw.setChecked(false);
    }
    sw.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView,
                                     boolean isChecked) {

            if (isChecked) {
                new AlertDialog.Builder(BaseSet.this).setTitle(R.string.tip)
                        .setMessage("请设置桌面秀动态壁纸,以此激活桌面动画!")
                        .setPositiveButton("前往", new OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Intent intent = new Intent();
                                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
                                startActivity(intent);
                                listLength = setLenght + baseLenght + animationLenght;
                                adapter.notifyDataSetChanged();
                            }
                        }).setNegativeButton(R.string.action_cancel, null).show();
                sw.setChecked(false);

            } else {
                new AlertDialog.Builder(BaseSet.this).setTitle(R.string.tip)
                        .setMessage("请设重新设置壁纸,即可关闭桌面动画!")
                        .setPositiveButton(R.string.action_ok, null).show();
                sw.setChecked(true);
            }
        }
    });
}
 
Example 12
Source File: BaseSet.java    From MainScreenShow with GNU General Public License v2.0 4 votes vote down vote up
/**
 * show Switch PictureWall 锁屏专属(仅播放一张图片)
 *
 * @param convertView
 */
protected void showPictureWall_LockScreen(View convertView) {
    if (sp_date
            .getString("animation" + VALUE, "")
            .equals(PropertiesUtils
                    .getAnimationInfo(BaseSet.this)[C.ANIMATION_PICTUREWALL])) {
        TextView title_ = (TextView) convertView
                .findViewById(R.id.tv_msseventset_title_);
        TextView tip = (TextView) convertView
                .findViewById(R.id.tv_msseventset_tip);
        title_.setText(R.string.setting_pictureWall_onlyOne);
        tip.setText(R.string.tip_picturewall_onlyone);
        sp_setA = getSharedPreferences(
                eventName
                        + PropertiesUtils
                        .getAnimationInfo(BaseSet.this)[C.ANIMATION_PICTUREWALL],
                0);
        Switch sw = (Switch) convertView
                .findViewById(R.id.sw_msseventset);
        sw.setVisibility(View.VISIBLE);
        sw.setChecked(sp_setA.getBoolean("onlyone", false));
        sw.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(
                    CompoundButton buttonView, boolean isChecked) {

                sp_setA.edit().putBoolean("onlyone", isChecked)
                        .commit();
                if (isChecked) {
                    new AlertDialog.Builder(BaseSet.this)
                            .setTitle(R.string.tip)
                            .setMessage(
                                    getString(R.string.tip_msg_picture))
                            .setNegativeButton(R.string.action_ok, null)
                            .show();
                }
            }
        });
    }
}