Skip to content

Commit

Permalink
Adding a user via tox dns discovery will set their name to the local …
Browse files Browse the repository at this point in the history
…part of the email address
  • Loading branch information
markwinter committed Apr 4, 2014
1 parent 6a265a7 commit 4fc7d56
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void onCreate(Bundle savedInstanceState) {
if (!alias.equals(""))
ID = alias;

db.addFriend(ID, "Friend Request Sent", alias);
db.addFriend(ID, "Friend Request Sent", alias, intent.getStringExtra("originalUsername"));
} else {
toast = Toast.makeText(context, getString(R.string.addfriend_friend_exists), Toast.LENGTH_SHORT);
}
Expand Down Expand Up @@ -197,7 +197,7 @@ public void addFriend(View view) {
if (!alias.equals(""))
ID = alias;

db.addFriend(ID, "Friend Request Sent", alias);
db.addFriend(ID, "Friend Request Sent", alias, _originalUsername);
} else {
toast = Toast.makeText(context, getString(R.string.addfriend_friend_exists), Toast.LENGTH_SHORT);
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/im/tox/antox/data/AntoxDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,17 @@ private boolean isColumnInTable(SQLiteDatabase db, String table, String column)
// Currently we are not able to fetch Note,username so keep it null.
//So storing the received message as his/her personal note.

public void addFriend(String key, String message, String alias) {
public void addFriend(String key, String message, String alias, String username) {
SQLiteDatabase db = this.getWritableDatabase();

if(username.contains("@"))
username = username.substring(0, username.indexOf("@"));

ContentValues values = new ContentValues();
values.put(Constants.COLUMN_NAME_KEY, key);
values.put(Constants.COLUMN_NAME_STATUS, "0");
values.put(Constants.COLUMN_NAME_NOTE, message);
values.put(Constants.COLUMN_NAME_USERNAME, "");
values.put(Constants.COLUMN_NAME_USERNAME, username);
values.put(Constants.COLUMN_NAME_ISONLINE, false);
values.put(Constants.COLUMN_NAME_ALIAS, alias);
db.insert(Constants.TABLE_FRIENDS, null, values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void onClick(DialogInterface dialog, int index) {
switch (index){
case 0:
AntoxDB db = new AntoxDB(getActivity().getApplicationContext());
db.addFriend(item.first, "Friend Accepted", "");
db.addFriend(item.first, "Friend Accepted", "", "");
db.close();
main_act.updateLeftPane();
Intent acceptRequestIntent = new Intent(getActivity(), ToxService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
public void onClick(View view) {
getActivity().getSupportFragmentManager().popBackStack();
AntoxDB db = new AntoxDB(getActivity().getApplicationContext());
db.addFriend(key, "Friend Accepted", "");
db.addFriend(key, "Friend Accepted", "", "");
db.close();
((MainActivity) getActivity()).updateLeftPane();
((MainActivity) getActivity()).pane.openPane();
Expand Down

0 comments on commit 4fc7d56

Please sign in to comment.