Skip to content

Commit

Permalink
fixes conflict on merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dethstar committed Apr 13, 2014
2 parents b538bee + 57cfaf0 commit 407fa92
Show file tree
Hide file tree
Showing 26 changed files with 992 additions and 89 deletions.
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="im.tox.antox.activities.MainActivity" />
</activity>
<activity
android:name="im.tox.antox.activities.ManageGroupsActivity"
android:label="@string/title_activity_manage_groups"
android:parentActivityName="im.tox.antox.activities.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="im.tox.antox.activities.MainActivity" />
</activity>

<receiver android:name="im.tox.antox.utils.ConnectionChangeReceiver"
android:label="NetworkConnection">
Expand Down
47 changes: 39 additions & 8 deletions app/src/main/java/im/tox/antox/activities/AddFriendActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
Expand All @@ -18,14 +19,20 @@
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
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 java.util.ArrayList;
import java.util.List;
import java.util.Map;

import im.tox.QR.IntentIntegrator;
import im.tox.QR.IntentResult;
import im.tox.antox.data.AntoxDB;
Expand All @@ -35,6 +42,7 @@
import im.tox.antox.R;
import im.tox.antox.tox.ToxService;
import im.tox.antox.utils.DhtNode;
import im.tox.antox.utils.GroupItem;

/**
* Activity to allow the user to add a friend. Also as a URI handler to automatically insert public
Expand All @@ -59,6 +67,7 @@ public class AddFriendActivity extends ActionBarActivity implements PinDialogFra
EditText friendID;
EditText friendMessage;
EditText friendAlias;
Spinner friendGroup;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -79,25 +88,45 @@ public void onCreate(Bundle savedInstanceState) {
}

// Check to see if user is connected to dht first

if(!DhtNode.connected) {
AlertDialog notConnectedalertDialog = new AlertDialog.Builder(this).create();
notConnectedalertDialog.setTitle(R.string.addfriend_no_internet);
notConnectedalertDialog.setMessage(getString(R.string.addfriend_no_internet_text));
notConnectedalertDialog.setIcon(R.drawable.ic_launcher);
notConnectedalertDialog.setButton("OK", new DialogInterface.OnClickListener() {
AlertDialog notConnectedAlertDialog = new AlertDialog.Builder(this).create();
notConnectedAlertDialog.setTitle(R.string.addfriend_no_internet);
notConnectedAlertDialog.setMessage(getString(R.string.addfriend_no_internet_text));
notConnectedAlertDialog.setIcon(R.drawable.ic_launcher);
notConnectedAlertDialog.setButton(getString(R.string.button_ok), new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
finish();
}
});
notConnectedalertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

notConnectedAlertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
});
notConnectedAlertDialog.show();
}

//set the spinner
friendGroup = (Spinner) findViewById(R.id.spinner_add_friend_group);
ArrayList<String> spinnerArray = new ArrayList<String>();
spinnerArray.add(getResources().getString(R.string.manage_groups_friends));
SharedPreferences sharedPreferences = getSharedPreferences("groups", Context.MODE_PRIVATE);
if (!sharedPreferences.getAll().isEmpty()) {
Map<String,?> keys = sharedPreferences.getAll();

for(Map.Entry<String,?> entry : keys.entrySet()){
String groupName = entry.getValue().toString();
spinnerArray.add(groupName);
}

notConnectedalertDialog.show();
}
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerArray);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
friendGroup.setAdapter(spinnerAdapter);

context = getApplicationContext();
text = getString(R.string.addfriend_friend_added);
Expand Down Expand Up @@ -165,7 +194,8 @@ private int checkAndSend(String key, String originalUsername) {
if (!alias.equals(""))
ID = alias;

db.addFriend(ID, "Friend Request Sent", alias, originalUsername);
String group = friendGroup.getSelectedItem().toString();
db.addFriend(ID, "Friend Request Sent", alias, originalUsername, group);
} else {
return -2;
}
Expand Down Expand Up @@ -210,6 +240,7 @@ public void addFriend(View view) {
finalFriendKey = _friendID;

if(!isV2) {

if(checkAndSend(finalFriendKey, "") == 0) {
toast = Toast.makeText(context, text, duration);
toast.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
Expand All @@ -10,8 +11,10 @@
import android.os.Environment;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

Expand All @@ -22,6 +25,8 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;

import im.tox.QR.Contents;
import im.tox.QR.QRCodeEncode;
Expand All @@ -35,13 +40,15 @@ public class FriendProfileActivity extends ActionBarActivity {

String friendName = null;
String friendKey = null;
String friendGroup = null;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_friend_profile);

friendKey = getIntent().getStringExtra("key");
friendGroup = getIntent().getStringExtra("group");
AntoxDB db = new AntoxDB(this);
String[] friendDetails = db.getFriendDetails(friendKey);
friendName = friendDetails[0];
Expand All @@ -60,6 +67,28 @@ public void onCreate(Bundle savedInstanceState) {
TextView editFriendKey = (TextView) findViewById(R.id.friendKeyText);
editFriendKey.setText(friendKey);

//set the spinner
Spinner friendGroupSpinner = (Spinner) findViewById(R.id.spinner_friend_profile_group);
ArrayList<String> spinnerArray = new ArrayList<String>();
spinnerArray.add(getResources().getString(R.string.manage_groups_friends));
SharedPreferences sharedPreferences = getSharedPreferences("groups", Context.MODE_PRIVATE);
int position = 0;
if (!sharedPreferences.getAll().isEmpty()) {
Map<String,?> keys = sharedPreferences.getAll();

for(Map.Entry<String,?> entry : keys.entrySet()){
String groupName = entry.getValue().toString();
spinnerArray.add(groupName);
if (groupName.equals(friendGroup)) {
position = spinnerArray.size() - 1;
}
}
}
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerArray);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
friendGroupSpinner.setAdapter(spinnerAdapter);
friendGroupSpinner.setSelection(position);

/* Looks for the userkey qr.png if it doesn't exist then it creates it with the generateQR method.
* adds onClickListener to the ImageButton to add share the QR
* */
Expand Down Expand Up @@ -99,9 +128,14 @@ public void onClick(View v) {

public void updateAlias(View view) {
AntoxDB db = new AntoxDB(this);
TextView friendKey = (TextView) findViewById(R.id.friendKeyText);
TextView friendKeyText = (TextView) findViewById(R.id.friendKeyText);
EditText friendAlias = (EditText) findViewById(R.id.friendAliasText);
db.updateAlias(friendAlias.getText().toString(), friendKey.getText().toString());
db.updateAlias(friendAlias.getText().toString(), friendKeyText.getText().toString());

Spinner friendGroupSpinner = (Spinner) findViewById(R.id.spinner_friend_profile_group);
String group = friendGroupSpinner.getSelectedItem().toString();
db.moveUserToOtherGroup(friendKey, group);

db.close();

Context context = getApplicationContext();
Expand Down

0 comments on commit 407fa92

Please sign in to comment.