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());
          }
        });
  }
  public void showDialogInitializingCommandPlayer(
      final Activity uiContext, boolean warningNoneProvider, Runnable run, boolean showDialog) {
    String voiceProvider = osmandSettings.VOICE_PROVIDER.get();
    if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
      if (warningNoneProvider && voiceProvider == null) {
        Builder builder = new AccessibleAlertBuilder(uiContext);
        LinearLayout ll = new LinearLayout(uiContext);
        ll.setOrientation(LinearLayout.VERTICAL);
        final TextView tv = new TextView(uiContext);
        tv.setPadding(7, 3, 7, 0);
        tv.setText(R.string.voice_is_not_available_msg);
        tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19);
        ll.addView(tv);

        final CheckBox cb = new CheckBox(uiContext);
        cb.setText(R.string.shared_string_remember_my_choice);
        LinearLayout.LayoutParams lp =
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        lp.setMargins(7, 10, 7, 0);
        cb.setLayoutParams(lp);
        ll.addView(cb);

        builder.setCancelable(true);
        builder.setNegativeButton(
            R.string.shared_string_cancel,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                if (cb.isChecked()) {
                  osmandSettings.VOICE_PROVIDER.set(OsmandSettings.VOICE_PROVIDER_NOT_USE);
                }
              }
            });
        builder.setPositiveButton(
            R.string.shared_string_ok,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(uiContext, SettingsActivity.class);
                intent.putExtra(
                    SettingsActivity.INTENT_KEY_SETTINGS_SCREEN,
                    SettingsActivity.SCREEN_GENERAL_SETTINGS);
                uiContext.startActivity(intent);
              }
            });

        builder.setTitle(R.string.voice_is_not_available_title);
        builder.setView(ll);
        // builder.setMessage(R.string.voice_is_not_available_msg);
        builder.show();
      }

    } else {
      if (player == null || !Algorithms.objectEquals(voiceProvider, player.getCurrentVoice())) {
        appInitializer.initVoiceDataInDifferentThread(uiContext, voiceProvider, run, showDialog);
      }
    }
  }
Beispiel #3
0
 public View getView(Context context) throws UnsupportedOperationException {
   CheckBox checkbox = new CheckBox(context);
   checkbox.setLayoutParams(
       new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
   checkbox.setText(mLabel);
   checkbox.setChecked(mChecked);
   mView = (View) checkbox;
   return mView;
 }
Beispiel #4
0
  private void addCheckbox(int i, int checkboxLayout, LayoutInflater li) {
    CheckBox view = (CheckBox) li.inflate(checkboxLayout, this, false);
    LayoutParams params = new TableRow.LayoutParams(0, view.getLayoutParams().height, 1f);
    if (i > 0) {
      params.setMargins(mPadding, 0, 0, 0);
    }
    view.setLayoutParams(params);

    view.setCompoundDrawablePadding(0);
    view.setTag(i);
    view.setText(String.valueOf(i + 1));

    view.setOnCheckedChangeListener(this);
    addView(view);
  }
  public static String showTitleInputBox(
      Context context, String title, final InputDialogSetHandler handler) {
    AlertDialog.Builder dlg = new AlertDialog.Builder(context);
    dlg.setTitle(title);

    final LayoutParams viewProp =
        new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

    final LinearLayout layout = new LinearLayout(context);

    final EditText input = new EditText(context);
    final CheckBox chkValidate = new CheckBox(context);

    chkValidate.setText("akıllı gel");

    layout.setOrientation(LinearLayout.VERTICAL);

    input.setLayoutParams(viewProp);
    chkValidate.setLayoutParams(viewProp);

    layout.addView(input);
    layout.addView(chkValidate);

    dlg.setView(layout);

    dlg.setPositiveButton(
        "tamam",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {

            handler.onInputContentGet(input.getText().toString(), chkValidate.isChecked());
          }
        });

    dlg.setNegativeButton(
        "vazcay",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {}
        });

    dlg.show();

    return input.getText().toString();
  }
    public View getView() {
      if (type.equals("checkbox")) {
        CheckBox checkbox = new CheckBox(GeckoApp.mAppContext);
        checkbox.setLayoutParams(
            new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        checkbox.setText(label);
        try {
          Boolean value = mJSONInput.getBoolean("checked");
          checkbox.setChecked(value);
        } catch (Exception ex) {
        }
        view = (View) checkbox;
      } else if (type.equals("textbox") || this.type.equals("password")) {
        EditText input = new EditText(GeckoApp.mAppContext);
        int inputtype = InputType.TYPE_CLASS_TEXT;
        if (type.equals("password")) {
          inputtype |=
              InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
        input.setInputType(inputtype);

        try {
          String value = mJSONInput.getString("value");
          input.setText(value);
        } catch (Exception ex) {
        }

        if (!hint.equals("")) {
          input.setHint(hint);
        }
        view = (View) input;
      } else if (type.equals("menulist")) {
        Spinner spinner = new Spinner(GeckoApp.mAppContext);
        try {
          String[] listitems = getStringArray(mJSONInput, "values");
          if (listitems.length > 0) {
            ArrayAdapter<String> adapter =
                new ArrayAdapter<String>(
                    GeckoApp.mAppContext, android.R.layout.simple_dropdown_item_1line, listitems);
            spinner.setAdapter(adapter);
          }
        } catch (Exception ex) {
        }
        view = (View) spinner;
      }
      return view;
    }
Beispiel #7
0
 /**
  * Adds a manual checkbox after the Add Manual Tags button
  *
  * @param index
  */
 private void addManualCheckBox(int index) {
   int id = index + autotags.length;
   CheckBox box = new CheckBox(AddTags.this);
   RelativeLayout.LayoutParams params =
       new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   params.addRule(RelativeLayout.BELOW, index == 0 ? bNewTag.getId() : id);
   box.setLayoutParams(params);
   box.setId(id + 1);
   box.setText(manualtags.get(index));
   box.setTextColor(Color.BLACK);
   for (String tag : tags) {
     if (tag.equals(manualtags.get(index))) {
       box.setChecked(true);
       break;
     }
   }
   // add listener to add/remove the tag from the tags list
   box.setOnCheckedChangeListener(new TagCheckChangeListener());
   rlAddTag.addView(box);
 }
  protected void onCreate(Bundle savedInstanceState) {
    final FotoBot fb = (FotoBot) getApplicationContext();
    super.onCreate(savedInstanceState);
    fb.LoadSettings();

    // fb.logger.fine("Tab_Foto_Activity");

    Log.d(LOG_TAG, "Tab3: onCreate");
    //      final FotoBot fb = (FotoBot) getApplicationContext();
    Display display = getWindowManager().getDefaultDisplay();
    screenWidth = display.getWidth();
    screenHeight = display.getHeight();

    // Main Container (Vertical LinearLayout)
    LinearLayout FullFrame = new LinearLayout(this);
    FullFrame.setOrientation(LinearLayout.VERTICAL);
    FullFrame.setPadding(5, 5, 5, 5);
    FullFrame.setBackgroundColor(Color.rgb(192, 192, 192));
    LinearLayout.LayoutParams lpFull_Frame =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
    FullFrame.setLayoutParams(lpFull_Frame);
    FullFrame.setMinimumHeight(fb.Working_Area_Height - fb.menuheight);
    // FullFrame.setBackgroundColor(Color.WHITE);
    //  setContentView(FullFrame);

    // ------------------------------------------------------------------------------------------------

    // JPEG сжатие

    // Контейнер для JPG сжатие
    RelativeLayout linLayout_JPEG_Compression = new RelativeLayout(this);
    //   linLayout_JPEG_Compression.setOrientation(LinearLayout.HORIZONTAL);
    RelativeLayout.LayoutParams lpView =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_m =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams lpView_et =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    linLayout_JPEG_Compression.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для пояснение
    LinearLayout linLayout_JPEG_Compression_notes = new LinearLayout(this);
    linLayout_JPEG_Compression_notes.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_JPEG_Compression_notes.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для разделителя
    LinearLayout linLayout_JPEG_Compression_divider = new LinearLayout(this);
    linLayout_JPEG_Compression_divider.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_JPEG_Compression_divider.setPadding(5, 9, 5, 9);

    // Название
    TextView tv_JPEG_Compression = new TextView(this);
    tv_JPEG_Compression.setTypeface(Typeface.DEFAULT_BOLD);
    tv_JPEG_Compression.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size);
    tv_JPEG_Compression.setTextColor(Color.BLACK);
    tv_JPEG_Compression.setText(getResources().getString(R.string.jpeg_compression));
    tv_JPEG_Compression.setWidth((screenWidth - padding) / 100 * 80);
    tv_JPEG_Compression.setLayoutParams(lpView);
    tv_JPEG_Compression.setTypeface(Typeface.DEFAULT_BOLD);

    lpView.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_JPEG_Compression.getId());
    tv_JPEG_Compression.setLayoutParams(lpView);
    linLayout_JPEG_Compression.addView(tv_JPEG_Compression);

    // Ввод данных

    editText_JPEG_Compression = new EditText(this);
    editText_JPEG_Compression.setLayoutParams(lpView_et);
    String jpg = Integer.toString(fb.JPEG_Compression);
    editText_JPEG_Compression.setText(jpg);
    editText_JPEG_Compression.setTextColor(Color.rgb(50, 100, 150));
    ViewGroup.LayoutParams lp = editText_JPEG_Compression.getLayoutParams();
    lp.width = (screenWidth - padding) / 100 * 20;
    editText_JPEG_Compression.setLayoutParams(lp);
    //   editText_JPEG_Compression.setGravity(Gravity.RIGHT);

    lpView_m.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, editText_JPEG_Compression.getId());
    editText_JPEG_Compression.setLayoutParams(lpView_m);
    linLayout_JPEG_Compression.addView(editText_JPEG_Compression);

    // Заметка для JPEG сжатия
    TextView tv_JPEG_Compression_note = new TextView(this);
    tv_JPEG_Compression_note.setTypeface(null, Typeface.NORMAL);
    tv_JPEG_Compression_note.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2);
    tv_JPEG_Compression_note.setTextColor(Color.BLACK);
    tv_JPEG_Compression_note.setText(
        getResources().getString(R.string.jpeg_compression_description));
    // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99);
    tv_JPEG_Compression_note.setLayoutParams(lpView);
    //  tv_JPEG_Compression_note.setTextColor(Color.GRAY);
    tv_JPEG_Compression_note.setPadding(5, 9, 5, 9);
    linLayout_JPEG_Compression_notes.addView(tv_JPEG_Compression_note);

    // Разделитель
    View line_JPEG_Compression = new View(this);
    line_JPEG_Compression.setLayoutParams(
        new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 1));
    line_JPEG_Compression.setBackgroundColor(Color.rgb(210, 210, 210));
    line_JPEG_Compression.getLayoutParams().height = 3;
    linLayout_JPEG_Compression_divider.addView(line_JPEG_Compression);

    // ------------------------------------------------------------------------------------------------

    // Метод обработки фото

    // Контейнер для метода
    RelativeLayout linLayout_Photo_Processing_Method = new RelativeLayout(this);
    //   linLayout_Photo_Processing_Method.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Processing_Method.setBackgroundColor(Color.rgb(192, 192, 192));
    RelativeLayout.LayoutParams lpView_m1 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_m2 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    //        LinearLayout.LayoutParams lpView = new
    // LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
    // LinearLayout.LayoutParams.WRAP_CONTENT);
    //      LinearLayout.LayoutParams lpView_et = new
    // LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
    // LinearLayout.LayoutParams.WRAP_CONTENT);

    // Контейнер для пояснение
    LinearLayout linLayout_Photo_Processing_Method_notes = new LinearLayout(this);
    linLayout_Photo_Processing_Method_notes.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Processing_Method_notes.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для разделителя
    LinearLayout linLayout_Photo_Processing_Method_divider = new LinearLayout(this);
    linLayout_Photo_Processing_Method_divider.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Processing_Method_divider.setPadding(5, 9, 5, 9);

    // Название
    TextView tv_Photo_Processing_Method = new TextView(this);
    tv_Photo_Processing_Method.setTypeface(Typeface.DEFAULT_BOLD);
    tv_Photo_Processing_Method.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size);
    tv_Photo_Processing_Method.setTextColor(Color.BLACK);
    tv_Photo_Processing_Method.setText(getResources().getString(R.string.photo_processing_method));
    //   tv_Photo_Processing_Method.setWidth((screenWidth - padding) / 100 * 80);
    //   tv_Photo_Processing_Method.setLayoutParams(lpView);
    tv_Photo_Processing_Method.setTypeface(Typeface.DEFAULT_BOLD);

    lpView_m1.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Photo_Processing_Method.getId());
    lpView_m1.width = (screenWidth - padding) / 100 * 60;
    tv_Photo_Processing_Method.setLayoutParams(lpView_m1);
    linLayout_Photo_Processing_Method.addView(tv_Photo_Processing_Method);

    // Список
    spinnerArray_ppm = new ArrayList<String>();
    spinnerArray_ppm.add("Hardware");
    spinnerArray_ppm.add("Software");

    spinner_ppm = new Spinner(this);
    ArrayAdapter<String> spinnerArrayAdapter_ppm =
        new ArrayAdapter<String>(this, R.layout.spinner_item, spinnerArray_ppm);
    spinner_ppm.setAdapter(spinnerArrayAdapter_ppm);
    spinner_ppm.setSelection(getIndex(spinner_ppm, fb.Photo_Post_Processing_Method));
    spinner_ppm.setMinimumWidth((screenWidth - padding) / 100 * 50);
    spinner_ppm.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {

          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

            if (spinnerArray_ppm.get(i) == "Hardware") {
              tv_Photo_Size_s.setVisibility(View.GONE);
              spinner_Software.setVisibility(View.GONE);
              tv_Photo_Size_h.setVisibility(View.VISIBLE);
              spinner_Hardware.setVisibility(View.VISIBLE);
              linLayout_Photo_Size_h_notes.setVisibility(View.VISIBLE);
              linLayout_Photo_Size_s_notes.setVisibility(View.GONE);
            } else {
              tv_Photo_Size_s.setVisibility(View.VISIBLE);
              spinner_Software.setVisibility(View.VISIBLE);
              tv_Photo_Size_h.setVisibility(View.GONE);
              spinner_Hardware.setVisibility(View.GONE);
              linLayout_Photo_Size_h_notes.setVisibility(View.GONE);
              linLayout_Photo_Size_s_notes.setVisibility(View.VISIBLE);
            }
          }

          // If no option selected
          public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

          }
        });

    lpView_m2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, spinner_ppm.getId());
    lpView_m2.width = (screenWidth - padding) / 100 * 40;
    spinner_ppm.setLayoutParams(lpView_m2);
    linLayout_Photo_Processing_Method.addView(spinner_ppm);

    // Заметка для метода
    TextView tv_Photo_Processing_Method_note = new TextView(this);
    tv_Photo_Processing_Method_note.setTypeface(null, Typeface.NORMAL);
    tv_Photo_Processing_Method_note.setTextSize(
        TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2);
    tv_Photo_Processing_Method_note.setTextColor(Color.BLACK);
    tv_Photo_Processing_Method_note.setText(
        getResources().getString(R.string.photo_processing_method_dscription));
    // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99);
    tv_Photo_Processing_Method_note.setLayoutParams(lpView);
    //   tv_Photo_Processing_Method_note.setTextColor(Color.GRAY);
    tv_Photo_Processing_Method_note.setPadding(5, 9, 5, 9);
    linLayout_Photo_Processing_Method_notes.addView(tv_Photo_Processing_Method_note);

    // ------------------------------------------------------------------------------------------------

    // Параметры изображения

    // Контейнер для метода
    RelativeLayout linLayout_Photo_Size = new RelativeLayout(this);
    // linLayout_Photo_Size.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams lpView_photo_size =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams lpView_photo_size_et =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    RelativeLayout.LayoutParams lpView_m3 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_m4 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_m5 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_m6 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    linLayout_Photo_Size.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для пояснение
    linLayout_Photo_Size_h_notes = new LinearLayout(this);
    linLayout_Photo_Size_h_notes.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Size_h_notes.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для пояснение
    linLayout_Photo_Size_s_notes = new LinearLayout(this);
    linLayout_Photo_Size_s_notes.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Size_s_notes.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для разделителя
    LinearLayout linLayout_Photo_Size_divider = new LinearLayout(this);
    linLayout_Photo_Processing_Method_divider.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Processing_Method_divider.setPadding(5, 9, 5, 9);

    // Масштаб фото
    tv_Photo_Size_h = new TextView(this);
    tv_Photo_Size_h.setTypeface(Typeface.DEFAULT_BOLD);
    tv_Photo_Size_h.setTextSize(14);
    tv_Photo_Size_h.setTextColor(Color.BLACK);
    tv_Photo_Size_h.setText(getResources().getString(R.string.photo_scale));
    // tv_Photo_Size_h.setWidth((screenWidth - padding) / 100 * 80);
    tv_Photo_Size_h.setLayoutParams(lpView_photo_size);

    lpView_m3.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Photo_Size_h.getId());
    lpView_m3.width = (screenWidth - padding) / 100 * 60;
    tv_Photo_Size_h.setLayoutParams(lpView_m3);
    linLayout_Photo_Size.addView(tv_Photo_Size_h);

    // Коэффициенты масштабирования
    ArrayList<String> spinnerArray_Hardware = new ArrayList<String>();
    spinnerArray_Hardware.add("1/16");
    spinnerArray_Hardware.add("1/8");
    spinnerArray_Hardware.add("1/4");
    spinnerArray_Hardware.add("1/2");
    spinnerArray_Hardware.add("1");

    spinner_Hardware = new Spinner(this);
    spinnerArrayAdapter_Hardware =
        new ArrayAdapter<String>(this, R.layout.spinner_item, spinnerArray_Hardware);
    spinner_Hardware.setAdapter(spinnerArrayAdapter_Hardware);
    spinner_Hardware.setSelection(getIndex(spinner_Hardware, fb.Image_Scale));
    //  spinner_Hardware.setMinimumWidth((screenWidth - padding) / 100 * 20);
    // spinner_Hardware.setGravity(Gravity.RIGHT);

    lpView_m4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, spinner_Hardware.getId());
    lpView_m4.width = (screenWidth - padding) / 100 * 40;
    spinner_Hardware.setLayoutParams(lpView_m4);
    linLayout_Photo_Size.addView(spinner_Hardware);

    // Размер фото
    tv_Photo_Size_s = new TextView(this);
    tv_Photo_Size_s.setTypeface(Typeface.DEFAULT_BOLD);
    tv_Photo_Size_s.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size);
    tv_Photo_Size_s.setTextColor(Color.BLACK);
    tv_Photo_Size_s.setText(getResources().getString(R.string.photo_resolution));
    //  tv_Photo_Size_s.setWidth((screenWidth - padding) / 100 * 80);
    tv_Photo_Size_s.setLayoutParams(lpView_photo_size);

    lpView_m5.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Photo_Size_s.getId());
    lpView_m5.width = (screenWidth - padding) / 100 * 60;
    tv_Photo_Size_s.setLayoutParams(lpView_m5);
    linLayout_Photo_Size.addView(tv_Photo_Size_s);

    // Доступные разрешения
    ArrayList<String> spinnerArray = new ArrayList<String>();

    Camera.Size mSize = null;

    int fe_w = (int) fb.camera_resolutions.get(0).width;
    int fe_h = (int) fb.camera_resolutions.get(0).height;
    float fe_s, fe_z;

    fe_z = (float) fe_w / (float) fe_h;

    for (Camera.Size size : fb.camera_resolutions) {
      fe_w = (int) size.width;
      fe_h = (int) size.height;
      fe_s = (float) fe_w / (float) fe_h;

      if (Math.abs(fe_s - fe_z) < 0.01f) {
        spinnerArray.add(size.width + "x" + size.height);
      }
    }

    spinner_Software = new Spinner(this);
    spinnerArrayAdapter1 = new ArrayAdapter<String>(this, R.layout.spinner_item, spinnerArray);
    spinner_Software.setAdapter(spinnerArrayAdapter1);

    spinner_Software.setSelection(getIndex(spinner_Software, fb.Image_Size));
    //   spinner_Software.setMinimumWidth((screenWidth - padding) / 100 * 20);
    //  spinner_Software.setGravity(Gravity.RIGHT);

    lpView_m6.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, spinner_Software.getId());
    lpView_m6.width = (screenWidth - padding) / 100 * 40;
    spinner_Software.setLayoutParams(lpView_m6);

    linLayout_Photo_Size.addView(spinner_Software);

    // Заметка для Hardware
    TextView tv_Photo_Size_h_note = new TextView(this);
    tv_Photo_Size_h_note.setTypeface(null, Typeface.NORMAL);
    tv_Photo_Size_h_note.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2);
    tv_Photo_Size_h_note.setTextColor(Color.BLACK);
    tv_Photo_Size_h_note.setText("Hardware");
    // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99);
    tv_Photo_Size_h_note.setLayoutParams(lpView);
    // tv_Photo_Size_h_note.setTextColor(Color.GRAY);
    tv_Photo_Size_h_note.setPadding(5, 9, 5, 9);
    linLayout_Photo_Size_h_notes.addView(tv_Photo_Size_h_note);

    // Заметка для Software
    TextView tv_Photo_Size_s_note = new TextView(this);
    tv_Photo_Size_s_note.setTypeface(null, Typeface.NORMAL);
    tv_Photo_Size_s_note.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2);
    tv_Photo_Size_s_note.setTextColor(Color.BLACK);
    tv_Photo_Size_s_note.setText("Software");
    // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99);
    tv_Photo_Size_s_note.setLayoutParams(lpView);
    //   tv_Photo_Size_s_note.setTextColor(Color.GRAY);
    tv_Photo_Size_s_note.setPadding(5, 9, 5, 9);
    linLayout_Photo_Size_s_notes.addView(tv_Photo_Size_s_note);

    // Разделитель
    View line_Photo_Size = new View(this);
    line_Photo_Size.setLayoutParams(
        new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 1));
    line_Photo_Size.setBackgroundColor(Color.rgb(210, 210, 210));
    line_Photo_Size.getLayoutParams().height = 3;
    linLayout_Photo_Size_divider.addView(line_Photo_Size);

    // ------------------------------------------------------------------------------------------------

    // Вспышка

    // Flash Container
    RelativeLayout linLayout_Flash = new RelativeLayout(this);
    // linLayout_Flash.setOrientation(LinearLayout.HORIZONTAL);
    RelativeLayout.LayoutParams lpView_Flash =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_Flash_m =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams lpView_et_Flash =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    linLayout_Flash.setBackgroundColor(Color.rgb(192, 192, 192));

    // Flash TextView
    TextView tv_Flash = new TextView(this);
    tv_Flash.setText(getResources().getString(R.string.flash));
    tv_Flash.setWidth((screenWidth - padding) / 100 * 90);
    tv_Flash.setLayoutParams(lpView_Flash);
    tv_Flash.setTypeface(Typeface.DEFAULT_BOLD);
    tv_Flash.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size);
    tv_Flash.setTextColor(Color.BLACK);

    lpView_Flash.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Flash.getId());
    tv_Flash.setLayoutParams(lpView_Flash);
    linLayout_Flash.addView(tv_Flash);

    // CheckBox
    checkBox_Flash = new CheckBox(this);
    checkBox_Flash.setChecked(fb.Use_Flash);

    lpView_Flash_m.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, checkBox_Flash.getId());
    checkBox_Flash.setLayoutParams(lpView_Flash_m);
    linLayout_Flash.addView(checkBox_Flash);

    // Second Container (Horizontal LinearLayout)
    LinearLayout linLayout2 = new LinearLayout(this);
    linLayout2.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams lpView2 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    LinearLayout.LayoutParams lpViewbutton =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    linLayout2.setGravity(Gravity.BOTTOM | Gravity.CENTER);

    // linLayout2.setLayoutParams(lpView2);

    // ------------------------------------------------------------------------------------------------

    // Buttons

    // Container
    LinearLayout linLayout_Buttons = new LinearLayout(this);
    linLayout_Buttons.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Buttons.setGravity(Gravity.BOTTOM | Gravity.CENTER);
    LinearLayout.LayoutParams lpViewbutton1 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
    LinearLayout.LayoutParams lpViewbutton2 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
    lpViewbutton1.setMargins(0, 0, 5, 0);
    LinearLayout.LayoutParams lpView3 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
    linLayout_Buttons.setLayoutParams(lpView3);
    linLayout_Buttons.setBackgroundColor(Color.rgb(192, 192, 192));
    linLayout_Buttons.setPadding(15, 15, 15, 15);

    linLayout_Buttons.setBaselineAligned(false);
    linLayout_Buttons.setGravity(Gravity.BOTTOM);

    // Apply Button
    btn = new Button(this);
    btn.setText(getResources().getString(R.string.apply_button));
    btn.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    btn.setBackgroundColor(Color.rgb(90, 89, 91));
    btn.setTextColor(Color.rgb(250, 250, 250));
    btn.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);

    btn.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
              btn.setBackgroundColor(Color.rgb(90, 90, 90));
            } else if (event.getAction() == MotionEvent.ACTION_DOWN) {
              btn.setBackgroundColor(Color.rgb(128, 128, 128));
            }
            return false;
          }
        });

    btn.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            SharedPreferences pref =
                getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE);
            SharedPreferences.Editor editor = pref.edit();

            if (checkBox_Flash.isChecked()) {
              editor.putBoolean("Use_Flash", true);
            } else {
              editor.putBoolean("Use_Flash", false);
            }

            String input = editText_JPEG_Compression.getText().toString();
            editor.putString(
                "Photo_Post_Processing_Method", spinner_ppm.getSelectedItem().toString());
            editor.putInt(
                "JPEG_Compression",
                Integer.parseInt(editText_JPEG_Compression.getText().toString()));
            editor.putString("Image_Scale", spinner_Hardware.getSelectedItem().toString());
            editor.putString("Image_Size", spinner_Software.getSelectedItem().toString());

            // Save the changes in SharedPreferences
            editor.commit(); // commit changes
          }
        });

    // GoTo Main Page Button
    btn_mp = new Button(this);
    btn_mp.setText(getResources().getString(R.string.back_button));
    btn_mp.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    btn_mp.setBackgroundColor(Color.rgb(90, 89, 91));
    btn_mp.setTextColor(Color.rgb(250, 250, 250));
    // lpViewbutton2.setMargins(5,5,5,5);
    btn_mp.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);

    btn_mp.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
              btn_mp.setBackgroundColor(Color.rgb(90, 90, 90));
            } else if (event.getAction() == MotionEvent.ACTION_DOWN) {
              btn_mp.setBackgroundColor(Color.rgb(128, 128, 128));
            }
            return false;
          }
        });

    btn_mp.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intent;
            intent = new Intent(v.getContext(), MainActivity.class);
            startActivity(intent);
          }
        });

    linLayout_Buttons.addView(btn, lpViewbutton1);
    linLayout_Buttons.addView(btn_mp, lpViewbutton2);

    FullFrame.addView(linLayout_JPEG_Compression);
    FullFrame.addView(linLayout_JPEG_Compression_notes);
    //   FullFrame.addView(linLayout_JPEG_Compression_divider);

    FullFrame.addView(linLayout_Photo_Processing_Method);
    FullFrame.addView(linLayout_Photo_Processing_Method_notes);

    FullFrame.addView(linLayout_Photo_Size);
    FullFrame.addView(linLayout_Photo_Size_h_notes);
    FullFrame.addView(linLayout_Photo_Size_s_notes);
    //        FullFrame.addView(linLayout_Photo_Size_divider);

    FullFrame.addView(linLayout_Flash);

    FullFrame.addView(linLayout_Buttons);

    ScrollView m_Scroll = new ScrollView(this);
    m_Scroll.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    m_Scroll.addView(
        FullFrame,
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    setContentView(m_Scroll);
  }
  public static LinearLayout createIntervalChooseLayout(
      final Context uiCtx,
      final String patternMsg,
      final int[] seconds,
      final int[] minutes,
      final ValueHolder<Boolean> choice,
      final ValueHolder<Integer> v,
      DisplayMetrics dm) {
    LinearLayout ll = new LinearLayout(uiCtx);
    final TextView tv = new TextView(uiCtx);
    tv.setPadding((int) (7 * dm.density), (int) (3 * dm.density), (int) (7 * dm.density), 0);
    tv.setText(String.format(patternMsg, uiCtx.getString(R.string.int_continuosly)));

    SeekBar sp = new SeekBar(uiCtx);
    sp.setPadding((int) (7 * dm.density), (int) (5 * dm.density), (int) (7 * dm.density), 0);
    final int secondsLength = seconds.length;
    final int minutesLength = minutes.length;
    sp.setMax(secondsLength + minutesLength - 1);
    sp.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            String s;
            if (progress == 0) {
              s = uiCtx.getString(R.string.int_continuosly);
              v.value = 0;
            } else {
              if (progress < secondsLength) {
                s = seconds[progress] + " " + uiCtx.getString(R.string.int_seconds);
                v.value = seconds[progress] * 1000;
              } else {
                s = minutes[progress - secondsLength] + " " + uiCtx.getString(R.string.int_min);
                v.value = minutes[progress - secondsLength] * 60 * 1000;
              }
            }
            tv.setText(String.format(patternMsg, s));
          }
        });

    for (int i = 0; i < secondsLength + minutesLength - 1; i++) {
      if (i < secondsLength) {
        if (v.value <= seconds[i] * 1000) {
          sp.setProgress(i);
          break;
        }
      } else {
        if (v.value <= minutes[i - secondsLength] * 1000 * 60) {
          sp.setProgress(i);
          break;
        }
      }
    }

    ll.setOrientation(LinearLayout.VERTICAL);
    ll.addView(tv);
    ll.addView(sp);
    if (choice != null) {
      final CheckBox cb = new CheckBox(uiCtx);
      cb.setText(R.string.shared_string_remember_my_choice);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
      lp.setMargins((int) (7 * dm.density), (int) (10 * dm.density), (int) (7 * dm.density), 0);
      cb.setLayoutParams(lp);
      cb.setOnCheckedChangeListener(
          new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              choice.value = isChecked;
            }
          });
      ll.addView(cb);
    }
    return ll;
  }
  @Override
  public View updateView(final View view, final TreeNodeInfo<Item> treeNodeInfo) {
    final Item item = treeNodeInfo.getId();
    LinearLayout viewLayout = (LinearLayout) view;

    TextView itemContent = (TextView) viewLayout.findViewById(R.id.item_list_item_content);
    TextView itemLabels = (TextView) viewLayout.findViewById(R.id.item_list_item_labels);
    ImageView itemNotes = (ImageView) viewLayout.findViewById(R.id.item_list_item_notes);
    TextView itemNoteCount = (TextView) viewLayout.findViewById(R.id.item_list_item_note_count);
    ImageView itemRepeat = (ImageView) viewLayout.findViewById(R.id.item_list_item_repeat);
    TextView itemDueDate = (TextView) viewLayout.findViewById(R.id.item_list_item_due_date);
    LinearLayout itemDateLayout =
        (LinearLayout) viewLayout.findViewById(R.id.item_list_item_date_layout);
    final CheckBox itemCheckbox = (CheckBox) viewLayout.findViewById(R.id.item_list_item_checkbox);

    mTextSize = mStorage.getTextSize();
    mItemViewInQueryMode = mItemListView.getItemViewInQueryMode();

    // Display the formatted text (highlighting, etc)
    itemContent.setText(TodoistTextFormatter.formatText(item.getContent()));

    itemContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mTextSize);
    // Linkify any emails, web addresses and phone numbers in the item's content
    Linkify.addLinks(itemContent, Linkify.ALL);

    itemLabels.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mTextSize - 4);

    if ((mItemViewMode == ItemViewMode.FILTER_BY_LABELS)
        || ((mItemViewMode == ItemViewMode.FILTER_BY_QUERIES)
            && (mItemViewInQueryMode == ItemViewInQueryMode.PROJECTS))) {
      // Show item's projects
      Project project = mClient.getProjectById(item.projectId);

      if (project != null) {
        itemLabels.setText(project.getName());
        itemLabels.setBackgroundColor((0xFF << 24) | project.getColor());
      } else {
        // Rare case that shouldn't happen - item is pointing to an old project that no longer
        // exists
        itemLabels.setText("");
        itemLabels.setBackgroundColor((0xFF << 24) | Color.WHITE);
      }

    } else {
      itemLabels.setText("");
      itemLabels.setBackgroundColor((0x00 << 24)); // Transparent background color

      // Show item's labels
      if (item.labelIds != null) {
        // Fill out the labels
        for (int i = 0; i < item.labelIds.size(); i++) {
          int labelId = item.labelIds.get(i);
          Label currentLabel = mIdToLabels.get(labelId);

          if (currentLabel == null) {
            // Weird case when we have an ID but no matching label for it
            // TODO: What should we do other than this?
            continue;
          }

          itemLabels.append(
              Html.fromHtml(
                  String.format(
                      "<font color='#%X'><i>%s</i></font>",
                      currentLabel.getColor(), currentLabel.name)));

          if (i < item.labelIds.size() - 1) {
            itemLabels.append(", ");
          }
        }

        // Since Italic text gets cut off on "wrap_contents" TextView width
        itemLabels.append(" ");
      }
    }

    if (mClient.isPremium()) {
      itemNoteCount.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mTextSize - 7);
      if (item.noteCount > 0) {
        itemNotes.setVisibility(View.VISIBLE);
        itemNoteCount.setText(String.valueOf(item.noteCount));
        itemNoteCount.setVisibility(View.VISIBLE);
      } else {
        // No notes (don't show an icon)
        itemNotes.setVisibility(View.GONE);
        itemNoteCount.setVisibility(View.GONE);
      }

      itemNotes.setTag(item);
      itemNotes.setOnClickListener(this);

    } else {
      // Only premium users have task notes
      itemNotes.setVisibility(View.GONE);
      itemNoteCount.setVisibility(View.GONE);
    }

    // Show a "recurring" image for item if necessary
    if (item.isRecurring()) {
      itemRepeat.setVisibility(View.VISIBLE);
    } else {
      itemRepeat.setVisibility(View.GONE);
    }

    itemDueDate.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mTextSize - 4);

    if ((item.dueDate == null) || (item.dueDate.getTime() == 0)) {
      itemDateLayout.setVisibility(View.GONE);
    } else {
      itemDateLayout.setVisibility(View.VISIBLE);
      itemDueDate.setText(
          item.getDueDateDescription(
              mClient.getUser().timeFormat, mClient.getUser().timezoneOffsetMinutes));
      itemDateLayout.setBackgroundColor((0xFF << 24) | item.getDueDateColor());
    }

    itemCheckbox.setTag(item);
    itemCheckbox.setOnCheckedChangeListener(null);
    itemCheckbox.setChecked(item.completed);

    // Determine which checkbox to display according to text size
    int checkBoxDrawable;
    int checkBoxHeight;

    if (mTextSize <= 10) {
      checkBoxDrawable = R.drawable.checkbox_selector_small;
      checkBoxHeight = 16; // DP - height and width are the same
    } else if (mTextSize <= 13) {
      checkBoxDrawable = R.drawable.checkbox_selector_medium;
      checkBoxHeight = 24; // DP - height and width are the same
    } else {
      checkBoxDrawable = R.drawable.checkbox_selector_large;
      checkBoxHeight = 32; // DP - height and width are the same
    }

    // Convert from Device-Independent pixels to actual screen pixels
    int dpHeight =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP,
                checkBoxHeight,
                mItemListView.getResources().getDisplayMetrics());

    // Set the checkbox image + dimensions to use
    itemCheckbox.setLayoutParams(new LinearLayout.LayoutParams(dpHeight, dpHeight));
    itemCheckbox.setButtonDrawable(checkBoxDrawable);

    if (item.completed) itemContent.setTextColor(Color.GRAY);
    else itemContent.setTextColor((0xFF << 24) | item.getItemPriorityColor());

    itemCheckbox.setOnCheckedChangeListener(onCheckedChange);

    if (!item.canBeCompleted()) {
      // Some items can be marked as non-completeable
      itemCheckbox.setVisibility(View.INVISIBLE);
    } else {
      itemCheckbox.setVisibility(View.VISIBLE);
    }

    viewLayout.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            if (item.canBeCompleted()) {
              itemCheckbox.setChecked(!itemCheckbox.isChecked());
            }
          }
        });
    viewLayout.setLongClickable(true);

    viewLayout.setTag(item);

    return viewLayout;
  }
  public void createCheckableButtons(
      int[] order, DatabaseQuestion question, boolean[] intialState) {
    int numberOfButtons = question.allOptionsLength();
    String[] optionsToDisplay = new String[numberOfButtons];
    checkableButtons = new CheckBox[numberOfButtons];
    if (intialState == null) {
      intialState = new boolean[numberOfButtons];
    }
    if (order == null) {
      order = new int[numberOfButtons];
      for (int i = 0; i < numberOfButtons; i++) {
        order[i] = i;
      }
    }
    this.answerLocations.clear();
    String[] tempAnswer = question.getAnswer();
    for (int i = 0; i < question.getAnswer().length; i++) {
      answerLocations.add(order[i]);
      optionsToDisplay[order[i]] = tempAnswer[i];
    }
    String[] tempOption = question.getOptionsArray();
    for (int i = 0; i < tempOption.length; i++) {
      optionsToDisplay[order[i + tempAnswer.length]] = tempOption[i];
    }

    setContentView(R.layout.activity_my);
    answerButtonsLayout = (LinearLayout) findViewById(R.id.subLinear);
    if (answerButtonsLayout != null) {
      answerButtonsLayout.removeAllViews();
    }
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT, 1);

    // Investigate TableView and ListView

    for (int i = 0; i < numberOfButtons; i++) {
      // build checkable buttons for multiple answers
      CheckBox box1 = new CheckBox(this);
      if (i < alphabet.length) {
        box1.setText(Character.toString(alphabet[i]).concat(")") + optionsToDisplay[i]);
      } else {
        box1.setText(Integer.toString(i).concat(") ") + optionsToDisplay[i]);
      }
      box1.setOnCheckedChangeListener(
          new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              if (buttonView.isChecked()) {
                buttonView.setBackgroundColor(Color.GREEN);
              } else {
                buttonView.setBackgroundColor(Color.TRANSPARENT); // Color.parseColor()
              }
            }
          });
      /**
       * box1.setOnClickListener(new View.OnClickListener() { public void onClick(View v){ CheckBox
       * check=(CheckBox) v; if(check.isChecked()){ check.setBackgroundColor(0x0000FF00); }else{
       * check.setBackgroundColor(Color.TRANSPARENT); } }
       *
       * <p>});
       */
      box1.setLayoutParams(params);
      box1.setChecked(intialState[i]);
      checkableButtons[i] = box1;
      answerButtonsLayout.addView(box1);
    }
    // Submit button
    submitCheckableButtons = new Button(this);
    submitCheckableButtons.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            checkableButtonsAnswer(v);
          }
        });

    submitCheckableButtons.setText("Submit");
    submitCheckableButtons.setLayoutParams(params);

    LinearLayout submitButtonLayout = (LinearLayout) findViewById(R.id.submit);
    if (submitButtonLayout != null) {
      submitButtonLayout.removeAllViews();
    }
    submitButtonLayout.addView(submitCheckableButtons);

    TextView questionView = (TextView) findViewById(R.id.textView);
    questionView.setMovementMethod(new ScrollingMovementMethod());
    questionView.setText(question.getQuestion());
  }
  protected void createView() {

    Display display = this.getWindow().getWindowManager().getDefaultDisplay();
    Point size = new Point();

    if (Build.VERSION.SDK_INT > 12) {
      display.getSize(size);
    } else {
      size.y = display.getHeight();
      size.x = display.getWidth();
    }

    int width_times = Math.round((float) size.x / (56.0f * density));
    float dialog_width = ((float) (width_times - 1) * 56.0f * density);

    // add a view to margin the space
    LayoutParams mvParams = new LayoutParams((int) dialog_width, LayoutParams.WRAP_CONTENT);
    LinearLayout messageView = new LinearLayout(this.getContext());
    messageView.setLayoutParams(mvParams);
    messageView.setPadding(view_padding, view_padding, view_padding, view_padding);
    messageView.setGravity(Gravity.TOP | Gravity.CENTER);
    messageView.setOrientation(LinearLayout.VERTICAL);

    // icon
    LayoutParams iconParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    iconParams.setMargins(0, 0, 0, view_margin);
    iconParams.gravity = Gravity.CENTER;
    ImageView icon = new ImageView(this.getContext());
    icon.setLayoutParams(iconParams);
    icon.setId(android.R.id.icon);
    icon.setVisibility(View.GONE);

    // title
    LayoutParams titleParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    titleParams.setMargins(0, 0, 0, view_margin);
    TextView title = new TextView(this.getContext());
    title.setLayoutParams(titleParams);
    title.setTextColor(this.getContext().getResources().getColor(R.color.text_color_dark));
    title.setTextSize(20);
    title.setTypeface(null, Typeface.BOLD);
    title.setId(android.R.id.title);
    title.setVisibility(View.GONE);

    // message
    LayoutParams msgParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    TextView message = new TextView(this.getContext());
    message.setLayoutParams(msgParams);
    message.setTextColor(this.getContext().getResources().getColor(R.color.text_color_dark));
    message.setTextSize(18);
    message.setId(android.R.id.message);
    message.setVisibility(View.GONE);

    // optional choice
    LayoutParams checkBoxParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    checkBoxParams.setMargins(0, view_margin, 0, 0);
    CheckBox checkBox = new CheckBox(this.getContext());
    checkBox.setLayoutParams(checkBoxParams);
    checkBox.setId(android.R.id.checkbox);
    checkBox.setTextColor(this.getContext().getResources().getColor(R.color.text_color_dark));
    checkBox.setVisibility(View.GONE);

    // add elements to body view
    messageView.addView(icon);
    messageView.addView(title);
    messageView.addView(message);
    messageView.addView(checkBox);

    // button area
    LayoutParams btnsParams = new LayoutParams((int) dialog_width, (int) (52.0f * density));
    LinearLayout buttons = new LinearLayout(this.getContext());
    buttons.setMinimumHeight((int) (52.0f * density));
    buttons.setLayoutParams(btnsParams);
    buttons.setGravity(Gravity.RIGHT | Gravity.CENTER);
    buttons.setId(android.R.id.extractArea);
    buttons.setPadding(0, 0, (int) (8.0f * density), 0);

    contentView.addView(messageView);
    contentView.addView(buttons);

    this.setContentView(contentView);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate");

    scroll = new ScrollView(this);
    setContentView(scroll);

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    layout.setPadding(10, 10, 10, 10);
    scroll.addView(
        layout,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    viewNetwork = new Button(this);
    viewNetwork.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    viewNetwork.setText(getResources().getString(R.string.view_network_button));
    viewNetwork.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            final String[] networkTreeCopy = networkTree;
            AlertDialog.Builder builder = new AlertDialog.Builder(AddPrinterActivity.this);
            // builder.setTitle(R.string.network);
            builder.setItems(
                networkTreeCopy,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, final int which) {
                    dialog.dismiss();
                    String selected = networkTreeCopy[which];
                    selected = selected.trim();
                    if (!selected.startsWith("\\\\")) return;
                    selected = selected.substring(2);
                    if (selected.indexOf("\\") == -1) return;
                    String server = selected.substring(0, selected.indexOf("\\"));
                    String share = selected.substring(selected.indexOf("\\") + 1);
                    share = share.split("\\s+")[0];
                    AddPrinterActivity.this.server.setText(server);
                    AddPrinterActivity.this.printer.setText(share);
                    AddPrinterActivity.this.name.setText(server + "-" + share);
                    String workgroup = "";
                    for (int i = 0; i < which; i++) {
                      if (networkTreeCopy[i].indexOf("\\") == -1) workgroup = networkTreeCopy[i];
                    }
                    if (workgroup.length() > 0) AddPrinterActivity.this.domain.setText(workgroup);
                  }
                });
            builder.setNegativeButton(
                R.string.close,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface d, int s) {
                    d.dismiss();
                    if (user.getText().toString().length() == 0
                        || password.getText().toString().length() == 0)
                      Toast.makeText(
                              AddPrinterActivity.this,
                              R.string.login_password_hint,
                              Toast.LENGTH_LONG)
                          .show();
                  }
                });
            builder.setPositiveButton(
                R.string.view_network_button_scan_again,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface d, int s) {
                    d.dismiss();
                    updateNetworkTree();
                    if (user.getText().toString().length() == 0
                        || password.getText().toString().length() == 0)
                      Toast.makeText(
                              AddPrinterActivity.this,
                              R.string.login_password_hint,
                              Toast.LENGTH_LONG)
                          .show();
                  }
                });
            AlertDialog alert = builder.create();
            alert.setOwnerActivity(AddPrinterActivity.this);
            alert.show();
          }
        });
    layout.addView(viewNetwork);

    TextView text = null;

    text = new TextView(this);
    text.setText(R.string.name_desc);
    text.setTextSize(20);
    layout.addView(text);

    name = new EditText(this);
    name.setHint(R.string.name_hint);
    name.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    layout.addView(name);

    text = new TextView(this);
    text.setText(R.string.server_desc);
    text.setTextSize(20);
    layout.addView(text);

    server = new EditText(this);
    server.setHint(R.string.server_hint);
    server.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    layout.addView(server);

    text = new TextView(this);
    text.setText(R.string.printer_desc);
    text.setTextSize(20);
    layout.addView(text);

    printer = new EditText(this);
    printer.setHint(R.string.printer_hint);
    printer.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    layout.addView(printer);

    text = new TextView(this);
    text.setText(R.string.model_desc);
    text.setTextSize(20);
    layout.addView(text);

    model = new EditText(this);
    model.setHint(R.string.model_button_reading);
    model.setEnabled(false);
    model.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    model.addTextChangedListener(
        new TextWatcher() {
          public void afterTextChanged(Editable s) {
            if (s.length() >= 1 && modelList != null) {
              // selectModel.setEnabled(true);
              selectModel.setText(getResources().getString(R.string.model_button_search));
            } else {
              // selectModel.setEnabled(false);
              selectModel.setText(getResources().getString(R.string.model_button_type));
            }
          }

          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          public void onTextChanged(CharSequence s, int start, int before, int count) {}
        });
    layout.addView(model);

    selectModel = new Button(this);
    selectModel.setText(getResources().getString(R.string.model_button_reading));
    selectModel.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            if (!model.isEnabled()) {
              model.setEnabled(true);
              model.setText("");
              return;
            }
            String search = model.getText().toString().toLowerCase();
            final ArrayList<CharSequence> values = new ArrayList<CharSequence>();
            AlertDialog.Builder builder = new AlertDialog.Builder(AddPrinterActivity.this);
            builder.setTitle(R.string.select_printer_model);
            for (String s : modelList.keySet()) {
              if (s.toLowerCase().indexOf(search) != -1) {
                Log.d(TAG, "Found model: " + s);
                values.add(s);
              }
            }
            if (values.size() == 0) {
              builder.setMessage(R.string.no_models_found);
              builder.setPositiveButton(
                  R.string.ok,
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface d, int s) {
                      d.dismiss();
                    }
                  });
            } else {
              builder.setItems(
                  values.toArray(new CharSequence[0]),
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                      model.setText(values.get(which));
                      model.setEnabled(false);
                      selectModel.setText(getResources().getString(R.string.model_button_clear));
                    }
                  });
            }
            AlertDialog alert = builder.create();
            alert.setOwnerActivity(AddPrinterActivity.this);
            alert.show();
          }
        });
    selectModel.setEnabled(false);
    layout.addView(selectModel);

    text = new TextView(this);
    text.setText(R.string.domain_desc);
    text.setTextSize(20);
    layout.addView(text);

    domain = new EditText(this);
    domain.setHint(R.string.domain_hint);
    domain.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    layout.addView(domain);

    text = new TextView(this);
    text.setText(R.string.user_desc);
    text.setTextSize(20);
    layout.addView(text);

    user = new EditText(this);
    user.setHint(R.string.user_hint);
    user.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    layout.addView(user);

    text = new TextView(this);
    text.setText(R.string.password_desc);
    text.setTextSize(20);
    text.setLayoutParams(
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f));

    CheckBox showPassword = new CheckBox(this);
    showPassword.setText(R.string.show_password);
    showPassword.setTextSize(20);
    showPassword.setLayoutParams(
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0.0f));
    showPassword.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            int selection = password.getSelectionStart();
            if (isChecked) {
              password.setInputType(
                  InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
              password.setTransformationMethod(null);
            } else {
              password.setInputType(
                  InputType.TYPE_CLASS_TEXT
                      | InputType.TYPE_TEXT_VARIATION_PASSWORD
                      | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
              password.setTransformationMethod(PasswordTransformationMethod.getInstance());
            }
            password.setSelection(selection);
          }
        });

    LinearLayout layout2 = new LinearLayout(this);
    layout2.setOrientation(LinearLayout.HORIZONTAL);
    layout2.setLayoutParams(
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    layout2.addView(text);
    layout2.addView(showPassword);

    layout.addView(layout2);

    password = new EditText(this);
    password.setHint(R.string.password_hint);
    password.setInputType(
        InputType.TYPE_CLASS_TEXT
            | InputType.TYPE_TEXT_VARIATION_PASSWORD
            | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    password.setTransformationMethod(PasswordTransformationMethod.getInstance());
    layout.addView(password);

    text = new TextView(this);
    text.setText("");
    layout.addView(text);

    addPrinter = new Button(this);
    addPrinter.setEnabled(false);
    addPrinter.setText(
        getResources().getString(R.string.add_printer_button)
            + " - "
            + getResources().getString(R.string.model_button_reading));
    addPrinter.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            if (name.getText().length() == 0
                || server.getText().length() == 0
                || printer.getText().length() == 0
                || model.isEnabled()
                || model.getText().length() == 0) {
              AlertDialog.Builder builder = new AlertDialog.Builder(AddPrinterActivity.this);
              builder.setTitle(R.string.error);
              builder.setMessage(R.string.error_empty_fields);
              builder.setPositiveButton(
                  R.string.ok,
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface d, int s) {
                      d.dismiss();
                    }
                  });
              AlertDialog alert = builder.create();
              alert.setOwnerActivity(AddPrinterActivity.this);
              alert.show();
              return;
            }
            progressCircle.show();
            new Thread(
                    new Runnable() {
                      public void run() {
                        Cups.addPrinter(
                            AddPrinterActivity.this,
                            name.getText().toString(),
                            server.getText().toString(),
                            printer.getText().toString(),
                            modelList.get(model.getText().toString()),
                            domain.getText().toString().toUpperCase(),
                            user.getText().toString(),
                            password.getText().toString());
                        Cups.updatePrintersInfo(AddPrinterActivity.this);
                        runOnUiThread(
                            new Runnable() {
                              public void run() {
                                progressCircle.dismiss();
                                Toast.makeText(
                                        AddPrinterActivity.this,
                                        R.string.printer_added_successfully,
                                        Toast.LENGTH_LONG)
                                    .show();
                                finish();
                              }
                            });
                      }
                    })
                .start();
          }
        });
    layout.addView(addPrinter);

    progressCircle = new ProgressDialog(this);
    progressCircle.setMessage(getResources().getString(R.string.please_wait));

    updateNetworkTree();

    Uri uri = getIntent() != null ? getIntent().getData() : null;
    if (uri != null
        && uri.getScheme() != null
        && uri.getHost() != null
        && getResources().getString(R.string.add_printer_scheme).equals(uri.getScheme())
        && getResources().getString(R.string.add_printer_host).equals(uri.getHost())) {
      name.setText(uri.getQueryParameter("n"));
      server.setText(uri.getQueryParameter("s"));
      printer.setText(uri.getQueryParameter("p"));
      model.setText(uri.getQueryParameter("m"));
      domain.setText(uri.getQueryParameter("d"));
      user.setText(uri.getQueryParameter("u"));
      password.setText(uri.getQueryParameter("pw"));
    }

    updateModelList();
  }
    public View getView() throws UnsupportedOperationException {
      if (mType.equals("checkbox")) {
        CheckBox checkbox = new CheckBox(GeckoApp.mAppContext);
        checkbox.setLayoutParams(
            new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        checkbox.setText(mLabel);
        checkbox.setChecked(getSafeBool(mJSONInput, "checked"));
        mView = (View) checkbox;
      } else if (mType.equals("date")) {
        try {
          DateTimePicker input =
              new DateTimePicker(
                  GeckoApp.mAppContext, "yyyy-MM-dd", mValue, DateTimePicker.PickersState.DATE);
          input.toggleCalendar(true);
          mView = (View) input;
        } catch (UnsupportedOperationException ex) {
          // We can't use our custom version of the DatePicker widget because the sdk is too old.
          // But we can fallback on the native one.
          DatePicker input = new DatePicker(GeckoApp.mAppContext);
          try {
            if (!TextUtils.isEmpty(mValue)) {
              GregorianCalendar calendar = new GregorianCalendar();
              calendar.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(mValue));
              input.updateDate(
                  calendar.get(Calendar.YEAR),
                  calendar.get(Calendar.MONTH),
                  calendar.get(Calendar.DAY_OF_MONTH));
            }
          } catch (Exception e) {
            Log.e(LOGTAG, "error parsing format string: " + e);
          }
          mView = (View) input;
        }
      } else if (mType.equals("week")) {
        DateTimePicker input =
            new DateTimePicker(
                GeckoApp.mAppContext, "yyyy-'W'ww", mValue, DateTimePicker.PickersState.WEEK);
        mView = (View) input;
      } else if (mType.equals("time")) {
        TimePicker input = new TimePicker(GeckoApp.mAppContext);
        input.setIs24HourView(DateFormat.is24HourFormat(GeckoApp.mAppContext));

        GregorianCalendar calendar = new GregorianCalendar();
        if (!TextUtils.isEmpty(mValue)) {
          try {
            calendar.setTime(new SimpleDateFormat("kk:mm").parse(mValue));
          } catch (Exception e) {
          }
        }
        input.setCurrentHour(calendar.get(GregorianCalendar.HOUR_OF_DAY));
        input.setCurrentMinute(calendar.get(GregorianCalendar.MINUTE));
        mView = (View) input;
      } else if (mType.equals("datetime-local") || mType.equals("datetime")) {
        DateTimePicker input =
            new DateTimePicker(
                GeckoApp.mAppContext,
                "yyyy-MM-dd kk:mm",
                mValue,
                DateTimePicker.PickersState.DATETIME);
        input.toggleCalendar(true);
        mView = (View) input;
      } else if (mType.equals("month")) {
        DateTimePicker input =
            new DateTimePicker(
                GeckoApp.mAppContext, "yyyy-MM", mValue, DateTimePicker.PickersState.MONTH);
        mView = (View) input;
      } else if (mType.equals("textbox") || mType.equals("password")) {
        EditText input = new EditText(GeckoApp.mAppContext);
        int inputtype = InputType.TYPE_CLASS_TEXT;
        if (mType.equals("password")) {
          inputtype |=
              InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
        input.setInputType(inputtype);
        input.setText(mValue);

        if (!TextUtils.isEmpty(mHint)) {
          input.setHint(mHint);
        }

        if (mAutofocus) {
          input.setOnFocusChangeListener(
              new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
                  if (hasFocus) {
                    ((InputMethodManager)
                            GeckoApp.mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .showSoftInput(v, 0);
                  }
                }
              });
          input.requestFocus();
        }

        mView = (View) input;
      } else if (mType.equals("menulist")) {
        Spinner spinner = new Spinner(GeckoApp.mAppContext);
        try {
          String[] listitems = getStringArray(mJSONInput, "values");
          if (listitems.length > 0) {
            ArrayAdapter<String> adapter =
                new ArrayAdapter<String>(
                    GeckoApp.mAppContext, R.layout.simple_dropdown_item_1line, listitems);
            spinner.setAdapter(adapter);
            int selectedIndex = getSafeInt(mJSONInput, "selected");
            spinner.setSelection(selectedIndex);
          }
        } catch (Exception ex) {
        }
        mView = (View) spinner;
      } else if (mType.equals("label")) {
        // not really an input, but a way to add labels and such to the dialog
        TextView view = new TextView(GeckoApp.mAppContext);
        view.setText(Html.fromHtml(mLabel));
        mView = view;
      }
      return mView;
    }
Beispiel #15
0
  public void displayAccounts() {
    accounts = b2evolution.DB.getAccounts(this);
    HashMap<?, ?> notificationOptions = b2evolution.DB.getNotificationOptions(this);
    boolean sound = false, vibrate = false, light = false, taglineValue = false;
    String tagline = "";

    if (notificationOptions != null) {
      if (notificationOptions.get("sound").toString().equals("1")) {
        sound = true;
      }
      if (notificationOptions.get("vibrate").toString().equals("1")) {
        vibrate = true;
      }
      if (notificationOptions.get("light").toString().equals("1")) {
        light = true;
      }
      if (notificationOptions.get("tagline_flag").toString().equals("1")) {
        taglineValue = true;
      }
      tagline = notificationOptions.get("tagline").toString();
    }

    if (accounts.size() > 0) {
      ScrollView sv = new ScrollView(this);
      sv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
      sv.setBackgroundColor(Color.parseColor("#FFFFFFFF"));
      LinearLayout layout = new LinearLayout(this);

      layout.setPadding(14, 14, 14, 14);
      layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

      layout.setOrientation(LinearLayout.VERTICAL);
      layout.setGravity(Gravity.LEFT);

      final LinearLayout cbLayout = new LinearLayout(this);

      cbLayout.setLayoutParams(
          new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

      cbLayout.setOrientation(LinearLayout.VERTICAL);

      LinearLayout.LayoutParams section1Params =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

      section1Params.setMargins(0, 0, 0, 20);

      LinearLayout section1 = new LinearLayout(this);
      section1.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg));
      section1.setLayoutParams(section1Params);
      section1.setOrientation(LinearLayout.VERTICAL);

      LinearLayout.LayoutParams headerParams =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      headerParams.setMargins(1, 1, 1, 0);
      TextView textView = new TextView(this);
      textView.setLayoutParams(headerParams);
      textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      textView.setTypeface(Typeface.DEFAULT_BOLD);
      textView.setPadding(0, 4, 0, 4);
      textView.setShadowLayer(1, 0, 2, Color.parseColor("#FFFFFFFF"));
      textView.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg_header));
      textView.setText("  " + getResources().getText(R.string.comment_notifications));

      section1.addView(textView);

      LinearLayout.LayoutParams cbParams =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      cbParams.setMargins(4, 0, 0, 6);

      for (int i = 0; i < accounts.size(); i++) {

        HashMap<?, ?> curHash = (HashMap<?, ?>) accounts.get(i);
        String curBlogName = curHash.get("blogName").toString();
        String accountID = curHash.get("id").toString();
        int runService = Integer.valueOf(curHash.get("runService").toString());
        accountNames.add(i, curBlogName);

        final CheckBox checkBox = new CheckBox(this);
        checkBox.setTextColor(Color.parseColor("#444444"));
        checkBox.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        checkBox.setText(EscapeUtils.unescapeHtml(curBlogName));
        checkBox.setId(Integer.valueOf(accountID));
        checkBox.setLayoutParams(cbParams);

        if (runService == 1) {
          checkBox.setChecked(true);
        }

        cbLayout.addView(checkBox);
      }

      if (cbLayout.getChildCount() > 0) {
        section1.addView(cbLayout);
      }

      // add spinner and buttons
      TextView textView2 = new TextView(this);
      LinearLayout.LayoutParams labelParams =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      labelParams.setMargins(8, 0, 0, 0);
      textView2.setLayoutParams(labelParams);
      textView2.setTextColor(Color.parseColor("#444444"));
      textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      textView2.setText(getResources().getText(R.string.notifications_interval));

      section1.addView(textView2);

      final Spinner sInterval = new Spinner(this);
      LinearLayout.LayoutParams spinnerParams =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      spinnerParams.setMargins(4, 0, 4, 10);
      sInterval.setLayoutParams(spinnerParams);
      ArrayAdapter<Object> sIntervalArrayAdapter =
          new ArrayAdapter<Object>(
              this,
              R.layout.spinner_textview,
              new String[] {
                "5 Minutes",
                "10 Minutes",
                "15 Minutes",
                "30 Minutes",
                "1 Hour",
                "3 Hours",
                "6 Hours",
                "12 Hours",
                "Daily"
              });
      sIntervalArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      sInterval.setAdapter(sIntervalArrayAdapter);
      String interval = b2evolution.DB.getInterval(this);

      if (interval != "") {
        sInterval.setSelection(sIntervalArrayAdapter.getPosition(interval));
      }

      section1.addView(sInterval);

      final LinearLayout nOptionsLayout = new LinearLayout(this);

      nOptionsLayout.setLayoutParams(
          new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

      nOptionsLayout.setOrientation(LinearLayout.VERTICAL);

      CheckBox soundCB = new CheckBox(this);
      soundCB.setTag("soundCB");
      soundCB.setTextColor(Color.parseColor("#444444"));
      soundCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      soundCB.setText(getResources().getText(R.string.notification_sound));
      soundCB.setLayoutParams(cbParams);
      soundCB.setChecked(sound);

      nOptionsLayout.addView(soundCB);

      CheckBox vibrateCB = new CheckBox(this);
      vibrateCB.setTag("vibrateCB");
      vibrateCB.setTextColor(Color.parseColor("#444444"));
      vibrateCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      vibrateCB.setText(getResources().getText(R.string.notification_vibrate));
      vibrateCB.setLayoutParams(cbParams);
      vibrateCB.setChecked(vibrate);

      nOptionsLayout.addView(vibrateCB);

      CheckBox lightCB = new CheckBox(this);
      lightCB.setTag("lightCB");
      lightCB.setTextColor(Color.parseColor("#444444"));
      lightCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      lightCB.setText(getResources().getText(R.string.notification_blink));
      lightCB.setLayoutParams(cbParams);
      lightCB.setChecked(light);

      nOptionsLayout.addView(lightCB);

      section1.addView(nOptionsLayout);

      layout.addView(section1);

      final LinearLayout section2 = new LinearLayout(this);
      section2.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg));
      section2.setOrientation(LinearLayout.VERTICAL);
      LinearLayout.LayoutParams section2Params =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      section2Params.setMargins(0, 0, 0, 20);
      section2.setLayoutParams(section2Params);
      section2.setPadding(0, 0, 0, 10);

      TextView section2lbl = new TextView(this);
      section2lbl.setLayoutParams(headerParams);
      section2lbl.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      section2lbl.setTypeface(Typeface.DEFAULT_BOLD);
      section2lbl.setShadowLayer(1, 0, 2, Color.parseColor("#FFFFFFFF"));
      section2lbl.setPadding(0, 4, 0, 4);
      section2lbl.setText("  " + getResources().getText(R.string.post_signature));
      section2lbl.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg_header));

      section2.addView(section2lbl);

      CheckBox taglineCB = new CheckBox(this);
      taglineCB.setTag("taglineCB");
      taglineCB.setTextColor(Color.parseColor("#444444"));
      taglineCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      taglineCB.setText(getResources().getText(R.string.add_tagline));
      taglineCB.setLayoutParams(cbParams);
      taglineCB.setChecked(taglineValue);

      section2.addView(taglineCB);

      EditText taglineET = new EditText(this);
      LinearLayout.LayoutParams taglineParams =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      taglineParams.setMargins(4, 0, 4, 4);
      taglineET.setLayoutParams(taglineParams);
      if (tagline != null) {
        if (tagline.equals("")) {
          if (BlackBerryUtils.getInstance().isBlackBerry())
            taglineET.setText(getResources().getText(R.string.posted_from_blackberry));
          else taglineET.setText(getResources().getText(R.string.posted_from));
        } else {
          taglineET.setText(tagline);
        }
      }
      taglineET.setMinLines(2);
      section2.addView(taglineET);

      layout.addView(section2);

      final LinearLayout section3 = new LinearLayout(this);
      section3.setOrientation(LinearLayout.HORIZONTAL);
      section3.setGravity(Gravity.RIGHT);
      LinearLayout.LayoutParams section3Params =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      section3Params.setMargins(0, 0, 0, 20);
      section3.setLayoutParams(section3Params);

      final Button cancel = new Button(this);

      LinearLayout.LayoutParams cancelParams =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      cancelParams.setMargins(0, 0, 10, 0);
      cancel.setLayoutParams(cancelParams);
      cancel.setBackgroundDrawable(getResources().getDrawable(R.drawable.b2evo_button_small));
      cancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
      cancel.setText(getResources().getText(R.string.cancel));
      cancel.setOnClickListener(
          new Button.OnClickListener() {
            public void onClick(View v) {
              finish();
            }
          });
      section3.addView(cancel);

      final Button save = new Button(this);

      save.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));
      save.setBackgroundDrawable(getResources().getDrawable(R.drawable.b2evo_button_small));
      save.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
      save.setText(getResources().getText(R.string.save));

      save.setOnClickListener(
          new Button.OnClickListener() {
            public void onClick(View v) {

              boolean sound = false, vibrate = false, light = false, tagValue = false;
              checkCtr = 0;

              int listItemCount = cbLayout.getChildCount();
              for (int i = 0; i < listItemCount; i++) {
                CheckBox cbox = (CheckBox) cbLayout.getChildAt(i);
                int id = cbox.getId();
                if (cbox.isChecked()) {
                  checkCtr++;
                  b2evolution.DB.updateNotificationFlag(id, true);
                  Log.i("CommentService", "Service enabled for " + cbox.getText());
                } else {
                  b2evolution.DB.updateNotificationFlag(id, false);
                }
              }

              int noOptionsItemCount = nOptionsLayout.getChildCount();
              for (int i = 0; i < noOptionsItemCount; i++) {
                CheckBox cbox = (CheckBox) nOptionsLayout.getChildAt(i);
                if (cbox.getTag().equals("soundCB")) {
                  sound = cbox.isChecked();
                } else if (cbox.getTag().equals("vibrateCB")) {
                  vibrate = cbox.isChecked();
                } else if (cbox.getTag().equals("lightCB")) {
                  light = cbox.isChecked();
                }
              }

              CheckBox tagFlag = (CheckBox) section2.getChildAt(1);
              tagValue = tagFlag.isChecked();

              EditText taglineET = (EditText) section2.getChildAt(2);
              String taglineText = taglineET.getText().toString();

              b2evolution.DB.updateNotificationSettings(
                  sInterval.getSelectedItem().toString(),
                  sound,
                  vibrate,
                  light,
                  tagValue,
                  taglineText);

              if (checkCtr > 0) {

                String updateInterval = sInterval.getSelectedItem().toString();
                int UPDATE_INTERVAL = 3600000;

                // configure time interval
                if (updateInterval.equals("5 Minutes")) {
                  UPDATE_INTERVAL = 300000;
                } else if (updateInterval.equals("10 Minutes")) {
                  UPDATE_INTERVAL = 600000;
                } else if (updateInterval.equals("15 Minutes")) {
                  UPDATE_INTERVAL = 900000;
                } else if (updateInterval.equals("30 Minutes")) {
                  UPDATE_INTERVAL = 1800000;
                } else if (updateInterval.equals("1 Hour")) {
                  UPDATE_INTERVAL = 3600000;
                } else if (updateInterval.equals("3 Hours")) {
                  UPDATE_INTERVAL = 10800000;
                } else if (updateInterval.equals("6 Hours")) {
                  UPDATE_INTERVAL = 21600000;
                } else if (updateInterval.equals("12 Hours")) {
                  UPDATE_INTERVAL = 43200000;
                } else if (updateInterval.equals("Daily")) {
                  UPDATE_INTERVAL = 86400000;
                }

                Intent intent = new Intent(Preferences.this, CommentBroadcastReceiver.class);
                PendingIntent pIntent = PendingIntent.getBroadcast(Preferences.this, 0, intent, 0);

                AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

                alarmManager.setRepeating(
                    AlarmManager.RTC_WAKEUP,
                    System.currentTimeMillis() + (5 * 1000),
                    UPDATE_INTERVAL,
                    pIntent);

              } else {
                Intent stopIntent = new Intent(Preferences.this, CommentBroadcastReceiver.class);
                PendingIntent stopPIntent =
                    PendingIntent.getBroadcast(Preferences.this, 0, stopIntent, 0);
                AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
                alarmManager.cancel(stopPIntent);

                Intent service = new Intent(Preferences.this, CommentService.class);
                stopService(service);
              }

              finish();
            }
          });

      section3.addView(save);
      layout.addView(section3);

      sv.addView(layout);

      setContentView(sv);
    }
  }
 public void setMarginRightCheckBox(int marginRight) {
   LayoutParams params = (LayoutParams) checkOption.getLayoutParams();
   params.rightMargin = marginRight;
   checkOption.setLayoutParams(params);
 }
Beispiel #17
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_6_tags);

    initializeWizard(this, FirstStart.class, 0);
    data = getIntent().getExtras();

    title = this.getResources().getString(R.string.help_add_tags_title);
    helpText = this.getResources().getString(R.string.help_add_tags);

    // Override the default next button behaviour
    bNext.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            fillData();

            // Submit the activity to the server
            boolean success = Caller.getInstance(getApplicationContext()).addRecommendation(data);
            if (success) {
              Toast.makeText(AddTags.this, getString(R.string.msgAddSuccess), Toast.LENGTH_LONG)
                  .show();
            } else {
              Toast.makeText(AddTags.this, getString(R.string.msgAddFailure), Toast.LENGTH_LONG)
                  .show();
            }
            // Return back to first activity (pop other activities off stack)
            Intent i = new Intent(AddTags.this, FirstStart.class);
            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(i);
          }
        });
    bNext.setText(getString(R.string.bSubmit));

    tags = new ArrayList<String>();
    manualtags = new ArrayList<String>();
    restoreData();

    rlAddTag = (RelativeLayout) findViewById(R.id.rlAddTagScrollableContent);
    tvAutoTag = (TextView) findViewById(R.id.tvAddAutoTag);
    tvManualTag = (TextView) findViewById(R.id.tvAddManualTag);

    // Add Manual Tags button
    bNewTag = (Button) findViewById(R.id.bAddNewTag);
    bNewTag.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            showDialog(DIALOG_ADD_MANUAL_TAG);
          }
        });

    // Get autotags from the server if we need to
    if (autotags == null) {
      autotags = getAutoGeneratedTags();
    }
    if (autotags == null || autotags.length == 0) {
      tvAutoTag.setVisibility(View.GONE);
      tvManualTag.setText(R.string.tvAddManualTagNoAuto);
    } else {
      // Programmatically create the check boxes for the autotags
      for (int i = 0; i < autotags.length; ++i) {
        CheckBox box = new CheckBox(AddTags.this);
        RelativeLayout.LayoutParams params =
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.BELOW, i == 0 ? tvAutoTag.getId() : i);
        box.setLayoutParams(params);
        box.setId(i + 1);
        box.setText(autotags[i]);
        box.setTextColor(Color.BLACK);
        for (String tag : tags) {
          if (tag.equals(autotags[i])) {
            box.setChecked(true);
            break;
          }
        }
        // add listener to add/remove the tag from the tags list
        box.setOnCheckedChangeListener(new TagCheckChangeListener());
        rlAddTag.addView(box);

        params = (RelativeLayout.LayoutParams) tvManualTag.getLayoutParams();
        params.addRule(RelativeLayout.BELOW, i + 1);
      }
    }

    // Create checkboxes for previously added manual tags
    if (manualtags.size() > 0) {
      for (int i = 0; i < manualtags.size(); ++i) {
        addManualCheckBox(i);
      }
    }

    if (tags.size() == 0) {
      bNext.setEnabled(false);
    }
  }
Beispiel #18
0
  private void dibujarDias() {
    for (int i = 0; i < mDias.size(); i++) {
      final List<String> needPhotos = new ArrayList<>();

      View vDia = LayoutInflater.from(this).inflate(R.layout.proyectos_detalle, null, false);

      TextView dia_p_programado = (TextView) vDia.findViewById(R.id.programado);
      final TextView dia_p_real = (TextView) vDia.findViewById(R.id.real);
      TextView dia_n = (TextView) vDia.findViewById(R.id.dia);
      final LinearLayout dia_contenido = (LinearLayout) vDia.findViewById(R.id.content);
      final LinearLayout dia_actividades = (LinearLayout) vDia.findViewById(R.id.activityList);
      final EditText p_real = (EditText) vDia.findViewById(R.id.avance);
      final EditText p_fecha = (EditText) vDia.findViewById(R.id.fecha);
      EditText p_observacion = (EditText) vDia.findViewById(R.id.observacion);
      final ImageButton expand = (ImageButton) vDia.findViewById(R.id.expand);
      ImageButton dia_foto = (ImageButton) vDia.findViewById(R.id.foto);

      /*p_fecha.setOnFocusChangeListener(new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View view, boolean b) {
              if (b) {
                  p_fecha.setText("");
              }
          }
      });*/
      dia_foto.setVisibility(View.GONE);

      expand.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              if (dia_contenido.getVisibility() == View.GONE) {
                dia_contenido.setVisibility(View.VISIBLE);
                expand.setImageResource(R.drawable.ic_action_close);
              } else {
                dia_contenido.setVisibility(View.GONE);
                expand.setImageResource(R.drawable.ic_action_open);
              }
            }
          });

      final Dia dia = mDias.get(i);
      final ArrayList<Actividad> actividadArrayList = dia.getActividades();
      dia.setAdvanceToday("0");

      p_fecha.setText(dia.getDate());

      /*p_fecha.setOnFocusChangeListener(new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View view, boolean b) {
              if (!b) {
                  if (!Funciones.validateDate(p_fecha.getText().toString())) {
                      AlertDialog.Builder b1 = new AlertDialog.Builder(mContext);
                      b1.setIcon(android.R.drawable.ic_dialog_alert);
                      b1.setMessage("Formato de fecha Incorrecto.\nDebe ser AAAA-MM-DD");
                      b1.setTitle("Dia " + dia.getDayNumber());
                      b1.setNeutralButton("OK", new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialogInterface, int i) {
                              dialogInterface.dismiss();
                          }
                      });
                      b1.show();
                      error = true;
                  } else {
                      error = false;
                      try {
                          DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
                          Date hoy = new Date();
                          Date fecha_envia = formatter.parse(p_fecha.getText().toString());

                          Log.d("FECHAS", hoy + "  " + fecha_envia);
                          if (formatter.format(fecha_envia).compareTo(formatter.format(hoy)) < 0) {
                              AlertDialog.Builder b1 = new AlertDialog.Builder(mContext);
                              b1.setIcon(android.R.drawable.ic_dialog_alert);
                              b1.setMessage("No puede ingresar una fecha anterior al día de hoy.");
                              b1.setTitle("Dia " + dia.getDayNumber());
                              b1.setNeutralButton("OK", new DialogInterface.OnClickListener() {
                                  @Override
                                  public void onClick(DialogInterface dialogInterface, int i) {
                                      dialogInterface.dismiss();
                                  }
                              });
                              b1.show();
                              error = true;
                          }
                      } catch (Exception e) {
                          e.printStackTrace();
                          error = true;
                      }

                  }
              }
          }
      });*/

      p_observacion.setText(dia.getDescriptionDay());
      dia_p_programado.setText(dia.getProgrammedAdvance());
      dia_p_real.setText(dia.getRealAdvance());
      dia_n.setText("DIA " + dia.getDayNumber());

      dia.setFecha(p_fecha);
      dia.setlContenido(dia_contenido);

      ArrayList<CheckBox> checkBoxes = new ArrayList<>();
      for (int j = 0; j < actividadArrayList.size(); j++) {
        final Actividad a = actividadArrayList.get(j);

        /** SI una actividad requiere foto se activara el boton * */
        if (a.isFoto()) dia_foto.setVisibility(View.VISIBLE);
        needPhotos.add(dia.getDayNumber() + ";" + a.getNameActivity());

        CheckBox c = new CheckBox(mContext);
        c.setLayoutParams(
            new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        c.setText(a.getNameActivity());
        c.setPadding(0, 0, 0, 24);

        if (a.isSelected()) {
          c.setEnabled(false);
          c.setChecked(true);
        }

        c.setOnCheckedChangeListener(
            new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton compoundButton, boolean b) {

                Log.i("CHECKBOX LISTENER", "****");
                float advance;
                if (dia.getAdvanceToday() == null) {
                  advance = 0;
                } else advance = Float.parseFloat(dia.getAdvanceToday());
                Log.i("CHECKBOX LISTENER", "advance: " + advance);
                try {
                  if (b) {
                    advance += a.getAdvance();
                    avance_real_total += a.getAdvance();
                    dia.setModify(true);

                    for (int k = dia.getDayNumber() - 1; k < mAvances.size(); k++) {
                      float actual = Float.parseFloat(mAvances.get(k).getText().toString());
                      mAvances
                          .get(k)
                          .setText(
                              String.format(Locale.US, FLOAT_FORMAT, (actual + a.getAdvance())));
                    }

                  } else {
                    advance -= a.getAdvance();
                    avance_real_total -= a.getAdvance();
                    if (advance < 0) advance *= -1;

                    for (int k = dia.getDayNumber() - 1; k < mAvances.size(); k++) {
                      float actual = Float.parseFloat(mAvances.get(k).getText().toString());
                      mAvances
                          .get(k)
                          .setText(
                              String.format(Locale.US, FLOAT_FORMAT, (actual - a.getAdvance())));
                    }
                  }

                  Log.i("CHECKBOX LISTENER", "to: " + advance);
                  dia.setAdvanceToday(String.format(Locale.US, FLOAT_FORMAT, advance));
                  p_real.setText(String.format(Locale.US, FLOAT_FORMAT, advance));
                  updateProgresoTotal();
                } catch (Exception e) {
                  Toast.makeText(
                          mContext,
                          e.getMessage() + "\n" + e.getCause() + "\n" + e.getLocalizedMessage(),
                          Toast.LENGTH_LONG)
                      .show();
                }
              }
            });
        checkBoxes.add(c);
        dia_actividades.addView(c);
      }

      dia_foto.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              DateFormat timestamp_name = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
              imgActual = new ImagenDia(mProyecto.getId(), dia.getDayNumber(), null, new Date());
              imgActual.setFilename(
                  imgActual.getIdproject()
                      + "_"
                      + imgActual.getIdday()
                      + "_"
                      + timestamp_name.format(imgActual.getTimestamp())
                      + ".png");
              tomarFotografia();
            }
          });

      mAvances.add(dia_p_real);
      dia.setFecha(p_fecha);
      dia.setObservacion(p_observacion);
      dia.setAvance(p_real);
      dia.setCheckBoxes(checkBoxes);
      listadoDias.addView(vDia);
    }
  }