Skip to content

Commit

Permalink
Move remaining ToxService cases to asynctasks and completely remove T…
Browse files Browse the repository at this point in the history
…oxService
  • Loading branch information
markwinter committed Jun 4, 2014
1 parent 9b7e1c0 commit 052d279
Show file tree
Hide file tree
Showing 20 changed files with 251 additions and 328 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,20 @@
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.TXTRecord;
import org.xbill.DNS.Type;


import im.tox.QR.IntentIntegrator;
import im.tox.QR.IntentResult;
import im.tox.antox.R;
import im.tox.antox.data.AntoxDB;

import im.tox.antox.fragments.PinDialogFragment;
import im.tox.antox.tox.ToxSingleton;
import im.tox.antox.utils.Constants;
import im.tox.antox.R;
import im.tox.antox.utils.DhtNode;
import im.tox.jtoxcore.FriendExistsException;
import im.tox.jtoxcore.ToxException;
Expand All @@ -56,7 +53,6 @@ public class AddFriendActivity extends ActionBarActivity implements PinDialogFra
EditText friendID;
EditText friendMessage;
EditText friendAlias;
Spinner friendGroup;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -169,7 +165,6 @@ private int checkAndSend(String key, String originalUsername) {
if (!alias.equals(""))
ID = alias;

String group = friendGroup.getSelectedItem().toString();
Log.d("AddFriendActivity","Adding friend to database");
db.addFriend(ID, "Friend Request Sent", alias, originalUsername);
} else {
Expand Down
18 changes: 0 additions & 18 deletions app/src/main/java/im/tox/antox/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
Expand All @@ -16,7 +15,6 @@
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.SlidingPaneLayout;
import android.support.v7.app.ActionBarActivity;
Expand All @@ -25,7 +23,6 @@
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;

import java.io.File;
import java.sql.Timestamp;
Expand All @@ -36,7 +33,6 @@
import im.tox.antox.adapters.LeftPaneAdapter;
import im.tox.antox.data.AntoxDB;
import im.tox.antox.fragments.ChatFragment;
import im.tox.antox.fragments.ContactsFragment;
import im.tox.antox.tox.ToxDoService;
import im.tox.antox.tox.ToxSingleton;
import im.tox.antox.utils.AntoxFriend;
Expand Down Expand Up @@ -98,25 +94,11 @@ public void onReceive(Context context, Intent intent) {
Log.d(TAG, "action: " + action);
if (action.equals(Constants.UPDATE_LEFT_PANE)) {
updateLeftPane();
} else if (action.equals(Constants.REJECT_FRIEND_REQUEST)) {
updateLeftPane();
Context ctx = getApplicationContext();
String text = getString(R.string.friendrequest_deleted);
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(ctx, text, duration);
toast.show();
} else if (action.equals(Constants.UPDATE_MESSAGES)) {
updateLeftPane();
if (intent.getStringExtra("key").equals(toxSingleton.activeFriendKey)) {
updateChat(toxSingleton.activeFriendKey);
}
} else if (action.equals(Constants.ACCEPT_FRIEND_REQUEST)) {
updateLeftPane();
Context ctx = getApplicationContext();
String text = getString(R.string.friendrequest_accepted);
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(ctx, text, duration);
toast.show();
} else if (action.equals(Constants.UPDATE)) {
updateLeftPane();
if (toxSingleton.rightPaneActive) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.TimeZone;

import im.tox.antox.R;
import im.tox.antox.utils.ChatMessages;
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/im/tox/antox/adapters/RecentAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package im.tox.antox.callbacks;

import android.content.Context;
import android.util.Log;

import im.tox.antox.utils.AntoxFriend;
import im.tox.jtoxcore.callbacks.OnActionCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import im.tox.antox.tox.ToxSingleton;
import im.tox.antox.utils.AntoxFriend;
import im.tox.antox.utils.Constants;
import im.tox.antox.tox.ToxService;
import im.tox.antox.utils.Message;
import im.tox.jtoxcore.ToxException;
import im.tox.jtoxcore.callbacks.OnConnectionStatusCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

import im.tox.antox.R;
import im.tox.antox.activities.MainActivity;
import im.tox.antox.data.AntoxDB;
import im.tox.antox.tox.ToxSingleton;
import im.tox.antox.utils.Constants;
import im.tox.antox.tox.ToxService;
import im.tox.antox.utils.FriendRequest;
import im.tox.jtoxcore.callbacks.OnFriendRequestCallback;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package im.tox.antox.callbacks;

import im.tox.antox.R;
import im.tox.antox.activities.MainActivity;
import im.tox.antox.data.AntoxDB;
import im.tox.antox.tox.ToxSingleton;
import im.tox.antox.utils.Constants;
import im.tox.antox.utils.AntoxFriend;
import im.tox.antox.tox.ToxService;
import im.tox.jtoxcore.callbacks.OnMessageCallback;

import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
Expand All @@ -18,13 +9,17 @@
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

import im.tox.antox.R;
import im.tox.antox.activities.MainActivity;
import im.tox.antox.data.AntoxDB;
import im.tox.antox.tox.ToxSingleton;
import im.tox.antox.utils.AntoxFriend;
import im.tox.antox.utils.Constants;
import im.tox.jtoxcore.callbacks.OnMessageCallback;

public class AntoxOnMessageCallback implements OnMessageCallback<AntoxFriend> {
public static final String TAG = "AntoxOnMessageCallback";
public static final String MESSAGE = "im.tox.antox.AntoxOnMessageCallback.MESSAGE";
public static final String KEY = "im.tox.antox.AntoxOnMessageCallback.KEY";
public static final String FRIEND_NUMBER = "im.tox.antox.AntoxOnMessageCallback.FRIEND_NUMBER";

private Context ctx;

Expand All @@ -36,13 +31,6 @@ public AntoxOnMessageCallback(Context ctx) {

@Override
public void execute(AntoxFriend friend, String message) {
Intent intent = new Intent(this.ctx, ToxService.class);
intent.setAction(Constants.ON_MESSAGE);
intent.putExtra(MESSAGE, message);
intent.putExtra(FRIEND_NUMBER, friend.getFriendnumber());
intent.putExtra(KEY, friend.getId());
this.ctx.startService(intent);

/* Add message to database */
AntoxDB db = new AntoxDB(this.ctx);
if(!db.isFriendBlocked(friend.getId()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

import im.tox.antox.data.AntoxDB;
import im.tox.antox.utils.AntoxFriend;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

import im.tox.antox.data.AntoxDB;
import im.tox.antox.utils.AntoxFriend;
import im.tox.antox.utils.Constants;
import im.tox.antox.tox.ToxService;
import im.tox.jtoxcore.callbacks.OnReadReceiptCallback;

public class AntoxOnReadReceiptCallback implements OnReadReceiptCallback<AntoxFriend> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

import im.tox.antox.data.AntoxDB;
import im.tox.antox.utils.AntoxFriend;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package im.tox.antox.callbacks;

import android.content.Context;
import android.util.Log;

import im.tox.antox.utils.AntoxFriend;
import im.tox.jtoxcore.callbacks.OnTypingChangeCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

import im.tox.antox.data.AntoxDB;
import im.tox.antox.utils.AntoxFriend;
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/im/tox/antox/data/AntoxDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import im.tox.antox.utils.Friend;
import im.tox.antox.utils.FriendRequest;
import im.tox.antox.utils.Message;
import im.tox.antox.utils.PrettyTimestamp;
import im.tox.antox.utils.Tuple;
import im.tox.jtoxcore.ToxUserStatus;

Expand Down
10 changes: 0 additions & 10 deletions app/src/main/java/im/tox/antox/fragments/ChatFragment.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
package im.tox.antox.fragments;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.Random;

import im.tox.antox.R;
import im.tox.antox.activities.MainActivity;
import im.tox.antox.adapters.ChatMessagesAdapter;
import im.tox.antox.data.AntoxDB;
import im.tox.antox.tox.ToxService;
import im.tox.antox.tox.ToxSingleton;
import im.tox.antox.utils.AntoxFriend;
import im.tox.antox.utils.ChatMessages;
import im.tox.antox.utils.Constants;
import im.tox.antox.utils.Friend;
import im.tox.antox.utils.Message;
import im.tox.antox.utils.Triple;
import im.tox.antox.utils.Tuple;
import im.tox.jtoxcore.ToxException;
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
Expand Down

0 comments on commit 052d279

Please sign in to comment.