Replaced ContactAddedView with a toast (development task #39).

This commit is contained in:
akwizgran
2013-12-05 12:27:45 +00:00
parent f383532ecd
commit b7dbacb000
2 changed files with 17 additions and 60 deletions

View File

@@ -5,6 +5,7 @@ import static android.bluetooth.BluetoothAdapter.ACTION_STATE_CHANGED;
import static android.bluetooth.BluetoothAdapter.EXTRA_STATE;
import static android.bluetooth.BluetoothAdapter.STATE_ON;
import static android.net.wifi.WifiManager.NETWORK_STATE_CHANGED_ACTION;
import static android.widget.Toast.LENGTH_LONG;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
@@ -14,6 +15,7 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import net.sf.briar.R;
import net.sf.briar.android.identity.LocalAuthorItem;
import net.sf.briar.android.identity.LocalAuthorItemComparator;
import net.sf.briar.android.identity.LocalAuthorSpinnerAdapter;
@@ -38,6 +40,7 @@ import android.content.IntentFilter;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.widget.Toast;
public class AddContactActivity extends RoboActivity
implements InvitationListener {
@@ -100,7 +103,8 @@ implements InvitationListener {
} else if(contactName == null) {
setView(new CodesDoNotMatchView(this));
} else {
setView(new ContactAddedView(this));
showToastAndFinish();
return;
}
} else {
// A background task exists - listen to it and get its state
@@ -132,9 +136,12 @@ implements InvitationListener {
} else if(!remoteCompared) {
setView(new WaitForContactView(this));
} else if(localMatched && remoteMatched) {
if(contactName == null)
if(contactName == null) {
setView(new ContactDetailsView(this));
else setView(new ContactAddedView(this));
} else {
showToastAndFinish();
return;
}
} else {
setView(new CodesDoNotMatchView(this));
}
@@ -161,6 +168,11 @@ implements InvitationListener {
view.wifiStateChanged();
}
private void showToastAndFinish() {
Toast.makeText(this, R.string.contact_added, LENGTH_LONG).show();
finish();
}
@Override
public void onResume() {
super.onResume();
@@ -185,7 +197,7 @@ implements InvitationListener {
public void onDestroy() {
super.onDestroy();
if(task != null) task.removeListener(this);
unregisterReceiver(receiver);
if(receiver != null) unregisterReceiver(receiver);
}
void setView(AddContactView view) {
@@ -366,7 +378,7 @@ implements InvitationListener {
runOnUiThread(new Runnable() {
public void run() {
contactName = remoteName;
setView(new ContactAddedView(AddContactActivity.this));
showToastAndFinish();
}
});
}

View File

@@ -1,55 +0,0 @@
package net.sf.briar.android.invitation;
import static android.view.Gravity.CENTER;
import static net.sf.briar.android.util.CommonLayoutParams.WRAP_WRAP;
import net.sf.briar.R;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
class ContactAddedView extends AddContactView implements OnClickListener {
ContactAddedView(Context ctx) {
super(ctx);
}
void populate() {
removeAllViews();
Context ctx = getContext();
LinearLayout innerLayout = new LinearLayout(ctx);
innerLayout.setOrientation(HORIZONTAL);
innerLayout.setGravity(CENTER);
ImageView icon = new ImageView(ctx);
icon.setImageResource(R.drawable.navigation_accept);
innerLayout.addView(icon);
TextView added = new TextView(ctx);
added.setTextSize(22);
added.setPadding(10, 10, 10, 10);
added.setText(R.string.contact_added);
innerLayout.addView(added);
addView(innerLayout);
TextView contactName = new TextView(ctx);
contactName.setGravity(CENTER);
contactName.setTextSize(22);
contactName.setPadding(10, 0, 10, 10);
contactName.setText(container.getContactName());
addView(contactName);
Button doneButton = new Button(ctx);
doneButton.setLayoutParams(WRAP_WRAP);
doneButton.setText(R.string.done_button);
doneButton.setOnClickListener(this);
addView(doneButton);
}
public void onClick(View view) {
container.finish();
}
}