Exemplo n.º 1
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item = menu.findItem(R.id.action_sending);
    ParseUser currentUser = ParseUser.getCurrentUser();
    String[] list = getResources().getStringArray(R.array.admin_mail_address);
    item.setVisible(false);
    if (currentUser != null) {
      Log.e("Name", currentUser.getUsername());
      Log.e("Name", currentUser.getEmail());

    } else {
      Log.e("NULL USER", "NOT LOGGED IN");
    }
    if (currentUser != null) {
      for (String s : list) {
        if (currentUser.getEmail().equals(s)) {
          item.setVisible(true);
          Log.e("Vis", "TRUE");
          break;
        }
      }
    }
    super.onPrepareOptionsMenu(menu);
    return true;
  }
Exemplo n.º 2
0
  public static User getLoggedUser(Class<? extends SunshineUser> c) {
    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser != null) {

      if (user == null) user = new User();

      if (currentUser.get("facebookData") == null) {
        user.setImg(currentUser.getParseFile("img").getUrl());
      } else {

        try {
          JSONObject fb = new JSONObject(currentUser.getString("facebookData"));
          String id = fb.getString("id");
          user.setImg("https://graph.facebook.com/" + id + "/picture?type=large");
        } catch (JSONException e) {
          e.printStackTrace();
        }
      }
      user.setEmail(currentUser.getEmail());
      user.setName(currentUser.getString("name"));
      user.setUserName(currentUser.getUsername());
      user.setObjectId(currentUser.getObjectId());
      user.setCreatedAt(currentUser.getCreatedAt());
      user.setUpdateAt(currentUser.getUpdatedAt());
      return user;
    } else {
      return null;
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Don't show the Action Bar on the start screen
    getActionBar().hide();

    setFonts();

    buttonStart = (Button) findViewById(R.id.button_play);
    buttonStart.setVisibility(View.INVISIBLE);

    buttonFbLogin = (Button) findViewById(R.id.facebook);
    buttonFbLogin.setVisibility(View.INVISIBLE);

    ParseUser currentUser = ParseUser.getCurrentUser();

    if (currentUser != null) {
      System.out.println("doctor please");
      System.out.println(currentUser.getEmail());
      System.out.println(currentUser.getUsername());
    }

    progressBar = (ProgressBar) findViewById(R.id.progress_bar);
    progressBar.setVisibility(View.VISIBLE);

    new GetIdsAsync().execute("");
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    holder = new ViewHolder();
    if (position == 0) {
      convertView = inflater.inflate(R.layout.profile_navigation, parent, false);

      holder.name = (TextView) convertView.findViewById(R.id.name);
      holder.email = (TextView) convertView.findViewById(R.id.email);
      if (user != null) {
        holder.name.setText(user.getString("name"));
        holder.email.setText(user.getEmail());
      } else {
        holder.name.setText("Guest User");
      }

    } else {
      convertView = inflater.inflate(resourceId, parent, false);

      holder.nameTxt = (TextView) convertView.findViewById(R.id.text_navigationlist);
      holder.imageView = (ImageView) convertView.findViewById(R.id.icon_navigationlist);

      holder.nameTxt.setText(names[position]);
      holder.imageView.setImageDrawable(icons.getDrawable(position));
    }

    return convertView;
  }
 /** Shows the profile of the given user. */
 private void showProfileLoggedIn() {
   titleTextView.setText(R.string.profile_title_logged_in);
   emailTextView.setText(currentUser.getEmail());
   String fullName = currentUser.getString("name");
   if (fullName != null) {
     nameTextView.setText(fullName);
   }
   loginOrLogoutButton.setText(R.string.profile_logout_button_label);
 }
Exemplo n.º 6
0
  private void populateFromUser(ParseUser user) {
    if (user == null) {
      user = ParseUser.getCurrentUser();
    }

    this.username.setText(user.getUsername());
    this.email.setText(user.getEmail());
    this.first.setText(user.getString(Constants.kFirstNameKey));
    this.last.setText(user.getString(Constants.kLastNameKey));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    // Show the Up button in the action bar.
    setupActionBar();
    actionBar = getActionBar();
    actionBar.setIcon(getResources().getDrawable(R.drawable.logo));

    sharedpreferences = getSharedPreferences(SignUpActivity.MyPREFERENCES, Context.MODE_PRIVATE);

    mListviewSettings = (ListView) findViewById(R.id.settingsListView);

    if (ParseUser.getCurrentUser() != null) currentUser = ParseUser.getCurrentUser();

    MyCustomAdapter mAdapter;

    mAdapter = new MyCustomAdapter();

    mAdapter.addSeparatorItem("CURRENT ACCOUNT:");
    mAdapter.addItem("Username: "******"Email: " + "Change Email Id via FB.");
    } else mAdapter.addItem("Email: " + currentUser.getEmail());
    mAdapter.addItem("Change Profile Picture ");

    mAdapter.addSeparatorItem("SPREAD THE WORD:");
    mAdapter.addItem("Invite Your Friends");

    mAdapter.addSeparatorItem("MORE INFO:");
    mAdapter.addItem("Terms of Use");
    mAdapter.addItem("Privacy Policy");
    mAdapter.addItem("Getting Started");

    mListviewSettings.setAdapter(mAdapter);
    // setListAdapter(mAdapter);

    mListviewSettings.setOnItemClickListener(this);
  }
Exemplo n.º 8
0
 private SphereUser(ParseUser sphereUser) {
   try {
     mSphereUser = sphereUser.fetch();
     mUsername = mSphereUser.getUsername();
     mEmail = mSphereUser.getEmail();
     mUserId = mSphereUser.getObjectId();
     mFullName = mSphereUser.getString(FULL_NAME);
     mTagLine = mSphereUser.getString(TAG_LINE);
     mUserPhotoFile = mSphereUser.getParseFile(USER_PHOTO);
   } catch (ParseException e) {
     Log.e(TAG, "error creating sphere user");
   }
 }
Exemplo n.º 9
0
  /** Execute code when activity is resumed */
  @Override
  public void onResume() {
    super.onResume();
    try {
      ParseUser user = ParseUser.getCurrentUser();

      TextView userName = (TextView) navHeaderLayout.findViewById(R.id.userNameNav);
      userName.setText(user.getString("name"));

      TextView userEmail = (TextView) navHeaderLayout.findViewById(R.id.userEmailNav);
      userEmail.setText(user.getEmail());
    } catch (Exception e) {
    }
  }
Exemplo n.º 10
0
  private void setInformation(ParseUser user) {

    name.setText(user.getString("name"));
    if (user.getString("website") != null) {
      website.setText(user.getString("website"));
    }
    if (user.getString("bio") != null) {
      bio.setText(user.getString("bio"));
    }
    if (user.getEmail() != null) {
      email.setText(user.getEmail());
    }
    if (user.getString("phone_number") != null) {
      phoneNumber.setText(user.getString("phone_number"));
    }
    if (user.getString("gender") != null) {
      switch (user.getString("gender")) {
        case "Male":
          genderSpinner.setSelection(1);
          break;
        case "Female":
          genderSpinner.setSelection(2);
          break;
        default:
          genderSpinner.setSelection(0);
          break;
      }
    }

    nameBeforeChange = name.getText().toString();
    websiteBeforeChange = website.getText().toString();
    bioBeforeChange = bio.getText().toString();
    emailBeforeChange = email.getText().toString();
    phoneNumberBeforeChange = phoneNumber.getText().toString();
    genederBeforeChange = genderSpinner.getSelectedItem().toString();
  }
Exemplo n.º 11
0
 private void getUserDetailsFromParse() {
   parseUser = ParseUser.getCurrentUser();
   Log.e(
       LOG_TAG,
       "email is "
           + parseUser.getEmail()
           + ", username is "
           + parseUser.getUsername()
           + ", DOB is "
           + parseUser.getString("dob"));
   Toast.makeText(
           LoginActivity.this, "Welcome back " + parseUser.getUsername(), Toast.LENGTH_SHORT)
       .show();
   startMainActivity();
 }
Exemplo n.º 12
0
  private void getUserDetailsFromParse() {
    parseUser = ParseUser.getCurrentUser();

    // Fetch profile photo
    try {
      ParseFile parseFile = parseUser.getParseFile("profileThumb");
      byte[] data = parseFile.getData();
      Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
      mProfileImage.setImageBitmap(bitmap);
    } catch (Exception e) {
      e.printStackTrace();
    }

    mEmailID.setText(parseUser.getEmail());
    mUsername.setText(parseUser.getUsername());

    Toast.makeText(
            MainActivity.this, "Welcome back " + mUsername.getText().toString(), Toast.LENGTH_SHORT)
        .show();
  }
Exemplo n.º 13
0
 public String getEmail() {
   if (u == null) return null;
   email = u.getEmail();
   return email;
 }
Exemplo n.º 14
0
  @Override
  public void onClick(View v) {
    final ParseUser currentUser = ParseUser.getCurrentUser();

    switch (v.getId()) {
      case (R.id.reset_password_button):
        Utils.resetPassword(ProfileEditActivity.this, currentUser.getEmail());
        break;

      case (R.id.save_changes_button):

        // check that all the user availabilities are valid
        for (int i = 0; i < availabilityAdapter.getCount() - 1; i++) {
          if (!availabilityAdapter.getItem(i).isValid()) {
            Utils.showMessageBox(
                v.getContext(),
                "Invalid period",
                "At least one of the availability period are invalid");
            return;
          }
        }

        // handle name
        String name = nameEdit.getText().toString();
        if (!name.isEmpty()) {
          currentUser.put("name", name);
        }

        // handle address
        if (address != null) {
          currentUser.put("address", Utils.addressToJSONArray(address));
          currentUser.put(
              "addressLocation", new ParseGeoPoint(address.getLatitude(), address.getLongitude()));
        }

        // handle phone number
        String phone = phoneEdit.getText().toString();
        if (!phone.isEmpty()) {
          currentUser.put("phone", phone);
        }
        currentUser.put("sharePhone", phoneShareEdit.isChecked());

        final ProgressDialog pd =
            ProgressDialog.show(ProfileEditActivity.this, "", "Saving profile...", true, false);
        List<Task<Void>> tasks = new ArrayList<>();

        // handle profile picture (save before proceeding
        if (picByteArray != null) {
          Log.d("My Loggggg", "profile picture changed");
          final ParseFile photoFile =
              new ParseFile(currentUser.getUsername().toString() + "profile_pic.jpg", picByteArray);

          tasks.add(
              photoFile
                  .saveInBackground()
                  .onSuccess(
                      new Continuation<Void, Void>() {
                        @Override
                        public Void then(Task<Void> task) throws Exception {
                          currentUser.put("photo", photoFile);
                          return null;
                        }
                      }));
        }

        // save changes in user availability
        for (int i = 0; i < availabilityAdapter.getCount() - 1; i++) {
          Integer id = (Integer) availabilityAdapter.getItem(i).getTag();
          AvailabilityRecord record = availabilityAdapter.getItem(i);
          if (id != null) {
            // update if need old records
            ParseObject userAvailability = userAvailabilitiesList.get(id);
            userAvailabilitiesList.set(id, null);
            record.toParseObject(userAvailability);
            tasks.add(userAvailability.saveInBackground());
          } else {
            // else is a new record
            ParseObject newUserAvailability = record.toParseObject();
            newUserAvailability.put("user", currentUser);
            tasks.add(newUserAvailability.saveInBackground());
          }
        }
        // remove from parse all availabilities that user remove
        for (ParseObject availability : userAvailabilitiesList) {
          if (availability != null) {
            tasks.add(availability.deleteInBackground());
          }
        }

        Task.whenAll(tasks)
            .onSuccessTask(
                new Continuation<Void, Task<Void>>() {
                  @Override
                  public Task<Void> then(Task<Void> task) throws Exception {
                    return currentUser.saveInBackground();
                  }
                })
            .continueWith(
                new Continuation<Void, Void>() {
                  @Override
                  public Void then(Task<Void> task) throws Exception {
                    pd.dismiss();
                    if (!task.isFaulted()) {
                      Toast.makeText(
                              getApplicationContext(),
                              "Changes saved successfully",
                              Toast.LENGTH_LONG)
                          .show();
                      finish();
                    } else {
                      Log.e("ProfileEdit", "error saving changes: " + task.getError().getMessage());
                      Utils.showMessageBox(
                          ProfileEditActivity.this,
                          "Failed saving changes",
                          getString(R.string.unknown_error_occur));
                    }
                    return null;
                  }
                },
                Task.UI_THREAD_EXECUTOR);

        break;

      case (R.id.change_pic_button):
        // create Intent to take a picture and return control to the calling application
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, CAMERA_REQUEST);

        break;

      case R.id.profile_address_change_edit:
        // move user to address selection activity
        Intent addressSelectionIntent =
            new Intent(ProfileEditActivity.this, AddressSelectionActivity.class);
        startActivityForResult(addressSelectionIntent, REQUEST_ADDRESS);

        break;
    }
  }
Exemplo n.º 15
0
  @Override
  public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {

    if (position == 1) {
      isFblogin = sharedpreferences.getBoolean(ParseConstants.KEY_LOGIN_VIA_FACEBOOK, false);
      if (isFblogin) {

        String msg = "Username can be changed via facebook.";
        String tit = getString(R.string.signup_error_title);
        Common.callDialog(SettingsActivity.this, msg, tit);
      } else {

        Intent intent = new Intent(SettingsActivity.this, EditUsernameActivity.class);
        intent.putExtra("USERNAME", currentUser.getUsername());
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
      }
    }

    if (position == 2) {
      isFblogin = sharedpreferences.getBoolean(ParseConstants.KEY_LOGIN_VIA_FACEBOOK, false);
      if (isFblogin) {

        String msg = "Email can be changed via facebook.";
        String tit = getString(R.string.signup_error_title);
        Common.callDialog(SettingsActivity.this, msg, tit);

      } else {

        Intent intent = new Intent(SettingsActivity.this, EditEmailActivity.class);
        if (currentUser.getEmail() != null) {
          intent.putExtra("EMAIL", currentUser.getEmail());
          intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          startActivity(intent);
        }
      }
    }

    if (position == 3) {
      Intent intent = new Intent(SettingsActivity.this, EditProfilePictureActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(intent);
    }

    if (position == 5) {
      Intent intent = new Intent(Intent.ACTION_SEND);

      intent.putExtra(Intent.EXTRA_SUBJECT, "Hey! Found this awesome app!");
      intent.putExtra(
          android.content.Intent.EXTRA_TEXT,
          Html.fromHtml(getResources().getString(R.string.email_text)));
      intent.setType("plain/text");
      startActivity(Intent.createChooser(intent, ""));

      // startActivityForResult(Intent.createChooser(intent, "a"),
      // MY_REQUEST_CODE);

    }

    if (position == 7) {
      Intent intent = new Intent(SettingsActivity.this, TermsOfUseActivity.class);
      startActivity(intent);
    }

    if (position == 8) {
      Intent intent = new Intent(SettingsActivity.this, PrivacyPolicyActivity.class);
      startActivity(intent);
    }

    if (position == 9) {
      Intent intent = new Intent(SettingsActivity.this, GettingStartedActivity.class);
      startActivity(intent);
    }
  }
Exemplo n.º 16
0
 public String getEmail() {
   return mParseUser.getEmail();
 }