Moved delete contact button + fix for delete + removed warnings in other code
This commit is contained in:
parent
129140f945
commit
e462133076
9 changed files with 71 additions and 71 deletions
BIN
res/drawable-xhdpi/contact_delete_default.9.png
Normal file
BIN
res/drawable-xhdpi/contact_delete_default.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
res/drawable-xhdpi/contact_delete_over.9.png
Normal file
BIN
res/drawable-xhdpi/contact_delete_over.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
8
res/drawable/contact_delete.xml
Normal file
8
res/drawable/contact_delete.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/contact_delete_over" />
|
||||
<item
|
||||
android:drawable="@drawable/contact_delete_default" />
|
||||
</selector>
|
||||
|
|
@ -11,6 +11,20 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:contentDescription="@string/content_description_delete"
|
||||
android:id="@+id/deleteContact"
|
||||
android:background="@drawable/contact_delete"
|
||||
android:text="@string/button_delete_all"
|
||||
android:gravity="center"
|
||||
android:paddingTop="20dp"
|
||||
android:textColor="@drawable/text_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<TextView
|
||||
android:contentDescription="@string/content_description_edit"
|
||||
android:id="@+id/editContact"
|
||||
|
@ -25,20 +39,6 @@
|
|||
android:adjustViewBounds="true"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<!-- <TextView
|
||||
android:contentDescription="@string/content_description_add_contact"
|
||||
android:id="@+id/newContact"
|
||||
android:background="@drawable/contact_add_contact"
|
||||
android:text="@string/button_add_contact"
|
||||
android:gravity="center"
|
||||
android:paddingTop="20dp"
|
||||
android:textColor="@color/text_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="1"/> -->
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -11,6 +11,20 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:contentDescription="@string/content_description_delete"
|
||||
android:id="@+id/deleteContact"
|
||||
android:background="@drawable/contact_delete"
|
||||
android:text="@string/button_delete_all"
|
||||
android:gravity="center"
|
||||
android:paddingTop="20dp"
|
||||
android:textColor="@drawable/text_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<TextView
|
||||
android:contentDescription="@string/content_description_edit"
|
||||
android:id="@+id/editContact"
|
||||
|
@ -21,6 +35,7 @@
|
|||
android:textColor="@drawable/text_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"/>
|
||||
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/delete_contact"
|
||||
android:background="@drawable/alert"
|
||||
android:textColor="@android:color/white"
|
||||
android:gravity="center"
|
||||
android:textSize="30dp"
|
||||
android:textStyle="bold"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:layout_margin="30dp">
|
||||
</TextView>
|
|
@ -18,13 +18,16 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
import java.io.InputStream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.AvatarWithShadow;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentProviderOperation;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -39,7 +42,7 @@ import android.widget.TextView;
|
|||
*/
|
||||
public class ContactFragment extends Fragment implements OnClickListener {
|
||||
private Contact contact;
|
||||
private TextView editContact;
|
||||
private TextView editContact, deleteContact;
|
||||
private LayoutInflater inflater;
|
||||
private View view;
|
||||
private boolean displayChatAddressOnly = false;
|
||||
|
@ -74,6 +77,9 @@ public class ContactFragment extends Fragment implements OnClickListener {
|
|||
editContact = (TextView) view.findViewById(R.id.editContact);
|
||||
editContact.setOnClickListener(this);
|
||||
|
||||
deleteContact = (TextView) view.findViewById(R.id.deleteContact);
|
||||
deleteContact.setOnClickListener(this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -83,6 +89,7 @@ public class ContactFragment extends Fragment implements OnClickListener {
|
|||
displayContact(inflater, view);
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
private void displayContact(LayoutInflater inflater, View view) {
|
||||
AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);
|
||||
if (contact.getPhotoUri() != null) {
|
||||
|
@ -195,6 +202,27 @@ public class ContactFragment extends Fragment implements OnClickListener {
|
|||
|
||||
if (id == R.id.editContact) {
|
||||
LinphoneActivity.instance().editContact(contact);
|
||||
} else if (id == R.id.deleteContact) {
|
||||
deleteExistingContact();
|
||||
LinphoneActivity.instance().removeContactFromLists(contact);
|
||||
LinphoneActivity.instance().displayContacts(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteExistingContact() {
|
||||
String select = ContactsContract.Data.CONTACT_ID + " = ?";
|
||||
String[] args = new String[] { contact.getID() };
|
||||
|
||||
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
|
||||
ops.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI)
|
||||
.withSelection(select, args)
|
||||
.build()
|
||||
);
|
||||
|
||||
try {
|
||||
getActivity().getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
|
||||
} catch (Exception e) {
|
||||
Log.w(e.getMessage() + ":" + e.getStackTrace());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,10 @@ package org.linphone;
|
|||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.ui.AvatarWithShadow;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentProviderOperation;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
|
@ -34,7 +33,6 @@ public class EditContactFragment extends Fragment {
|
|||
private TextView ok;
|
||||
private EditText firstName, lastName;
|
||||
private LayoutInflater inflater;
|
||||
private View deleteContact;
|
||||
|
||||
private boolean isNewContact = true;
|
||||
private Contact contact;
|
||||
|
@ -214,19 +212,6 @@ public class EditContactFragment extends Fragment {
|
|||
if (view != null)
|
||||
controls.addView(view);
|
||||
}
|
||||
|
||||
if (!isNewContact) {
|
||||
deleteContact = inflater.inflate(R.layout.contact_delete_button, null);
|
||||
deleteContact.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
deleteExistingContact();
|
||||
LinphoneActivity.instance().removeContactFromLists(contact);
|
||||
LinphoneActivity.instance().displayContacts(false);
|
||||
}
|
||||
});
|
||||
controls.addView(deleteContact, controls.getChildCount());
|
||||
}
|
||||
|
||||
// Add one for phone numbers, one for SIP address
|
||||
if (!getResources().getBoolean(R.bool.hide_phone_numbers_in_editor)) {
|
||||
|
@ -243,6 +228,7 @@ public class EditContactFragment extends Fragment {
|
|||
return displayNumberOrAddress(controls, numberOrAddress, false);
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
private View displayNumberOrAddress(final TableLayout controls, String numberOrAddress, boolean forceAddNumber) {
|
||||
boolean isSip = LinphoneUtils.isStrictSipAddress(numberOrAddress) || !LinphoneUtils.isNumberAddress(numberOrAddress);
|
||||
|
||||
|
@ -307,6 +293,7 @@ public class EditContactFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
private void addEmptyRowToAllowNewNumberOrAddress(final TableLayout controls, final boolean isSip) {
|
||||
final View view = inflater.inflate(R.layout.contact_add_row, null);
|
||||
|
||||
|
@ -365,11 +352,6 @@ public class EditContactFragment extends Fragment {
|
|||
controls.addView(view);
|
||||
}
|
||||
}
|
||||
if (deleteContact != null) {
|
||||
// Move to the bottom the remove contact button
|
||||
controls.removeView(deleteContact);
|
||||
controls.addView(deleteContact, controls.getChildCount());
|
||||
}
|
||||
}
|
||||
|
||||
private void createNewContact() {
|
||||
|
@ -405,22 +387,6 @@ public class EditContactFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void deleteExistingContact() {
|
||||
String select = ContactsContract.Data.CONTACT_ID + "=?";
|
||||
String[] args = new String[] { String.valueOf(contactID) };
|
||||
|
||||
ops.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI)
|
||||
.withSelection(select, args)
|
||||
.build()
|
||||
);
|
||||
|
||||
try {
|
||||
getActivity().getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String getDisplayName() {
|
||||
String displayName = null;
|
||||
if (firstName.getText().length() > 0 && lastName.getText().length() > 0)
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.linphone.core.LinphoneCoreException;
|
|||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.core.PayloadType;
|
||||
import org.linphone.core.TunnelConfig;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
|
@ -59,7 +58,6 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
private static final int WIZARD_INTENT = 1;
|
||||
private LinphonePreferences mPrefs;
|
||||
private Handler mHandler = new Handler();
|
||||
private TunnelConfig tunnelConfig;
|
||||
|
||||
public SettingsFragment() {
|
||||
super(R.xml.preferences);
|
||||
|
@ -503,7 +501,6 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
findPreference(getString(R.string.pref_adaptive_rate_algorithm_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
ListPreference listPreference = (ListPreference) preference;
|
||||
mPrefs.setAdaptiveRateAlgorithm(AdaptiveRateAlgorithm.fromString((String)newValue));
|
||||
preference.setSummary(String.valueOf(mPrefs.getAdaptiveRateAlgorithm()));
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue