浏览代码

添加 tcl 头像

liuzhenxing1118 5 天之前
父节点
当前提交
4250fb6ca2

+ 4 - 4
app/src/main/java/com/xplora/xplauncher/adapter/ContactsRecyclerAdapter.java

@@ -67,10 +67,10 @@ public class ContactsRecyclerAdapter extends RecyclerView.Adapter<ContactItemVie
             ContactBean contactBean = recentBean.contactBean;
             if (viewHolder.mIcon != null) {
                 String profilePath = contactBean != null?  contactBean.profilePath : "";
-                ToolsUtils.setImageView(viewHolder.mIcon, profilePath, 0, R.drawable.default_contact);
+                ToolsUtils.setImageView(viewHolder.mIcon, profilePath, 0, contactBean.getHeadDefaultId(mContext));
             }
             if (viewHolder.mTitle != null) {
-                String name = contactBean != null ? contactBean.name : recentBean.caller;
+                String name = contactBean != null ? contactBean.getNickName(mContext) : recentBean.caller;
                 //String s = name.length() <= 7 ? name : name.substring(0, 7) + "...";
                 viewHolder.mTitle.setText(name);
             }
@@ -93,11 +93,11 @@ public class ContactsRecyclerAdapter extends RecyclerView.Adapter<ContactItemVie
         } else {
             ContactBean contactBean = (ContactBean)baseBean;
             if (viewHolder.mIcon != null) {
-                ToolsUtils.setImageView(viewHolder.mIcon, contactBean.profilePath, 0, R.drawable.default_contact);
+                ToolsUtils.setImageView(viewHolder.mIcon, contactBean.profilePath, 0, contactBean.getHeadDefaultId(mContext));
             }
             if (viewHolder.mTitle != null) {
                 //String s = contactBean.name.length() <= 7 ? contactBean.name : contactBean.name.substring(0, 7) + "...";
-                viewHolder.mTitle.setText(contactBean.name);
+                viewHolder.mTitle.setText(contactBean.getNickName(mContext));
             }
         }
 

+ 76 - 6
app/src/main/java/com/xplora/xplauncher/model/ContactBean.java

@@ -1,8 +1,13 @@
 package com.xplora.xplauncher.model;
 
+import android.content.Context;
+
+import com.xplora.xplauncher.R;
+
 public class ContactBean extends BaseBean {
     public long _id = 0;
     public String id = "";
+    public String userId = "";
     public String name = "";
     public String profile = ""; //头像
     public String profilePath = "";//头像本地路径
@@ -10,14 +15,79 @@ public class ContactBean extends BaseBean {
     public String countryPN = "";
     public int rate = 0;
     public int unRead = 0;
-
-    public int isGroup() {
-        return id.startsWith("G_") ? 1:0;
-    }
-
     // 1 : First guardian(SOS target)
     // 2 : Second guardian
     // 3 : General contact(Not member of XPLORA server)
     // 4 : Friend
+    // 100: Group
     public int type = 0;
-}
+
+    public int isGroup() {
+        return id.startsWith("G_") || type >= 100 ? 1:0;
+    }
+
+    public String getNickName(Context context) {
+        String[] value = name.split("_");
+        int index = Integer.parseInt(value[0]);
+        if (index == 11) {
+            return value[1];
+        } else {
+            switch (index) {
+                case 0:
+                    return context.getString(R.string.tcl_family_0);
+                case 1:
+                    return context.getString(R.string.tcl_family_1);
+                case 2:
+                    return context.getString(R.string.tcl_family_2);
+                case 3:
+                    return context.getString(R.string.tcl_family_3);
+                case 4:
+                    return context.getString(R.string.tcl_family_4);
+                case 5:
+                    return context.getString(R.string.tcl_family_5);
+                case 6:
+                    return context.getString(R.string.tcl_family_6);
+                case 7:
+                    return context.getString(R.string.tcl_family_7);
+                default:
+                    return "";
+            }
+        }
+    }
+
+    public int getHeadDefaultId(Context context) {
+        String[] value = name.split("_");
+        int index = Integer.parseInt(value[0]);
+        if (index == 11) {
+            return R.drawable.default_contact;
+        } else {
+            switch (index) {
+                case 0:
+                    return R.drawable.default_contact_0;
+                case 1:
+                    return R.drawable.default_contact_1;
+                case 2:
+                    return R.drawable.default_contact_2;
+                case 3:
+                    return R.drawable.default_contact_3;
+                case 4:
+                    return R.drawable.default_contact_4;
+                case 5:
+                    return R.drawable.default_contact_5;
+                case 6:
+                    return R.drawable.default_contact_6;
+                case 7:
+                    return R.drawable.default_contact_7;
+                default:
+                    return 0;
+            }
+        }
+    }
+
+    public String beanToString() {
+        return "_id:" + _id + " id:" + id + " type:" + type + " userId:" + userId +
+                " name:" + name + " profilePath:" + profilePath +
+                " countryPN:" + countryPN + " phoneNumber : " + phoneNumber +
+                " unRead:" + unRead;
+    }
+}

二进制
app/src/main/res/drawable-xhdpi/default_contact_0.png


二进制
app/src/main/res/drawable-xhdpi/default_contact_1.png


二进制
app/src/main/res/drawable-xhdpi/default_contact_2.png


二进制
app/src/main/res/drawable-xhdpi/default_contact_3.png


二进制
app/src/main/res/drawable-xhdpi/default_contact_4.png


二进制
app/src/main/res/drawable-xhdpi/default_contact_5.png


二进制
app/src/main/res/drawable-xhdpi/default_contact_6.png


二进制
app/src/main/res/drawable-xhdpi/default_contact_7.png


+ 9 - 0
app/src/main/res/values-zh-rCN/strings.xml

@@ -52,4 +52,13 @@
     <string name="disable_charging_use">请在使用前将其从充电器上取下</string>
     <string name="notification_empty">无消息</string>
     <string name="sk_disable_hot">手表过热\n请稍后使用</string>
+    <string name="tcl_family_0">父亲</string>
+    <string name="tcl_family_1">母亲</string>
+    <string name="tcl_family_2">祖父</string>
+    <string name="tcl_family_3">祖母</string>
+    <string name="tcl_family_4">叔叔</string>
+    <string name="tcl_family_5">阿姨</string>
+    <string name="tcl_family_6">兄弟</string>
+    <string name="tcl_family_7">姐妹</string>
+    <string name="tcl_family_11">自定义</string>
 </resources>

+ 9 - 0
app/src/main/res/values-zh-rTW/strings.xml

@@ -52,4 +52,13 @@
     <string name="notification_empty">無數據</string>
     <string name="sk_disable_hot">手錶過熱\n請稍後使用</string>
     <string name="app_name">launcher</string>
+    <string name="tcl_family_0">父親</string>
+    <string name="tcl_family_1">母親</string>
+    <string name="tcl_family_2">祖父</string>
+    <string name="tcl_family_3">祖母</string>
+    <string name="tcl_family_4">叔叔</string>
+    <string name="tcl_family_5">阿姨</string>
+    <string name="tcl_family_6">兄弟</string>
+    <string name="tcl_family_7">姊妹</string>
+    <string name="tcl_family_11">自定義</string>
 </resources>

+ 10 - 0
app/src/main/res/values/strings.xml

@@ -67,4 +67,14 @@
     <string name="disable_charging">The watch is charging, please remove it from the charger before using it.</string>
     <string name="notification_empty">no datas</string>
     <string name="sk_disable_hot">Watch overheating.\nPlease use it later.</string>
+
+    <string name="tcl_family_0">Father</string>
+    <string name="tcl_family_1">Mother</string>
+    <string name="tcl_family_2">Grandfather</string>
+    <string name="tcl_family_3">grandmother</string>
+    <string name="tcl_family_4">Uncle</string>
+    <string name="tcl_family_5">Aunt</string>
+    <string name="tcl_family_6">Brothers</string>
+    <string name="tcl_family_7">Sisters</string>
+    <string name="tcl_family_11">Custom</string>
 </resources>