Skip to content

Commit

Permalink
Fixing dns disovery for toxv1 and various crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
markwinter committed Apr 25, 2014
1 parent 9f5dc54 commit c934ea5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,13 @@ protected Void doInBackground(String... params) {
e.printStackTrace();
}

Log.d("DNS", txt.toString());

if(txt != null) {
String txtString = txt.toString().substring(txt.toString().indexOf('"'));

if(txtString.contains("tox1")) {
String key = txtString.substring(11, txtString.length()-1);
String key = txtString.substring(11, 11+76);
_friendID = key;

} else if (txtString.contains("tox2")) {
Expand Down
14 changes: 2 additions & 12 deletions app/src/main/java/im/tox/antox/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ public void onReceive(Context context, Intent intent) {
String action = intent.getStringExtra("action");
if (action != null) {
Log.d(TAG, "action: " + action);
if (action.equals(Constants.FRIEND_REQUEST)) {

} else if (action.equals(Constants.UPDATE_LEFT_PANE)) {
if (action.equals(Constants.UPDATE_LEFT_PANE)) {
updateLeftPane();
} else if (action.equals(Constants.REJECT_FRIEND_REQUEST)) {
updateLeftPane();
Expand All @@ -140,8 +138,6 @@ public void onReceive(Context context, Intent intent) {
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(ctx, text, duration);
toast.show();
} else if (action.equals(Constants.FRIEND_LIST)) {

} else if (action.equals(Constants.UPDATE)) {
updateLeftPane();
if (toxSingleton.rightPaneActive) {
Expand Down Expand Up @@ -177,7 +173,6 @@ protected void onNewIntent(Intent i) {
if (i.getAction() != null) {
if (i.getAction().equals(Constants.SWITCH_TO_FRIEND) && toxSingleton.friendsList.getById(i.getStringExtra("key")) != null) {
String key = i.getStringExtra("key");
String name = i.getStringExtra("name");
Fragment newFragment = new ChatFragment();
toxSingleton.activeFriendKey = key;
toxSingleton.activeFriendRequestKey = null;
Expand Down Expand Up @@ -211,8 +206,6 @@ protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = getSharedPreferences("main",
Context.MODE_PRIVATE);

SharedPreferences settings = getSharedPreferences("settings", Context.MODE_PRIVATE);

// If beenLoaded is 0, then never been run
if (pref.getInt("beenLoaded", 0) == 0) {
// Launch welcome activity which will run the user through initial
Expand Down Expand Up @@ -705,7 +698,7 @@ private void openGroupManagement() {
private void clearUselessNotifications () {
AntoxDB db = new AntoxDB(getApplicationContext());
if (toxSingleton.rightPaneActive && toxSingleton.activeFriendKey != null
&& toxSingleton.friendsList.all().size() > 0 && !db.isFriendBlocked(toxSingleton.activeFriendKey)) {
&& toxSingleton.friendsList.all().size() > 0) {
AntoxFriend friend = toxSingleton.friendsList.getById(toxSingleton.activeFriendKey);
toxSingleton.mNotificationManager.cancel(friend.getFriendnumber());
}
Expand Down Expand Up @@ -1043,7 +1036,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
} else if(requestCode==Constants.SENDFILE_PICKEDFRIEND_CODE && resultCode==RESULT_OK) {
Uri uri= data.getData();
File pickedFile = new File(uri.getPath());
MimeTypeMap mime = MimeTypeMap.getSingleton();
Log.d("file picked",""+pickedFile.getAbsolutePath() );
Log.d("file type",""+getContentResolver().getType(uri));
} else if(requestCode==Constants.UPDATE_SETTINGS_REQUEST_CODE && resultCode==RESULT_OK) {
Expand Down Expand Up @@ -1115,8 +1107,6 @@ public void onPanelOpened(View view) {

toxSingleton.rightPaneActive =false;
toxSingleton.leftPaneActive = true;
InputMethodManager imm = (InputMethodManager)getSystemService(
Context.INPUT_METHOD_SERVICE);
}

@Override
Expand Down
9 changes: 7 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 @@ -506,8 +506,13 @@ public String[] getFriendDetails(String key) {
String note = cursor.getString(4);
String alias = cursor.getString(5);

if(name.equals(""))
name = key.substring(0,7);
if(name == null)
name = "";

if(name.equals("")) {
int length = 7 > name.length() ? name.length() : 7;
name = key.substring(0, length);
}

details[0] = name;
details[1] = alias;
Expand Down

0 comments on commit c934ea5

Please sign in to comment.