delete account code now accessible again
This commit is contained in:
parent
4fd8620c6c
commit
c01f2cedb6
|
@ -41,8 +41,9 @@ public final class R {
|
||||||
}
|
}
|
||||||
public static final class id {
|
public static final class id {
|
||||||
public static final int account_confirm_password_desc=0x7f0a0011;
|
public static final int account_confirm_password_desc=0x7f0a0011;
|
||||||
public static final int account_disable=0x7f0a002c;
|
public static final int account_delete=0x7f0a002c;
|
||||||
public static final int account_enable=0x7f0a002d;
|
public static final int account_disable=0x7f0a002d;
|
||||||
|
public static final int account_enable=0x7f0a002e;
|
||||||
public static final int account_jid=0x7f0a0000;
|
public static final int account_jid=0x7f0a0000;
|
||||||
public static final int account_list=0x7f0a0021;
|
public static final int account_list=0x7f0a0021;
|
||||||
public static final int account_password=0x7f0a000f;
|
public static final int account_password=0x7f0a000f;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
<item android:icon="@drawable/ic_action_delete"
|
<item
|
||||||
|
android:id="@+id/account_delete"
|
||||||
|
android:icon="@drawable/ic_action_delete"
|
||||||
android:title="Delete"
|
android:title="Delete"
|
||||||
android:showAsAction="always"
|
android:showAsAction="always"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -59,15 +59,9 @@ public class Account extends AbstractEntity{
|
||||||
|
|
||||||
public void setOption(int option, boolean value) {
|
public void setOption(int option, boolean value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
Log.d("xmppService","options: "+options);
|
|
||||||
this.options = (this.options | 1 << option);
|
this.options = (this.options | 1 << option);
|
||||||
Log.d("xmppService","setting option "+option+" to 1");
|
|
||||||
Log.d("xmppService","options: "+options);
|
|
||||||
} else {
|
} else {
|
||||||
Log.d("xmppService","options: "+options);
|
|
||||||
Log.d("xmppService","setting option "+option+" to 0");
|
|
||||||
this.options = (this.options ^ 1 << option);
|
this.options = (this.options ^ 1 << option);
|
||||||
Log.d("xmppService","options: "+options);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import de.gultsch.chat.utils.UIHelper;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.v4.widget.SlidingPaneLayout;
|
import android.support.v4.widget.SlidingPaneLayout;
|
||||||
|
@ -278,6 +279,12 @@ public class ConversationActivity extends XmppActivity {
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
nm.cancelAll();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
|
@ -29,8 +29,6 @@ public class EditAccount extends DialogFragment {
|
||||||
|
|
||||||
public interface EditAccountListener {
|
public interface EditAccountListener {
|
||||||
public void onAccountEdited(Account account);
|
public void onAccountEdited(Account account);
|
||||||
|
|
||||||
public void onAccountDelete(Account account);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EditAccountListener listener = null;
|
protected EditAccountListener listener = null;
|
||||||
|
@ -92,27 +90,6 @@ public class EditAccount extends DialogFragment {
|
||||||
usernameText.setText(account.getUsername());
|
usernameText.setText(account.getUsername());
|
||||||
serverText.setText(account.getServer());
|
serverText.setText(account.getServer());
|
||||||
okButtonDesc = "Edit";
|
okButtonDesc = "Edit";
|
||||||
/*builder.setNegativeButton("Delete Account", new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
||||||
builder.setTitle("Are you sure?");
|
|
||||||
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
|
||||||
builder.setMessage("If you delete your account your entire conversation history will be lost");
|
|
||||||
builder.setPositiveButton("Delete", new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (listener!=null) {
|
|
||||||
listener.onAccountDelete(account);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton("Cancel",null);
|
|
||||||
builder.create().show();
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
} else {
|
} else {
|
||||||
builder.setTitle("Add account");
|
builder.setTitle("Add account");
|
||||||
okButtonDesc = "Add";
|
okButtonDesc = "Add";
|
||||||
|
|
|
@ -9,6 +9,8 @@ import de.gultsch.chat.ui.EditAccount.EditAccountListener;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -122,11 +124,6 @@ public class ManageAccountActivity extends XmppActivity implements ActionMode.Ca
|
||||||
public void onAccountEdited(Account account) {
|
public void onAccountEdited(Account account) {
|
||||||
xmppConnectionService.updateAccount(account);
|
xmppConnectionService.updateAccount(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccountDelete(Account account) {
|
|
||||||
xmppConnectionService.deleteAccount(account);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
dialog.show(getFragmentManager(), "edit_account");
|
dialog.show(getFragmentManager(), "edit_account");
|
||||||
} else {
|
} else {
|
||||||
|
@ -177,7 +174,6 @@ public class ManageAccountActivity extends XmppActivity implements ActionMode.Ca
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
|
||||||
getMenuInflater().inflate(R.menu.manageaccounts, menu);
|
getMenuInflater().inflate(R.menu.manageaccounts, menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -207,17 +203,12 @@ public class ManageAccountActivity extends XmppActivity implements ActionMode.Ca
|
||||||
xmppConnectionService.createAccount(account);
|
xmppConnectionService.createAccount(account);
|
||||||
activity.getActionBar().setDisplayHomeAsUpEnabled(true);
|
activity.getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccountDelete(Account account) {
|
|
||||||
// this will never be called
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
dialog.show(getFragmentManager(), "add_account");
|
dialog.show(getFragmentManager(), "add_account");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
public boolean onActionItemClicked(final ActionMode mode, MenuItem item) {
|
||||||
if (item.getItemId()==R.id.account_disable) {
|
if (item.getItemId()==R.id.account_disable) {
|
||||||
selectedAccountForActionMode.setOption(Account.OPTION_DISABLED, true);
|
selectedAccountForActionMode.setOption(Account.OPTION_DISABLED, true);
|
||||||
xmppConnectionService.updateAccount(selectedAccountForActionMode);
|
xmppConnectionService.updateAccount(selectedAccountForActionMode);
|
||||||
|
@ -226,6 +217,22 @@ public class ManageAccountActivity extends XmppActivity implements ActionMode.Ca
|
||||||
selectedAccountForActionMode.setOption(Account.OPTION_DISABLED, false);
|
selectedAccountForActionMode.setOption(Account.OPTION_DISABLED, false);
|
||||||
xmppConnectionService.updateAccount(selectedAccountForActionMode);
|
xmppConnectionService.updateAccount(selectedAccountForActionMode);
|
||||||
mode.finish();
|
mode.finish();
|
||||||
|
} else if (item.getItemId()==R.id.account_delete) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle("Are you sure?");
|
||||||
|
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||||
|
builder.setMessage("If you delete your account your entire conversation history will be lost");
|
||||||
|
builder.setPositiveButton("Delete", new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
xmppConnectionService.deleteAccount(selectedAccountForActionMode);
|
||||||
|
selectedAccountForActionMode = null;
|
||||||
|
mode.finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("Cancel",null);
|
||||||
|
builder.create().show();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ public class UIHelper {
|
||||||
mBuilder.setContentTitle(conversation.getName());
|
mBuilder.setContentTitle(conversation.getName());
|
||||||
mBuilder.setContentText(conversation.getLatestMessage());
|
mBuilder.setContentText(conversation.getLatestMessage());
|
||||||
mBuilder.setSmallIcon(R.drawable.notification);
|
mBuilder.setSmallIcon(R.drawable.notification);
|
||||||
|
mBuilder.setLights(0xffffffff, 2000, 4000);
|
||||||
if (ringtone!=null) {
|
if (ringtone!=null) {
|
||||||
mBuilder.setSound(Uri.parse(ringtone));
|
mBuilder.setSound(Uri.parse(ringtone));
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,9 @@ public class XmppConnection implements Runnable {
|
||||||
Element failure = tagReader.readElement(nextTag);
|
Element failure = tagReader.readElement(nextTag);
|
||||||
Log.d(LOGTAG,"read failure element"+failure.toString());
|
Log.d(LOGTAG,"read failure element"+failure.toString());
|
||||||
account.setStatus(Account.STATUS_UNAUTHORIZED);
|
account.setStatus(Account.STATUS_UNAUTHORIZED);
|
||||||
|
if (statusListener!=null) {
|
||||||
|
statusListener.onStatusChanged(account);
|
||||||
|
}
|
||||||
tagWriter.writeTag(Tag.end("stream"));
|
tagWriter.writeTag(Tag.end("stream"));
|
||||||
} else if (nextTag.isStart("iq")) {
|
} else if (nextTag.isStart("iq")) {
|
||||||
processIq(nextTag);
|
processIq(nextTag);
|
||||||
|
|
Loading…
Reference in New Issue