public static void save(Context context, String username, String password) {
    // TODO Add encryption
    Credentials.get(context);
    credentials.username().put(username);

    String cred = Base64.encodeToString((username + ":" + password).getBytes(), Base64.DEFAULT);
    credentials.credentials().put(cred);
  }
示例#2
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.bLogout:
        userLocalStore.clearUserData();
        userLocalStore.setUserLoggedIn(false);

        startActivity(new Intent(this, Login.class));
        break;
    }
  }
  private void logUserIn(User returnedUser) {
    userLocalStore.storeUserData(returnedUser);

    checkBox = (CheckBox) findViewById(R.id.checkBox);
    boolean checked = checkBox.isChecked();

    if (checked) {
      userLocalStore.setUserLoggedIn(true);
      Log.d("tag1", "checked");
    }
    // should go to the profile page but going ot the register page temporarily
    startActivity(new Intent(this, DonationHistory.class));
    finish();
  }
示例#4
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int id = item.getItemId();
   if (id == R.id.action_settings) {
     return super.onOptionsItemSelected(item);
   } else if (id == R.id.action_logout) {
     AccessToken usedFacebook = AccessToken.getCurrentAccessToken();
     if (usedFacebook != null) {
       facebookLogin.logOut();
     } else {
       userLocalStore.clearUserData();
       userLocalStore.setUserLoggedIn(false);
     }
     Intent loginIntent = new Intent(this, LoginActivity.class);
     startActivity(loginIntent);
     return true;
   }
   return super.onOptionsItemSelected(item);
 }
示例#5
0
  /* the onClick listener will validate all of the event data fields
   * and then will pass on the data to the submitEvent method
   */
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.submitNewEvent:
        /* TODO: add validation for event form
         *
         */
        int messageResId = 0; // will be used to make toast
        User currentUser = userLocalStore.getLoggedInUser();

        // For event table, we need: host email, host event count, event name, location, time,
        // description
        String hostEmail = currentUser.email;
        int eventCount = currentUser.eventCount + 1;
        User user =
            new User(currentUser.fullName, currentUser.email, currentUser.password, eventCount);
        ArrayList<Friend> invitedFriends = dropdownListAdapter.getSelectedFriends();
        String eventName = new_event_name.getText().toString();

        // String eventLocation = mAutocompleteView.getText().toString();
        if (invitedFriends.size() == 0
            || eventName == ""
            || eventLocation == null
            || !isEventTimeSet()) {
          messageResId = R.string.missing_event_field;
        }
        if (messageResId == 0) {
          /*TODO: Parse invitedFriends into eventGuestList
           *TODO: get email to friends class
           */
          Intent currentIntent = this.getIntent();
          hostEmail = currentIntent.getStringExtra("currentUserEmail");
          int hostEventCounter = currentIntent.getIntExtra("currentUserEventCount", 0);
          Event event =
              new Event(
                  hostEmail,
                  hostEventCounter,
                  eventName,
                  eventLocation.toString(),
                  eventTime.toString(),
                  "");
          submitEvent(event);
        } else {
          Toast.makeText(this, messageResId, Toast.LENGTH_SHORT).show();
        }
        break;
      default:
        break;
    }
  }
示例#6
0
文件: Login.java 项目: dhurng/ODFapp
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.bLogin:
        String username = etUsername.getText().toString();
        String password = etPassword.getText().toString();

        User user = new User(username, password);

        authenticate(user);

        // user logged in and store it
        userLocalStore.storeUserData(user);
        userLocalStore.setUserLoggedIn(true);

        break;

      case R.id.tvRegisterLink:
        // start activity when clicked
        startActivity(new Intent(this, Register.class));

        break;
    }
  }
  private void displayListView() {
    userLocalStore = new UserLocalStore(this);
    User user = userLocalStore.getLoggedInUser();
    // ((AppDelegate)this.getApplication()).yourFriends;
    friends = ((AppDelegate) this.getApplication()).yourFriends;
    groups = ((AppDelegate) this.getApplication()).getGroups();
    Log.d("JJK", "number of friends: " + String.valueOf(friends.size()));
    dataAdapter = new FriendSendAdapter(sendRendezvous.this, friends);
    adapter = new GroupAdapter(sendRendezvous.this, groups);

    ListView listView = (ListView) findViewById(R.id.listView1);
    ListView listView2 = (ListView) findViewById(R.id.listView2);
    // Assign adapter to ListView
    listView.setAdapter(dataAdapter);
    listView2.setAdapter(adapter);
    dataAdapter.notifyDataSetChanged();
    adapter.notifyDataSetChanged();
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // When clicked, show a toast with the TextView text
            Friend friend = (Friend) parent.getItemAtPosition(position);
            Toast.makeText(
                    getApplicationContext(),
                    "Clicked on Row: " + friend.getShowname(),
                    Toast.LENGTH_LONG)
                .show();
          }
        });

    listView2.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // When clicked, show a toast with the TextView text
            Group friend = (Group) parent.getItemAtPosition(position);
            Toast.makeText(
                    getApplicationContext(),
                    "Clicked on Row: " + friend.groupname,
                    Toast.LENGTH_LONG)
                .show();
          }
        });
  }
  private void returnSendlist() {
    User user = userLocalStore.getLoggedInUser();
    ArrayList<Friend> friendlistsend = dataAdapter.friendList;
    for (int i = 0; i < friendlistsend.size(); i++) {
      Friend friend = friendlistsend.get(i);
      if (friend.isSelected()) {
        Friend friendsend = new Friend(friend.username, friend.friendname, null, null, -1);
        sendingFriendlist.add(friendsend);

        if (((AppDelegate) this.getApplication()).isTheFriendInTheWoz(friend.username)) {
          // if you send a rendez and your friends chat is allocated, need to append.
          // else the first instance will be able to retrieve this
          SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
          dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
          String time = dateFormatGmt.format(new Date()).toString();
          RendezStatus tem =
              new RendezStatus(
                  user.username,
                  statusTitle,
                  details,
                  location,
                  null,
                  timefor,
                  type,
                  -1,
                  friend.username);
          rendezChatDictionary temp =
              ((AppDelegate) this.getApplication()).getRendezDictionary(friend.username);
          temp.allDeesRendez.add(0, tem);
          // ((AppDelegate) this.getApplication()).putItInTheWoz(friend.username, temp);
        }
      }
    }

    for (int i = 0; i < groups.size(); i++) {
      if (groups.get(i).isSelected()) {
        Friend friendsend =
            new Friend(groups.get(i).groupname, groups.get(i).groupdetail, null, null, -1);
        sendingFriendlist.add(friendsend);
        /*
         * need to figure out the emits for this...
         * */

        if (((AppDelegate) this.getApplication()).isTheFriendInTheWoz(groups.get(i).groupname)) {
          SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
          dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
          String time = dateFormatGmt.format(new Date()).toString();
          RendezStatus tem =
              new RendezStatus(
                  user.username,
                  statusTitle,
                  details,
                  location,
                  null,
                  timefor,
                  type,
                  -1,
                  groups.get(i).groupname);
          rendezChatDictionary temp =
              ((AppDelegate) this.getApplication()).getRendezDictionary(groups.get(i).groupname);
          temp.allDeesRendez.add(0, tem);
          // ((AppDelegate) this.getApplication()).putItInTheWoz(groups.get(i).groupname, temp);
        }
      }
    }

    RendezStatus status =
        new RendezStatus(
            user.username, statusTitle, details, location, null, timefor, type, -1, null);
    ServerRequests serverRequests = new ServerRequests(this);
    serverRequests.sendToFriendsInBackground(
        user,
        sendingFriendlist,
        status,
        new SendRendezStatusCallback() {
          @Override
          public void done(ArrayList status) {
            ArrayList<RendezStatus> rs = status;
            for (int i = 0; i < status.size(); i++) {
              ((AppDelegate) getApplication())
                  .putItInTheWozRendezStatus(rs.get(i).username, rs.get(i));
              ((AppDelegate) getApplication())
                  .emitRendez(
                      rs.get(i).id,
                      sendingFriendlist.get(i).username,
                      statusTitle,
                      details,
                      location,
                      timefor,
                      type,
                      0);
            }
          }
        });
    Intent returnIntent = new Intent();
    returnIntent.putExtra("result", 1);
    setResult(RESULT_OK, returnIntent);
    finish();
  }
示例#9
0
文件: Login.java 项目: dhurng/ODFapp
  private void logUserIn(User returnedUser) {
    userLocalStore.storeUserData(returnedUser);
    userLocalStore.setUserLoggedIn(true);

    startActivity(new Intent(this, MainActivity.class));
  }
 public static String getHeader(Context context) {
   Credentials.get(context);
   String cred = credentials.credentials().get();
   Log.e("Auth", "Basic " + cred);
   return "Basic " + cred;
 }