Avatar improvements (including glitch while a call is incoming and device in landscape on small screens)
This commit is contained in:
parent
d07d039c53
commit
91cef7c6b9
16 changed files with 83 additions and 120 deletions
|
@ -760,4 +760,10 @@ public abstract class MainActivity extends LinphoneGenericActivity
|
|||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Others
|
||||
|
||||
public SideMenuFragment getSideMenuFragment() {
|
||||
return mSideMenuFragment;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -419,8 +419,9 @@ public class AccountSettingsFragment extends SettingsFragment {
|
|||
core.setDefaultProxyConfig(mProxyConfig);
|
||||
mUseAsDefault.setEnabled(false);
|
||||
}
|
||||
// FIXME TODO
|
||||
// LinphoneActivity.instance().refreshAccounts();
|
||||
((SettingsActivity) getActivity())
|
||||
.getSideMenuFragment()
|
||||
.displayAccountsInSideMenu();
|
||||
} else {
|
||||
Log.e("[Account Settings] No proxy config !");
|
||||
}
|
||||
|
@ -536,9 +537,10 @@ public class AccountSettingsFragment extends SettingsFragment {
|
|||
core.removeAuthInfo(mAuthInfo);
|
||||
}
|
||||
}
|
||||
// FIXME TODO
|
||||
/*LinphoneActivity.instance().displaySettings();
|
||||
LinphoneActivity.instance().refreshAccounts();*/
|
||||
((SettingsActivity) getActivity()).popBackStack();
|
||||
((SettingsActivity) getActivity())
|
||||
.getSideMenuFragment()
|
||||
.displayAccountsInSideMenu();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -187,12 +187,7 @@ public class AdvancedSettingsFragment extends SettingsFragment {
|
|||
i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
i.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
i.setData(Uri.parse("package:" + context.getPackageName()));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
// FIXME TODO
|
||||
// startActivityForResult(i,
|
||||
// LinphoneActivity.ANDROID_APP_SETTINGS_ACTIVITY);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -21,7 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
|
@ -31,12 +30,11 @@ import android.net.Uri;
|
|||
import android.provider.MediaStore;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import org.linphone.R;
|
||||
|
||||
public class ImageUtils {
|
||||
|
||||
public static Bitmap getRoundBitmapFromUri(Context context, Uri fromPictureUri) {
|
||||
Bitmap bm;
|
||||
Bitmap bm = null;
|
||||
Bitmap roundBm;
|
||||
if (fromPictureUri != null) {
|
||||
try {
|
||||
|
@ -44,10 +42,8 @@ public class ImageUtils {
|
|||
MediaStore.Images.Media.getBitmap(
|
||||
context.getContentResolver(), fromPictureUri);
|
||||
} catch (Exception e) {
|
||||
bm = BitmapFactory.decodeResource(context.getResources(), R.drawable.topbar_avatar);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
bm = BitmapFactory.decodeResource(context.getResources(), R.drawable.topbar_avatar);
|
||||
}
|
||||
if (bm != null) {
|
||||
roundBm = getRoundBitmap(bm);
|
||||
|
|
|
@ -27,7 +27,6 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.drawable.Icon;
|
||||
import android.util.ArraySet;
|
||||
import java.util.Set;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.chat.ChatActivity;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
|
@ -59,9 +58,7 @@ public class LinphoneShortcutManager {
|
|||
|
||||
Bitmap bm = null;
|
||||
if (contact != null && contact.getThumbnailUri() != null) {
|
||||
bm =
|
||||
ImageUtils.getRoundBitmapFromUri(
|
||||
LinphoneService.instance(), contact.getThumbnailUri());
|
||||
bm = ImageUtils.getRoundBitmapFromUri(mContext, contact.getThumbnailUri());
|
||||
}
|
||||
Icon icon =
|
||||
bm == null
|
||||
|
@ -101,9 +98,7 @@ public class LinphoneShortcutManager {
|
|||
if (contact != null) {
|
||||
Bitmap bm = null;
|
||||
if (contact != null && contact.getThumbnailUri() != null) {
|
||||
bm =
|
||||
ImageUtils.getRoundBitmapFromUri(
|
||||
LinphoneService.instance(), contact.getThumbnailUri());
|
||||
bm = ImageUtils.getRoundBitmapFromUri(mContext, contact.getThumbnailUri());
|
||||
}
|
||||
Icon icon =
|
||||
bm == null
|
||||
|
|
|
@ -20,35 +20,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
*/
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import java.io.IOException;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
import org.linphone.core.ChatRoomSecurityLevel;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.utils.ImageUtils;
|
||||
|
||||
class ContactAvatarHolder {
|
||||
public final ImageView contactPicture;
|
||||
public final ImageView avatarMask;
|
||||
public final ImageView avatarBorder;
|
||||
public final ImageView securityLevel;
|
||||
public final TextView generatedAvatar;
|
||||
public final ImageView generatedAvatarBackground;
|
||||
|
||||
public ContactAvatarHolder(View v) {
|
||||
contactPicture = v.findViewById(R.id.contact_picture);
|
||||
avatarMask = v.findViewById(R.id.mask);
|
||||
securityLevel = v.findViewById(R.id.security_level);
|
||||
generatedAvatar = v.findViewById(R.id.generated_avatar);
|
||||
generatedAvatarBackground = v.findViewById(R.id.generated_avatar_background);
|
||||
avatarBorder = v.findViewById(R.id.border);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
contactPicture.setVisibility(View.VISIBLE);
|
||||
generatedAvatar.setVisibility(View.VISIBLE);
|
||||
generatedAvatarBackground.setVisibility(View.VISIBLE);
|
||||
securityLevel.setVisibility(View.GONE);
|
||||
avatarBorder.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -99,8 +97,7 @@ public class ContactAvatar {
|
|||
}
|
||||
}
|
||||
|
||||
private static void displayAvatar(
|
||||
String displayName, View v, boolean showBorder, int maskResource) {
|
||||
public static void displayAvatar(String displayName, View v, boolean showBorder) {
|
||||
if (displayName == null || v == null) return;
|
||||
|
||||
ContactAvatarHolder holder = new ContactAvatarHolder(v);
|
||||
|
@ -112,31 +109,27 @@ public class ContactAvatar {
|
|||
// If display name is a phone number, use default avatar because generated one will be
|
||||
// +...
|
||||
holder.generatedAvatar.setVisibility(View.GONE);
|
||||
holder.generatedAvatarBackground.setVisibility(View.GONE);
|
||||
} else {
|
||||
String generatedAvatar = generateAvatar(displayName);
|
||||
if (generatedAvatar != null && generatedAvatar.length() > 0) {
|
||||
holder.generatedAvatar.setText(generatedAvatar);
|
||||
holder.generatedAvatar.setVisibility(View.VISIBLE);
|
||||
holder.generatedAvatarBackground.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.generatedAvatar.setVisibility(View.GONE);
|
||||
holder.generatedAvatarBackground.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
holder.securityLevel.setVisibility(View.GONE);
|
||||
|
||||
if (maskResource != 0) {
|
||||
holder.avatarMask.setImageResource(maskResource);
|
||||
}
|
||||
if (showBorder) {
|
||||
holder.avatarBorder.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void displayAvatar(String displayName, View v, boolean showBorder) {
|
||||
displayAvatar(displayName, v, showBorder, 0);
|
||||
}
|
||||
|
||||
public static void displayAvatar(String displayName, View v) {
|
||||
displayAvatar(displayName, v, false, 0);
|
||||
displayAvatar(displayName, v, false);
|
||||
}
|
||||
|
||||
public static void displayAvatar(
|
||||
|
@ -145,8 +138,7 @@ public class ContactAvatar {
|
|||
setSecurityLevel(securityLevel, v);
|
||||
}
|
||||
|
||||
private static void displayAvatar(
|
||||
LinphoneContact contact, View v, boolean showBorder, int maskResource) {
|
||||
public static void displayAvatar(LinphoneContact contact, View v, boolean showBorder) {
|
||||
if (contact == null || v == null) return;
|
||||
|
||||
ContactAvatarHolder holder = new ContactAvatarHolder(v);
|
||||
|
@ -163,47 +155,28 @@ public class ContactAvatar {
|
|||
: contact.getFullName()));
|
||||
|
||||
holder.generatedAvatar.setVisibility(View.GONE);
|
||||
holder.generatedAvatarBackground.setVisibility(View.GONE);
|
||||
holder.contactPicture.setVisibility(View.VISIBLE);
|
||||
holder.securityLevel.setVisibility(View.GONE);
|
||||
|
||||
Bitmap bm = null;
|
||||
try {
|
||||
if (contact.getThumbnailUri() != null) {
|
||||
bm =
|
||||
MediaStore.Images.Media.getBitmap(
|
||||
LinphoneService.instance().getContentResolver(),
|
||||
contact.getThumbnailUri());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
Bitmap bm = ImageUtils.getRoundBitmapFromUri(v.getContext(), contact.getThumbnailUri());
|
||||
if (bm != null) {
|
||||
holder.contactPicture.setImageBitmap(bm);
|
||||
holder.contactPicture.setVisibility(View.VISIBLE);
|
||||
holder.generatedAvatar.setVisibility(View.GONE);
|
||||
holder.generatedAvatarBackground.setVisibility(View.GONE);
|
||||
} else if (generated_avatars) {
|
||||
holder.generatedAvatar.setText(
|
||||
generateAvatar(
|
||||
contact.getFullName() == null
|
||||
? contact.getFirstName() + " " + contact.getLastName()
|
||||
: contact.getFullName()));
|
||||
holder.generatedAvatar.setVisibility(View.VISIBLE);
|
||||
holder.generatedAvatarBackground.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (maskResource != 0) {
|
||||
holder.avatarMask.setImageResource(maskResource);
|
||||
}
|
||||
if (showBorder) {
|
||||
holder.avatarBorder.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void displayAvatar(LinphoneContact contact, View v, boolean showBorder) {
|
||||
displayAvatar(contact, v, showBorder, 0);
|
||||
}
|
||||
|
||||
public static void displayAvatar(LinphoneContact contact, View v) {
|
||||
displayAvatar(contact, v, false, 0);
|
||||
displayAvatar(contact, v, false);
|
||||
}
|
||||
|
||||
public static void displayAvatar(
|
||||
|
@ -224,6 +197,7 @@ public class ContactAvatar {
|
|||
ContactAvatarHolder holder = new ContactAvatarHolder(v);
|
||||
holder.contactPicture.setImageResource(R.drawable.chat_group_avatar);
|
||||
holder.generatedAvatar.setVisibility(View.GONE);
|
||||
holder.generatedAvatarBackground.setVisibility(View.GONE);
|
||||
holder.securityLevel.setVisibility(View.GONE);
|
||||
holder.avatarBorder.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
5
app/src/main/res/drawable/avatar_border.xml
Normal file
5
app/src/main/res/drawable/avatar_border.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
|
||||
<stroke android:width="5dp" android:color="?attr/accentColor"/>
|
||||
<size android:width="200dp" android:height="200dp" />
|
||||
</shape>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
|
||||
<solid android:color="?attr/primaryTextColor"/>
|
||||
<size android:width="35dp" android:height="35dp"/>
|
||||
<size android:width="35dp" android:height="35dp" />
|
||||
</shape>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:alpha="0.8"
|
||||
android:background="@color/white_color"
|
||||
android:background="?attr/backgroundColor"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
|
@ -68,7 +68,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
remote_pause
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -112,7 +112,7 @@
|
|||
android:id="@+id/pause"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_below="@+id/active_call_info"
|
||||
android:layout_below="@id/active_call_info"
|
||||
android:layout_alignParentRight="true"
|
||||
android:contentDescription="@string/content_description_pause"
|
||||
android:padding="20dp"
|
||||
|
@ -122,7 +122,7 @@
|
|||
android:id="@+id/switchCamera"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_below="@+id/active_call_info"
|
||||
android:layout_below="@id/active_call_info"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:contentDescription="@string/content_description_switch_camera"
|
||||
android:padding="20dp"
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
android:id="@+id/pause"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_below="@+id/active_call_info"
|
||||
android:layout_below="@id/active_call_info"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_margin="20dp"
|
||||
android:contentDescription="@string/content_description_pause"
|
||||
|
@ -122,7 +122,7 @@
|
|||
android:id="@+id/switchCamera"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_below="@+id/active_call_info"
|
||||
android:layout_below="@id/active_call_info"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_margin="20dp"
|
||||
android:contentDescription="@string/content_description_switch_camera"
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
android:id="@+id/avatar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_margin="5dp"
|
||||
android:gravity="center">
|
||||
|
||||
<include layout="@layout/contact_avatar" />
|
||||
|
|
|
@ -12,33 +12,30 @@
|
|||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/generated_avatar_background"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/generated_avatar_bg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/generated_avatar"
|
||||
style="@style/generated_contact_avatar_font"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@drawable/generated_avatar_bg"
|
||||
android:gravity="center"
|
||||
android:maxLines="1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/mask"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar_mask"
|
||||
android:tint="?attr/backgroundColor" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/border"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar_border"
|
||||
android:tint="?attr/accentColor" />
|
||||
android:src="@drawable/avatar_border" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/security_level"
|
||||
|
|
|
@ -12,33 +12,30 @@
|
|||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/generated_avatar_background"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/generated_avatar_bg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/generated_avatar"
|
||||
style="@style/generated_contact_avatar_100_font"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@drawable/generated_avatar_bg"
|
||||
android:gravity="center"
|
||||
android:maxLines="1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/mask"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar_mask"
|
||||
android:tint="?attr/backgroundColor" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/border"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar_border"
|
||||
android:tint="?attr/accentColor" />
|
||||
android:src="@drawable/avatar_border" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/security_level"
|
||||
|
|
|
@ -12,33 +12,30 @@
|
|||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/generated_avatar_background"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/generated_avatar_bg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/generated_avatar"
|
||||
style="@style/generated_contact_avatar_100_font"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@drawable/generated_avatar_bg"
|
||||
android:gravity="center"
|
||||
android:maxLines="1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/mask"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar_mask"
|
||||
android:tint="?attr/backgroundColor" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/border"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar_border"
|
||||
android:tint="?attr/accentColor" />
|
||||
android:src="@drawable/avatar_border" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/security_level"
|
||||
|
|
|
@ -12,33 +12,30 @@
|
|||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/generated_avatar_background"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/generated_avatar_bg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/generated_avatar"
|
||||
style="@style/generated_contact_avatar_font"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@drawable/generated_avatar_bg"
|
||||
android:gravity="center"
|
||||
android:maxLines="1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/mask"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar_mask"
|
||||
android:tint="?attr/accentColorLight30"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/border"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/avatar_border"
|
||||
android:tint="?attr/accentColor" />
|
||||
android:src="@drawable/avatar_border" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/security_level"
|
||||
|
|
Loading…
Reference in a new issue