public void toggleService(boolean isChecked) {
    Intent service = new Intent(this, MainService.class);
    spe.putBoolean(CHECKBOX_SERVICE_CHECKED, isChecked);
    while (!spe.commit()) {}
    spe.apply();

    if (isChecked) {
      // Start service
      if (!isMyServiceRunning()) {
        startService(service);
      }
    } else {
      // Stop service
      stopService(service);
    }

    checkBoxVolumeButtonHack.setEnabled(isChecked);

    checkBoxMusicHack.setEnabled(isChecked && checkBoxVolumeButtonHack.isChecked());
    checkBoxVoiceCallHack.setEnabled(isChecked && checkBoxVolumeButtonHack.isChecked());
    checkBoxRingHack.setEnabled(isChecked && checkBoxVolumeButtonHack.isChecked());

    checkBoxToggleSafety.setEnabled(isChecked);
    // seekBarSafetyLevel.setEnabled(checkBoxToggleSafety.isChecked() &&
    // checkBoxToggleSafety.isEnabled());
  }
示例#2
0
  private void fillCtrls() {

    login.setText(prefs.getLogin());
    password.setText(prefs.getPassword());
    anonim.setChecked(prefs.isAnonim());
    View accListYesterdayLine = findViewById(R.id.accListYesterdayLine);
    TextView roleView = (TextView) findViewById(R.id.role);

    // Авторизованы?
    if (AccidentsGeneral.auth.isAuthorized()) {
      loginBtn.setEnabled(false);
      logoutBtn.setEnabled(true);
      anonim.setEnabled(false);
      accListYesterdayLine.setVisibility(View.GONE);
      String format = getString(R.string.mc_auth_role);
      roleView.setText(String.format(format, Role.getName(this)));
      roleView.setVisibility(View.VISIBLE);
      login.setEnabled(false);
      password.setEnabled(false);
    } else {
      //        if (prefs.isAnonim()) {
      loginBtn.setEnabled(true);
      logoutBtn.setEnabled(false);
      anonim.setEnabled(true);
      login.setEnabled(!anonim.isChecked());
      password.setEnabled(!anonim.isChecked());
      accListYesterdayLine.setVisibility(View.VISIBLE);
      roleView.setVisibility(View.GONE);
      enableLoginBtn();
    }
  }
 private void disableBonusBoxes() {
   modifyingCheckBoxes = true;
   CheckBox bbox1 = (CheckBox) findViewById(R.id.bonuscheck1);
   CheckBox bbox2 = (CheckBox) findViewById(R.id.bonuscheck2);
   CheckBox bbox3 = (CheckBox) findViewById(R.id.bonuscheck3);
   bbox1.setEnabled(false);
   bbox2.setEnabled(false);
   bbox3.setEnabled(false);
   modifyingCheckBoxes = false;
 }
  @Override
  public void onClick(View v) {
    if (v.getId() == R.id.button2) {
      EditStart.setText("");
      EditEnd.setText("");
      displayDate.setText("");
      displayStartTime.setText("");
      displayArrivalTime.setText("");
      eventId = "";
      groupId = "";
      btnSelectEvent.setEnabled(true);
      btnSelectGroup.setEnabled(true);
      EditStart.setHint("");
      EditEnd.setHint("");
      FromCurrentLocation.setChecked(false);
      ToCurrentLocation.setChecked(false);
      FromCurrentLocation.setEnabled(true);
      ToCurrentLocation.setEnabled(true);
    }
    if (v.getId() == R.id.buttonEvent) {
      selectEvent();
    }
    if (v.getId() == R.id.buttonGroup) {
      selectGroup();
    }
    if (v.getId() == R.id.current1 || v.getId() == R.id.current2) {
      getGps();
      checkGps();
      if (isCancelled) {
        System.out.println("isCancelled is cancelled");
        FromCurrentLocation.setChecked(false);
        ToCurrentLocation.setChecked(false);
        ToCurrentLocation.setEnabled(false);
        FromCurrentLocation.setEnabled(false);
      }
      if (!isCancelled) {
        System.out.println("isCancelled is on ");
        reverseAddress(OfferRide.this);
      }
    }

    if (v.getId() == R.id.button1) {
      offerRide(v);
    }
    if (v.getId() == R.id.setDateButton) {
      setDate(v);
    }
    if (v.getId() == R.id.setStartTimeButton) {
      setStartTime(v);
    }
    if (v.getId() == R.id.setEndTimeButton) {
      setArrivalTime(v);
    }
  }
  private void toggleVolumeButtonHack(boolean isChecked) {
    spe.putBoolean(CHECKBOX_VOLUME_BUTTON_HACK, isChecked);
    spe.apply();

    checkBoxMusicHack.setEnabled(isChecked);
    checkBoxVoiceCallHack.setEnabled(isChecked);
    checkBoxRingHack.setEnabled(isChecked);

    Intent service = new Intent(this, MainService.class);
    service.putExtra(MainService.HEADSET_STATUS, MainActivity.TOGGLE_VOLUME_HACK);
    startService(service);
  }
示例#6
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.new_space_dialog, container);
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    _prefs = new KvHelper(getActivity());
    int type = getTypeArg();
    if (type == -1) {

      setupPublicCheckBox(view);
      setupSharableCheckBox(view);
    } else {
      CheckBox isSharCheckBox = (CheckBox) view.findViewById(R.id.space_settings_resharable);
      CheckBox isPublicBox = (CheckBox) view.findViewById(R.id.space_settings_public);
      switch (type) {
        case SpaceProvider.Spaces.PUBLIC:
          setPublic(true);
          setSharable(true);

          isPublicBox.setChecked(true);
          isSharCheckBox.setChecked(true);
          isSharCheckBox.setVisibility(View.INVISIBLE);
          break;
        case SpaceProvider.Spaces.PRIVATE:
          setPublic(false);
          isPublicBox.setChecked(false);

          setSharable(false);
          isSharCheckBox.setChecked(false);
          isSharCheckBox.setVisibility(View.VISIBLE);
          break;
        default:
          setPublic(false);
          isPublicBox.setChecked(false);

          setSharable(true);
          isSharCheckBox.setChecked(true);
          isSharCheckBox.setVisibility(View.VISIBLE);
          break;
      }
      isSharCheckBox.setEnabled(false);
      isPublicBox.setEnabled(false);
    }
    setupNameEdit(view);
    setupButton(view);
    setupSeekBar(view);
    // setupMaxPresenceSeekBar(view);

    return view;
  }
 private void updateUI(boolean isUploading) {
   if (isUploading) {
     mTOSCheckbox.setEnabled(false);
     mProgressBar.setVisibility(View.VISIBLE);
     mButtonRetry.setEnabled(false);
     mButtonConfirm.setEnabled(false);
   } else {
     mTOSCheckbox.setEnabled(true);
     mProgressBar.setVisibility(View.INVISIBLE);
     mButtonRetry.setEnabled(true);
     mButtonConfirm.setEnabled(true);
   }
 }
 /*
  * if we are in the situation, where there are already exported transactions
  * we suggest to the user the default of again exporting without deleting
  * but if the user now changes to deleting, we enforce a complete export/reset
  * since a partial deletion of only transactions not yet exported would
  * lead to an inconsistent state
  */
 private void configure(boolean delete) {
   if (delete) {
     notYetExportedCB.setEnabled(false);
     notYetExportedCB.setChecked(false);
     warningTV.setVisibility(View.VISIBLE);
     handleDeletedGroup.setVisibility(View.VISIBLE);
   } else {
     notYetExportedCB.setEnabled(true);
     notYetExportedCB.setChecked(true);
     warningTV.setVisibility(View.GONE);
     handleDeletedGroup.setVisibility(View.GONE);
   }
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;
    TextView folder = null;
    CheckBox check = null;
    if (row == null) {
      LayoutInflater inflater = LayoutInflater.from(context);
      row = inflater.inflate(R.layout.folder_adapter_row, parent, false);
      folder = (TextView) row.findViewById(R.id.folder);
      folder.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View folder) {
              int position = (Integer) folder.getTag();
              // FolderAdapter.this.clear();
              directory.browseTo(position);
              currentChecked = -1;
              FolderAdapter.this.notifyDataSetChanged();
              doneButton.setEnabled(false);
            }
          });
      check = (CheckBox) row.findViewById(R.id.checkbox);
      check.setOnCheckedChangeListener(
          new CompoundButton.OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              // update last checked position
              int position = (Integer) buttonView.getTag();
              if (isChecked) currentChecked = position;
              else if (currentChecked == position) currentChecked = -1;
              FolderAdapter.this.notifyDataSetChanged();
              if (isChecked) doneButton.setEnabled(true);
            }
          });
    }
    folder = (TextView) row.findViewById(R.id.folder);
    folder.setText(directory.get(position));
    folder.setTag(new Integer(position));
    check = (CheckBox) row.findViewById(R.id.checkbox);
    // disable the "Up one level" checkbox; otherwise make sure its enabled
    if (position == 0 && !directory.isCurrentDirectoryRoot()) check.setEnabled(false);
    else check.setEnabled(true);
    check.setTag(new Integer(position));
    // set check state. only one can be checked
    boolean status = (currentChecked == position) ? true : false;
    check.setChecked(status);
    return (row);
  }
示例#10
0
  /** Updates the on-screen controls to reflect the current state of the app. */
  private void updateControls() {
    Button play = (Button) findViewById(R.id.play_stop_button);
    if (mShowStopLabel) {
      play.setText(R.string.stop_button_text);
    } else {
      play.setText(R.string.play_button_text);
    }
    play.setEnabled(mSurfaceTextureReady);

    // We don't support changes mid-play, so dim these.
    CheckBox check = (CheckBox) findViewById(R.id.locked60fps_checkbox);
    check.setEnabled(!mShowStopLabel);
    check = (CheckBox) findViewById(R.id.loopPlayback_checkbox);
    check.setEnabled(!mShowStopLabel);
  }
示例#11
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View view = convertView;
   if (view == null) {
     LayoutInflater inflater =
         (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     view = inflater.inflate(R.layout.input_withdraw_row, null);
   }
   TeamMemberRecord item = getItem(position);
   if (item != null) {
     TextView tvMember = (TextView) view.findViewById(R.id.inputWithdrawRow_memberTextView);
     CheckBox checkWithdraw = (CheckBox) view.findViewById(R.id.inputWithdrawRow_withdrawCheckBox);
     TextView tvAlreadyWithdrawn =
         (TextView) view.findViewById(R.id.inputWithdrawRow_withdrawTextView);
     if (tvMember != null) tvMember.setText(item.getMemberName());
     if (checkWithdraw != null) {
       if (item.isPrevWithdrawn()) {
         checkWithdraw.setEnabled(false);
       } else {
         checkWithdraw.setChecked(currentState.isCurrWithdrawn(item.getMember()));
         checkWithdraw.setOnClickListener(new WithdrawClickListener(item.getMember()));
       }
     }
     if (tvAlreadyWithdrawn != null) {
       if (!item.isPrevWithdrawn()) tvAlreadyWithdrawn.setText("");
     }
   }
   return view;
 }
示例#12
0
 @Override
 public void hydrate(final CheckBox checkBox, final PersistedDataBean payload) {
   CheckBoxBean bean = (CheckBoxBean) payload;
   checkBox.setText(bean.text);
   checkBox.setEnabled(bean.enabled);
   checkBox.setVisibility(bean.visibility);
 }
示例#13
0
 @Override
 public View getChildView(int i, final int i2, boolean b, View view, ViewGroup viewGroup) {
   SharedPreferences sharedPreferences =
       context.getSharedPreferences(
           SettingStrings.shared_user_settings + LinkBoxController.usrListData.usrKey, 0);
   final SharedPreferences.Editor editor = sharedPreferences.edit();
   if (view == null) {
     view = layoutInflater.inflate(R.layout.layout_notification_list_item, viewGroup, false);
   }
   BoxListData boxListData = getChild(i, i2);
   TextView tvChildNotification = ViewHolder.get(view, R.id.TV_child_notification_user_setting);
   CheckBox cbChildNotification = ViewHolder.get(view, R.id.CB_child_notification_user_setting);
   tvChildNotification.setText(boxListData.boxName);
   cbChildNotification.setEnabled(LinkBoxController.defaultAlarm);
   cbChildNotification.setChecked(sharedPreferences.getBoolean("notiCheck" + i2, true));
   Log.d(TAG, boxListData.boxName + " : " + sharedPreferences.getBoolean("notiCheck" + i2, true));
   cbChildNotification.setOnCheckedChangeListener(
       new CompoundButton.OnCheckedChangeListener() {
         @Override
         public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
           editor.putBoolean("notiCheck" + i2, b);
           editor.apply();
         }
       });
   return view;
 }
示例#14
0
  private void initViews() {
    boolean isEditable = transfer.getStatus() != PaymentStatus.COMPLETE;

    recipient.setText(transfer.getRecipient());
    recipient.setEnabled(isEditable);

    amountPay.setValue(transfer.getAmountPayment());
    amountPay.setEnabled(isEditable);

    amountDue.setValue(transfer.getAmountDue());
    amountDue.setEnabled(isEditable);

    comment.setText(transfer.getComment());
    comment.setEnabled(isEditable);

    useCodeProtection.setChecked(transfer.isCodeProtection());
    useCodeProtection.setEnabled(isEditable);

    protectionCode.setText(transfer.getProtectionCode());
    receivePeriod.setText(String.valueOf(transfer.getReceivePeriod()));

    receivePeriod.setEnabled(isEditable);

    paymentButton.setEnabled(isEditable);
  }
  public RowCheckBoxOmegaFi(Context context) {
    super(context);
    setTextSizeInformation(
        context.getResources().getDimensionPixelSize(R.dimen.text_12_notification));
    checkOption = new CheckBox(context);
    checkOption.setEnabled(true);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.setMargins(params.leftMargin, params.topMargin, 10, params.bottomMargin);
    checkOption.setLayoutParams(params);
    checkOption.setButtonDrawable(R.drawable.radio_button);
    checkOption.setSoundEffectsEnabled(true);
    this.addViewRight(checkOption);
    setTextColor(Color.GRAY);
    setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Log.d("onclick listener row", checkOption.isChecked() + "");
            checkOption.setChecked(!checkOption.isChecked());
          }
        });
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    ApplicationInfo applicationInfo = getApplicationInfo(position);
    if (applicationInfo == null) {
      Log.e(TAG, "Fail to retrieve application info for the entry: " + position);
      return null;
    }

    if (convertView == null) {
      convertView =
          LayoutInflater.from(getContext()).inflate(R.layout.enable_component_row, parent, false);
    }
    ImageView iconImageView = (ImageView) convertView.findViewById(R.id.pkg_icon);
    iconImageView.setImageDrawable(getApplicationIcon(applicationInfo));
    TextView pkgNameTextView = (TextView) convertView.findViewById(R.id.pkg_name);
    pkgNameTextView.setText(getDisplayName(position));
    CheckBox enableComponentCheckbox =
        (CheckBox) convertView.findViewById(R.id.enable_component_checkbox);
    enableComponentCheckbox.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // Only handles the onClick event if the component can be enabled or disabled.
            if (canModifyComponent(position)) {
              mIsComponentCheckedList.set(position, ((CheckBox) v).isChecked());
            } else {
              ((CheckBox) v).setChecked(mIsComponentCheckedList.get(position));
            }
          }
        });
    enableComponentCheckbox.setChecked(mIsComponentCheckedList.get(position));
    enableComponentCheckbox.setEnabled(canModifyComponent(position));
    return convertView;
  }
示例#17
0
  /** Returns the view for a specific item on the list */
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;

    final ToDoItem currentItem = getItem(position);

    if (row == null) {
      LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
      row = inflater.inflate(mLayoutResourceId, parent, false);
    }

    row.setTag(currentItem);
    final CheckBox checkBox = (CheckBox) row.findViewById(R.id.checkToDoItem);
    checkBox.setText(currentItem.getText());
    checkBox.setChecked(false);
    checkBox.setEnabled(true);

    checkBox.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            if (checkBox.isChecked()) {
              checkBox.setEnabled(false);
              if (mContext instanceof ToDoActivity) {
                ToDoActivity activity = (ToDoActivity) mContext;
                activity.checkItem(currentItem);
              }
            }
          }
        });

    return row;
  }
示例#18
0
  public void error(final String text) {
    final Activity activity = this;

    new AlertDialog.Builder(activity)
        .setTitle("Error")
        .setMessage(text)
        .setNeutralButton("OK", null)
        .show();
    if (udpSenderService != null) {
      udpSenderService.stop();
      start.setChecked(false);
      txtIp.setEnabled(true);
      txtPort.setEnabled(true);
      chkSendOrientation.setEnabled(true);
      chkSendRaw.setEnabled(true);
    }
  }
	/**
	 * Returns the view for a specific item on the list
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;

		final WorkItem currentItem = getItem(position);

		if (row == null) {
			LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
			row = inflater.inflate(mLayoutResourceId, parent, false);
		}

		row.setTag(currentItem);
		final CheckBox checkBox = (CheckBox) row
				.findViewById(R.id.checkToDoItem);
		final TextView txtDate = (TextView) row
				.findViewById(R.id.textDueDate);

		final Calendar c = Calendar.getInstance();
		c.setTime(currentItem.getDueDate());

		int year = c.get(Calendar.YEAR);
		int month = c.get(Calendar.MONTH);
		int day = c.get(Calendar.DAY_OF_MONTH);
		int hour = c.get(Calendar.HOUR_OF_DAY);
		int minute = c.get(Calendar.MINUTE);
		@SuppressWarnings("deprecation")
		String gmtTime = currentItem.getDueDate().toGMTString();
		// set current date into textview
		txtDate.setText(gmtTime);
		
		checkBox.setText(currentItem.getTitle());
		checkBox.setChecked(currentItem.isComplete());
		checkBox.setEnabled(true);
		checkBox.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				if (checkBox.isChecked()) {
					checkBox.setEnabled(false);
					if (mContext instanceof ToDoActivity) {
						ToDoActivity activity = (ToDoActivity) mContext;
						activity.checkItem(currentItem);
					}
				}
			}
		});
		
		Date currentDate = new Date();
		row.setBackgroundResource(R.color.normal);
		if(currentItem.getDueDate().before(currentDate))
		{
			row.setBackgroundResource(R.color.highlight);	
		}
		
		return row;
	}
    public void setEnabled(boolean enabled) {
      view.setEnabled(enabled);
      selected.setEnabled(enabled);
      mainUserId.setEnabled(enabled);
      mainUserIdRest.setEnabled(enabled);
      creation.setEnabled(enabled);
      statusIcon.setEnabled(enabled);

      // Sorta special: We set an item as clickable to disable it in the ListView. This works
      // because the list item will handle the clicks itself (which is a nop)
      view.setClickable(!enabled);
    }
 private void entireWallpaperOption() {
   if (!bEntire) {
     checkBoxScrollable.setEnabled(true);
     standardLinearLayout.setBackgroundResource(R.drawable.transparent_square);
     fixedLinearLayout.setBackgroundResource(R.drawable.transparent_square);
     entireLinearLayout.setBackgroundResource(R.drawable.circle_blue);
     bFixed = false;
     bStandard = false;
     bEntire = true;
     setSelection(0, 0, 0, 0);
     Log.e("CONF", "ENTIRE");
   }
 }
  private void changeEnabledViewStates() {
    viewsEnabled = !viewsEnabled;

    textView.setEnabled(viewsEnabled);
    imageView.setEnabled(viewsEnabled);
    editText.setEnabled(viewsEnabled);
    button.setEnabled(viewsEnabled);
    for (int i = 0; i < radioGroup.getChildCount(); i++) {
      radioGroup.getChildAt(i).setEnabled(viewsEnabled);
    }
    spinner.setEnabled(viewsEnabled);
    imageButton.setEnabled(viewsEnabled);
    autoCompleteTextView.setEnabled(viewsEnabled);
    checkBox1.setEnabled(viewsEnabled);
    checkBox2.setEnabled(viewsEnabled);
    checkBox3.setEnabled(viewsEnabled);
    toggleButton.setEnabled(viewsEnabled);
    switchButton.setEnabled(viewsEnabled);
    progressBar.setEnabled(viewsEnabled);

    updateEnableDisableLabel();
  }
  private void fixedWallpaperOption() {
    if (!bFixed) {
      checkBoxScrollable.setEnabled(false);
      standardLinearLayout.setBackgroundResource(R.drawable.transparent_square);
      fixedLinearLayout.setBackgroundResource(R.drawable.circle_blue);
      entireLinearLayout.setBackgroundResource(R.drawable.transparent_square);
      bFixed = true;
      bEntire = false;
      bStandard = false;
      Log.e("CONF", "FIXED");
      if (imageDimensionCategory == IMAGE_DIMENSION_HORIZONTAL) {
        int tempWidth = prev_selection.width();
        if (tempWidth > prev_selection.height()) {
          tempWidth /= standardRatio;
        }
        setSelection(
            (int) (shown_image_rect.left + shown_image_rect.right - tempWidth) / 2,
            prev_selection.top,
            tempWidth,
            prev_selection.height());
      } else if (imageDimensionCategory == IMAGE_DIMENSION_VERTICAL) {
        int tempHeight = prev_selection.height();
        if (tempHeight < prev_selection.width()) {
          tempHeight *= standardRatio;
        }
        setSelection(prev_selection.left, prev_selection.top, prev_selection.width(), tempHeight);
      } else if (imageDimensionCategory == IMAGE_DIMENSION_NOT_STANDARD) {

        float left = prev_selection.left;
        float top = prev_selection.top;
        float right = prev_selection.right;
        float bottom = prev_selection.bottom;
        float widthTemp = prev_selection.width();
        float heightTemp = prev_selection.height();

        //                int tempHeight = prev_selection.height();
        if (heightTemp < prev_selection.width()) {
          heightTemp *= standardRatio;
        }

        float ratioTemp = heightTemp / (shown_image_rect.bottom - shown_image_rect.top);
        widthTemp /= ratioTemp;
        heightTemp /= ratioTemp;
        setSelection(
            (int) (shown_image_rect.left + shown_image_rect.right - widthTemp) / 2,
            prev_selection.top,
            (int) widthTemp,
            (int) heightTemp);
      }
    }
  }
示例#24
0
  public TriggerWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);
    mPrompt = prompt;

    this.setOrientation(LinearLayout.VERTICAL);

    mTriggerButton = new CheckBox(getContext());
    mTriggerButton.setId(QuestionWidget.newUniqueId());
    mTriggerButton.setText(getContext().getString(R.string.trigger));
    mTriggerButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
    // mActionButton.setPadding(20, 20, 20, 20);
    mTriggerButton.setEnabled(!prompt.isReadOnly());

    mTriggerButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mTriggerButton.isChecked()) {
              mStringAnswer.setText(mOK);
              Collect.getInstance()
                  .getActivityLogger()
                  .logInstanceAction(TriggerWidget.this, "triggerButton", "OK", mPrompt.getIndex());
            } else {
              mStringAnswer.setText(null);
              Collect.getInstance()
                  .getActivityLogger()
                  .logInstanceAction(
                      TriggerWidget.this, "triggerButton", "null", mPrompt.getIndex());
            }
          }
        });

    mStringAnswer = new TextView(getContext());
    mStringAnswer.setId(QuestionWidget.newUniqueId());
    mStringAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
    mStringAnswer.setGravity(Gravity.CENTER);

    String s = prompt.getAnswerText();
    if (s != null) {
      if (s.equals(mOK)) {
        mTriggerButton.setChecked(true);
      } else {
        mTriggerButton.setChecked(false);
      }
      mStringAnswer.setText(s);
    }

    // finish complex layout
    this.addView(mTriggerButton);
    // this.addView(mStringAnswer);
  }
示例#25
0
 private void updateCalendarPanel() {
   boolean enabled = true;
   if (mOriginalItem != null && mOriginalItem.getCalendarEventId().isInitialised()) {
     mCalendarLabel.setText(getString(R.string.update_gcal_title));
     mCalendarDetail.setText(getString(R.string.update_gcal_detail));
   } else if (mShowDue && mShowStart) {
     mCalendarLabel.setText(getString(R.string.add_to_gcal_title));
     mCalendarDetail.setText(getString(R.string.add_to_gcal_detail));
   } else {
     mCalendarLabel.setText(getString(R.string.add_to_gcal_title));
     mCalendarDetail.setText(getString(R.string.add_to_gcal_detail_disabled));
     enabled = false;
   }
   mUpdateCalendarEntry.setEnabled(enabled);
   mUpdateCalendarCheckBox.setEnabled(enabled);
 }
 @Override
 protected void onResume() {
   super.onResume();
   force_landscape.setChecked(preferences.isForceLandscape());
   enable_hq.setChecked(preferences.isHighQualityOn());
   force_dark.setChecked(preferences.isDarkLayoutEnabled());
   force_dark_widget.setChecked(preferences.isDarkWidgetLayoutEnabled());
   hide_toolbars.setChecked(preferences.isToolbarsHidden());
   download_path.setText(preferences.getDownloadTarget());
   share_image.setChecked(preferences.isSharingImage());
   mobile_network.setChecked(preferences.isSlowNetwork());
   reverse_landscape.setVisibility(Build.VERSION.SDK_INT >= 9 ? View.VISIBLE : View.GONE);
   reverse_landscape.setEnabled(preferences.isForceLandscape());
   reverse_landscape.setChecked(
       preferences.isReversedLandscape() && preferences.isForceLandscape());
   open_at_latest_strip.setChecked(preferences.isShouldOpenAtLatestStrip());
   widget_always_show_latest.setChecked(preferences.isWidgetAlwaysShowLatest());
 }
  private void initStatus() {
    TextView tv = (TextView) findViewById(R.id.status);
    tv.setText(MbcpUtil.sEnvStatus);

    CheckBox cb = (CheckBox) findViewById(R.id.cb_no_dex_dep);
    cb.setEnabled(mIsEnvReady);
    if (mIsEnvReady) {
      cb.setChecked(MbcpUtil.isDexDepDisable());
      if (!mIsInited) {
        cb.setOnCheckedChangeListener(
            new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton b, boolean checked) {
                MbcpUtil.setDexDepDisable(checked);
              }
            });
      }
    }
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      LayoutInflater inflater =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View rowView = inflater.inflate(R.layout.view_list_item_dragable, parent, false);

      TextView textView = (TextView) rowView.findViewById(android.R.id.text1);
      textView.setText(values.get(position).getName());

      CheckBox checkView = (CheckBox) rowView.findViewById(android.R.id.checkbox);
      checkView.setClickable(false);
      checkView.setChecked(CalculatorSettings.isPageEnabled(getContext(), values.get(position)));

      if ("settings".equals(values.get(position).getKey())) {
        checkView.setEnabled(false);
      }

      return rowView;
    }
示例#29
0
 private void update() {
   isUpdating = true;
   AbstractContact abstractContact = RosterManager.getInstance().getBestContact(account, user);
   ContactTitleInflater.updateTitle(findViewById(R.id.title), this, abstractContact);
   verifiedView.setChecked(OTRManager.getInstance().isVerified(account, user));
   scanView.setEnabled(remoteFingerprint != null);
   verifiedView.setEnabled(remoteFingerprint != null);
   ((TextView) findViewById(R.id.otr_remote_fingerprint))
       .setText(
           remoteFingerprint == null
               ? getString(R.string.unknown)
               : CertificateManager.showFingerprint(remoteFingerprint));
   showView.setEnabled(localFingerprint != null);
   copyView.setEnabled(localFingerprint != null);
   ((TextView) findViewById(R.id.otr_local_fingerprint))
       .setText(
           localFingerprint == null
               ? getString(R.string.unknown)
               : CertificateManager.showFingerprint(localFingerprint));
   isUpdating = false;
 }
    @SuppressWarnings("unchecked")
    public ListMultiWidget(Context context, FormEntryPrompt prompt, boolean displayLabel) {
        super(context, prompt);

        mItems = prompt.getSelectChoices();
        mCheckboxes = new ArrayList<CheckBox>();
        mPrompt = prompt;

        // Layout holds the horizontal list of buttons
        LinearLayout buttonLayout = new LinearLayout(context);

        Vector<Selection> ve = new Vector<Selection>();
        if (prompt.getAnswerValue() != null) {
            ve = (Vector<Selection>) prompt.getAnswerValue().getValue();
        }

        if (mItems != null) {
            for (int i = 0; i < mItems.size(); i++) {
                CheckBox c = new CheckBox(getContext());
                c.setTag(Integer.valueOf(i));
                c.setId(QuestionWidget.newUniqueId());
                c.setFocusable(!prompt.isReadOnly());
                c.setEnabled(!prompt.isReadOnly());
                for (int vi = 0; vi < ve.size(); vi++) {
                    // match based on value, not key
                    if (mItems.get(i).getValue().equals(ve.elementAt(vi).getValue())) {
                        c.setChecked(true);
                        break;
                    }

                }
                mCheckboxes.add(c);

                // when clicked, check for readonly before toggling
                c.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (!mCheckboxInit && mPrompt.isReadOnly()) {
                            if (buttonView.isChecked()) {
                                buttonView.setChecked(false);
                               	Collect.getInstance().getActivityLogger().logInstanceAction(this, "onItemClick.deselect",
                            			mItems.get((Integer)buttonView.getTag()).getValue(), mPrompt.getIndex());
                            } else {
                                buttonView.setChecked(true);
                               	Collect.getInstance().getActivityLogger().logInstanceAction(this, "onItemClick.select",
                            			mItems.get((Integer)buttonView.getTag()).getValue(), mPrompt.getIndex());
                            }
                        }
                    }
                });

                String imageURI = null;
                imageURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                        FormEntryCaption.TEXT_FORM_IMAGE);

                // build image view (if an image is provided)
                ImageView mImageView = null;
                TextView mMissingImage = null;

                final int labelId = QuestionWidget.newUniqueId();

                // Now set up the image view
                String errorMsg = null;
                if (imageURI != null) {
                    try {
                        String imageFilename =
                            ReferenceManager._().DeriveReference(imageURI).getLocalURI();
                        final File imageFile = new File(imageFilename);
                        if (imageFile.exists()) {
                            Bitmap b = null;
                            try {
                                Display display =
                                    ((WindowManager) getContext().getSystemService(
                                        Context.WINDOW_SERVICE)).getDefaultDisplay();
                                int screenWidth = display.getWidth();
                                int screenHeight = display.getHeight();
                                b =
                                    FileUtils.getBitmapScaledToDisplay(imageFile, screenHeight,
                                        screenWidth);
                            } catch (OutOfMemoryError e) {
                                errorMsg = "ERROR: " + e.getMessage();
                            }

                            if (b != null) {
                                mImageView = new ImageView(getContext());
                                mImageView.setPadding(2, 2, 2, 2);
                                mImageView.setAdjustViewBounds(true);
                                mImageView.setImageBitmap(b);
                                mImageView.setId(labelId);
                            } else if (errorMsg == null) {
                                // An error hasn't been logged and loading the image failed, so it's
                                // likely
                                // a bad file.
                                errorMsg = getContext().getString(R.string.file_invalid, imageFile);

                            }
                        } else if (errorMsg == null) {
                            // An error hasn't been logged. We should have an image, but the file
                            // doesn't
                            // exist.
                            errorMsg = getContext().getString(R.string.file_missing, imageFile);
                        }

                        if (errorMsg != null) {
                            // errorMsg is only set when an error has occured
                            Log.e(t, errorMsg);
                            mMissingImage = new TextView(getContext());
                            mMissingImage.setText(errorMsg);

                            mMissingImage.setPadding(2, 2, 2, 2);
                            mMissingImage.setId(labelId);
                        }
                    } catch (InvalidReferenceException e) {
                        Log.e(t, "image invalid reference exception");
                        e.printStackTrace();
                    }
                } else {
                    // There's no imageURI listed, so just ignore it.
                }

                // build text label. Don't assign the text to the built in label to he
                // button because it aligns horizontally, and we want the label on top
                TextView label = new TextView(getContext());
                label.setText(prompt.getSelectChoiceText(mItems.get(i)));
                label.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
                label.setGravity(Gravity.CENTER_HORIZONTAL);
                if (!displayLabel) {
                    label.setVisibility(View.GONE);
                }

                // answer layout holds the label text/image on top and the radio button on bottom
                RelativeLayout answer = new RelativeLayout(getContext());
                RelativeLayout.LayoutParams headerParams =
                        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                headerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                headerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
                
                RelativeLayout.LayoutParams buttonParams =
                        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                buttonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);

                if (mImageView != null) {
                	mImageView.setScaleType(ScaleType.CENTER);
                    if (!displayLabel) {
                        mImageView.setVisibility(View.GONE);
                    }
                    answer.addView(mImageView, headerParams);
                } else if (mMissingImage != null) {
                    answer.addView(mMissingImage, headerParams);
                } else {
                    if (displayLabel) {
                    	label.setId(labelId);
                        answer.addView(label, headerParams);
                    }

                }
                if (displayLabel) {
                	buttonParams.addRule(RelativeLayout.BELOW, labelId);
                }
                answer.addView(c, buttonParams);
                answer.setPadding(4, 0, 4, 0);

                // /Each button gets equal weight
                LinearLayout.LayoutParams answerParams =
                    new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
                            LayoutParams.WRAP_CONTENT);
                answerParams.weight = 1;

                buttonLayout.addView(answer, answerParams);

            }
        }

        // Align the buttons so that they appear horizonally and are right justified
        // buttonLayout.setGravity(Gravity.RIGHT);
        buttonLayout.setOrientation(LinearLayout.HORIZONTAL);
        // LinearLayout.LayoutParams params = new
        // LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        // buttonLayout.setLayoutParams(params);

        // The buttons take up the right half of the screen
        LinearLayout.LayoutParams buttonParams =
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
        buttonParams.weight = 1;

        questionLayout.addView(buttonLayout, buttonParams);
        addView(questionLayout);

    }