Browse Source

调整代码样式提高可阅读性;

tanwenkang 2 years ago
parent
commit
1d58d3bfe8

+ 1 - 4
app/build.gradle

@@ -14,7 +14,6 @@ android {
         multiDexEnabled true
         vectorDrawables.useSupportLibrary = true
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
-        ndk { abiFilters "armeabi", "armeabi-v7a" }
 
         manifestPlaceholders.put("network_security_config", "@xml/network_security_config")
         manifestPlaceholders.put("app_icon", "@drawable/logo_r")
@@ -32,9 +31,7 @@ android {
         debug {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
-            ndk {
-                abiFilters "armeabi", "x86", "armeabi-v7a"
-            }
+            ndk { abiFilters "x86", "armeabi", "armeabi-v7a" }
         }
     }
 

+ 6 - 0
app/multidex-config.pro

@@ -0,0 +1,6 @@
+# Additional ProGuard rules to be used to determine which classes are compiled into the main dex file.
+# If set, rules from this file are used in combination with the default rules used by the build system.
+
+# web3j
+-keep class org.web3j.crypto.WalletFile{*;}
+-keep class org.web3j.tx.Contract{*;}

+ 2 - 2
app/proguard-rules.pro

@@ -24,5 +24,5 @@
 # hide the original source file name.
 #-renamesourcefileattribute SourceFile
 
--dontwarn com.tencent.bugly.**
--keep public class com.tencent.bugly.**{*;}
+-keep class com.finogeeks.**{*;}
+-keep class com.finogeeks.auth.** {*;}

+ 0 - 1
app/src/main/AndroidManifest.xml

@@ -102,7 +102,6 @@
 
         <activity
             android:name="com.finogeeks.auth.WebViewActivity"
-            android:process=":finAuthWebView"
             android:theme="@style/FinAuthWebViewTheme">
             <meta-data
                 android:name="FinAuthHost"

+ 6 - 13
app/src/main/java/com/finogeeks/finochatapp/FinoChatApplication.kt

@@ -11,26 +11,19 @@ class FinoChatApplication : MultiDexApplication() {
 
     override fun onCreate() {
         super.onCreate()
-        init()
-    }
 
-    private fun init() {
-        val processName = processName()
-        if (processName?.endsWith(":finAuthWebView").isTrue) return
-        if (processName?.contains(":FinApp").isTrue) return
-        doAsync { initFinoChatSDK() }
+        // FinApplet multi-thread condition.
+        if (processName()?.contains(":FinApp").isTrue) return
+
+        doAsync { FinoChatSDKInitializer(this@FinoChatApplication).init() }
     }
 
     private fun processName(): String? {
         return try {
             (getSystemService(Context.ACTIVITY_SERVICE) as? ActivityManager)
-                ?.runningAppProcesses?.firstOrNull { it.pid == Process.myPid() }?.processName
+                    ?.runningAppProcesses?.firstOrNull { it.pid == Process.myPid() }?.processName
         } catch (e: Exception) {
             e.localizedMessage
         }
     }
-
-    private fun initFinoChatSDK() {
-        FinoChatSDKInitializer(this).init()
-    }
-}
+}

File diff suppressed because it is too large
+ 34 - 62
app/src/main/java/com/finogeeks/finochatapp/FinoChatSDKInitializer.kt


+ 20 - 62
app/src/main/java/com/finogeeks/finochatapp/modules/home/HomeActivity.java

@@ -7,20 +7,21 @@ import android.content.Intent;
 import android.content.IntentFilter;
 import android.net.Uri;
 import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-import androidx.viewpager.widget.ViewPager;
-import androidx.appcompat.app.ActionBar;
-import androidx.appcompat.app.AlertDialog;
 import android.text.TextUtils;
-import android.view.Gravity;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.FrameLayout;
 import android.widget.RelativeLayout;
 
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AlertDialog;
+import androidx.core.view.GravityCompat;
+import androidx.fragment.app.Fragment;
+import androidx.localbroadcastmanager.content.LocalBroadcastManager;
+import androidx.viewpager.widget.ViewPager;
+
 import com.finogeeks.finochat.modules.base.BaseActivity;
 import com.finogeeks.finochat.repository.ScreenShotListenManager;
 import com.finogeeks.finochat.repository.ThemeKit;
@@ -67,13 +68,10 @@ public class HomeActivity extends BaseActivity implements
         INetworkManager.NetworkEventListener,
         ForegroundCallbacks.Listener {
 
-    // Fragment实例
     private Fragment[] fragments;
 
-    // Tabs图标
     private int ICONS_RES[][];
 
-    // Tabs标题
     private int[] tab_main_title;
 
     private TabContainerView mTabLayout;
@@ -99,9 +97,7 @@ public class HomeActivity extends BaseActivity implements
         }
     };
 
-    // OkHttp Call, cancel when onDestroy().
     private Call mCall;
-
     private OkHttpClient mClient;
 
     private final static long DAY_MILL_SEC = 24 * 60 * 60 * 1000; // One day in mill-second.
@@ -109,7 +105,7 @@ public class HomeActivity extends BaseActivity implements
     private static final String FINO_VERSION_PREFS = "FINO_VERSION_PREFS";
 
     /**
-     * 版本升级检查
+     * 版本升级检查,非标准SDK能力
      */
     private Callback mCallback = new Callback() {
         @Override
@@ -174,19 +170,15 @@ public class HomeActivity extends BaseActivity implements
     };
 
     private static int parseInt(String s) {
-        // 本身是空
         if (TextUtils.isEmpty(s)) {
             return 0;
         }
 
         s = s.replaceAll("[^\\d]", "");
-
-        // 裁剪之后字符串为空
         if (TextUtils.isEmpty(s)) {
             return 0;
         }
 
-        // 裁剪之后不为空
         try {
             return Integer.parseInt(s);
         } catch (Exception e) {
@@ -310,7 +302,6 @@ public class HomeActivity extends BaseActivity implements
                 + option.getApiPrefix()
                 + "finchat-control/updateApp/query?typeList=apk";
 
-//        String url = "http://111.230.173.185:8000/api/v1/finchat-control/updateApp/query?typeList=apk";
         Request builder = new Request.Builder().url(url).build();
         mCall = mClient.newCall(builder);
         mCall.enqueue(mCallback);
@@ -327,7 +318,6 @@ public class HomeActivity extends BaseActivity implements
         fragments = new Fragment[]{
                 FinoChatClient.getInstance().chatUIManager().conversationFragment(),
                 FinoChatClient.getInstance().chatUIManager().contactFragment(),
-//                new WorkFragment(),
                 FinoChatClient.getInstance().chatUIManager().workFragment(),
                 FinoChatClient.getInstance().chatUIManager().mineFragment()};
 
@@ -342,7 +332,7 @@ public class HomeActivity extends BaseActivity implements
                 R.string.tab_main_contact,
                 R.string.tab_main_title_work,
                 R.string.tab_main_title_me};
-        Boolean isWork = (Boolean) FinoChatClient.getInstance().getOptions().getSettings().isWorkTab;
+        Boolean isWork = FinoChatClient.getInstance().getOptions().getSettings().isWorkTab;
         if (Boolean.FALSE.equals(isWork)) {
             fragments = ArrayUtils.remove(fragments, 2);
             ICONS_RES = ArrayUtils.remove(ICONS_RES, 2);
@@ -368,32 +358,6 @@ public class HomeActivity extends BaseActivity implements
                 if (FloatWindowPermissionHelper.INSTANCE.checkPermission(this)) {
                     if (isForeground) mFeedbackView.show(imagePath);
                 }
-
-                // 产品说如果系统没有权限,不需要提示用户获取,即不使用此功能
-//                else {
-//                    if (Build.VERSION.SDK_INT >= 23) {
-//                        new AlertDialog.Builder(this)
-//                                .setMessage("没有浮窗权限,请前往权限页面开启")
-//                                .setTitle("权限提示")
-//                                .setPositiveButton("开启", (dialog, which) -> {
-//                                    Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
-//                                    intent.setData(Uri.parse("package:" + getApplicationContext().getPackageName()));
-//                                    intent.putExtra("imagePath", imagePath);
-//                                    HomeActivity.this.startActivityForResult(intent, PERMISSION_ACTIVITY_RESULT);
-//                                })
-//                                .setNegativeButton("取消", (dialog, which) -> dialog.cancel())
-//                                .create()
-//                                .show();
-//                    } else {
-//                        new AlertDialog.Builder(this)
-//                                .setMessage("没有浮窗权限,请前往权限页面开启")
-//                                .setTitle("权限提示")
-//                                .setPositiveButton("知道了", (dialog, which) -> {
-//                                })
-//                                .create()
-//                                .show();
-//                    }
-//                }
             });
         }
 
@@ -456,7 +420,8 @@ public class HomeActivity extends BaseActivity implements
         mDrawerViewContainer = findViewById(R.id.fl_drawer_view_container);
         if (FinoChatClient.getInstance().getLicenseService().getFeature().isApplet()) {
             mDrawerLayout.setDrawerLockMode(LOCK_MODE_UNLOCKED);
-            FinoChatClient.getInstance().chatUIManager()
+            FinoChatClient.getInstance()
+                    .chatUIManager()
                     .inflateAppletDrawerView(mDrawerLayout, mDrawerViewContainer);
         } else {
             mDrawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED);
@@ -466,14 +431,8 @@ public class HomeActivity extends BaseActivity implements
     @Override
     protected void onResume() {
         super.onResume();
-        // https://github.com/vector-im/vector-android/issues/323
-        // the tool bar color is not restored on some devices.
-        // mToolbar.setBackgroundResource(R.color.color_fafafa);
         startListenNetworkStatus();
-
-        // 反馈建议
-        if (mManager != null)
-            mManager.startListen();
+        if (mManager != null) mManager.startListen();
     }
 
     @Override
@@ -522,7 +481,8 @@ public class HomeActivity extends BaseActivity implements
         getMenuInflater().inflate(R.menu.home_toolbar_menu, menu);
         MenuItem itemDrawer = menu.findItem(R.id.home_toolbar_menu_item_drawer);
         if (itemDrawer != null) {
-            itemDrawer.setVisible(FinoChatClient.getInstance().getLicenseService().getFeature().isApplet());
+            boolean isApplet = FinoChatClient.getInstance().getLicenseService().getFeature().isApplet();
+            itemDrawer.setVisible(isApplet);
         }
         return super.onCreateOptionsMenu(menu);
     }
@@ -555,7 +515,7 @@ public class HomeActivity extends BaseActivity implements
      */
     private void openDrawer() {
         if (mDrawerLayout != null) {
-            mDrawerLayout.openDrawer(Gravity.START);
+            mDrawerLayout.openDrawer(GravityCompat.START);
         }
     }
 
@@ -565,12 +525,10 @@ public class HomeActivity extends BaseActivity implements
 
     @Override
     public void onTabDoubleClicked(int tabIndex) {
-        switch (tabIndex) {
-            case 0:
-                FinoChatClient.getInstance().chatUIManager().locateToNextChatWithUnreadMessages(fragments[0]);
-                break;
-            default:
-                break;
+        if (tabIndex == 0) {
+            FinoChatClient.getInstance()
+                    .chatUIManager()
+                    .locateToNextChatWithUnreadMessages(fragments[0]);
         }
     }
 

+ 3 - 3
app/src/main/java/com/finogeeks/finochatapp/modules/home/TabFragmentAdapter.java

@@ -1,18 +1,18 @@
 package com.finogeeks.finochatapp.modules.home;
 
 
+import android.view.ViewGroup;
+
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentManager;
 import androidx.fragment.app.FragmentPagerAdapter;
 
-import android.view.ViewGroup;
-
 
 public class TabFragmentAdapter extends FragmentPagerAdapter {
 
     private Fragment[] fragments;
 
-    public TabFragmentAdapter(FragmentManager fm, Fragment[] fragments) {
+    TabFragmentAdapter(FragmentManager fm, Fragment[] fragments) {
         super(fm);
         this.fragments = fragments;
     }

+ 0 - 43
app/src/main/java/com/finogeeks/finochatapp/modules/home/WorkFragment.kt

@@ -1,43 +0,0 @@
-package com.finogeeks.finochatapp.modules.home
-
-import android.annotation.SuppressLint
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import com.alibaba.android.arouter.launcher.ARouter
-import com.finogeeks.finochat.modules.base.BaseFragment
-import com.finogeeks.finochat.router.RouterMap
-import com.finogeeks.finochatapp.R
-import com.jakewharton.rxbinding2.view.RxView
-import kotlinx.android.synthetic.main.fc_fragment_work.*
-
-/**
- * 工作页面
- */
-class WorkFragment : BaseFragment() {
-
-    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
-        return inflater.inflate(R.layout.fc_fragment_work, container, false)
-    }
-
-    @SuppressLint("CheckResult")
-    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
-        super.onViewCreated(view, savedInstanceState)
-
-        RxView.clicks(rlApplet).subscribe {
-            ARouter.getInstance().build(RouterMap.APPLET_APPLET_ACTIVITY)
-                    .navigation(activity)
-        }
-
-        RxView.clicks(rlChannel).subscribe {
-            ARouter.getInstance().build(RouterMap.CONVERSATION_CHANNEL_LIST_ACTIVITY)
-                    .navigation(activity)
-        }
-
-        RxView.clicks(rlNotice).subscribe {
-            ARouter.getInstance().build(RouterMap.WORK_NOTICE_ACTIVITY).navigation(activity)
-        }
-
-    }
-}

+ 3 - 3
app/src/main/java/com/finogeeks/finochatapp/modules/login/LoginActivity.kt

@@ -6,7 +6,6 @@ import android.app.Activity
 import android.content.Context
 import android.content.Intent
 import android.os.Bundle
-import androidx.core.content.ContextCompat
 import android.text.Editable
 import android.text.InputType
 import android.text.TextUtils
@@ -16,6 +15,7 @@ import android.text.method.PasswordTransformationMethod
 import android.view.MotionEvent
 import android.view.View
 import android.widget.Toast
+import androidx.core.content.ContextCompat
 import com.finogeeks.auth.AuthCallback
 import com.finogeeks.auth.AuthService
 import com.finogeeks.auth.model.TokenResponse
@@ -69,7 +69,7 @@ class LoginActivity : BaseActivity() {
 
         mAuthService = AuthService.Builder
                 .builder(this, mAuthCallback, R.raw.auth_config)
-                .isMultiProcess(true)
+                .isMultiProcess(false)
                 .build()
 
         RxView.clicks(button_login)
@@ -90,7 +90,7 @@ class LoginActivity : BaseActivity() {
             override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
             override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
             override fun afterTextChanged(s: Editable?) {
-                button_login.isEnabled = login_username.text!!.length >= 1 && login_password.text!!.length >= 1
+                button_login.isEnabled = login_username.text!!.isNotEmpty() && login_password.text!!.isNotEmpty()
             }
         }
 

+ 69 - 61
app/src/main/java/com/finogeeks/finochatapp/modules/login/PhoneVerifyActivity.kt

@@ -1,5 +1,6 @@
 package com.finogeeks.finochatapp.modules.login
 
+import android.annotation.SuppressLint
 import android.app.Activity
 import android.content.Intent
 import android.os.Bundle
@@ -33,23 +34,24 @@ class PhoneVerifyActivity : BaseActivity() {
      */
     private val mMode by lazy { intent.getIntExtra(EXTRA_MODE, MODE_REGISTER) }
 
+    @SuppressLint("CheckResult")
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_phone_verify)
 
         RxView.clicks(nextBtn)
-                .throttleFirst(3, TimeUnit.SECONDS)
-                .subscribe { onNextStep() }
+            .throttleFirst(3, TimeUnit.SECONDS)
+            .subscribe { onNextStep() }
 
         RxView.clicks(request_captcha)
-                .throttleFirst(2, TimeUnit.SECONDS)
-                .subscribe {
-                    if (mMode == MODE_REGISTER) {
-                        verifyAndSend()
-                    } else if (mMode == MODE_RESET_PASSWORD) {
-                        sendCaptcha()
-                    }
+            .throttleFirst(2, TimeUnit.SECONDS)
+            .subscribe {
+                if (mMode == MODE_REGISTER) {
+                    verifyAndSend()
+                } else if (mMode == MODE_RESET_PASSWORD) {
+                    sendCaptcha()
                 }
+            }
 
         // TextWatcher.
         val textWatcher = object : TextWatcher {
@@ -80,20 +82,20 @@ class PhoneVerifyActivity : BaseActivity() {
             phoneNumber.isEmpty() -> toast("请输入手机号")
             phoneNumber.length != 11 || !phoneNumber.startsWith("1") -> toast("请输入合法手机号")
             else -> FinoChatClient.getInstance().accountManager()
-                    .isPhoneAvailable(this, phoneNumber, object : SimpleCallBack<Int>() {
-                        override fun onSuccess(result: Int?) {
-                            when (result) {
-                                200 -> toast("该手机号已被注册")
-                                204 -> sendCaptcha()
-                                else -> longToast("服务器内部异常: $result")
-                            }
+                .isPhoneAvailable(this, phoneNumber, object : SimpleCallBack<Int>() {
+                    override fun onSuccess(result: Int?) {
+                        when (result) {
+                            200 -> toast("该手机号已被注册")
+                            204 -> sendCaptcha()
+                            else -> longToast("服务器内部异常: $result")
                         }
+                    }
 
-                        override fun onError(code: Int, error: String?) {
-                            Log.e(TAG, "requestCode", error ?: "Error but no message.")
-                            longToast("$error")
-                        }
-                    })
+                    override fun onError(code: Int, error: String?) {
+                        Log.e(TAG, "requestCode", error ?: "Error but no message.")
+                        longToast("$error")
+                    }
+                })
         }
     }
 
@@ -101,32 +103,32 @@ class PhoneVerifyActivity : BaseActivity() {
         requestCodeEnable(false)
 
         FinoChatClient.getInstance()
-                .accountManager()
-                .getRegisterSms(this, phone.text.toString(), object : SimpleCallBack<Void>() {
-                    override fun onSuccess(result: Void?) {
-                        super.onSuccess(result)
-                        code.requestFocus()
-                        toast("验证码已发送,请查收")
-                    }
+            .accountManager()
+            .getRegisterSms(this, phone.text.toString(), object : SimpleCallBack<Void>() {
+                override fun onSuccess(result: Void?) {
+                    super.onSuccess(result)
+                    code.requestFocus()
+                    toast("验证码已发送,请查收")
+                }
 
-                    override fun onError(code: Int, error: String) {
-                        super.onError(code, error)
-                        Log.e(TAG, error)
-                        requestCodeEnable(true)
-                        toast(error)
-                    }
-                })
+                override fun onError(code: Int, error: String) {
+                    super.onError(code, error)
+                    Log.e(TAG, error)
+                    requestCodeEnable(true)
+                    toast(error)
+                }
+            })
 
         mDisposable = Flowable.interval(0, 1, TimeUnit.SECONDS)
-                .onBackpressureBuffer()
-                .take(CAPTCHA_COUNT + 1)
-                .map { CAPTCHA_COUNT - it }
-                .bindUntilEvent(this, ActivityEvent.DESTROY)
-                .observeOn(AndroidSchedulers.mainThread())
-                .doOnSubscribe { requestCodeEnable(false) }
-                .subscribe({ request_captcha.text = "${it}秒后重新发送" },
-                        { Log.e(TAG, "sendCaptcha", it) },
-                        { requestCodeEnable(true) })
+            .onBackpressureBuffer()
+            .take(CAPTCHA_COUNT + 1)
+            .map { CAPTCHA_COUNT - it }
+            .bindUntilEvent(this, ActivityEvent.DESTROY)
+            .observeOn(AndroidSchedulers.mainThread())
+            .doOnSubscribe { requestCodeEnable(false) }
+            .subscribe({ request_captcha.text = "${it}秒后重新发送" },
+                { Log.e(TAG, "sendCaptcha", it) },
+                { requestCodeEnable(true) })
     }
 
     /**
@@ -152,24 +154,30 @@ class PhoneVerifyActivity : BaseActivity() {
         val code = code.text.toString()
 
         FinoChatClient.getInstance().accountManager()
-                .verifyPhoneNumber(this, phone, code, object : SimpleCallBack<Void?>() {
-                    override fun onSuccess(result: Void?) {
-                        when (mMode) {
-                            MODE_REGISTER -> {
-                                PhoneRegisterActivity.startForResult(this@PhoneVerifyActivity, phone, code, REQ_CODE_REGISTER)
-                            }
-
-                            MODE_RESET_PASSWORD -> {
-                                ResetPasswordActivity.startForResult(this@PhoneVerifyActivity, phone, code, REQ_CODE_REGISTER)
-                            }
+            .verifyPhoneNumber(this, phone, code, object : SimpleCallBack<Void?>() {
+                override fun onSuccess(result: Void?) {
+                    when (mMode) {
+                        MODE_REGISTER -> {
+                            PhoneRegisterActivity.startForResult(
+                                this@PhoneVerifyActivity,
+                                phone, code, REQ_CODE_REGISTER
+                            )
                         }
-                    }
 
-                    override fun onError(code: Int, error: String?) {
-                        toast("$error")
-                        Log.e(TAG, "onNextStep", "$code $error")
+                        MODE_RESET_PASSWORD -> {
+                            ResetPasswordActivity.startForResult(
+                                this@PhoneVerifyActivity,
+                                phone, code, REQ_CODE_REGISTER
+                            )
+                        }
                     }
-                })
+                }
+
+                override fun onError(code: Int, error: String?) {
+                    toast("$error")
+                    Log.e(TAG, "onNextStep", "$code $error")
+                }
+            })
     }
 
     override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@@ -198,8 +206,8 @@ class PhoneVerifyActivity : BaseActivity() {
 
         fun start(activity: Activity, mode: Int = MODE_REGISTER, requestCode: Int) {
             Intent(activity, PhoneVerifyActivity::class.java)
-                    .putExtra(EXTRA_MODE, mode)
-                    .run { activity.startActivityForResult(this, requestCode) }
+                .putExtra(EXTRA_MODE, mode)
+                .run { activity.startActivityForResult(this, requestCode) }
         }
     }
 }

+ 27 - 25
app/src/main/java/com/finogeeks/finochatapp/modules/login/ResetPasswordActivity.kt

@@ -3,12 +3,12 @@ package com.finogeeks.finochatapp.modules.login
 import android.app.Activity
 import android.content.Intent
 import android.os.Bundle
-import androidx.core.content.ContextCompat
 import android.text.InputType
 import android.text.method.HideReturnsTransformationMethod
 import android.text.method.PasswordTransformationMethod
 import android.view.MenuItem
 import android.view.MotionEvent
+import androidx.core.content.ContextCompat
 import com.finogeeks.finochat.modules.base.BaseActivity
 import com.finogeeks.finochat.sdk.FinoChatClient
 import com.finogeeks.finochat.sdk.SimpleCallBack
@@ -20,8 +20,13 @@ import org.jetbrains.anko.toast
 
 class ResetPasswordActivity : BaseActivity() {
 
-    private val eyesClose by lazy { ContextCompat.getDrawable(this, R.drawable.sdk_login_ic_eyeoff) }
-    private val eyesOpen by lazy { ContextCompat.getDrawable(this, R.drawable.sdk_login_ic_eye) }
+    private val eyesClose by lazy(LazyThreadSafetyMode.NONE) {
+        ContextCompat.getDrawable(this, R.drawable.sdk_login_ic_eyeoff)
+    }
+
+    private val eyesOpen by lazy(LazyThreadSafetyMode.NONE) {
+        ContextCompat.getDrawable(this, R.drawable.sdk_login_ic_eye)
+    }
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
@@ -31,9 +36,7 @@ class ResetPasswordActivity : BaseActivity() {
         supportActionBar?.setDisplayHomeAsUpEnabled(true)
 
         // 确认注册按钮
-        button_confirm.setOnClickListener {
-            confirm()
-        }
+        button_confirm.setOnClickListener { confirm() }
 
         password_visible.setOnClickListener {
             password_input.apply {
@@ -65,21 +68,21 @@ class ResetPasswordActivity : BaseActivity() {
             pw.length < MIN_PASSWORD_LENGTH -> toast("密码少于${MIN_PASSWORD_LENGTH}位")
             pw.length > MAX_PASSWORD_LENGTH -> toast("密码超过${MAX_PASSWORD_LENGTH}位")
             else -> FinoChatClient.getInstance()
-                    .accountManager()
-                    .resetPassword(phoneNumber, verificationCode, pw, object : SimpleCallBack<Void?>() {
-                        override fun onSuccess(result: Void?) {
-                            toast("密码修改成功,请登录")
-                            val i = Intent()
-                                    .putExtra(PhoneVerifyActivity.EXTRA_USERNAME, phoneNumber)
-                                    .putExtra(PhoneVerifyActivity.EXTRA_PASSWORD, pw)
-                            setResult(Activity.RESULT_OK, i)
-                            this@ResetPasswordActivity.finish()
-                        }
-
-                        override fun onError(code: Int, error: String) {
-                            toast(error)
-                        }
-                    })
+                .accountManager()
+                .resetPassword(phoneNumber, verificationCode, pw, object : SimpleCallBack<Void?>() {
+                    override fun onSuccess(result: Void?) {
+                        toast("密码修改成功,请登录")
+                        val i = Intent()
+                            .putExtra(PhoneVerifyActivity.EXTRA_USERNAME, phoneNumber)
+                            .putExtra(PhoneVerifyActivity.EXTRA_PASSWORD, pw)
+                        setResult(Activity.RESULT_OK, i)
+                        this@ResetPasswordActivity.finish()
+                    }
+
+                    override fun onError(code: Int, error: String) {
+                        toast(error)
+                    }
+                })
         }
     }
 
@@ -95,7 +98,6 @@ class ResetPasswordActivity : BaseActivity() {
     }
 
     override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
-        // 获得当前得到焦点的View,一般情况下就是EditText
         if (ev.action == MotionEvent.ACTION_DOWN && currentFocus.isShouldHideInput(ev)) {
             hideSoftInput()
         }
@@ -111,9 +113,9 @@ class ResetPasswordActivity : BaseActivity() {
 
         fun startForResult(activity: Activity, phone: String, code: String, requestCode: Int) {
             Intent(activity, ResetPasswordActivity::class.java)
-                    .putExtra(EXTRA_PHONE, phone)
-                    .putExtra(EXTRA_CODE, code)
-                    .run { activity.startActivityForResult(this, requestCode) }
+                .putExtra(EXTRA_PHONE, phone)
+                .putExtra(EXTRA_CODE, code)
+                .run { activity.startActivityForResult(this, requestCode) }
         }
     }
 }

+ 22 - 79
app/src/main/java/com/finogeeks/finochatapp/views/TabContainerView.java

@@ -3,24 +3,22 @@ package com.finogeeks.finochatapp.views;
 import android.annotation.SuppressLint;
 import android.content.Context;
 import android.graphics.Canvas;
-import androidx.viewpager.widget.PagerAdapter;
-import androidx.viewpager.widget.ViewPager;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
+import androidx.viewpager.widget.PagerAdapter;
+import androidx.viewpager.widget.ViewPager;
+
 import com.finogeeks.finochatapp.R;
 import com.finogeeks.finochatapp.utils.ViewExtKt;
 import com.finogeeks.utility.views.BadgeView;
 
 public class TabContainerView extends LinearLayout {
 
-    private static final String TAG = "TabContainerView";
-
     private ViewPager mViewPager;
-//    private ViewPager.OnPageChangeListener mViewPagerPageChangeListener;
 
     /**
      * 默认颜色
@@ -97,9 +95,6 @@ public class TabContainerView extends LinearLayout {
      */
     private static final boolean mShowTransitionColor = true;
 
-    /**
-     * {@link EventListener}对象
-     */
     private EventListener mListener;
 
     public TabContainerView(Context context) {
@@ -111,10 +106,10 @@ public class TabContainerView extends LinearLayout {
     }
 
     public void initContainer(int[] titles, int[][] iconsRes, int[] colors) {
-        this.mTitles = titles;
-        this.mIconRes = iconsRes;
-        this.mTextNormalColor = colors[0];
-        this.mTextSelectedColor = colors[1];
+        mTitles = titles;
+        mIconRes = iconsRes;
+        mTextNormalColor = colors[0];
+        mTextSelectedColor = colors[1];
     }
 
     /**
@@ -136,30 +131,6 @@ public class TabContainerView extends LinearLayout {
         mIconHeight = height;
     }
 
-    /**
-     * <p>设置布局文件及相关控件id --只有文本</p>
-     *
-     * @param layout layout布局文件 id
-     * @param textId TextView 控件 id
-     * @param width  icon 宽度
-     * @param height icon 高度
-     */
-    public void setSingleTextLayout(int layout, int textId, int width, int height) {
-        setContainerLayout(layout, 0, 0, textId, width, height);
-    }
-
-    /**
-     * <p>设置布局文件及相关控件id</p>
-     *
-     * @param layout layout布局文件 id
-     * @param iconId ImageView 控件 id
-     * @param width  icon 宽度
-     * @param height icon 高度
-     */
-    public void setSingleIconLayout(int layout, int iconId, int width, int height) {
-        setContainerLayout(layout, iconId, 0, 0, width, height);
-    }
-
     public void setViewPager(ViewPager viewPager) {
         removeAllViews();
         mViewPager = viewPager;
@@ -170,7 +141,7 @@ public class TabContainerView extends LinearLayout {
     }
 
     /**
-     * <p>添加tab view到当前容器</p>
+     * 添加tab view到当前容器
      */
     private void addTabViewToContainer() {
         final PagerAdapter adapter = mViewPager.getAdapter();
@@ -185,36 +156,30 @@ public class TabContainerView extends LinearLayout {
             final View tabView = LayoutInflater.from(getContext()).inflate(mLayoutId, this, false);
             mTabViews[index] = tabView;
 
-            /*tabIconView初始化*/
             TabIconView iconView = null;
             if (mIconViewId > 0) {
                 iconView = tabView.findViewById(mIconViewId);
                 iconView.init(mIconRes[index][0], mIconRes[index][1], mIconWidth, mIconHeight);
             }
 
-            /*BadgeView初始化*/
             BadgeView badgeView;
             if (mBadgeViewId > 0) {
                 badgeView = tabView.findViewById(mBadgeViewId);
                 badgeView.setVisibility(View.GONE);
             }
 
-            /*tabTextView初始化*/
             TextView textView = null;
             if (mTextViewId > 0) {
                 textView = tabView.findViewById(mTextViewId);
                 textView.setText(getResources().getString(mTitles[index]));
             }
 
-            /*设置宽度,等分container*/
             LayoutParams lp = (LayoutParams) tabView.getLayoutParams();
             lp.width = 0;
             lp.weight = 1;
 
-            /*添加tab点击事件*/
             addOnTabClicksListener(index);
 
-            /*设置当前状态*/
             if (index == mViewPager.getCurrentItem()) {
                 if (iconView != null) {
                     iconView.offsetChanged(0);
@@ -238,22 +203,19 @@ public class TabContainerView extends LinearLayout {
         @Override
         public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
             onViewPagerPageChanged(position, positionOffset);
-
-//            if (mViewPagerPageChangeListener != null) {
-//                mViewPagerPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
-//            }
         }
 
         @Override
         public void onPageSelected(int position) {
 
-            /*完成滑动动作后更新每个Item TextView的颜色值以及ImageView的状态值*/
             for (int i = 0; i < getChildCount(); i++) {
                 if (mIconViewId > 0) {
-                    ((TabIconView) mTabViews[i].findViewById(mIconViewId)).offsetChanged(position == i ? 0 : 1);
+                    int pos = position == i ? 0 : 1;
+                    ((TabIconView) mTabViews[i].findViewById(mIconViewId)).offsetChanged(pos);
                 }
                 if (mTextViewId > 0) {
-                    ((TextView) mTabViews[i].findViewById(mTextViewId)).setTextColor(position == i ? mTextSelectedColor : mTextNormalColor);
+                    int color = position == i ? mTextSelectedColor : mTextNormalColor;
+                    ((TextView) mTabViews[i].findViewById(mTextViewId)).setTextColor(color);
                 }
             }
 
@@ -264,19 +226,11 @@ public class TabContainerView extends LinearLayout {
             for (int i = 0, size = getChildCount(); i < size; i++) {
                 getChildAt(i).setSelected(position == i);
             }
-
-//            if (mViewPagerPageChangeListener != null) {
-//                mViewPagerPageChangeListener.onPageSelected(position);
-//            }
         }
 
         @Override
         public void onPageScrollStateChanged(int state) {
             mScrollState = state;
-
-//            if (mViewPagerPageChangeListener != null) {
-//                mViewPagerPageChangeListener.onPageScrollStateChanged(state);
-//            }
         }
     }
 
@@ -299,31 +253,25 @@ public class TabContainerView extends LinearLayout {
     protected void onDraw(Canvas canvas) {
         super.onDraw(canvas);
         if (getChildCount() > 0) {
-            /*当发生偏移时,绘制渐变区域*/
             if (mSelectionOffset > 0f && mSelectedPosition < (getChildCount() - 1) && mShowTransitionColor) {
 
-                /*获取当前tab和下一tab view */
                 View selectedTab = getChildAt(mSelectedPosition);
                 View nextTab = getChildAt(mSelectedPosition + 1);
 
-                /*显示tab icon时,刷新各自view 透明度*/
                 if (mIconViewId > 0) {
                     View selectedIconView = selectedTab.findViewById(mIconViewId);
                     View nextIconView = nextTab.findViewById(mIconViewId);
 
-                    //draw icon alpha
                     if (selectedIconView instanceof TabIconView && nextIconView instanceof TabIconView) {
                         ((TabIconView) selectedIconView).offsetChanged(mSelectionOffset);
                         ((TabIconView) nextIconView).offsetChanged(1 - mSelectionOffset);
                     }
                 }
 
-                /*显示tab text,刷新各自view 透明度*/
                 if (mTextViewId > 0) {
                     View selectedTextView = selectedTab.findViewById(mTextViewId);
                     View nextTextView = nextTab.findViewById(mTextViewId);
 
-                    //draw text color
                     int selectedColor = evaluate(mSelectionOffset, mTextSelectedColor, mTextNormalColor);
                     int nextColor = evaluate(1 - mSelectionOffset, mTextSelectedColor, mTextNormalColor);
 
@@ -341,24 +289,20 @@ public class TabContainerView extends LinearLayout {
      *
      * @param index The index of the tab in {@link #mTabViews}
      */
+    @SuppressWarnings("ResultOfMethodCallIgnored")
     @SuppressLint("CheckResult")
     public void addOnTabClicksListener(final int index) {
-        ViewExtKt.clicks(mTabViews[index])
-                .subscribe(i -> {
-                    if (i > 1) {
-                        if (mListener != null) {
-                            mListener.onTabDoubleClicked(index);
-                        }
-                    } else if (i > 0) {
-                        mViewPager.setCurrentItem(index, false);
-                    }
-                });
+        ViewExtKt.clicks(mTabViews[index]).subscribe(i -> {
+            if (i > 1) {
+                if (mListener != null) {
+                    mListener.onTabDoubleClicked(index);
+                }
+            } else if (i > 0) {
+                mViewPager.setCurrentItem(index, false);
+            }
+        });
     }
 
-//    public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
-//        mViewPagerPageChangeListener = listener;
-//    }
-
     /**
      * This function returns the calculated in-between value for a color
      * given integers that represent the start and end values in the four
@@ -412,7 +356,6 @@ public class TabContainerView extends LinearLayout {
     }
 
     public interface EventListener {
-
         /**
          * Invoked when a tab was double clicked.
          *

+ 2 - 3
app/src/main/java/com/finogeeks/finochatapp/wxapi/WXEntryActivity.java

@@ -14,15 +14,14 @@ import com.tencent.mm.opensdk.openapi.WXAPIFactory;
 
 public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
 
-    private static final String TAG = "WXEntryActivity";
-
     private IWXAPI api;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        api = WXAPIFactory.createWXAPI(this, FinoChatClient.getInstance().getOptions().getShareParams().wechatAppId, false);
+        String id = FinoChatClient.getInstance().getOptions().getShareParams().wechatAppId;
+        api = WXAPIFactory.createWXAPI(this, id, false);
 
         try {
             api.handleIntent(getIntent(), this);

+ 4 - 1
gradle.properties

@@ -6,7 +6,6 @@
 # http://www.gradle.org/docs/current/userguide/build_environment.html
 # Specifies the JVM arguments used for the daemon process.
 # The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx1536m
 # When configured, Gradle will run in incubating parallel mode.
 # This option should only be used with decoupled projects. More details, visit
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
@@ -15,3 +14,7 @@ org.gradle.jvmargs=-Xmx1536m
 kotlin.code.style=official
 android.useAndroidX=true
 android.enableJetifier=true
+org.gradle.jvmargs=-Xmx1800m
+org.gradle.daemon=true
+org.gradle.parallel=true
+android.enableD8=true