예제 #1
0
  public void CreateClick(View view) throws ParseException {
    String name;
    String description;
    String date;

    EditText viewText = (EditText) findViewById(R.id.editText);
    name = viewText.getText().toString();

    viewText = (EditText) findViewById(R.id.editText2);
    description = viewText.getText().toString();

    // viewText = (EditText) findViewById(R.id.calendarView);
    // date = viewText.getText().toString();

    ParseUser user = ParseUser.getCurrentUser();
    ParseObject bulletin = new ParseObject("BulletinBoard");
    bulletin.put("DeleteDate", "Oct 31, 2015");
    bulletin.put("Notification", description);
    bulletin.put("Name", name);
    bulletin.put("Apartment", user.get("Apartment"));

    bulletin.saveInBackground();
    finish();
    viewText = (EditText) findViewById(R.id.calendarView);
    date = viewText.getText().toString();

    bulletin.put("DeleteDate", date);
    bulletin.put("Notification", description);
    bulletin.put("Name", name);
    bulletin.put("Apartment", user.get("Apartment"));
    bulletin.saveInBackground();
  }
  @Test
  public void testHasReadAccessWithReadAccess() {
    ParseUser user = mock(ParseUser.class);
    when(user.getObjectId()).thenReturn("test");

    ParseACL acl = mock(ParseACL.class);
    when(acl.getReadAccess(user)).thenReturn(true);

    ParseObject object = mock(ParseObject.class);
    when(object.getACL()).thenReturn(acl);

    assertTrue(OfflineQueryLogic.hasReadAccess(user, object));
  }
  @Test
  public void testMatcherWithNoReadAccess() throws ParseException {
    OfflineQueryLogic logic = new OfflineQueryLogic(null);

    ParseQuery.State<ParseObject> query = new ParseQuery.State.Builder<>("TestObject").build();

    ParseACL acl = new ParseACL();
    acl.setPublicReadAccess(false);
    ParseObject object = new ParseObject("TestObject");
    object.setACL(acl);

    ParseUser user = mock(ParseUser.class);
    when(user.getObjectId()).thenReturn("test");

    assertFalse(matches(logic, query, object, user));
  }
예제 #4
0
 private void retrieveAccessTokenAndFacebookIdFromRelation(
     final UserDataRetrieveCallback callback) {
   ParseRelation relation = ParseUser.getCurrentUser().getRelation("ItsBeta");
   if (relation != null) {
     relation
         .getQuery()
         .findInBackground(
             new FindCallback() {
               @Override
               public void done(List<ParseObject> parseObjects, ParseException e) {
                 if (e == null) {
                   if (parseObjects.size() == 1) {
                     facebookId = parseObjects.get(0).getString("facebookUserId");
                     accessToken = parseObjects.get(0).getString("facebookAccessToken");
                     callback.done();
                   } else {
                     callback.relationNotFound();
                   }
                 } else {
                   callback.error();
                 }
               }
             });
   }
 }
예제 #5
0
  private void checkUser() {
    if (ParseAnonymousUtils.isLinked(ParseUser.getCurrentUser())) {
      Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
      startActivity(intent);
      finish();

    } else {
      ParseUser currentUser = ParseUser.getCurrentUser();
      if (currentUser != null) {
        Intent intent = new Intent(SplashActivity.this, TabActivity.class);
        intent.putExtra("user", currentUser.getUsername());
        startActivity(intent);
        finish();
      } else {
        Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
        startActivity(intent);
        finish();
      }
    }
  }
예제 #6
0
 protected ParseUser getParseUser(String number) {
   ParseUser parseUser = new ParseUser();
   parseUser.setUsername("parse4j-user" + number);
   parseUser.setPassword("parse4j-password");
   parseUser.setEmail("parse4j-email" + number + "@gmail.com");
   parseUser.put("dob", new Date());
   parseUser.put("city", "westbury");
   parseUser.put("state", "ny");
   return parseUser;
 }
예제 #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);

    /*
    This line gets the unique id associated with each android device. Can only be reset by wiping the phone
     */
    final String android_id =
        Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
    Log.d("ANDROID ID", android_id);

    ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.whereEqualTo(
        "androidID",
        android_id); // If these id's match, an account has already been registered on that account
    query.findInBackground(
        new FindCallback<ParseUser>() {
          public void done(List<ParseUser> scoreList, ParseException e) {
            if (e == null) {
              if (scoreList.size() > 0) {
                Log.d("id", "android_id matches one already in the table");
                // Displays dialog to inform the user the passwords were unequal and they must try
                // again
                AlertDialog.Builder builder = new AlertDialog.Builder(Register.this);
                builder
                    .setMessage(R.string.androidIdAlertMessage)
                    .setTitle(R.string.androidIdAlertTitle);
                builder.setCancelable(
                    false); // Makes it so a user can't click outside of the alert to close the
                            // dialog. They must click the button
                builder.setPositiveButton(
                    "Back to Home",
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int id) {
                        // These two lines automatically take the user back to the home page after a
                        // successful registration
                        Intent goHome = new Intent(Register.this, HomePage.class);
                        startActivity(goHome);
                      }
                    });
                AlertDialog alert = builder.create();
                alert.show();
              } else {
                Log.d("No Match", "Android ID does not match any in table");
              }

            } else {
              Log.d("score", "Error: " + e.getMessage());
            }
          }
        });
  }
예제 #8
0
  public void discLoad() {

    // Acessa todos os dados de uma tabela
    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Disciplina");
    query.whereEqualTo("owner", ParseUser.getCurrentUser());
    query.findInBackground(
        new FindCallback<ParseObject>() {
          public void done(List<ParseObject> markers, ParseException e) {
            if (e == null) {

              for (ParseObject p : markers) {
                if (!p.getString("day_1").isEmpty()) {

                  TextView t = listTextViewHour.get(p.getString("day_1"));
                  String text =
                      p.getString("hour_1")
                          + " - "
                          + p.getString("name")
                          + "    ("
                          + p.getParseObject("course").getString("name")
                          + ")\n";
                  t.append(text);
                }

                if (!p.getString("day_2").isEmpty()) {

                  TextView t = listTextViewHour.get(p.getString("day_2"));
                  String text =
                      p.getString("hour_2")
                          + " - "
                          + p.getString("name")
                          + "    ("
                          + p.getParseObject("course").getString("name")
                          + ")\n";
                  t.append(text);
                }
              }

              for (int i = 0; i < listTextViewHour.size(); i++) {
                if (listTextViewHour.get(days[i]).getText().toString().isEmpty())
                  listTextViewHour
                      .get(days[i])
                      .setText("Você não tem nenhuma disciplina neste dia!");
              }

            } else {
              // handle Parse Exception here
              e.getCause();
            }
          }
        });
  }
예제 #9
0
 public static void countItsBetaRelationInBackground(CountCallback callback) {
   ParseRelation relation = ParseUser.getCurrentUser().getRelation("ItsBeta");
   if (relation != null) {
     relation.getQuery().countInBackground(callback);
   }
 }
예제 #10
0
  @Override
  public View getItemView(SingleWorkout workout, View convertView, ViewGroup parent) {
    super.getItemView(workout, convertView, parent);
    final ViewHolder holder;
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.list_item_cards, parent, false);
      holder = new ViewHolder();
      holder.ivImage = (ImageView) convertView.findViewById(R.id.imageViewProfilePic);
      holder.ivPeek1 = (ImageView) convertView.findViewById(R.id.imageViewPeek1);
      holder.ivPeek2 = (ImageView) convertView.findViewById(R.id.imageViewPeek2);
      holder.ivPeek3 = (ImageView) convertView.findViewById(R.id.imageViewPeek3);
      holder.tvTitle = (TextView) convertView.findViewById(R.id.textViewTitle);
      holder.tvDifficulty = (TextView) convertView.findViewById(R.id.textViewDifficulty);
      holder.tvTime = (TextView) convertView.findViewById(R.id.textViewTime);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.tvTitle.setText(workout.get_title());
    holder.tvTime.setText(workout.get_time());
    holder.tvDifficulty.setText(workout.get_difficulty());

    try {
      JSONArray mJsonArray = new JSONArray(workout.get_pictureArrayJSON());
      String pictureVal1 = "w" + mJsonArray.getString(0);
      String pictureVal2 = "w" + mJsonArray.getString(1);
      String pictureVal3 = "w" + mJsonArray.getString(2);

      holder.ivPeek1.setImageResource(
          getContext()
              .getResources()
              .getIdentifier(pictureVal1, "drawable", getContext().getPackageName()));
      holder.ivPeek2.setImageResource(
          getContext()
              .getResources()
              .getIdentifier(pictureVal2, "drawable", getContext().getPackageName()));
      holder.ivPeek3.setImageResource(
          getContext()
              .getResources()
              .getIdentifier(pictureVal3, "drawable", getContext().getPackageName()));

    } catch (JSONException e) {
      e.printStackTrace();
    }

    // needed to get User profile pic for parse feed
    try {
      ParseUser mUser = workout.getParseUser("user");
      mUser.fetchInBackground(
          new GetCallback<ParseObject>() {
            @Override
            public void done(ParseObject parseObject, ParseException e) {
              try {
                final byte[] mBytes = parseObject.getBytes("photo");
                if (mBytes != null) {
                  new Handler()
                      .post(
                          new Runnable() {
                            @Override
                            public void run() {
                              Bitmap bitmap =
                                  BitmapFactory.decodeByteArray(mBytes, 0, mBytes.length);
                              holder.ivImage.setImageBitmap(bitmap);
                            }
                          });
                }
              } catch (Exception f) {
                Log.e(TAG, f.getMessage());
              }
            }
          });
    } catch (Exception e) {
      Log.e(TAG, e.getMessage());
    }

    // still need to populate the ivPeek with icons

    return convertView;
  }
예제 #11
0
  /** Checks to see if any fields are empty and/or if two password fields are equal */
  public void checkFields(View v) {

    EditText name_field = (EditText) findViewById(R.id.nameField);
    EditText addr_field = (EditText) findViewById(R.id.addressField);
    EditText dob_field = (EditText) findViewById(R.id.dateOfBirthField);
    EditText email_field = (EditText) findViewById(R.id.emailField);
    EditText pass1 = (EditText) findViewById(R.id.passwordField);
    EditText pass2 = (EditText) findViewById(R.id.passwordConfirmField);

    String name = name_field.getText().toString().trim();
    String address = addr_field.getText().toString().trim();
    String dob = dob_field.getText().toString().trim();
    String email = email_field.getText().toString().trim();
    String password = pass1.getText().toString().trim();
    String passwordRetry = pass2.getText().toString().trim();

    if (TextUtils.isEmpty(name)) {
      name_field.setError("You must enter a username");
    }

    if (TextUtils.isEmpty(address)) {
      name_field.setError("You must enter an address");
    }

    if (TextUtils.isEmpty(dob)) {
      name_field.setError("You must enter a date of birth");
    }

    if (TextUtils.isEmpty(email)) {
      email_field.setError("You must enter an email");
    }

    if (TextUtils.isEmpty(password)) {
      pass1.setError("You must enter a password");
    }

    if (TextUtils.isEmpty(passwordRetry)) {
      pass2.setError("You must enter a password");
    }

    if (password.equals(passwordRetry)) {

      String android_id =
          Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
      Log.d("ANDROID ID", android_id);

      ParseUser user = new ParseUser();
      user.setUsername(name);
      user.setPassword(password);
      user.setEmail(email);
      user.put("address", address);
      user.put("dateOfBirth", dob);
      user.put("androidID", android_id);

      user.signUpInBackground(
          new SignUpCallback() {
            public void done(ParseException e) {
              if (e == null) {
                // success
              } else {
                // Sign up didn't succeed. Look at the ParseException
                // to figure out what went wrong
                Log.d("Error", e.toString());
              }
            }
          });

      // These two lines automatically take the user back to the home page after a successful
      // registration
      Intent goHome = new Intent(Register.this, HomePage.class);
      startActivity(goHome);

    } else {
      // Displays dialog to inform the user the passwords were unequal and they must try again
      AlertDialog.Builder builder = new AlertDialog.Builder(Register.this);
      builder.setMessage(R.string.unequalPasswords).setTitle(R.string.passwordDialogTitle);
      builder.setCancelable(true);
      builder.setPositiveButton(
          "Ok",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
            }
          });
      AlertDialog alert = builder.create();
      alert.show();
    }
  }