Added menus to contact view + refreshed contact after edition

This commit is contained in:
Sylvain Berfini 2012-07-27 11:08:50 +02:00
parent 72ff54e33c
commit 4d5cbe6461
96 changed files with 123 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

8
res/drawable/back.xml Normal file
View 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/back_over" />
<item
android:drawable="@drawable/back_default" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
res/drawable/back_over.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View 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_edit_over" />
<item
android:drawable="@drawable/contact_edit_default" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -6,6 +6,41 @@
android:background="@drawable/background"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/back"
android:src="@drawable/back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_weight="1"/>
<ImageView
android:id="@+id/editContact"
android:src="@drawable/chat_edit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_weight="1"/>
<ImageView
android:contentDescription="@string/content_description_add_contact"
android:id="@+id/newContact"
android:src="@drawable/new_contact"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -20,6 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import java.io.Serializable;
import java.util.List;
import org.linphone.compatibility.Compatibility;
import android.content.ContentResolver;
import android.graphics.Bitmap;
import android.net.Uri;
@ -81,4 +84,9 @@ public class Contact implements Serializable {
public void setNumerosOrAddresses(List<String> numerosOrAddresses) {
this.numerosOrAddresses = numerosOrAddresses;
}
public void refresh(ContentResolver cr) {
this.numerosOrAddresses = Compatibility.extractContactNumbersAndAddresses(id, cr);
this.name = Compatibility.refreshContactName(cr, id);
}
}

View file

@ -22,6 +22,7 @@ import java.io.InputStream;
import org.linphone.compatibility.Compatibility;
import org.linphone.ui.AvatarWithShadow;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@ -29,23 +30,41 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TableLayout;
import android.widget.TextView;
/**
* @author Sylvain Berfini
*/
public class ContactFragment extends Fragment {
public class ContactFragment extends Fragment implements OnClickListener {
private Contact contact;
private ImageView back, editContact, newContact;
private OnClickListener dialListener, chatListener;
private LayoutInflater inflater;
private View view;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
contact = (Contact) getArguments().getSerializable("Contact");
contact.setNumerosOrAddresses(Compatibility.extractContactNumbersAndAddresses(contact.getID(), getActivity().getContentResolver()));
View view = inflater.inflate(R.layout.contact, container, false);
this.inflater = inflater;
view = inflater.inflate(R.layout.contact, container, false);
back = (ImageView) view.findViewById(R.id.back);
back.setOnClickListener(this);
editContact = (ImageView) view.findViewById(R.id.editContact);
editContact.setOnClickListener(this);
newContact = (ImageView) view.findViewById(R.id.newContact);
newContact.setOnClickListener(this);
chatListener = getChatListener();
dialListener = getDialListener();
return view;
}
private void displayContact(LayoutInflater inflater, View view) {
AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);
if (contact.getPhotoUri() != null) {
InputStream input = Compatibility.getContactPictureInputStream(getActivity().getContentResolver(), contact.getID());
@ -54,14 +73,11 @@ public class ContactFragment extends Fragment {
contactPicture.setBackgroundResource(R.drawable.unknown_small);
}
chatListener = getChatListener();
dialListener = getDialListener();
TextView contactName = (TextView) view.findViewById(R.id.contactName);
contactName.setText(contact.getName());
TableLayout controls = (TableLayout) view.findViewById(R.id.controls);
controls.removeAllViews();
for (String numberOrAddress : contact.getNumerosOrAddresses()) {
View v = inflater.inflate(R.layout.contact_control_row, null);
@ -79,8 +95,6 @@ public class ContactFragment extends Fragment {
controls.addView(v);
}
return view;
}
@Override
@ -89,6 +103,8 @@ public class ContactFragment extends Fragment {
if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT);
}
contact.refresh(getActivity().getContentResolver());
displayContact(inflater, view);
}
public OnClickListener getDialListener() {
@ -108,4 +124,26 @@ public class ContactFragment extends Fragment {
}
};
}
@Override
public void onClick(View v) {
int id = v.getId();
Intent intent;
switch (id) {
case R.id.back:
LinphoneActivity.instance().onBackPressed();
break;
case R.id.editContact:
intent = Compatibility.prepareEditContactIntent(Integer.parseInt(contact.getID()));
startActivity(intent);
break;
case R.id.newContact:
intent = Compatibility.prepareAddContactIntent("", "");
startActivity(intent);
break;
}
}
}

View file

@ -267,4 +267,12 @@ public class ApiFivePlus {
return null;
}
public static String refreshContactName(ContentResolver cr, String id) {
Cursor c = getGeneralContactCursor(cr, Data.CONTACT_ID + " = '" + id + "'", false);
if (c.moveToFirst()) {
return getContactDisplayName(c);
}
return null;
}
}

View file

@ -167,4 +167,13 @@ public class Compatibility {
}
return notif;
}
public static String refreshContactName(ContentResolver cr, String id) {
if (Version.sdkAboveOrEqual(5)) {
return ApiFivePlus.refreshContactName(cr, id);
} else {
//TODO
}
return null;
}
}