Exemple #1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    Intent myIntent;

    switch (item.getItemId()) {
      case R.id.notes:
        myIntent = new Intent(getBaseContext(), Notes.class);
        myIntent.putExtra("previousActivity", ActivityEnum.ViewNote.toString());
        startActivity(myIntent);
        return true;
      case R.id.change_children_profile:
        myIntent = new Intent(getBaseContext(), ChangeChildrenProfile.class);
        myIntent.putExtra("previousActivity", ActivityEnum.ViewNote.toString());
        startActivity(myIntent);
        return true;
      case R.id.logout:
        DataManager.reset();
        myIntent = new Intent(getBaseContext(), Login.class);
        myIntent.putExtra("previousActivity", ActivityEnum.Notes.toString());
        startActivity(myIntent);

        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
Exemple #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_note);

    DataManager.getCurrentState().setActivity(this);

    imageView_photo = (ImageView) findViewById(R.id.imageView_photo);
    textView_tittle = (TextView) findViewById(R.id.textView_tittle);
    textView_description = (TextView) findViewById(R.id.textView_description);
    button_edit = (Button) findViewById(R.id.button_edit);
    button_back = (Button) findViewById(R.id.button_back);

    Note note = DataManager.getNote();
    // Note note = new Note();
    // note.setTitle("title");
    // note.setDescription("asdasdasdjlshdddddddddddddddddddddddddddddddasdas;ldka;sldkasljdkajshdlksjahfljasdhlkjasdhfad");
    //
    // Bitmap bmp1 = BitmapFactory.decodeResource(getResources(),
    // R.drawable.add);
    //
    // note.setPhoto(DataManager.getImageBytes(bmp1));
    // //note.hasImage = false;

    textView_tittle.setText(note.getTitle());
    textView_description.setText(note.getDescription());

    if (note.hasImage) {
      Bitmap bmp = DataManager.getImageFromBytes(note.getPhoto());
      imageView_photo.setImageBitmap(bmp);
    } else imageView_photo.setVisibility(View.GONE);

    button_edit.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            //				Intent myIntent = new Intent(getBaseContext(), EditNote.class);
            //				myIntent.putExtra("previousActivity",
            //						ActivityEnum.ViewNote.toString());
            //				myIntent.putExtra("isUpdate", true);
            //				startActivity(myIntent);
            DataManager.getCurrentState().leftButtonBarButtonClicked(getBaseContext());
          }
        });

    button_back.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            //				String value = getIntent().getStringExtra("previousActivity");
            //				ActivityEnum aEnum = ActivityEnum.valueOf(value);
            //
            //				Intent myIntent;
            //
            //				switch (aEnum) {
            ////				case ChangeChildrenProfile:
            ////					myIntent = new Intent(getBaseContext(),
            ////							ChangeChildrenProfile.class);
            ////					myIntent.putExtra("previousActivity",
            ////							ActivityEnum.ViewNote.toString());
            ////					startActivity(myIntent);
            ////					break;
            //				case Notes:
            //					myIntent = new Intent(getBaseContext(), Notes.class);
            //					myIntent.putExtra("previousActivity",
            //							ActivityEnum.ViewNote.toString());
            //					startActivity(myIntent);
            //					break;
            //				case EditNote:
            //					myIntent = new Intent(getBaseContext(),
            //							Notes.class);
            //					myIntent.putExtra("previousActivity",
            //							ActivityEnum.ViewNote.toString());
            //					startActivity(myIntent);
            //					break;
            //				}

            DataManager.getCurrentState().rightButtonBarButtonClicked(getBaseContext());
          }
        });

    ActionBar aBar = getActionBar();
    aBar.setDisplayShowTitleEnabled(false);
    aBar.setDisplayShowHomeEnabled(false);
    aBar.show();
    getOverflowMenu();
  }
Exemple #3
0
  @SuppressWarnings("deprecation")
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration_hints);

    DataManager.getCurrentState().setActivity(this);
    edit_name = (EditText) findViewById(R.id.edit_name);
    edit_surname = (EditText) findViewById(R.id.edit_surname);
    edit_middlename = (EditText) findViewById(R.id.edit_middlename);
    edit_login = (EditText) findViewById(R.id.edit_login);
    edit_password = (EditText) findViewById(R.id.edit_password);
    edit_passwordConfirm = (EditText) findViewById(R.id.edit_passwordConfirm);
    datepicker_birthdate = (DatePicker) findViewById(R.id.datePicker_birthdate);
    button_ok = (Button) findViewById(R.id.button_ok);
    button_back = (Button) findViewById(R.id.button_back);

    checkBox_showPassword = (CheckBox) findViewById(R.id.checkBox_showPassword);

    adapter = new DataAdapter(this);
    adapter.open();

    Intent intent = getIntent();
    isUpdate = intent.getBooleanExtra("isUpdate", false);
    edit_login.setText(intent.getStringExtra("login"));
    if (isUpdate) {
      // loginLayout.setVisibility(1);
      edit_login.setVisibility(1);
      // edit_name.setText(intent.getStringExtra("name"));
      // edit_surname.setText(intent.getStringExtra("surname"));
      // edit_middlename.setText(intent.getStringExtra("middlename"));
      // index = intent.getIntExtra("id", 0);
      // String birthdate = intent.getStringExtra("birthdate");
      // SimpleDateFormat format = new SimpleDateFormat(
      // DataAdapter.DATE_FORMAT);
      // Date date = new Date();
      // try {
      // date = format.parse(birthdate);
      // } catch (ParseException e) {
      // e.printStackTrace();
      // }

      edit_name.setText(DataManager.getAccount().getName());
      edit_surname.setText(DataManager.getAccount().getSurname());
      edit_middlename.setText(DataManager.getAccount().getMiddlename());
      index = DataManager.getAccount().getId();
      Date date = DataManager.getAccount().getBirthdate();

      datepicker_birthdate.init(
          date.getYear(),
          date.getMonth(),
          date.getDate(),
          new DatePicker.OnDateChangedListener() {
            @Override
            public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {}
          });
    }

    button_ok.setOnClickListener(
        new View.OnClickListener() {
          @SuppressWarnings("deprecation")
          @Override
          public void onClick(View v) {
            try {
              String message = "";
              if (!isPasswordValid(edit_password.getText().toString())) {
                message = "ѕароль должен быть не меньше " + _passwordLength + " символов";
                edit_password.setError(message);
                new MyAsyncTask(getApplicationContext()).execute(message);
                return;
              }
              if (!passwordConfirmed) {
                message = "ѕароли не свопадают";
                edit_passwordConfirm.setError(message);
                new MyAsyncTask(getApplicationContext()).execute(message);
                return;
              }

              Account parent = new Account();
              parent.setId(index);
              parent.setName(edit_name.getText().toString());
              parent.setSurname(edit_surname.getText().toString());
              parent.setMiddlename(edit_middlename.getText().toString());
              parent.setLogin(edit_login.getText().toString());
              parent.setPassword(edit_password.getText().toString());

              // Date date = new Date();
              //
              // date.setDate(datepicker_birthdate.getDayOfMonth());
              // date.setMonth(datepicker_birthdate.getMonth());
              // date.setYear(datepicker_birthdate.getYear());

              Date date =
                  new Date(
                      datepicker_birthdate.getYear() - 1900,
                      datepicker_birthdate.getMonth(),
                      datepicker_birthdate.getDayOfMonth());

              parent.setBirthdate(date);

              if (isUpdate) adapter.updateParent(parent);
              else {
                adapter.insertParent(parent);
              }
              int id = adapter.getAccountId(parent.getLogin());
              parent.setId(id);
              DataManager.setAccount(parent);

              adapter.close();

              // переход на профиль ребенка
              //					Intent myIntent = new Intent(getBaseContext(),
              //							ChildrenProfile.class);
              //					myIntent.putExtra("previousActivity",
              //							ActivityEnum.Registration.toString());
              //					startActivity(myIntent);
              DataManager.getCurrentState().leftButtonBarButtonClicked(getBaseContext());
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });

    button_back.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            //				Intent myIntent = new Intent(getBaseContext(),
            //						Login.class);
            //				myIntent.putExtra("previousActivity",
            //						ActivityEnum.Registration.toString());
            //				startActivity(myIntent);
            DataManager.getCurrentState().rightButtonBarButtonClicked(getBaseContext());
          }
        });

    checkBox_showPassword.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (checkBox_showPassword.isChecked()) {
              edit_password.setInputType(InputType.TYPE_CLASS_TEXT);
              edit_passwordConfirm.setInputType(InputType.TYPE_CLASS_TEXT);
            } else {
              edit_password.setInputType(
                  InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
              edit_passwordConfirm.setInputType(
                  InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            }
          }
        });

    TextWatcher watcher =
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

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

          @Override
          public void afterTextChanged(Editable s) {
            if (edit_password
                .getText()
                .toString()
                .equals(edit_passwordConfirm.getText().toString())) {
              edit_passwordConfirm.setBackgroundColor(Color.GREEN);
              passwordConfirmed = true;
            } else {
              edit_passwordConfirm.setBackgroundColor(Color.RED);
              passwordConfirmed = false;
            }
            edit_passwordConfirm.refreshDrawableState();
          }
        };

    edit_passwordConfirm.addTextChangedListener(watcher);
    edit_password.addTextChangedListener(watcher);
  }