husong 4 jaren geleden
bovenliggende
commit
0ba2c0fbfc

BIN
app/release/app-release.apk


+ 91 - 0
app/src/main/java/com/technology/tederen/HMSPushHelper.java

@@ -0,0 +1,91 @@
+package com.hyphenate.chatuidemo;
+
+import android.app.Activity;
+import android.app.Application;
+import android.text.TextUtils;
+
+import com.huawei.android.hms.agent.HMSAgent;
+import com.huawei.android.hms.agent.common.handler.ConnectHandler;
+import com.huawei.android.hms.agent.push.handler.GetTokenHandler;
+import com.hyphenate.chat.EMClient;
+import com.hyphenate.util.EMLog;
+
+import java.lang.reflect.Method;
+
+/**
+ * Created by lzan13 on 2018/4/10.
+ */
+
+public class HMSPushHelper {
+
+    private static HMSPushHelper instance;
+
+    // 是否使用华为 hms
+    private boolean isUseHMSPush = false;
+
+    private HMSPushHelper(){}
+
+    public static HMSPushHelper getInstance() {
+        if (instance == null) {
+            instance = new HMSPushHelper();
+        }
+        return instance;
+    }
+
+    /**
+     * 初始化华为 HMS 推送服务
+     */
+    public void initHMSAgent(Application application){
+        if (EMClient.getInstance().isFCMAvailable()) {
+            return;
+        }
+        try {
+            if(Class.forName("com.huawei.hms.support.api.push.HuaweiPush") != null){
+                Class<?> classType = Class.forName("android.os.SystemProperties");
+                Method getMethod = classType.getDeclaredMethod("get", new Class<?>[] {String.class});
+                String buildVersion = (String)getMethod.invoke(classType, new Object[]{"ro.build.version.emui"});
+                //在某些手机上,invoke方法不报错
+                if(!TextUtils.isEmpty(buildVersion)){
+                    EMLog.d("HWHMSPush", "huawei hms push is available!");
+                    isUseHMSPush = true;
+                    HMSAgent.init(application);
+                }else{
+                    EMLog.d("HWHMSPush", "huawei hms push is unavailable!");
+                }
+            }else{
+                EMLog.d("HWHMSPush", "no huawei hms push sdk or mobile is not a huawei phone");
+            }
+        } catch (Exception e) {
+            EMLog.d("HWHMSPush", "no huawei hms push sdk or mobile is not a huawei phone");
+        }
+    }
+
+    /**
+     * 连接华为移动服务,并获取华为推送
+     * 注册华为推送 token 通用错误码列表
+     * http://developer.huawei.com/consumer/cn/service/hms/catalog/huaweipush_agent.html?page=hmssdk_huaweipush_api_reference_errorcode
+     */
+    public void getHMSToken(Activity activity){
+        if (isUseHMSPush) {
+            HMSAgent.connect(activity, new ConnectHandler() {
+                @Override
+                public void onConnect(int rst) {
+                    EMLog.d("HWHMSPush", "huawei hms push connect result code:" + rst);
+                    if (rst == HMSAgent.AgentResultCode.HMSAGENT_SUCCESS) {
+                        HMSAgent.Push.getToken(new GetTokenHandler() {
+                            @Override
+                            public void onResult(int rst) {
+                                EMLog.d("HWHMSPush", "get huawei hms push token result code:" + rst);
+                            }
+                        });
+                    }
+                }
+            });
+        }
+    }
+
+    public boolean isUseHMSPush() {
+        return isUseHMSPush;
+    }
+
+}

+ 34 - 0
app/src/main/java/com/technology/tederen/receiver/HMSPushReceiver.java

@@ -0,0 +1,34 @@
+/*
+ *  * EaseMob CONFIDENTIAL
+ * __________________
+ * Copyright (C) 2017 EaseMob Technologies. All rights reserved.
+ *
+ * NOTICE: All information contained herein is, and remains
+ * the property of EaseMob Technologies.
+ * Dissemination of this information or reproduction of this material
+ * is strictly forbidden unless prior written permission is obtained
+ * from EaseMob Technologies.
+ */
+package com.hyphenate.chatuidemo.receiver;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import com.huawei.hms.support.api.push.PushReceiver;
+import com.hyphenate.chat.EMClient;
+import com.hyphenate.util.EMLog;
+
+public class HMSPushReceiver extends PushReceiver{
+    private static final String TAG = HMSPushReceiver.class.getSimpleName();
+
+    @Override
+    public void onToken(Context context, String token, Bundle extras){
+        if(token != null && !token.equals("")){
+            //没有失败回调,假定token失败时token为null
+            EMLog.d("HWHMSPush", "register huawei hms push token success token:" + token);
+            EMClient.getInstance().sendHMSPushTokenToServer(token);
+        }else{
+            EMLog.e("HWHMSPush", "register huawei hms push token fail!");
+        }
+    }
+}

File diff suppressed because it is too large
+ 1677 - 0
app/src/main/java/com/technology/tederen/widget/WebActivity.java


+ 177 - 0
app/src/main/res/layout/activity_web.xml

@@ -0,0 +1,177 @@
+<?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"
+    xmlns:fresco="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+
+    android:background="@color/white"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:id="@+id/ll_title"
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:background="@color/white"
+        android:orientation="vertical"
+        android:visibility="gone" />
+    <android.support.v4.widget.DrawerLayout
+        android:id="@+id/dl_main"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="#EEEEEE"
+        >
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical">
+
+
+            <FrameLayout
+                android:layout_width="match_parent"
+                android:layout_height="44dp"
+                android:background="#FFFFFF"
+                android:orientation="horizontal">
+
+                <ImageView
+                    android:id="@+id/iv_close"
+                    android:layout_width="44dp"
+                    android:layout_height="44dp"
+                    android:padding="15dp"
+                    android:src="@mipmap/to_left" />
+                <ImageView
+                    android:id="@+id/iv_menu"
+                    android:layout_width="44dp"
+                    android:layout_height="44dp"
+                    android:layout_gravity="left|center"
+                    android:layout_marginLeft="44dp"
+                    android:padding="15dp"
+                    android:src="@mipmap/black_menu" />
+                <TextView
+                    android:id="@+id/hyjy_title"
+                    android:visibility="gone"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_gravity="center"
+                    android:gravity="center"
+                    android:text="会议纪要"
+                    android:textColor="#333333"
+                    android:textSize="17sp" />
+                <TextView
+                    android:id="@+id/xz_ht_title"
+                    android:visibility="gone"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_gravity="center"
+                    android:gravity="center"
+                    android:text="写话题"
+                    android:textColor="#333333"
+                    android:textSize="17sp" />
+                <TextView
+                    android:id="@+id/tz_title"
+                    android:visibility="gone"
+
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_gravity="center"
+                    android:gravity="center"
+                    android:text="写通知"
+                    android:textColor="#333333"
+                    android:textSize="17sp" />
+                <TextView
+                    android:id="@+id/ht_title"
+                    android:visibility="gone"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_gravity="center"
+                    android:singleLine="true"
+                    android:maxLines="1"
+                    android:layout_marginRight="100dp"
+                    android:layout_marginLeft="100dp"
+                    android:background="?attr/selectableItemBackground"
+                    android:drawableRight="@mipmap/xiala"
+                    android:drawablePadding="5dp"
+                    android:gravity="center"
+                    android:paddingLeft="10dp"
+                    android:paddingRight="10dp"
+                    android:text="选择范围"
+                    android:textColor="#333333"
+                    android:textSize="17sp" />
+                <TextView
+                    android:id="@+id/bj_title_no"
+                    android:visibility="gone"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_gravity="center"
+                    android:gravity="center"
+                    android:text="编辑笔记"
+                    android:textColor="#333333"
+                    android:textSize="17sp" />
+                <TextView
+                    android:id="@+id/bj_title"
+                    android:visibility="gone"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_gravity="center"
+                    android:singleLine="true"
+                    android:maxLines="1"
+                    android:layout_marginRight="100dp"
+                    android:layout_marginLeft="100dp"
+                    android:background="?attr/selectableItemBackground"
+                    android:drawableRight="@mipmap/xiala"
+                    android:drawablePadding="5dp"
+                    android:gravity="center"
+                    android:paddingLeft="10dp"
+                    android:paddingRight="10dp"
+                    android:text="根目录"
+                    android:textColor="#333333"
+                    android:textSize="17sp" />
+                <TextView
+                    android:id="@+id/znx_title"
+                    android:visibility="gone"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_gravity="center"
+                    android:layout_marginTop="2dp"
+                    android:background="?attr/selectableItemBackground"
+                    android:drawableRight="@mipmap/xiala"
+                    android:drawablePadding="5dp"
+                    android:gravity="center"
+                    android:paddingLeft="10dp"
+                    android:paddingRight="10dp"
+                    android:text="写信件"
+                    android:textColor="#333333"
+                    android:textSize="17sp" />
+                <TextView
+                    android:id="@+id/send"
+                    android:layout_width="88dp"
+                    android:layout_height="match_parent"
+                    android:layout_gravity="right"
+                    android:background="?attr/selectableItemBackground"
+                    android:gravity="center"
+                    android:paddingLeft="15dp"
+                    android:paddingRight="15dp"
+                    android:text="完成"
+                    android:textColor="#999999"
+                    android:textSize="15sp" />
+            </FrameLayout>
+            <View
+                android:layout_width="match_parent"
+                android:layout_height="0.5dp"
+                android:background="@color/view_color"/>
+            <WebView
+                android:id="@+id/web"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"></WebView>
+        </LinearLayout>
+
+        <android.support.design.widget.NavigationView
+            android:id="@+id/navigation_view"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_gravity="start"
+            app:insetForeground="@android:color/transparent" />
+
+    </android.support.v4.widget.DrawerLayout>
+</LinearLayout>

BIN
hmspush/libs/base-2.6.1.301.aar


BIN
hmspush/libs/push-2.6.1.301.aar