Browse Source

修改:仅系统群才显示送礼物按钮

Junqin Wang 8 years ago
parent
commit
eaeeeb3e21
39 changed files with 665 additions and 143 deletions
  1. 4 1
      app/AndroidManifest.xml
  2. 7 7
      app/app.iml
  3. BIN
      app/res/drawable-hdpi/add_group_members.png
  4. BIN
      app/res/drawable-hdpi/ico_add_grey.png
  5. BIN
      app/res/drawable-hdpi/ico_phone_contacts.png
  6. BIN
      app/res/drawable-mdpi/add_group_members.png
  7. BIN
      app/res/drawable-mdpi/ico_add_grey.png
  8. BIN
      app/res/drawable-mdpi/ico_phone_contacts.png
  9. BIN
      app/res/drawable-xhdpi/add_group_members.png
  10. BIN
      app/res/drawable-xhdpi/ico_add_grey.png
  11. BIN
      app/res/drawable-xhdpi/ico_phone_contacts.png
  12. BIN
      app/res/drawable-xxhdpi/add_group_members.png
  13. BIN
      app/res/drawable-xxhdpi/ico_add_grey.png
  14. BIN
      app/res/drawable-xxhdpi/ico_phone_contacts.png
  15. BIN
      app/res/drawable-xxxhdpi/add_group_members.png
  16. BIN
      app/res/drawable-xxxhdpi/ico_add_grey.png
  17. BIN
      app/res/drawable-xxxhdpi/ico_phone_contacts.png
  18. 15 0
      app/res/drawable/btn2_selector.xml
  19. 87 28
      app/res/layout/area_group_create_group.xml
  20. 6 0
      app/res/layout/friends_phone_contacts.xml
  21. 33 13
      app/src/com/sheishuo/app/common/util/location/LocationHelper.java
  22. 82 0
      app/src/com/sheishuo/app/common/util/location/SheishuoLocationHelper.java
  23. 5 1
      app/src/com/sheishuo/app/common/util/net/NetImpl.java
  24. 28 0
      app/src/com/sheishuo/app/common/views/CustomScrollLinearLayoutManager.java
  25. 8 0
      app/src/com/sheishuo/app/core_module/friends/activity/ContactsListActivity.java
  26. 19 0
      app/src/com/sheishuo/app/core_module/friends/activity/PhoneContactsActivity.java
  27. 194 0
      app/src/com/sheishuo/app/core_module/sheishuo/view/ui/CreateNewGroupActivity.java
  28. 1 2
      app/src/com/sheishuo/app/core_module/sheishuo/view/ui/MoreGroupsInTheAreaActivity.java
  29. 16 13
      app/src/com/sheishuo/app/core_module/trade/view/adapter/TradeItemAdapter.java
  30. 33 1
      app/src/com/sheishuo/app/login/LoginAndRegActivity.java
  31. 28 25
      app/src/com/sheishuo/app/main/fragment/AreaGroupsFragment.java
  32. 1 0
      gradle.properties
  33. 2 1
      uikit/res/layout/input_panel_bottom_func_bar.xml
  34. 8 8
      uikit/res/layout/nim_message_activity_text_layout.xml
  35. 1 0
      uikit/src/com/netease/nim/uikit/NimUIKit.java
  36. 5 2
      uikit/src/com/netease/nim/uikit/session/activity/TeamMessageActivity.java
  37. 34 0
      uikit/src/com/netease/nim/uikit/session/fragment/SheishuoTeamMessageFragment.java
  38. 4 4
      uikit/src/com/netease/nim/uikit/session/fragment/TeamMessageFragment.java
  39. 44 37
      uikit/src/com/netease/nim/uikit/session/module/input/InputPanel.java

+ 4 - 1
app/AndroidManifest.xml

@@ -114,9 +114,12 @@
             android:theme="@style/AppTheme.NoActionBar"
             android:windowSoftInputMode="adjustResize|stateHidden"/>
 
-        <!--地区群-->
+        <!--群-->
         <activity android:name=".core_module.sheishuo.view.ui.MoreGroupsInTheAreaActivity"
             android:theme="@style/AppTheme.NoActionBar"/>
+        <activity android:name=".core_module.sheishuo.view.ui.CreateNewGroupActivity"
+            android:theme="@style/AppTheme.NoActionBar"/>
+
         <!--朋友圈相关-->
         <activity android:name=".core_module.circle.activity.NewTweetingActivity"
             android:theme="@style/AppTheme.NoActionBar"/>

+ 7 - 7
app/app.iml

@@ -59,13 +59,6 @@
       <sourceFolder url="file://$MODULE_DIR$/assets" type="java-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
@@ -73,6 +66,13 @@
       <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
       <excludeFolder url="file://$MODULE_DIR$/build/.DS_Store" />
       <excludeFolder url="file://$MODULE_DIR$/build/freeline" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/.DS_Store" />

BIN
app/res/drawable-hdpi/add_group_members.png


BIN
app/res/drawable-hdpi/ico_add_grey.png


BIN
app/res/drawable-hdpi/ico_phone_contacts.png


BIN
app/res/drawable-mdpi/add_group_members.png


BIN
app/res/drawable-mdpi/ico_add_grey.png


BIN
app/res/drawable-mdpi/ico_phone_contacts.png


BIN
app/res/drawable-xhdpi/add_group_members.png


BIN
app/res/drawable-xhdpi/ico_add_grey.png


BIN
app/res/drawable-xhdpi/ico_phone_contacts.png


BIN
app/res/drawable-xxhdpi/add_group_members.png


BIN
app/res/drawable-xxhdpi/ico_add_grey.png


BIN
app/res/drawable-xxhdpi/ico_phone_contacts.png


BIN
app/res/drawable-xxxhdpi/add_group_members.png


BIN
app/res/drawable-xxxhdpi/ico_add_grey.png


BIN
app/res/drawable-xxxhdpi/ico_phone_contacts.png


+ 15 - 0
app/res/drawable/btn2_selector.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="false">
+        <shape android:shape="rectangle">
+            <corners android:radius="24dp" />
+            <solid android:color="@color/colorPrimary" />
+        </shape>
+    </item>
+    <item android:state_pressed="true" >
+        <shape>
+            <corners android:radius="24dp" />
+            <solid android:width="3dp" android:color="@color/colorPrimaryDark" />
+        </shape>
+    </item>
+</selector>

+ 87 - 28
app/res/layout/area_group_create_group.xml

@@ -1,47 +1,106 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:orientation="vertical"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
     <com.sheishuo.app.common.views.BaseToolbar
         android:id="@+id/toolbar"
+        style="@style/fullToolbarStyle"
         android:layout_width="match_parent"
         android:layout_height="@dimen/action_bar_height"
-        style="@style/fullToolbarStyle"
-        android:title="创建群组"
-        app:right_text="创建"/>
+        android:title="创建群组" />
 
-    <android.support.design.widget.TextInputLayout
+
+    <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:hint="请输入群名称"
+        android:layout_height="match_parent"
+        android:orientation="vertical"
         android:padding="8dp">
-        <EditText
-            android:id="@+id/create_group_name"
+
+        <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="wrap_content" />
-    </android.support.design.widget.TextInputLayout>
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:padding="8dp">
 
-    <android.support.design.widget.TextInputLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:padding="8dp">
-        <EditText
-            android:id="@+id/create_group_announcement"
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:gravity="center"
+                android:text="群头像"
+                android:textSize="18sp" />
+
+            <com.netease.nim.uikit.common.ui.imageview.HeadImageView
+                android:id="@+id/create_group_avatar"
+                android:layout_width="48dp"
+                android:layout_height="48dp"
+                android:src="@drawable/ico_add_grey"
+                android:layout_marginStart="8dp"
+                android:layout_marginLeft="8dp" />
+        </LinearLayout>
+
+        <android.support.design.widget.TextInputLayout
             android:layout_width="match_parent"
-            android:layout_height="256dp"
-            android:hint="请输入群公告"
-            android:gravity="start"/>
-    </android.support.design.widget.TextInputLayout>
+            android:layout_height="wrap_content"
+            android:hint="群昵称"
+            android:padding="8dp">
 
-    <HorizontalScrollView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
-        <ImageView
+            <EditText
+                android:id="@+id/create_group_name"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+        </android.support.design.widget.TextInputLayout>
 
+        <android.support.design.widget.TextInputLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="8dp">
+
+            <EditText
+                android:id="@+id/create_group_announcement"
+                android:layout_width="match_parent"
+                android:layout_height="128dp"
+                android:gravity="start"
+                android:hint="群简介" />
+        </android.support.design.widget.TextInputLayout>
+
+        <TextView
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content" />
-    </HorizontalScrollView>
+            android:layout_height="wrap_content"
+            android:padding="8dp"
+            android:text="群聊成员" />
+
+        <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="8dp">
+
+            <LinearLayout
+                android:id="@+id/create_group_members_layout"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent">
+                <com.netease.nim.uikit.common.ui.imageview.HeadImageView
+                    android:id="@+id/create_group_add_member"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:src="@drawable/add_group_members" />
+            </LinearLayout>
+
+        </HorizontalScrollView>
+
+        <Button
+            android:id="@+id/create_group_btn"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="@drawable/btn2_selector"
+            android:text="创建群组"
+            android:textColor="@color/white"
+            android:textStyle="bold"
+            android:layout_marginTop="8dp"/>
+
+    </LinearLayout>
+
 
 </LinearLayout>

+ 6 - 0
app/res/layout/friends_phone_contacts.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical" android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+</LinearLayout>

+ 33 - 13
app/src/com/sheishuo/app/common/util/location/LocationHelper.java

@@ -1,9 +1,13 @@
 package com.sheishuo.app.common.util.location;
 
+import android.Manifest;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.location.Location;
 import android.location.LocationManager;
+import android.support.v4.app.ActivityCompat;
+import android.util.Log;
 import android.view.View;
 import android.widget.Toast;
 
@@ -21,15 +25,17 @@ import java.util.List;
  * Created by KN on 2017/8/21.
  */
 public class LocationHelper implements LocationProvider {
+    private static String TAG = LocationHelper.class.getSimpleName();
     private static LocationManager locationManager;
     private static String provider;
     private static Location location;
+    private static Context context;
 
 
-
-
-    public static void init(Context context){
+    public static void init(Context context) {
+        LocationHelper.context = context;
         initLocation(context);
+
     }
 
     @Override
@@ -77,40 +83,54 @@ public class LocationHelper implements LocationProvider {
     }
 
 
-
-    private static void initLocation(Context context){
+    private static void initLocation(Context context) {
         //获取定位服务
         locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
         //获取当前可用的位置控制器
         List<String> list = locationManager.getProviders(true);
+        Log.e(TAG,"Provider size" + list.size());
 
         if (list.contains(LocationManager.GPS_PROVIDER)) {
             //是否为GPS位置控制器
             provider = LocationManager.GPS_PROVIDER;
-        }
-        else if (list.contains(LocationManager.NETWORK_PROVIDER)) {
+        } else if (list.contains(LocationManager.NETWORK_PROVIDER)) {
             //是否为网络位置控制器
             provider = LocationManager.NETWORK_PROVIDER;
 
         } else {
-            Toast.makeText(context,"请检查网络或GPS是否打开",Toast.LENGTH_LONG).show();
+            Toast.makeText(context, "请检查网络或GPS是否打开", Toast.LENGTH_LONG).show();
             return;
         }
-         location = locationManager.getLastKnownLocation(provider);
-        if (location != null) {
-            //获取当前位置,这里只用到了经纬度
-            String string = "纬度为:" + location.getLatitude() + ",经度为:"
-                    + location.getLongitude();
+        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+            // TODO: Consider calling
+            //    ActivityCompat#requestPermissions
+            // here to request the missing permissions, and then overriding
+            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
+            //                                          int[] grantResults)
+            // to handle the case where the user grants the permission. See the documentation
+            // for ActivityCompat#requestPermissions for more details.
+            location = locationManager.getLastKnownLocation(provider);
+            return;
         }
+
+        location = locationManager.getLastKnownLocation(provider);
+        if (location == null)Log.e(TAG,"location is null");
+    }
+
+
+    public static void updateLocation(){
+        initLocation(context);
     }
 
     public static String getLatitude(){
         if (location != null)return String.valueOf(location.getLatitude());
+        Log.e(TAG,"Latitude获取失败");
         return "0.0";
     }
 
     public static String getLongitude(){
         if (location != null)return String.valueOf(location.getLongitude());
+        Log.e(TAG,"Longitude获取失败");
         return "0.0";
     }
 

+ 82 - 0
app/src/com/sheishuo/app/common/util/location/SheishuoLocationHelper.java

@@ -0,0 +1,82 @@
+package com.sheishuo.app.common.util.location;
+
+import android.Manifest;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.os.Bundle;
+import android.support.v4.app.ActivityCompat;
+import android.widget.Toast;
+
+import java.util.List;
+
+/**
+ * Created by KN on 2017/8/17.
+ */
+
+public class SheishuoLocationHelper {
+    private LocationManager locationManager;
+    private String locationProvider;
+
+
+    public void updateLocation(Context context) {
+        //获取地理位置管理器
+        locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
+        //获取所有可用的位置提供器
+        List<String> providers = locationManager.getProviders(true);
+        if (providers.contains(LocationManager.GPS_PROVIDER)) {
+            //如果是GPS
+            locationProvider = LocationManager.GPS_PROVIDER;
+        } else if (providers.contains(LocationManager.NETWORK_PROVIDER)) {
+            //如果是Network
+            locationProvider = LocationManager.NETWORK_PROVIDER;
+        } else {
+            Toast.makeText(context, "没有可用的位置提供器", Toast.LENGTH_SHORT).show();
+            return;
+        }
+        //获取Location
+        Location location = locationManager.getLastKnownLocation(locationProvider);
+        if (location != null) {
+            //不为空,显示地理位置经纬度
+        }
+        //监视地理位置变化
+        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+            // TODO: Consider calling
+            //    ActivityCompat#requestPermissions
+            // here to request the missing permissions, and then overriding
+            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
+            //                                          int[] grantResults)
+            // to handle the case where the user grants the permission. See the documentation
+            // for ActivityCompat#requestPermissions for more details.
+            return;
+        }
+        locationManager.requestLocationUpdates(locationProvider, 3000, 1, locationListener);
+    }
+
+
+    LocationListener locationListener =  new LocationListener() {
+
+        @Override
+        public void onStatusChanged(String provider, int status, Bundle arg2) {
+
+        }
+
+        @Override
+        public void onProviderEnabled(String provider) {
+
+        }
+
+        @Override
+        public void onProviderDisabled(String provider) {
+
+        }
+
+        @Override
+        public void onLocationChanged(Location location) {
+            //如果位置发生变化,重新显示
+
+        }
+    };
+}

+ 5 - 1
app/src/com/sheishuo/app/common/util/net/NetImpl.java

@@ -90,6 +90,8 @@ public class NetImpl implements INet {
             @Override
             public void run() {
                 try {
+                    LocationHelper.updateLocation();
+
                     FormBody body = new FormBody.Builder()
                             .add("id",AccountCache.getAccount().getId())
                             .add("latitude", LocationHelper.getLatitude())
@@ -107,7 +109,9 @@ public class NetImpl implements INet {
                     if (200 == responseCode){
                         Log.e("code",""+responseCode);
                         LoginBean.DBean account = AccountCache.getAccount();
-                        JSONObject data = new JSONObject(response.body().string()).getJSONObject("d");
+                        String resultStr = response.body().string();
+                        JSONObject data = new JSONObject(resultStr).getJSONObject("d");
+                        Log.e("json" ,data.toString());
                         if (data.getBoolean("update")){
                             account.setProvince(data.getString("province"));
                             account.setCity(data.getString("city"));

+ 28 - 0
app/src/com/sheishuo/app/common/views/CustomScrollLinearLayoutManager.java

@@ -0,0 +1,28 @@
+package com.sheishuo.app.common.views;
+
+import android.content.Context;
+import android.support.v7.widget.LinearLayoutManager;
+
+/**
+ * Created by KN on 2017/8/18.
+ */
+
+public class CustomScrollLinearLayoutManager extends LinearLayoutManager {
+
+    boolean enable;
+    public CustomScrollLinearLayoutManager(Context context) {
+        super(context);
+    }
+
+    public void setScrollEnable(boolean enable){
+        this.enable = enable;
+    }
+
+
+
+
+    @Override
+    public boolean canScrollVertically() {
+        return enable && super.canScrollVertically();
+    }
+}

+ 8 - 0
app/src/com/sheishuo/app/core_module/friends/activity/ContactsListActivity.java

@@ -11,6 +11,7 @@ import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.netease.nim.uikit.common.activity.UI;
+import com.netease.nim.uikit.common.ui.imageview.HeadImageView;
 import com.netease.nim.uikit.contact.ContactsCustomization;
 import com.netease.nim.uikit.contact.ContactsFragment;
 import com.netease.nim.uikit.contact.core.item.AbsContactItem;
@@ -103,6 +104,7 @@ public class ContactsListActivity extends SheishuoUI {
         static final FuncItem ADVANCED_TEAM = new FuncItem();
         static final FuncItem BLACK_LIST = new FuncItem();
         static final FuncItem MY_COMPUTER = new FuncItem();
+        static final FuncItem PHONE_CONTACTS = new FuncItem();
 
         @Override
         public int getItemType() {
@@ -142,6 +144,9 @@ public class ContactsListActivity extends SheishuoUI {
                 else if (item == ADVANCED_TEAM) {
                     funcName.setText("群组");
                     image.setImageResource(R.drawable.ic_advanced_team);
+                }else if (item == PHONE_CONTACTS){
+                    funcName.setText("通讯录联系人");
+                    image.setImageResource(R.drawable.ico_phone_contacts);
                 }
 //                else if (item == BLACK_LIST) {
 //                    funcName.setText("黑名单");
@@ -177,6 +182,7 @@ public class ContactsListActivity extends SheishuoUI {
             items.add(ADVANCED_TEAM);
 //            items.add(BLACK_LIST);
 //            items.add(MY_COMPUTER);
+            items.add(PHONE_CONTACTS);
 
             return items;
         }
@@ -194,6 +200,8 @@ public class ContactsListActivity extends SheishuoUI {
                 SessionHelper.startP2PSession(context, AccountCache.getAccount().getId());
             } else if (item == BLACK_LIST) {
                 BlackListActivity.start(context);
+            }else if(item == PHONE_CONTACTS){
+
             }
         }
     }

+ 19 - 0
app/src/com/sheishuo/app/core_module/friends/activity/PhoneContactsActivity.java

@@ -0,0 +1,19 @@
+package com.sheishuo.app.core_module.friends.activity;
+
+import android.os.Bundle;
+
+import com.sheishuo.app.uikit_implements.SheishuoUI;
+
+/**
+ * Created by KN on 2017/8/18.
+ */
+
+public class PhoneContactsActivity extends SheishuoUI {
+
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+    }
+}

+ 194 - 0
app/src/com/sheishuo/app/core_module/sheishuo/view/ui/CreateNewGroupActivity.java

@@ -1,9 +1,50 @@
 package com.sheishuo.app.core_module.sheishuo.view.ui;
 
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
 import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.HorizontalScrollView;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
 
+import com.bumptech.glide.Glide;
+import com.netease.nim.uikit.NimUIKit;
+import com.netease.nim.uikit.common.media.picker.PickImageHelper;
+import com.netease.nim.uikit.common.media.picker.activity.PickImageActivity;
+import com.netease.nim.uikit.common.media.picker.model.PhotoInfo;
+import com.netease.nim.uikit.common.ui.imageview.HeadImageView;
+import com.netease.nim.uikit.common.util.media.ImageUtil;
+import com.netease.nim.uikit.contact_selector.activity.ContactSelectActivity;
+import com.netease.nim.uikit.session.helper.MessageHelper;
+import com.netease.nimlib.sdk.NIMClient;
+import com.netease.nimlib.sdk.RequestCallback;
+import com.netease.nimlib.sdk.msg.MessageBuilder;
+import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
+import com.netease.nimlib.sdk.msg.model.IMMessage;
+import com.netease.nimlib.sdk.team.TeamService;
+import com.netease.nimlib.sdk.team.constant.TeamFieldEnum;
+import com.netease.nimlib.sdk.team.constant.TeamTypeEnum;
+import com.netease.nimlib.sdk.team.model.Team;
+import com.netease.nimlib.sdk.uinfo.UserInfoProvider;
+import com.netease.nimlib.sdk.uinfo.UserService;
+import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
+import com.sheishuo.app.R;
+import com.sheishuo.app.common.util.img.ImgUtil;
+import com.sheishuo.app.common.views.BaseToolbar;
 import com.sheishuo.app.uikit_implements.SheishuoUI;
 
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jp.wasabeef.glide.transformations.CropCircleTransformation;
+
 /**
  * Created by KN on 2017/8/16.
  */
@@ -11,9 +52,162 @@ import com.sheishuo.app.uikit_implements.SheishuoUI;
 public class CreateNewGroupActivity extends SheishuoUI {
 
 
+    private String TAG = this.getClass().getSimpleName();
+    private Context context = this;
+    private BaseToolbar toolbar;
+    private EditText groupNameTV, groupAnnouncementTV;
+    private HeadImageView groupAvatar, groupMemberImg;
+    private Button createGroupBtn;
+    private LinearLayout membersLayout;
+
+
+    private String avatarIcon = "";
+    private List<String> memberIds = new ArrayList<>();
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        setContentView(R.layout.area_group_create_group);
+        findViews();
+        init();
+
+    }
+
+
+    void findViews() {
+        toolbar = findView(R.id.toolbar);
+        groupAvatar = findView(R.id.create_group_avatar);
+        groupNameTV = findView(R.id.create_group_name);
+        groupAnnouncementTV = findView(R.id.create_group_announcement);
+        groupMemberImg = findView(R.id.create_group_add_member);
+        createGroupBtn = findView(R.id.create_group_btn);
+        membersLayout = findView(R.id.create_group_members_layout);
+    }
+
+    void init() {
+        initToolbar();
+        initCreateBtn();
+        initAddMembersBtn();
+        initAvatarBtn();
+    }
+
+
+    void initToolbar() {
+
+    }
+
+    void initCreateBtn() {
+        final TeamService teamService = NIMClient.getService(TeamService.class);
+        createGroupBtn.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                String groupName = groupNameTV.getText().toString().trim();
+                String groupIntroduce = groupAnnouncementTV.getText().toString().trim();
+
+                if (avatarIcon.isEmpty() || groupName.isEmpty() || groupIntroduce.isEmpty()) {
+                    showToast(context, "请先完善群信息");
+                    return;
+                }
+
+                Map<TeamFieldEnum, Serializable> teamInfoMap = new HashMap<>();
+                teamInfoMap.put(TeamFieldEnum.Name, groupName);
+                teamInfoMap.put(TeamFieldEnum.Introduce, groupIntroduce);
+                teamService.createTeam(teamInfoMap, TeamTypeEnum.Advanced, "邀请您加入群", memberIds).setCallback(new RequestCallback<Team>() {
+                    @Override
+                    public void onSuccess(Team team) {
+                        showToast(context, "创建群组成功");
+                        NimUIKit.startTeamSession(context, team.getId());
+                        finish();
+                    }
+
+                    @Override
+                    public void onFailed(int i) {
+                        showToast(context, "创建群组失败,错误代码:" + i);
+                    }
+
+                    @Override
+                    public void onException(Throwable throwable) {
+                        throwable.printStackTrace();
+                        showToast(context, "创建群组失败");
+                    }
+                });
+            }
+        });
+    }
+
+
+    void initAddMembersBtn() {
+        groupMemberImg.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                ContactSelectActivity.Option option = new ContactSelectActivity.Option();
+
+                ContactSelectActivity.startActivityForResult(context,option,0);
+            }
+        });
+    }
+
+    void initAvatarBtn(){
+        groupAvatar.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                PickImageHelper.PickImageOption option = new PickImageHelper.PickImageOption();
+                option.multiSelect = false;
+//                PickImageHelper.pickImage(context,1,option);
+
+                int requestCode = 1;
+                int from = PickImageActivity.FROM_LOCAL;
+                if (!option.crop) {
+                    PickImageActivity.start((Activity) context, requestCode, from, option.outputPath, option.multiSelect,
+                            option.multiSelectMaxCount, true, false, 0, 0);
+                } else {
+                    PickImageActivity.start((Activity) context, requestCode, from, option.outputPath, false, 1,
+                            false, true, option.cropOutputImageWidth, option.cropOutputImageHeight);
+                }
+            }
+        });
+    }
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (resultCode == RESULT_OK && requestCode == 0){
+
+            //添加成员
+            memberIds.addAll(data.getStringArrayListExtra(ContactSelectActivity.RESULT_DATA));
+            List<NimUserInfo> userInfoList = NIMClient.getService(UserService.class).getUserInfoList(memberIds);
+            membersLayout.removeAllViews();
+
+            for (NimUserInfo userInfo : userInfoList){
+                ImageView avatar = new ImageView(context);
+                avatar.setAdjustViewBounds(true);
+                avatar.setMaxWidth((int) ImgUtil.convertDpToPixel(48,context));
+                avatar.setMaxHeight((int) ImgUtil.convertDpToPixel(48,context));
+                if (userInfo.getAvatar().isEmpty()){
+                    Glide.with(context)
+                            .load(R.drawable.nim_avatar_default)
+                            .bitmapTransform(new CropCircleTransformation(context))
+                            .placeholder(R.drawable.nim_avatar_default)
+                            .into(avatar);
+                }else {
+                    Glide.with(context)
+                            .load(userInfo.getAvatar())
+                            .bitmapTransform(new CropCircleTransformation(context))
+                            .placeholder(R.drawable.nim_avatar_default)
+                            .into(avatar);
+                }
+
+
+                membersLayout.addView(avatar);
+            }
 
+        }else if (resultCode == RESULT_OK && requestCode == 1){
+            //群头像选择
+            Bundle result = data.getExtras();
+            List<PhotoInfo> photoInfoList = (List<PhotoInfo>) result.getSerializable("photo_list");
+            avatarIcon = photoInfoList.get(0).getFilePath();
+            Glide.with(context)
+                    .load(avatarIcon)
+                    .into(groupAvatar);
+        }
     }
 }

+ 1 - 2
app/src/com/sheishuo/app/core_module/sheishuo/view/ui/MoreGroupsInTheAreaActivity.java

@@ -49,7 +49,6 @@ public class MoreGroupsInTheAreaActivity extends SheishuoUI {
         province = intent.getStringExtra("province");
         city = intent.getStringExtra("city");
 
-        Log.e("more Rooms", province + "    " + city);
         findViews();
         init();
     }
@@ -61,7 +60,7 @@ public class MoreGroupsInTheAreaActivity extends SheishuoUI {
 
     void init(){
         List<String> districts = new ArrayList<>();
-        districts.addAll(CityDataHelper.getArea(city.replace("市","")));
+        districts.addAll(CityDataHelper.getArea(city));
         adapter = new AreaGroupsAdapter(context,new ArrayList<String>());
         recyclerView.setLayoutManager(layoutManager);
         recyclerView.setAdapter(adapter);

+ 16 - 13
app/src/com/sheishuo/app/core_module/trade/view/adapter/TradeItemAdapter.java

@@ -103,19 +103,22 @@ public class TradeItemAdapter extends RecyclerView.Adapter<TradeItemAdapter.Trad
         holder.date.setText(bean.getInputtime());
 
         //判断有无置顶加权
-        switch (bean.getPriority_type()){
-            case PRIORITY_DISTRICT:
-                holder.priority.setText("地区x" + bean.getPriority());
-                break;
-            case PRIORITY_CITY:
-                holder.priority.setText("城市x" + bean.getPriority());
-                break;
-            case PRIORITY_PROVINCE:
-                holder.priority.setText("省份x" + bean.getPriority());
-                break;
-            case PRIORITY_COUNTRY:
-                holder.priority.setText("国家x" + bean.getPriority());
-                break;
+//        switch (bean.getPriority_type()){
+//            case PRIORITY_DISTRICT:
+//                holder.priority.setText("地区x" + bean.getPriority());
+//                break;
+//            case PRIORITY_CITY:
+//                holder.priority.setText("城市x" + bean.getPriority());
+//                break;
+//            case PRIORITY_PROVINCE:
+//                holder.priority.setText("省份x" + bean.getPriority());
+//                break;
+//            case PRIORITY_COUNTRY:
+//                holder.priority.setText("国家x" + bean.getPriority());
+//                break;
+//        }
+        if (Integer.valueOf(bean.getPriority()) > 0){
+            holder.priority.setText("置顶x" + bean.getPriority());
         }
 
         //判断是否为自己发布的交易帖,如果是才能编辑置顶加权

+ 33 - 1
app/src/com/sheishuo/app/login/LoginAndRegActivity.java

@@ -4,12 +4,16 @@ import android.Manifest;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
+import android.support.annotation.NonNull;
 import android.util.Log;
 import android.view.View;
 import android.widget.Button;
 import android.widget.Toast;
 
 import com.netease.nim.uikit.permission.MPermission;
+import com.netease.nim.uikit.permission.annotation.OnMPermissionDenied;
+import com.netease.nim.uikit.permission.annotation.OnMPermissionGranted;
+import com.netease.nim.uikit.permission.annotation.OnMPermissionNeverAskAgain;
 import com.sheishuo.app.R;
 import com.sheishuo.app.cache.AccountCache;
 import com.sheishuo.app.common.util.data.SPHelper;
@@ -17,10 +21,12 @@ import com.sheishuo.app.common.util.net.NetImpl;
 import com.sheishuo.app.common.util.net.ResponseCallback;
 import com.sheishuo.app.login.beans.LoginBean;
 import com.sheishuo.app.login.helper.LoginHelper;
+import com.sheishuo.app.main.activity.MainActivity;
 import com.sheishuo.app.uikit_implements.SheishuoUI;
 
 public class LoginAndRegActivity extends SheishuoUI implements View.OnClickListener{
 
+    private final int BASIC_PERMISSION_REQUEST_CODE = 123;
     String TAG = this.getClass().getSimpleName();
     Context context = this;
     Button loginBtn,regBtn;
@@ -31,7 +37,14 @@ public class LoginAndRegActivity extends SheishuoUI implements View.OnClickListe
 
     private final String[] BASIC_PERMISSIONS = new String[]{
             Manifest.permission.WRITE_EXTERNAL_STORAGE,
-            Manifest.permission.READ_EXTERNAL_STORAGE
+            Manifest.permission.READ_EXTERNAL_STORAGE,
+            Manifest.permission.WRITE_EXTERNAL_STORAGE,
+            Manifest.permission.READ_EXTERNAL_STORAGE,
+            Manifest.permission.CAMERA,
+            Manifest.permission.READ_PHONE_STATE,
+            Manifest.permission.RECORD_AUDIO,
+            Manifest.permission.ACCESS_COARSE_LOCATION,
+            Manifest.permission.ACCESS_FINE_LOCATION,
     };
 
 
@@ -125,4 +138,23 @@ public class LoginAndRegActivity extends SheishuoUI implements View.OnClickListe
                 break;
         }
     }
+
+
+    @Override
+    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+        MPermission.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
+    }
+
+    @OnMPermissionGranted(BASIC_PERMISSION_REQUEST_CODE)
+    public void onBasicPermissionSuccess() {
+        Toast.makeText(this, "授权成功", Toast.LENGTH_SHORT).show();
+        MPermission.printMPermissionResult(false, this, BASIC_PERMISSIONS);
+    }
+
+    @OnMPermissionDenied(BASIC_PERMISSION_REQUEST_CODE)
+    @OnMPermissionNeverAskAgain(BASIC_PERMISSION_REQUEST_CODE)
+    public void onBasicPermissionFailed() {
+        Toast.makeText(this, "未全部授权,部分功能可能无法正常运行!", Toast.LENGTH_SHORT).show();
+        MPermission.printMPermissionResult(false, this, BASIC_PERMISSIONS);
+    }
 }

+ 28 - 25
app/src/com/sheishuo/app/main/fragment/AreaGroupsFragment.java

@@ -20,13 +20,14 @@ import com.sheishuo.app.cache.AccountCache;
 import com.sheishuo.app.cache.GiftCache;
 import com.sheishuo.app.common.beans.GiftBean;
 import com.sheishuo.app.common.beans.NearbyGroupsBean;
-import com.sheishuo.app.common.util.location.LocationHelper;
 import com.sheishuo.app.common.util.net.INet;
 import com.sheishuo.app.common.util.net.NetImpl;
 import com.sheishuo.app.common.util.net.NetInfo;
 import com.sheishuo.app.common.util.net.ResponseCallback;
 import com.sheishuo.app.common.views.BaseToolbar;
+import com.sheishuo.app.common.views.CustomScrollLinearLayoutManager;
 import com.sheishuo.app.core_module.location.LocationSelectActivity;
+import com.sheishuo.app.core_module.sheishuo.view.ui.CreateNewGroupActivity;
 import com.sheishuo.app.core_module.sheishuo.view.ui.MoreGroupsInTheAreaActivity;
 import com.sheishuo.app.login.beans.LoginBean;
 import com.sheishuo.app.main.activity.MainActivity;
@@ -51,13 +52,13 @@ public class AreaGroupsFragment extends MainTabFragment {
     private BaseToolbar toolbar;
     private MainActivity parent;
 
-    private RecyclerView areaGroupsRecyclerview, nearbyGroupsRecyclerview;
+    private RecyclerView areaGroupsRecyclerview, recentGroupsRecyclerview;
 
-    private AreaGroupsAdapter areaGroupsAdapter, nearbyGroupsAdapter;
+    private AreaGroupsAdapter areaGroupsAdapter, recentGroupsAdapter;
 
     private TextView moreAreaGroupsTV;
     private LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
-    private LinearLayoutManager nearbyLayoutManager = new LinearLayoutManager(getActivity());
+    private CustomScrollLinearLayoutManager recentLayoutManager = new CustomScrollLinearLayoutManager(getActivity());
 
     private String location = AccountCache.getAccount().getCity() + AccountCache.getAccount().getDistrict();
     private INet net = new NetImpl();
@@ -73,7 +74,7 @@ public class AreaGroupsFragment extends MainTabFragment {
         parent = (MainActivity) getActivity();
         toolbar = (BaseToolbar) parent.getToolBar();
         areaGroupsRecyclerview = findView(R.id.area_groups_recyclerview);
-        nearbyGroupsRecyclerview = findView(R.id.area_groups_nearby_recyclerview);
+        recentGroupsRecyclerview = findView(R.id.area_groups_nearby_recyclerview);
         moreAreaGroupsTV = findView(R.id.area_groups_more_rooms_tv);
     }
 
@@ -108,7 +109,8 @@ public class AreaGroupsFragment extends MainTabFragment {
         toolbar.getRightTV().setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                ContactSelectActivity.startActivityForResult(getActivity(), TeamHelper.getContactSelectOption(null), MainActivity.REQUEST_CODE_ADVANCED);
+//                ContactSelectActivity.startActivityForResult(getActivity(), TeamHelper.getContactSelectOption(null), MainActivity.REQUEST_CODE_ADVANCED);
+                startActivity(new Intent(getActivity(), CreateNewGroupActivity.class));
 
             }
         });
@@ -209,10 +211,11 @@ public class AreaGroupsFragment extends MainTabFragment {
                             getHandler().post(new Runnable() {
                                 @Override
                                 public void run() {
-                                    nearbyGroupsAdapter = new AreaGroupsAdapter(getActivity(), nearbyGroupIds);
-                                    nearbyGroupsRecyclerview.setAdapter(nearbyGroupsAdapter);
-                                    nearbyGroupsRecyclerview.setLayoutManager(nearbyLayoutManager);
-                                    nearbyGroupsAdapter.setOnItemClickListener(new OnItemClickListener() {
+                                    recentGroupsAdapter = new AreaGroupsAdapter(getActivity(), nearbyGroupIds);
+                                    recentGroupsRecyclerview.setAdapter(recentGroupsAdapter);
+                                    recentLayoutManager.setScrollEnable(false);
+                                    recentGroupsRecyclerview.setLayoutManager(recentLayoutManager);
+                                    recentGroupsAdapter.setOnItemClickListener(new OnItemClickListener() {
                                         @Override
                                         public void onItemClick(View view) {
                                             String groupId = (String) view.getTag();
@@ -326,21 +329,21 @@ public class AreaGroupsFragment extends MainTabFragment {
             String province = data.getExtras().getString(LocationSelectActivity.LOCATION_PROVINCE);
             String city = data.getExtras().getString(LocationSelectActivity.LOCATION_CITY);
             String area = data.getExtras().getString(LocationSelectActivity.LOCATION_AREA);
-            if (province.equals("北京")
-                    || province.equals("天津")
-                    || province.equals("上海")
-                    || province.equals("重庆")) {
-                province = province + "市";
-            }else if (!province.equals("钓鱼岛")
-                    && !province.equals("香港")
-                    && !province.equals("澳门")){
-                province = province + "省";
-            }
-
-            if (!city.contains("特别")
-                    && !city.contains("自治")) {
-                city = city + "市";
-            }
+//            if (province.equals("北京")
+//                    || province.equals("天津")
+//                    || province.equals("上海")
+//                    || province.equals("重庆")) {
+//                province = province + "市";
+//            }else if (!province.equals("钓鱼岛")
+//                    && !province.equals("香港")
+//                    && !province.equals("澳门")){
+//                province = province + "省";
+//            }
+//
+//            if (!city.contains("特别")
+//                    && !city.contains("自治")) {
+//                city = city + "市";
+//            }
 
 
 

+ 1 - 0
gradle.properties

@@ -15,3 +15,4 @@
 #Fri Jul 14 11:00:13 CST 2017
 systemProp.http.proxyHost=127.0.0.1
 systemProp.http.proxyPort=1086
+org.gradle.jvmargs=-Xmx4608M

+ 2 - 1
uikit/res/layout/input_panel_bottom_func_bar.xml

@@ -31,7 +31,8 @@
             android:layout_weight="2"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:src="@drawable/chat_04_unpressed"/>
+            android:src="@drawable/chat_04_unpressed"
+            android:visibility="gone"/>
         <ImageView
             android:id="@+id/chat_bottom_bar_05"
             android:layout_weight="2"

+ 8 - 8
uikit/res/layout/nim_message_activity_text_layout.xml

@@ -15,14 +15,14 @@
         android:layout_marginLeft="@dimen/bottom_component_margin_horizontal"
         android:layout_marginRight="@dimen/bottom_component_margin_horizontal">
 
-        <ImageView
-            android:id="@+id/buttonAudioMessage"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:background="@drawable/nim_message_button_bottom_audio_selector"
-            android:contentDescription="@string/empty"
-            android:scaleType="center"
-            android:visibility="gone"/>
+        <!--<ImageView-->
+            <!--android:id="@+id/buttonAudioMessage"-->
+            <!--android:layout_width="wrap_content"-->
+            <!--android:layout_height="wrap_content"-->
+            <!--android:background="@drawable/nim_message_button_bottom_audio_selector"-->
+            <!--android:contentDescription="@string/empty"-->
+            <!--android:scaleType="center"-->
+            <!--android:visibility="gone"/>-->
 
         <ImageView
             android:id="@+id/buttonTextMessage"

+ 1 - 0
uikit/src/com/netease/nim/uikit/NimUIKit.java

@@ -281,6 +281,7 @@ public final class NimUIKit {
         if (sessionType == SessionTypeEnum.P2P) {
             P2PMessageActivity.start(context, id, customization, anchor);
         } else if (sessionType == SessionTypeEnum.Team) {
+            Log.e("TeamId",id);
             TeamMessageActivity.start(context, id, customization, null, anchor);
         }
     }

+ 5 - 2
uikit/src/com/netease/nim/uikit/session/activity/TeamMessageActivity.java

@@ -4,6 +4,7 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
+import android.util.Log;
 import android.view.View;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -16,6 +17,7 @@ import com.netease.nim.uikit.model.ToolBarOptions;
 import com.netease.nim.uikit.session.SessionCustomization;
 import com.netease.nim.uikit.session.constant.Extras;
 import com.netease.nim.uikit.session.fragment.MessageFragment;
+import com.netease.nim.uikit.session.fragment.SheishuoTeamMessageFragment;
 import com.netease.nim.uikit.session.fragment.TeamMessageFragment;
 import com.netease.nimlib.sdk.NIMClient;
 import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
@@ -41,7 +43,7 @@ public class TeamMessageActivity extends BaseMessageActivity {
 
     private TextView invalidTeamTipText;
 
-    private TeamMessageFragment fragment;
+    private SheishuoTeamMessageFragment fragment;
 
     private Class<? extends Activity> backToClass;
 
@@ -123,6 +125,7 @@ public class TeamMessageActivity extends BaseMessageActivity {
      */
     private void updateTeamInfo(final Team d) {
         if (d == null) {
+            Log.e("Team","is null");
             return;
         }
 
@@ -221,7 +224,7 @@ public class TeamMessageActivity extends BaseMessageActivity {
         // 添加fragment
         Bundle arguments = getIntent().getExtras();
         arguments.putSerializable(Extras.EXTRA_TYPE, SessionTypeEnum.Team);
-        fragment = new TeamMessageFragment();
+        fragment = new SheishuoTeamMessageFragment();
         fragment.setArguments(arguments);
         fragment.setContainerId(R.id.message_fragment_container);
         return fragment;

+ 34 - 0
uikit/src/com/netease/nim/uikit/session/fragment/SheishuoTeamMessageFragment.java

@@ -0,0 +1,34 @@
+package com.netease.nim.uikit.session.fragment;
+
+import android.os.Bundle;
+import android.util.Log;
+
+/**
+ * Created by KN on 2017/8/18.
+ */
+
+public class SheishuoTeamMessageFragment extends TeamMessageFragment {
+
+    private String TAG = this.getClass().getSimpleName();
+
+
+
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        if (team == null) {
+            Log.e(TAG,"Team is null");
+            return;
+        }
+        if (team.getName().contains("国家")
+                ||team.getName().contains("省")
+                ||team.getName().contains("市")
+                ||team.getName().contains("区")
+                ||team.getName().contains("县")
+                ||team.getName().contains("自治")
+                ||team.getName().contains("特别行政区")){
+            inputPanel.setSendGiftEnable(true);
+        }
+    }
+}

+ 4 - 4
uikit/src/com/netease/nim/uikit/session/fragment/TeamMessageFragment.java

@@ -23,7 +23,7 @@ import java.util.regex.Pattern;
  */
 public class TeamMessageFragment extends MessageFragment {
 
-    private Team team;
+    protected Team team;
 
     @Override
     public boolean isAllowSendMessage(IMMessage message) {
@@ -58,7 +58,7 @@ public class TeamMessageFragment extends MessageFragment {
         this.team = team;
     }
 
-    private void setMemPushOption(Map<String, TeamMember> selectedMembers, IMMessage message) {
+    protected void setMemPushOption(Map<String, TeamMember> selectedMembers, IMMessage message) {
         if (message == null || selectedMembers == null) {
             return;
         }
@@ -81,7 +81,7 @@ public class TeamMessageFragment extends MessageFragment {
         message.setMemberPushOption(memberPushOption);
     }
 
-    private void removeInvalidAccount(Map<String, TeamMember> selectedMembers, IMMessage message) {
+    protected void removeInvalidAccount(Map<String, TeamMember> selectedMembers, IMMessage message) {
         if (message == null || selectedMembers == null) {
             return;
         }
@@ -98,7 +98,7 @@ public class TeamMessageFragment extends MessageFragment {
         }
     }
 
-    private void replaceNickName(Map<String, TeamMember> selectedMembers, IMMessage message) {
+    protected void replaceNickName(Map<String, TeamMember> selectedMembers, IMMessage message) {
         if (message == null || selectedMembers == null) {
             return;
         }

+ 44 - 37
uikit/src/com/netease/nim/uikit/session/module/input/InputPanel.java

@@ -82,7 +82,7 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
     protected View actionPanelBottomLayout; // 更多布局
     protected LinearLayout messageActivityBottomLayout;
     protected EditText messageEditText;// 文本消息编辑框
-    protected Button audioRecordBtn; // 录音按钮
+    //protected Button audioRecordBtn; // 录音按钮
     protected View audioAnimLayout; // 录音动画布局
     protected FrameLayout textAudioSwitchLayout; // 切换文本,语音按钮布局
     protected View switchToTextButtonInInputBar;// 文本消息选择按钮
@@ -141,6 +141,11 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
         this(container, view, actions, true);
     }
 
+
+    public void setSendGiftEnable(boolean enable){
+        if (enable)sendGiftBtn.setVisibility(View.VISIBLE);
+    }
+
     public void onPause() {
         // 停止录音
         if (audioMessageHelper != null) {
@@ -177,7 +182,7 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
         initViews();
         initInputBarListener();
         initTextEdit();
-        initAudioRecordButton();
+        //initAudioRecordButton();
         restoreText(false);
         setAitListener(true);
 
@@ -208,6 +213,8 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
         sendEmojiBtn = view.findViewById(R.id.chat_bottom_bar_05);
 
 
+
+
         //Gift Panel
         giftPanel = (GiftPanel) view.findViewById(R.id.gift_panel);
         giftPanel.setContainer(container);
@@ -217,14 +224,14 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
         messageActivityBottomLayout = (LinearLayout) view.findViewById(R.id.messageActivityBottomLayout);
         messageInputBar = view.findViewById(R.id.textMessageLayout);
         switchToTextButtonInInputBar = view.findViewById(R.id.buttonTextMessage);
-        switchToAudioButtonInInputBar = view.findViewById(R.id.buttonAudioMessage);
+//        switchToAudioButtonInInputBar = view.findViewById(R.id.buttonAudioMessage);
         moreFuntionButtonInInputBar = view.findViewById(R.id.buttonMoreFuntionInText);
         emojiButtonInInputBar = view.findViewById(R.id.emoji_button);
         sendMessageButtonInInputBar = view.findViewById(R.id.buttonSendMessage);
         messageEditText = (EditText) view.findViewById(R.id.editTextMessage);
 
         // 语音
-        audioRecordBtn = (Button) view.findViewById(R.id.audioRecord);
+        //audioRecordBtn = (Button) view.findViewById(R.id.audioRecord);
         audioAnimLayout = view.findViewById(R.id.layoutPlayAudio);
         time = (Chronometer) view.findViewById(R.id.timer);
         timerTip = (TextView) view.findViewById(R.id.timer_tip);
@@ -235,7 +242,7 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
 
         // 显示录音按钮
         switchToTextButtonInInputBar.setVisibility(View.GONE);
-        switchToAudioButtonInInputBar.setVisibility(View.VISIBLE);
+//        switchToAudioButtonInInputBar.setVisibility(View.VISIBLE);
 
         // 文本录音按钮切换布局
         textAudioSwitchLayout = (FrameLayout) view.findViewById(R.id.switchLayout);
@@ -248,7 +255,7 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
 
     private void initInputBarListener() {
         switchToTextButtonInInputBar.setOnClickListener(clickListener);
-        switchToAudioButtonInInputBar.setOnClickListener(clickListener);
+//        switchToAudioButtonInInputBar.setOnClickListener(clickListener);
         emojiButtonInInputBar.setOnClickListener(clickListener);
         sendMessageButtonInInputBar.setOnClickListener(clickListener);
         moreFuntionButtonInInputBar.setOnClickListener(clickListener);
@@ -432,10 +439,10 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
         hideEmojiLayout();
         hideActionPanelLayout();
 
-        audioRecordBtn.setVisibility(View.GONE);
+        //audioRecordBtn.setVisibility(View.GONE);
         messageEditText.setVisibility(View.VISIBLE);
         switchToTextButtonInInputBar.setVisibility(View.GONE);
-        switchToAudioButtonInInputBar.setVisibility(View.VISIBLE);
+//        switchToAudioButtonInInputBar.setVisibility(View.VISIBLE);
 
         messageInputBar.setVisibility(View.VISIBLE);
 
@@ -463,7 +470,7 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
     // 切换成音频,收起键盘,按钮切换成键盘
     private void switchToAudioLayout() {
         messageEditText.setVisibility(View.GONE);
-        audioRecordBtn.setVisibility(View.VISIBLE);
+        //audioRecordBtn.setVisibility(View.VISIBLE);
         hideInputMethod();
         hideEmojiLayout();
         hideActionPanelLayout();
@@ -534,7 +541,7 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
 
     // 隐藏语音布局
     private void hideAudioLayout() {
-        audioRecordBtn.setVisibility(View.GONE);
+        //audioRecordBtn.setVisibility(View.GONE);
         messageEditText.setVisibility(View.VISIBLE);
         switchToTextButtonInInputBar.setVisibility(View.VISIBLE);
         switchToAudioButtonInInputBar.setVisibility(View.GONE);
@@ -544,7 +551,7 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
     private void showEmojiLayout() {
         hideInputMethod();
         hideActionPanelLayout();
-        hideAudioLayout();
+        //hideAudioLayout();
 
         messageEditText.requestFocus();
         uiHandler.postDelayed(showEmojiRunnable, 200);
@@ -717,28 +724,28 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
     /**
      * ****************************** 语音 ***********************************
      */
-    private void initAudioRecordButton() {
-        audioRecordBtn.setOnTouchListener(new View.OnTouchListener() {
-
-            @Override
-            public boolean onTouch(View v, MotionEvent event) {
-                if (event.getAction() == MotionEvent.ACTION_DOWN) {
-                    touched = true;
-                    initAudioRecord();
-                    onStartAudioRecord();
-                } else if (event.getAction() == MotionEvent.ACTION_CANCEL
-                        || event.getAction() == MotionEvent.ACTION_UP) {
-                    touched = false;
-                    onEndAudioRecord(isCancelled(v, event));
-                } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
-                    touched = true;
-                    cancelAudioRecord(isCancelled(v, event));
-                }
-
-                return false;
-            }
-        });
-    }
+//    private void initAudioRecordButton() {
+//        audioRecordBtn.setOnTouchListener(new View.OnTouchListener() {
+//
+//            @Override
+//            public boolean onTouch(View v, MotionEvent event) {
+//                if (event.getAction() == MotionEvent.ACTION_DOWN) {
+//                    touched = true;
+//                    initAudioRecord();
+//                    onStartAudioRecord();
+//                } else if (event.getAction() == MotionEvent.ACTION_CANCEL
+//                        || event.getAction() == MotionEvent.ACTION_UP) {
+//                    touched = false;
+//                    onEndAudioRecord(isCancelled(v, event));
+//                } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
+//                    touched = true;
+//                    cancelAudioRecord(isCancelled(v, event));
+//                }
+//
+//                return false;
+//            }
+//        });
+//    }
 
     // 上滑取消录音判断
     private static boolean isCancelled(View view, MotionEvent event) {
@@ -782,8 +789,8 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
         container.activity.getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
 
         audioMessageHelper.completeRecord(cancel);
-        audioRecordBtn.setText(R.string.record_audio);
-        audioRecordBtn.setBackgroundResource(R.drawable.nim_message_input_edittext_box);
+        //audioRecordBtn.setText(R.string.record_audio);
+        //audioRecordBtn.setBackgroundResource(R.drawable.nim_message_input_edittext_box);
         stopAudioRecordAnim();
     }
 
@@ -852,8 +859,8 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
             return;
         }
 
-        audioRecordBtn.setText(R.string.record_audio_end);
-        audioRecordBtn.setBackgroundResource(R.drawable.nim_message_input_edittext_box_pressed);
+        //audioRecordBtn.setText(R.string.record_audio_end);
+        //audioRecordBtn.setBackgroundResource(R.drawable.nim_message_input_edittext_box_pressed);
 
         updateTimerTip(false); // 初始化语音动画状态
         playAudioRecordAnim();