Contacts improved + better main layout for hdpi devices
This commit is contained in:
parent
01059beac3
commit
de116b0677
8 changed files with 189 additions and 17 deletions
120
res/layout-hdpi/main.xml
Normal file
120
res/layout-hdpi/main.xml
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/topLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignParentTop="true">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/fragmentContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="75dp"
|
||||||
|
android:paddingTop="20dp" />
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/status"
|
||||||
|
android:name="org.linphone.StatusFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:layout="@layout/status" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/menu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.2">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/history"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:contentDescription="@string/content_description_history"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/history" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/missedCalls"
|
||||||
|
android:layout_width="25dp"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:background="@drawable/missed_calls_bg"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/contacts"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.2"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:contentDescription="@string/content_description_contacts"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/contacts" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/dialer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.2"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:contentDescription="@string/content_description_dialer"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/dialer" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/settings"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.2"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:contentDescription="@string/content_description_settings"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/settings" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.2">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/chat"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:contentDescription="@string/content_description_chat"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/chat" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/missedChats"
|
||||||
|
android:layout_width="25dp"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:background="@drawable/missed_calls_bg"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -120,6 +120,10 @@ public class ContactFragment extends Fragment implements OnClickListener {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT);
|
||||||
}
|
}
|
||||||
contact.refresh(getActivity().getContentResolver());
|
contact.refresh(getActivity().getContentResolver());
|
||||||
|
if (contact.getName() == null || contact.getName().equals("")) {
|
||||||
|
//Contact has been deleted, return
|
||||||
|
LinphoneActivity.instance().displayContacts();
|
||||||
|
}
|
||||||
displayContact(inflater, view);
|
displayContact(inflater, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
private boolean onlyDisplayLinphoneContacts;
|
private boolean onlyDisplayLinphoneContacts;
|
||||||
private int lastKnownPosition;
|
private int lastKnownPosition;
|
||||||
private AlphabetIndexer indexer;
|
private AlphabetIndexer indexer;
|
||||||
|
private boolean editOnClick = false, editConsumed = false;
|
||||||
|
private String sipAddressToAdd;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
@ -58,6 +60,11 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
View view = inflater.inflate(R.layout.contacts_list, container, false);
|
View view = inflater.inflate(R.layout.contacts_list, container, false);
|
||||||
|
|
||||||
|
if (getArguments() != null) {
|
||||||
|
editOnClick = getArguments().getBoolean("EditOnClick");
|
||||||
|
sipAddressToAdd = getArguments().getString("SipAddress");
|
||||||
|
}
|
||||||
|
|
||||||
contactsList = (ListView) view.findViewById(R.id.contactsList);
|
contactsList = (ListView) view.findViewById(R.id.contactsList);
|
||||||
contactsList.setOnItemClickListener(this);
|
contactsList.setOnItemClickListener(this);
|
||||||
|
|
||||||
|
@ -91,7 +98,8 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (id == R.id.newContact) {
|
else if (id == R.id.newContact) {
|
||||||
Intent intent = Compatibility.prepareAddContactIntent(null, null);
|
editConsumed = true;
|
||||||
|
Intent intent = Compatibility.prepareAddContactIntent(null, sipAddressToAdd);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,22 +132,32 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
|
||||||
lastKnownPosition = contactsList.getFirstVisiblePosition();
|
Contact contact = (Contact) adapter.getItemAtPosition(position);
|
||||||
LinphoneActivity.instance().displayContact((Contact) adapter.getItemAtPosition(position));
|
if (editOnClick) {
|
||||||
|
editConsumed = true;
|
||||||
|
Intent intent = Compatibility.prepareEditContactIntentWithSipAddress(Integer.parseInt(contact.getID()), sipAddressToAdd);
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
lastKnownPosition = contactsList.getFirstVisiblePosition();
|
||||||
|
LinphoneActivity.instance().displayContact(contact);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
if (editConsumed) {
|
||||||
|
editOnClick = false;
|
||||||
|
sipAddressToAdd = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACTS);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACTS);
|
||||||
onlyDisplayLinphoneContacts = LinphoneActivity.instance().isLinphoneContactsPrefered();
|
onlyDisplayLinphoneContacts = LinphoneActivity.instance().isLinphoneContactsPrefered();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contactsList.getAdapter() == null) {
|
changeContactsAdapter();
|
||||||
changeContactsAdapter();
|
|
||||||
}
|
|
||||||
|
|
||||||
contactsList.setSelectionFromTop(lastKnownPosition, 0);
|
contactsList.setSelectionFromTop(lastKnownPosition, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
import org.linphone.compatibility.Compatibility;
|
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.ui.AddressAware;
|
import org.linphone.ui.AddressAware;
|
||||||
import org.linphone.ui.AddressText;
|
import org.linphone.ui.AddressText;
|
||||||
|
@ -25,7 +24,6 @@ import org.linphone.ui.CallButton;
|
||||||
import org.linphone.ui.EraseButton;
|
import org.linphone.ui.EraseButton;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -81,8 +79,7 @@ public class DialerFragment extends Fragment {
|
||||||
addContactListener = new OnClickListener() {
|
addContactListener = new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = Compatibility.prepareAddContactIntent(mAddress.getDisplayedName(), mAddress.getText().toString());
|
LinphoneActivity.instance().displayContactsForEdition(mAddress.getText().toString());
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
cancelListener = new OnClickListener() {
|
cancelListener = new OnClickListener() {
|
||||||
|
@ -167,9 +164,8 @@ public class DialerFragment extends Fragment {
|
||||||
mAddContact.setEnabled(true);
|
mAddContact.setEnabled(true);
|
||||||
mAddContact.setImageResource(R.drawable.add_contact);
|
mAddContact.setImageResource(R.drawable.add_contact);
|
||||||
mAddContact.setOnClickListener(addContactListener);
|
mAddContact.setOnClickListener(addContactListener);
|
||||||
|
enableDisableAddContact();
|
||||||
}
|
}
|
||||||
|
|
||||||
enableDisableAddContact();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableDisableAddContact() {
|
public void enableDisableAddContact() {
|
||||||
|
|
|
@ -17,10 +17,8 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
import org.linphone.compatibility.Compatibility;
|
|
||||||
import org.linphone.ui.AvatarWithShadow;
|
import org.linphone.ui.AvatarWithShadow;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -84,6 +82,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
private void displayHistory(String status, String callTime, String callDate) {
|
private void displayHistory(String status, String callTime, String callDate) {
|
||||||
if (pictureUri != null) {
|
if (pictureUri != null) {
|
||||||
LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture.getView(), Uri.parse(pictureUri), R.drawable.unknown_small);
|
LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture.getView(), Uri.parse(pictureUri), R.drawable.unknown_small);
|
||||||
|
view.findViewById(R.id.addContactRow).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
contactName.setText(displayName == null ? sipUri : displayName);
|
contactName.setText(displayName == null ? sipUri : displayName);
|
||||||
|
@ -121,8 +120,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
} else if (id == R.id.chat) {
|
} else if (id == R.id.chat) {
|
||||||
LinphoneActivity.instance().displayChat(sipUri);
|
LinphoneActivity.instance().displayChat(sipUri);
|
||||||
} else if (id == R.id.addToContacts) {
|
} else if (id == R.id.addToContacts) {
|
||||||
Intent intent = Compatibility.prepareAddContactIntent(displayName, sipUri);
|
LinphoneActivity.instance().displayContactsForEdition(sipUri);
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,6 +358,13 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
changeCurrentFragment(FragmentsAvailable.CONTACTS, null);
|
changeCurrentFragment(FragmentsAvailable.CONTACTS, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void displayContactsForEdition(String sipAddress) {
|
||||||
|
Bundle extras = new Bundle();
|
||||||
|
extras.putBoolean("EditOnClick", true);
|
||||||
|
extras.putString("SipAddress", sipAddress);
|
||||||
|
changeCurrentFragment(FragmentsAvailable.CONTACTS, extras);
|
||||||
|
}
|
||||||
|
|
||||||
public void displayChat(String sipUri) {
|
public void displayChat(String sipUri) {
|
||||||
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||||
Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, getContentResolver());
|
Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, getContentResolver());
|
||||||
|
|
|
@ -90,6 +90,28 @@ public class ApiFivePlus {
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Intent prepareEditContactIntentWithSipAddress(int id, String sipUri) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_EDIT, Contacts.CONTENT_URI);
|
||||||
|
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);
|
||||||
|
intent.setData(contactUri);
|
||||||
|
|
||||||
|
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
|
||||||
|
ArrayList<ContentValues> data = new ArrayList<ContentValues>();
|
||||||
|
ContentValues sipAddressRow = new ContentValues();
|
||||||
|
sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
|
||||||
|
sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
|
||||||
|
data.add(sipAddressRow);
|
||||||
|
data.add(sipAddressRow);
|
||||||
|
intent.putParcelableArrayListExtra(Insert.DATA, data);
|
||||||
|
} else {
|
||||||
|
// VoIP field not available, we store the address in the IM field
|
||||||
|
intent.putExtra(ContactsContract.Intents.Insert.IM_HANDLE, sipUri);
|
||||||
|
intent.putExtra(ContactsContract.Intents.Insert.IM_PROTOCOL, "sip");
|
||||||
|
}
|
||||||
|
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> extractContactNumbersAndAddresses(String id, ContentResolver cr) {
|
public static List<String> extractContactNumbersAndAddresses(String id, ContentResolver cr) {
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,13 @@ public class Compatibility {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Intent prepareEditContactIntentWithSipAddress(int id, String sipAddress) {
|
||||||
|
if (Version.sdkAboveOrEqual(5)) {
|
||||||
|
return ApiFivePlus.prepareEditContactIntentWithSipAddress(id, sipAddress);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> extractContactNumbersAndAddresses(String id, ContentResolver cr) {
|
public static List<String> extractContactNumbersAndAddresses(String id, ContentResolver cr) {
|
||||||
if (Version.sdkAboveOrEqual(5)) {
|
if (Version.sdkAboveOrEqual(5)) {
|
||||||
return ApiFivePlus.extractContactNumbersAndAddresses(id, cr);
|
return ApiFivePlus.extractContactNumbersAndAddresses(id, cr);
|
||||||
|
|
Loading…
Reference in a new issue