Fix account delete in side menu and status bar
This commit is contained in:
parent
18c2eef5b8
commit
3aa9f829c9
6 changed files with 48 additions and 26 deletions
|
@ -46,7 +46,7 @@
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/call"
|
android:id="@+id/contact_call"
|
||||||
android:src="@drawable/call_start_body_default"
|
android:src="@drawable/call_start_body_default"
|
||||||
android:contentDescription="@string/content_description_dial_back"
|
android:contentDescription="@string/content_description_dial_back"
|
||||||
android:layout_width="60dp"
|
android:layout_width="60dp"
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
android:layout_centerInParent="true"/>
|
android:layout_centerInParent="true"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/chat"
|
android:id="@+id/contact_chat"
|
||||||
android:src="@drawable/chat_start_body_default"
|
android:src="@drawable/chat_start_body_default"
|
||||||
android:contentDescription="@string/content_description_chat"
|
android:contentDescription="@string/content_description_chat"
|
||||||
android:layout_width="60dp"
|
android:layout_width="60dp"
|
||||||
|
|
|
@ -343,6 +343,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
||||||
delete.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
delete.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
mPrefs.deleteAccount(n);
|
mPrefs.deleteAccount(n);
|
||||||
|
LinphoneActivity.instance().refreshAccounts();
|
||||||
LinphoneActivity.instance().displaySettings();
|
LinphoneActivity.instance().displaySettings();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -447,6 +448,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
||||||
delete.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
delete.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
mPrefs.deleteAccount(n);
|
mPrefs.deleteAccount(n);
|
||||||
|
LinphoneActivity.instance().refreshAccounts();
|
||||||
LinphoneActivity.instance().displaySettings();
|
LinphoneActivity.instance().displaySettings();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.ContentProviderOperation;
|
import android.content.ContentProviderOperation;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
@ -37,6 +38,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TableLayout;
|
import android.widget.TableLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -152,13 +154,13 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
tv.setSelected(true);
|
tv.setSelected(true);
|
||||||
|
|
||||||
if (!displayChatAddressOnly) {
|
if (!displayChatAddressOnly) {
|
||||||
v.findViewById(R.id.call).setOnClickListener(dialListener);
|
v.findViewById(R.id.contact_call).setOnClickListener(dialListener);
|
||||||
v.findViewById(R.id.call).setTag(displayednumberOrAddress);
|
v.findViewById(R.id.contact_call).setTag(displayednumberOrAddress);
|
||||||
} else {
|
} else {
|
||||||
v.findViewById(R.id.call).setVisibility(View.GONE);
|
v.findViewById(R.id.contact_call).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
v.findViewById(R.id.chat).setOnClickListener(chatListener);
|
v.findViewById(R.id.contact_chat).setOnClickListener(chatListener);
|
||||||
LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
|
LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
|
||||||
if (lpc != null) {
|
if (lpc != null) {
|
||||||
displayednumberOrAddress = lpc.normalizePhoneNumber(displayednumberOrAddress);
|
displayednumberOrAddress = lpc.normalizePhoneNumber(displayednumberOrAddress);
|
||||||
|
@ -170,9 +172,9 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
if (!numberOrAddress.contains("@")) {
|
if (!numberOrAddress.contains("@")) {
|
||||||
tag = numberOrAddress + "@" + lpc.getDomain();
|
tag = numberOrAddress + "@" + lpc.getDomain();
|
||||||
}
|
}
|
||||||
v.findViewById(R.id.chat).setTag(tag);
|
v.findViewById(R.id.contact_chat).setTag(tag);
|
||||||
} else {
|
} else {
|
||||||
v.findViewById(R.id.chat).setTag(numberOrAddress);
|
v.findViewById(R.id.contact_chat).setTag(numberOrAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String finalNumberOrAddress = numberOrAddress;
|
final String finalNumberOrAddress = numberOrAddress;
|
||||||
|
@ -205,7 +207,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.disable_chat)) {
|
if (getResources().getBoolean(R.bool.disable_chat)) {
|
||||||
v.findViewById(R.id.chat).setVisibility(View.GONE);
|
v.findViewById(R.id.contact_chat).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
controls.addView(v);
|
controls.addView(v);
|
||||||
|
@ -236,17 +238,28 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
if (id == R.id.editContact) {
|
if (id == R.id.editContact) {
|
||||||
LinphoneActivity.instance().editContact(contact);
|
LinphoneActivity.instance().editContact(contact);
|
||||||
} else if (id == R.id.deleteContact) {
|
} else if (id == R.id.deleteContact) {
|
||||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
|
final Dialog dialog = LinphoneActivity.instance().displayDialog(getString(R.string.delete_text));
|
||||||
alertDialog.setMessage(getString(R.string.delete_contact_dialog));
|
Button delete = (Button) dialog.findViewById(R.id.delete);
|
||||||
alertDialog.setPositiveButton(getString(R.string.button_ok),new DialogInterface.OnClickListener() {
|
Button cancel = (Button) dialog.findViewById(R.id.cancel);
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
deleteExistingContact();
|
delete.setOnClickListener(new OnClickListener() {
|
||||||
ContactsManager.getInstance().removeContactFromLists(getActivity().getContentResolver(),contact);
|
@Override
|
||||||
LinphoneActivity.instance().displayContacts(false);
|
public void onClick(View view) {
|
||||||
|
deleteExistingContact();
|
||||||
|
ContactsManager.getInstance().removeContactFromLists(getActivity().getContentResolver(), contact);
|
||||||
|
LinphoneActivity.instance().displayContacts(false);
|
||||||
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
alertDialog.setNegativeButton(getString(R.string.button_cancel),null);
|
|
||||||
alertDialog.show();
|
cancel.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,11 +207,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(proxy == lc.getDefaultProxyConfig()){
|
refreshAccounts();
|
||||||
displayMainAccount();
|
|
||||||
} else {
|
|
||||||
refreshAccounts();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(state.equals(RegistrationState.RegistrationFailed) && newProxyConfig) {
|
if(state.equals(RegistrationState.RegistrationFailed) && newProxyConfig) {
|
||||||
newProxyConfig = false;
|
newProxyConfig = false;
|
||||||
|
@ -1352,6 +1348,8 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
if(proxy == null) {
|
if(proxy == null) {
|
||||||
displayName.setText(getString(R.string.no_account));
|
displayName.setText(getString(R.string.no_account));
|
||||||
status.setVisibility(View.GONE);
|
status.setVisibility(View.GONE);
|
||||||
|
address.setText("");
|
||||||
|
statusFragment.resetAccountStatus();
|
||||||
|
|
||||||
defaultAccount.setOnClickListener(new OnClickListener() {
|
defaultAccount.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1376,7 +1374,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshAccounts(){
|
public void refreshAccounts(){
|
||||||
if(LinphoneManager.getLc().getProxyConfigList().length > 1) {
|
if(LinphoneManager.getLc().getProxyConfigList().length > 1) {
|
||||||
accountsList.setVisibility(View.VISIBLE);
|
accountsList.setVisibility(View.VISIBLE);
|
||||||
accountsList.setAdapter(new AccountsListAdapter());
|
accountsList.setAdapter(new AccountsListAdapter());
|
||||||
|
@ -1391,6 +1389,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
} else {
|
} else {
|
||||||
accountsList.setVisibility(View.GONE);
|
accountsList.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
displayMainAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initAccounts() {
|
private void initAccounts() {
|
||||||
|
|
|
@ -700,13 +700,14 @@ public class LinphonePreferences {
|
||||||
|
|
||||||
public void deleteAccount(int n) {
|
public void deleteAccount(int n) {
|
||||||
final LinphoneProxyConfig proxyCfg = getProxyConfig(n);
|
final LinphoneProxyConfig proxyCfg = getProxyConfig(n);
|
||||||
|
|
||||||
if (proxyCfg != null)
|
if (proxyCfg != null)
|
||||||
getLc().removeProxyConfig(proxyCfg);
|
getLc().removeProxyConfig(proxyCfg);
|
||||||
if (getLc().getProxyConfigList().length != 0) {
|
if (getLc().getProxyConfigList().length != 0) {
|
||||||
resetDefaultProxyConfig();
|
resetDefaultProxyConfig();
|
||||||
getLc().refreshRegisters();
|
} else {
|
||||||
|
getLc().setDefaultProxyConfig(null);
|
||||||
}
|
}
|
||||||
|
getLc().refreshRegisters();
|
||||||
}
|
}
|
||||||
// End of accounts settings
|
// End of accounts settings
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,13 @@ public class StatusFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetAccountStatus(){
|
||||||
|
if(LinphoneManager.getLc().getProxyConfigList().length == 0){
|
||||||
|
statusLed.setImageResource(R.drawable.led_disconnected);
|
||||||
|
statusText.setText(getString(R.string.no_account));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void enableSideMenu(boolean enabled) {
|
public void enableSideMenu(boolean enabled) {
|
||||||
menu.setEnabled(enabled);
|
menu.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue