Java Code Examples for android.widget.CheckBox#setVisibility()
The following examples show how to use
android.widget.CheckBox#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: FragmentAnswer.java From FairEmail with GNU General Public License v3.0 | 6 votes |
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { Spanned spanned = HtmlHelper.fromHtml("<p>" + getString(R.string.title_answer_template_name) + "<br>" + getString(R.string.title_answer_template_email) + "</p>", false, getContext()); View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_ask_again, null); TextView tvMessage = dview.findViewById(R.id.tvMessage); CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain); tvMessage.setText(spanned); cbNotAgain.setVisibility(View.GONE); return new AlertDialog.Builder(getContext()) .setView(dview) .setNegativeButton(android.R.string.cancel, null) .create(); }
Example 2
Source File: ActivityMain.java From XPrivacyLua with GNU General Public License v3.0 | 6 votes |
@Override @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { View row; if (null == convertView) row = LayoutInflater.from(getContext()).inflate(this.resource, null); else row = convertView; DrawerItem item = getItem(position); TextView tv = row.findViewById(R.id.tvItem); CheckBox cb = row.findViewById(R.id.cbItem); tv.setText(item.getTitle()); cb.setVisibility(item.isCheckable() ? View.VISIBLE : View.GONE); cb.setChecked(item.isChecked()); return row; }
Example 3
Source File: SWCheckbox.java From AndroidAPS with GNU Affero General Public License v3.0 | 5 votes |
@Override public void generateDialog(LinearLayout layout) { Context context = layout.getContext(); // Get if there is already value in SP Boolean previousValue; previousValue = SP.getBoolean(preferenceId, false); checkBox = new CheckBox(context); checkBox.setText(label); checkBox.setChecked(previousValue); checkBox.setVisibility(View.VISIBLE); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { ArrayList<PluginBase> pluginsInCategory; pluginsInCategory = MainApp.getSpecificPluginsList(PluginType.PUMP); PluginBase found = null; for (PluginBase p : pluginsInCategory) { if (p.isEnabled(PluginType.PUMP) && found == null) { found = p; } else if (p.isEnabled(PluginType.PUMP)) { // set others disabled p.setPluginEnabled(PluginType.PUMP, false); } } log.debug("Enabled pump plugin:"+found.getClass()); save(checkBox.isChecked()); } }); layout.addView(checkBox); super.generateDialog(layout); }
Example 4
Source File: AuthActivity.java From samba-documents-provider with GNU General Public License v3.0 | 5 votes |
private void prepareUI(String shareUri) { mSharePathEditText = (EditText) findViewById(R.id.share_path); mUsernameEditText = (EditText) findViewById(R.id.username); mDomainEditText = (EditText) findViewById(R.id.domain); mPasswordEditText = (EditText) findViewById(R.id.password); CheckBox passwordCheckbox = (CheckBox) findViewById(R.id.needs_password); mPinShareCheckbox = (CheckBox) findViewById(R.id.pin_share); mSharePathEditText.setText(shareUri); mSharePathEditText.setEnabled(false); passwordCheckbox.setVisibility(View.GONE); mPinShareCheckbox.setVisibility(View.VISIBLE); Button mLoginButton = (Button) findViewById(R.id.mount); mLoginButton.setText(getResources().getString(R.string.login)); mLoginButton.setOnClickListener(mLoginListener); final Button cancel = (Button) findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); }
Example 5
Source File: SettingView.java From qplayer-sdk with MIT License | 5 votes |
private View generateGroupView(int groupPosition, String title, String summery, View convertView) { if (null == convertView) convertView = mInflater.inflate(R.layout.set_item, null); ImageView mImageView = (ImageView) convertView.findViewById(R.id.icon); switch(groupPosition) { case POS_VIDEOQUALITY: mImageView.setImageResource(R.drawable.set_videoquality); break; case POS_DOWNLOADFILE: mImageView.setImageResource(R.drawable.set_subtitle); break; case POS_COLORTYPE: mImageView.setImageResource(R.drawable.set_color); break; case POS_VIDEODEC: mImageView.setImageResource(R.drawable.set_subtitle); break; } TextView mTitle = (TextView) convertView.findViewById(R.id.title); mTitle.setText(title); TextView mSummery = (TextView) convertView.findViewById(R.id.summary); mSummery.setText(summery); CheckBox mCheckBox = (CheckBox) convertView.findViewById(R.id.checkbox); if (mLstValue.get(groupPosition).size() == 1) mCheckBox.setChecked(mLstValue.get(groupPosition).get(0)); ImageView mArrow = (ImageView) convertView.findViewById(R.id.selectedIcon); if (getChildrenCount(groupPosition) == 0) { mCheckBox.setVisibility(View.VISIBLE); mArrow.setVisibility(View.GONE); } else { mCheckBox.setVisibility(View.GONE); mArrow.setVisibility(View.VISIBLE); } return convertView; }
Example 6
Source File: RvNoteListAdapter.java From SuperNote with GNU General Public License v3.0 | 5 votes |
/** * 是否显示多选按钮 * * @describe */ private void showCheckBox(CheckBox checkBox, int position) { if (NoteListConstans.isShowMultiSelectAction) { checkBox.setVisibility(View.VISIBLE); if (mCheckList.get(position)) checkBox.setChecked(true); else checkBox.setChecked(false); } else { checkBox.setVisibility(View.INVISIBLE); checkBox.setChecked(false); } }
Example 7
Source File: CheckBoxDialogBuilder.java From Nimingban with Apache License 2.0 | 5 votes |
@SuppressLint("InflateParams") public CheckBoxDialogBuilder(Context context, CharSequence message, String checkText, boolean showCheckbox, boolean checked) { super(context); View view = LayoutInflater.from(context).inflate(R.layout.dialog_checkbox_builder, null); setView(view); TextView messageView = (TextView) view.findViewById(R.id.message); mShowCheckbox = showCheckbox; mCheckBox = (CheckBox) view.findViewById(R.id.checkbox); messageView.setText(message); mCheckBox.setText(checkText); mCheckBox.setChecked(checked); if (!showCheckbox) mCheckBox.setVisibility(View.GONE); }
Example 8
Source File: CreateReplyActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_reply); if (MainActivity.instance instanceof ForumConfig) { HttpGetImageAction.fetchImage(this, MainActivity.instance.avatar, findViewById(R.id.icon)); } else { ((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.icon,80,80); } TextView text = (TextView) findViewById(R.id.topicText); text.setText(MainActivity.post.topic); CheckBox checkbox = (CheckBox) findViewById(R.id.replyToParentCheckBox); if (MainActivity.post.parent != null && MainActivity.post.parent.length() != 0) { checkbox.setChecked(true); } else { checkbox.setVisibility(View.GONE); } final WebView web = (WebView) findViewById(R.id.detailsLabel); web.loadDataWithBaseURL(null, MainActivity.post.detailsText, "text/html", "utf-8", null); web.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { try { view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); } catch (Exception failed) { return false; } return true; } }); }
Example 9
Source File: CreateReplyActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_reply); if (MainActivity.instance instanceof ForumConfig) { HttpGetImageAction.fetchImage(this, MainActivity.instance.avatar, findViewById(R.id.icon)); } else { ((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.icon); } TextView text = (TextView) findViewById(R.id.topicText); text.setText(MainActivity.post.topic); CheckBox checkbox = (CheckBox) findViewById(R.id.replyToParentCheckBox); if (MainActivity.post.parent != null && MainActivity.post.parent.length() != 0) { checkbox.setChecked(true); } else { checkbox.setVisibility(View.GONE); } final WebView web = (WebView) findViewById(R.id.detailsLabel); web.loadDataWithBaseURL(null, MainActivity.post.detailsText, "text/html", "utf-8", null); web.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { try { view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); } catch (Exception failed) { return false; } return true; } }); }
Example 10
Source File: SetSecurityActivity.java From EhViewer with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_set_security); setNavigationIcon(R.drawable.v_arrow_left_dark_x24); mPatternView = (LockPatternView) ViewUtils.$$(this, R.id.pattern_view); mCancel = ViewUtils.$$(this, R.id.cancel); mSet = ViewUtils.$$(this, R.id.set); mFingerprint = (CheckBox) ViewUtils.$$(this, R.id.fingerprint_checkbox); String pattern = Settings.getSecurity(); if (!TextUtils.isEmpty(pattern)) { mPatternView.setPattern(LockPatternView.DisplayMode.Correct, LockPatternUtils.stringToPattern(pattern)); } if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class); // The line below prevents the false positive inspection from Android Studio // noinspection ResourceType if (fingerprintManager != null && hasEnrolledFingerprints(fingerprintManager)) { mFingerprint.setVisibility(View.VISIBLE); mFingerprint.setChecked(Settings.getEnableFingerprint()); } } mCancel.setOnClickListener(this); mSet.setOnClickListener(this); }
Example 11
Source File: FaBoServiceListActivity.java From DeviceConnect-Android with MIT License | 5 votes |
@Override public View getView(final int position, View convertView, ViewGroup viewGroup) { if (convertView == null) { convertView = mInflater.inflate(R.layout.item_fabo_service_list, null); } final DConnectService service = (DConnectService) getItem(position); convertView.setTag(service); convertView.setBackgroundResource(service.isOnline() ? R.color.service_list_item_background_online : R.color.service_list_item_background_offline); TextView statusView = convertView.findViewById(R.id.service_online_status); statusView.setText(service.isOnline() ? R.string.activity_fabo_service_online : R.string.activity_fabo_service_offline); TextView nameView = convertView.findViewById(R.id.service_name); nameView.setText(service.getName()); CheckBox checkBox = convertView.findViewById(R.id.activity_fabo_service_removal_checkbox); checkBox.setVisibility(hasCheckbox(service) ? View.VISIBLE : View.GONE); checkBox.setChecked(mRemoveServices.contains(service)); ImageView imageView = (ImageView) convertView.findViewById(R.id.activity_fabo_service_edit); imageView.setVisibility(hasImageView(service) ? View.VISIBLE : View.GONE); return convertView; }
Example 12
Source File: IRKitVirtualDeviceFragment.java From DeviceConnect-Android with MIT License | 5 votes |
@Override public View getView(final int position, final View convertView, final ViewGroup parent) { View cv = convertView; if (cv == null) { cv = mInflater.inflate(R.layout.item_irkitdevice_list, parent, false); } else { cv = convertView; } final VirtualDeviceContainer device = getItem(position); String name = device.getLabel(); TextView nameView = (TextView) cv.findViewById(R.id.devicelist_package_name); nameView.setText(name); Drawable icon = device.getIcon(); if (icon != null) { ImageView iconView = (ImageView) cv.findViewById(R.id.devicelist_icon); iconView.setImageDrawable(icon); } CheckBox removeCheck = (CheckBox) cv.findViewById(R.id.delete_check); if (mIsRemoved) { removeCheck.setVisibility(View.VISIBLE); removeCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mIsRemoves.set(position, b); } }); removeCheck.setChecked(device.isRemove()); removeCheck.setFocusable(false); } else { removeCheck.setVisibility(View.GONE); removeCheck.setOnCheckedChangeListener(null); } return cv; }
Example 13
Source File: SetSecurityActivity.java From MHViewer with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_set_security); setNavigationIcon(R.drawable.v_arrow_left_dark_x24); mPatternView = (LockPatternView) ViewUtils.$$(this, R.id.pattern_view); mCancel = ViewUtils.$$(this, R.id.cancel); mSet = ViewUtils.$$(this, R.id.set); mFingerprint = (CheckBox) ViewUtils.$$(this, R.id.fingerprint_checkbox); String pattern = Settings.getSecurity(); if (!TextUtils.isEmpty(pattern)) { mPatternView.setPattern(LockPatternView.DisplayMode.Correct, LockPatternUtils.stringToPattern(pattern)); } if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class); // The line below prevents the false positive inspection from Android Studio // noinspection ResourceType if (fingerprintManager != null && hasEnrolledFingerprints(fingerprintManager)) { mFingerprint.setVisibility(View.VISIBLE); mFingerprint.setChecked(Settings.getEnableFingerprint()); } } mCancel.setOnClickListener(this); mSet.setOnClickListener(this); }
Example 14
Source File: UpdateManager.java From BigApp_Discuz_Android with Apache License 2.0 | 4 votes |
public void showNoticeDialog(final Context context, final UpdateResponse response) { if(response != null && TextUtils.isEmpty(response.path)){ return; } StringBuilder updateMsg = new StringBuilder(); updateMsg.append(response.version); updateMsg.append(context.getString(R.string.analysissdk_update_new_impress)); updateMsg.append("\n"); updateMsg.append(response.content); updateMsg.append("\n"); updateMsg.append(context.getString(R.string.analysissdk_update_apk_size, sizeToString(response.size))); final Dialog dialog = new Dialog(context, R.style.AnalysisSDK_CommonDialog); dialog.setContentView(R.layout.analysissdk_update_notify_dialog); TextView tvContent = (TextView) dialog.findViewById(R.id.update_tv_dialog_content); tvContent.setMovementMethod(ScrollingMovementMethod.getInstance()); tvContent.setText(updateMsg); final CheckBox cBox = (CheckBox) dialog.findViewById(R.id.update_cb_ignore); if(UpdateConfig.isUpdateForce()){ cBox.setVisibility(View.GONE); }else { cBox.setVisibility(View.VISIBLE); } android.view.View.OnClickListener ocl = new android.view.View.OnClickListener() { public void onClick(View v) { if(v.getId() == R.id.update_btn_dialog_ok){ dialogBtnClick = UpdateStatus.Update; }else if(v.getId() == R.id.update_btn_dialog_cancel){ if(cBox.isChecked()){ dialogBtnClick = UpdateStatus.Ignore; } } dialog.dismiss(); UpdateAgent.updateDialogDismiss(context, dialogBtnClick, response); } }; dialog.findViewById(R.id.update_btn_dialog_ok).setOnClickListener(ocl); dialog.findViewById(R.id.update_btn_dialog_cancel).setOnClickListener(ocl); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(true); dialog.show(); }
Example 15
Source File: TextDetailDocumentsCell.java From SSForms with GNU General Public License v3.0 | 4 votes |
@SuppressLint("RtlHardcoded") public TextDetailDocumentsCell(Context context) { super(context); density = context.getResources().getDisplayMetrics().density; checkDisplaySize(); textView = new TextView(context); textView.setTextColor(0xff212121); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setGravity(Gravity.LEFT); addView(textView); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.height = LayoutParams.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(10, density); layoutParams.leftMargin = AndroidUtilities.dp(71, density); layoutParams.rightMargin = AndroidUtilities.dp(16, density); layoutParams.gravity = Gravity.LEFT; textView.setLayoutParams(layoutParams); valueTextView = new TextView(context); valueTextView.setTextColor(0xff8a8a8a); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); valueTextView.setLines(1); valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setGravity(Gravity.LEFT); addView(valueTextView); layoutParams = (LayoutParams) valueTextView.getLayoutParams(); layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.height = LayoutParams.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(35, density); layoutParams.leftMargin = AndroidUtilities.dp(71, density); layoutParams.rightMargin = AndroidUtilities.dp(16, density); layoutParams.gravity = Gravity.LEFT; valueTextView.setLayoutParams(layoutParams); typeTextView = new TextView(context); typeTextView.setBackgroundColor(0xff757575); typeTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE); typeTextView.setGravity(Gravity.CENTER); typeTextView.setSingleLine(true); typeTextView.setTextColor(0xffd1d1d1); typeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); typeTextView.setTypeface(Typeface.DEFAULT_BOLD); addView(typeTextView); layoutParams = (LayoutParams) typeTextView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(40, density); layoutParams.height = AndroidUtilities.dp(40, density); layoutParams.leftMargin = AndroidUtilities.dp(16, density); layoutParams.rightMargin = AndroidUtilities.dp(0, density); layoutParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; typeTextView.setLayoutParams(layoutParams); imageView = new ImageView(context); addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(40, density); layoutParams.height = AndroidUtilities.dp(40, density); layoutParams.leftMargin = AndroidUtilities.dp(16, density); layoutParams.rightMargin = AndroidUtilities.dp(0, density); layoutParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; imageView.setLayoutParams(layoutParams); checkBox = new CheckBox(context); checkBox.setVisibility(GONE); addView(checkBox); layoutParams = (LayoutParams) checkBox.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(22, density); layoutParams.height = AndroidUtilities.dp(22, density); layoutParams.topMargin = AndroidUtilities.dp(34, density); layoutParams.leftMargin = AndroidUtilities.dp(38, density) ; layoutParams.rightMargin = 0; layoutParams.gravity = Gravity.LEFT; checkBox.setLayoutParams(layoutParams); }
Example 16
Source File: DoTranslate.java From ArscEditor with Apache License 2.0 | 4 votes |
@SuppressLint("InflateParams") public void init(int _position) { // 获取需要翻译的条目所在位置 position = _position; LayoutInflater factory = LayoutInflater.from(mContext); // 得到自定义对话框 View DialogView = factory.inflate(R.layout.translate, null); // 创建对话框 new AlertDialog.Builder(mContext).setView(DialogView)// 设置自定义对话框的样式 .setTitle(R.string.translate) // 设置进度条对话框的标题 .setNegativeButton(R.string.translate, new DialogInterface.OnClickListener() // 设置按钮,并监听 { @SuppressWarnings("unchecked") @Override public void onClick(DialogInterface p1, int p2) { // 开启一个翻译线程 new translate_task().execute(source_list, target_list); } }).create()// 创建 .show(); // 显示对话框 // 找到显示源语言的Spinner控件 src_type = (Spinner) DialogView.findViewById(R.id.src_type); // 找到显示目标语言的Spinner控件 translate_to = (Spinner) DialogView.findViewById(R.id.translate_to); // 找到翻译商的选项的Spinner控件 translator = (Spinner) DialogView.findViewById(R.id.translator); // 找到显示跳过选项的CheckBox控件 skip_already_translate = (CheckBox) DialogView.findViewById(R.id.skip_already_translate); // 源语言默认自动识别 src_type.setSelection(0); // 翻译为默认选择中文 translate_to.setSelection(1); // 默认选择百度翻译 translator.setSelection(0); // 如果是翻译单个条目,需要隐藏“跳过已翻译的内容”的选项,否则需要显示该选项 skip_already_translate.setVisibility(translate_all ? View.VISIBLE : View.GONE); skip_already_translate.setOnCheckedChangeListener(this); }
Example 17
Source File: AddVoiceSettingActivity.java From your-local-weather with GNU General Public License v3.0 | 4 votes |
private void populateBtDevices(int spinnerViewId, int checkBoxViewId, VoiceSettingParamType voiceSettingParamType) { MultiSelectionSpinner btDevicesSpinner = findViewById(spinnerViewId); CheckBox allBtCheckbox = findViewById(checkBoxViewId); View btDevicePanel = findViewById(R.id.tts_bt_device_panel); btDevicesSpinner.setVoiceSettingId(voiceSettingId); BluetoothAdapter bluetoothAdapter = Utils.getBluetoothAdapter(getBaseContext()); if (bluetoothAdapter == null) { btDevicesSpinner.setVisibility(View.GONE); allBtCheckbox.setVisibility(View.GONE); btDevicePanel.setVisibility(View.GONE); return; } else { btDevicesSpinner.setVisibility(View.VISIBLE); allBtCheckbox.setVisibility(View.VISIBLE); btDevicePanel.setVisibility(View.VISIBLE); } Set<BluetoothDevice> bluetoothDeviceSet = bluetoothAdapter.getBondedDevices(); ArrayList<MultiselectionItem> items = new ArrayList<>(); ArrayList<MultiselectionItem> selection = new ArrayList<>(); ArrayList<String> selectedItems = new ArrayList<>(); String enabledBtDevices = voiceSettingParametersDbHelper.getStringParam( voiceSettingId, voiceSettingParamType.getVoiceSettingParamTypeId()); Boolean enabledVoiceDevices = voiceSettingParametersDbHelper.getBooleanParam( voiceSettingId, voiceSettingParamType.getVoiceSettingParamTypeId()); if ((enabledVoiceDevices != null) && enabledVoiceDevices) { allBtCheckbox.setChecked(true); findViewById(R.id.bt_when_devices).setVisibility(View.GONE); } else { findViewById(R.id.bt_when_devices).setVisibility(View.VISIBLE); } if (enabledBtDevices != null) { for (String btDeviceName: enabledBtDevices.split(",")) { selectedItems.add(btDeviceName); } } for(BluetoothDevice bluetoothDevice: bluetoothDeviceSet) { String currentDeviceName = bluetoothDevice.getName(); String currentDeviceAddress = bluetoothDevice.getAddress(); MultiselectionItem multiselectionItem; if (selectedItems.contains(currentDeviceAddress)) { multiselectionItem = new MultiselectionItem(currentDeviceName, currentDeviceAddress, true); selection.add(multiselectionItem); } else { multiselectionItem = new MultiselectionItem(currentDeviceName, currentDeviceAddress,false); } items.add(multiselectionItem); } btDevicesSpinner.setItems(items); btDevicesSpinner.setSelection(selection); }
Example 18
Source File: AddVoiceSettingActivity.java From your-local-weather with GNU General Public License v3.0 | 4 votes |
private void populateTriggerBtDevices(int spinnerViewId, int checkBoxViewId, VoiceSettingParamType voiceSettingParamType) { MultiSelectionTriggerSpinner btDevicesSpinner = findViewById(spinnerViewId); CheckBox allBtCheckbox = findViewById(checkBoxViewId); btDevicesSpinner.setVoiceSettingId(voiceSettingId); BluetoothAdapter bluetoothAdapter = Utils.getBluetoothAdapter(getBaseContext()); if (bluetoothAdapter == null) { btDevicesSpinner.setVisibility(View.GONE); allBtCheckbox.setVisibility(View.GONE); return; } else { btDevicesSpinner.setVisibility(View.VISIBLE); allBtCheckbox.setVisibility(View.VISIBLE); } Set<BluetoothDevice> bluetoothDeviceSet = bluetoothAdapter.getBondedDevices(); ArrayList<MultiselectionItem> items = new ArrayList<>(); ArrayList<MultiselectionItem> selection = new ArrayList<>(); ArrayList<String> selectedItems = new ArrayList<>(); String enabledBtDevices = voiceSettingParametersDbHelper.getStringParam( voiceSettingId, voiceSettingParamType.getVoiceSettingParamTypeId()); Boolean enabledVoiceDevices = voiceSettingParametersDbHelper.getBooleanParam( voiceSettingId, voiceSettingParamType.getVoiceSettingParamTypeId()); if ((enabledVoiceDevices != null) && enabledVoiceDevices) { allBtCheckbox.setChecked(true); findViewById(R.id.trigger_bt_when_devices).setVisibility(View.GONE); } else { findViewById(R.id.trigger_bt_when_devices).setVisibility(View.VISIBLE); } if (enabledBtDevices != null) { for (String btDeviceAddress: enabledBtDevices.split(",")) { selectedItems.add(btDeviceAddress); } } for(BluetoothDevice bluetoothDevice: bluetoothDeviceSet) { String currentDeviceName = bluetoothDevice.getName(); String currentDeviceAddress = bluetoothDevice.getAddress(); MultiselectionItem multiselectionItem; if (selectedItems.contains(currentDeviceAddress)) { multiselectionItem = new MultiselectionItem(currentDeviceName, currentDeviceAddress, true); selection.add(multiselectionItem); } else { multiselectionItem = new MultiselectionItem(currentDeviceName, currentDeviceAddress,false); } items.add(multiselectionItem); } btDevicesSpinner.setItems(items); btDevicesSpinner.setSelection(selection); }
Example 19
Source File: PostFormActivity.java From Overchan-Android with GNU General Public License v3.0 | 4 votes |
private void setViews() { setContentView(settings.isPinnedMarkup() ? R.layout.postform_layout_pinned_markup : R.layout.postform_layout); nameLayout = findViewById(R.id.postform_name_email_layout); nameField = (EditText) findViewById(R.id.postform_name_field); emailField = (EditText) findViewById(R.id.postform_email_field); passwordLayout = findViewById(R.id.postform_password_layout); passwordField = (EditText) findViewById(R.id.postform_password_field); chkboxLayout = findViewById(R.id.postform_checkbox_layout); sageChkbox = (CheckBox) findViewById(R.id.postform_sage_checkbox); sageChkbox.setOnClickListener(this); custommarkChkbox = (CheckBox) findViewById(R.id.postform_custommark_checkbox); attachmentsLayout = (LinearLayout) findViewById(R.id.postform_attachments_layout); spinner = (Spinner) findViewById(R.id.postform_spinner); subjectField = (EditText) findViewById(R.id.postform_subject_field); commentField = (EditText) findViewById(R.id.postform_comment_field); markLayout = (LinearLayout) findViewById(R.id.postform_mark_layout); for (int i=0, len=markLayout.getChildCount(); i<len; ++i) markLayout.getChildAt(i).setOnClickListener(this); captchaLayout = findViewById(R.id.postform_captcha_layout); captchaView = (ImageView) findViewById(R.id.postform_captcha_view); captchaView.setOnClickListener(this); captchaView.setOnCreateContextMenuListener(this); captchaLoading = findViewById(R.id.postform_captcha_loading); captchaField = (EditText) findViewById(R.id.postform_captcha_field); captchaField.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { send(); return true; } return false; } }); sendButton = (Button) findViewById(R.id.postform_send_button); sendButton.setOnClickListener(this); if (settings.isHidePersonalData()) { nameLayout.setVisibility(View.GONE); passwordLayout.setVisibility(View.GONE); } else { nameLayout.setVisibility(boardModel.allowNames || boardModel.allowEmails ? View.VISIBLE : View.GONE); nameField.setVisibility(boardModel.allowNames ? View.VISIBLE : View.GONE); emailField.setVisibility(boardModel.allowEmails ? View.VISIBLE : View.GONE); passwordLayout.setVisibility((boardModel.allowDeletePosts || boardModel.allowDeleteFiles) ? View.VISIBLE : View.GONE); if (boardModel.allowNames && !boardModel.allowEmails) nameField.setLayoutParams(getWideLayoutParams()); else if (!boardModel.allowNames && boardModel.allowEmails) emailField.setLayoutParams(getWideLayoutParams()); } boolean[] markupEnabled = { PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_QUOTE), PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_BOLD), PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_ITALIC), PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_UNDERLINE), PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_STRIKE), PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_SPOILER), }; if (markupEnabled[0] || markupEnabled[1] || markupEnabled[2] || markupEnabled[3] || markupEnabled[4] || markupEnabled[5]) { markLayout.setVisibility(View.VISIBLE); if (!markupEnabled[0]) markLayout.findViewById(R.id.postform_mark_quote).setVisibility(View.GONE); if (!markupEnabled[1]) markLayout.findViewById(R.id.postform_mark_bold).setVisibility(View.GONE); if (!markupEnabled[2]) markLayout.findViewById(R.id.postform_mark_italic).setVisibility(View.GONE); if (!markupEnabled[3]) markLayout.findViewById(R.id.postform_mark_underline).setVisibility(View.GONE); if (!markupEnabled[4]) markLayout.findViewById(R.id.postform_mark_strike).setVisibility(View.GONE); if (!markupEnabled[5]) markLayout.findViewById(R.id.postform_mark_spoiler).setVisibility(View.GONE); } else { markLayout.setVisibility(View.GONE); } subjectField.setVisibility(boardModel.allowSubjects ? View.VISIBLE : View.GONE); chkboxLayout.setVisibility(boardModel.allowSage || boardModel.allowCustomMark ? View.VISIBLE : View.GONE); sageChkbox.setVisibility(boardModel.allowSage ? View.VISIBLE : View.GONE); custommarkChkbox.setVisibility(boardModel.allowCustomMark ? View.VISIBLE : View.GONE); if (boardModel.customMarkDescription != null) custommarkChkbox.setText(boardModel.customMarkDescription); spinner.setVisibility(boardModel.allowIcons ? View.VISIBLE : View.GONE); if (boardModel.allowIcons) { spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, boardModel.iconDescriptions)); } }
Example 20
Source File: WifiAuthenticatorActivity.java From WiFiAfterConnect with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.wifi_auth_layout); Intent intent = getIntent(); try { url = new URL (intent.getStringExtra (WifiAuthenticator.OPTION_URL)); } catch (MalformedURLException e) { // TODO } String html = intent.getStringExtra (WifiAuthenticator.OPTION_PAGE); wifiAuth = new WifiAuthenticator (new Worker (new Logger (intent), this), url); parsedPage = new ParsedHttpInput (wifiAuth, url, html, new HashMap<String,String>()); authParams = wifiAuth.getStoredAuthParams(); authParams = parsedPage.addMissingParams(authParams); fieldsTable = (TableLayout)findViewById(R.id.fieldsTableLayout); fieldsTable.removeAllViews(); edits.clear(); Log.d(Constants.TAG, "Adding controls..."); HtmlInput passwordField = authParams.getFieldByType(HtmlInput.TYPE_PASSWORD); for (HtmlInput i : authParams.getFields()) { if (i != passwordField) addField (i); } checkSavePassword = (CheckBox)findViewById(R.id.checkSavePassword); if (passwordField != null) addField (passwordField); else if (checkSavePassword != null) { checkSavePassword.setVisibility (View.GONE); checkSavePassword = null; } buttonAuthenticate = (Button) findViewById(R.id.buttonAuthenticate); checkAlwaysDoThat = (CheckBox)findViewById(R.id.checkAlwaysDoThat); performAction (authParams.authAction); }