Skip to content

Commit

Permalink
Stop users adding friends when not connected to the Tox network
Browse files Browse the repository at this point in the history
  • Loading branch information
markwinter committed Apr 5, 2014
1 parent c101dd5 commit a2965fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
16 changes: 16 additions & 0 deletions app/src/main/java/im/tox/antox/activities/AddFriendActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package im.tox.antox.activities;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
Expand Down Expand Up @@ -32,6 +34,7 @@
import im.tox.antox.utils.Constants;
import im.tox.antox.R;
import im.tox.antox.tox.ToxService;
import im.tox.antox.utils.DhtNode;

/**
* Activity to allow the user to add a friend. Also as a URI handler to automatically insert public
Expand Down Expand Up @@ -70,6 +73,19 @@ public void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setIcon(R.drawable.ic_actionbar);
}

// Check to see if user is connected to dht first
if(!DhtNode.connected) {
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(R.string.addfriend_no_internet);
alertDialog.setMessage(getString(R.string.addfriend_no_internet_text));
alertDialog.setIcon(R.drawable.ic_launcher);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
alertDialog.show();
}

Intent intent = getIntent();
//If coming from tox uri link
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
<string name="main_friend_requests">Friend Requests</string>
<string name="main_friends">Friends</string>
<string name="main_no_internet">No Internet Connection</string>
<string name="main_not_connected">You are not connected to the Internet</string>
<string name="main_not_connected">
No internet connection has been detected. Without an internet connection, you will have
limited functionality.
</string>
<string name="main_node_list_download_error">Error Downloading Nodes List</string>

<!-- About Activity -->
Expand Down Expand Up @@ -83,6 +86,11 @@
<string name="addfriend_optional_title">Optional Extras</string>
<string name="dialog_pin">Enter your friend\'s pin</string>
<string name="addfriend_invalid_pin">Invalid Pin</string>
<string name="addfriend_no_internet">No Tox network connection</string>
<string name="addfriend_no_internet_text">
Unfortunately you aren\'t connected to the Tox network so you cannot add a friend right now.
Try restarting the application.
</string>

<!-- Profile Activity -->
<string name="share_with">Share With</string>
Expand Down

0 comments on commit a2965fe

Please sign in to comment.