From df9930f1fffd7477aaecf315962c5b31b591ebee Mon Sep 17 00:00:00 2001 From: lijie <675862284@qq.com> Date: Tue, 8 Aug 2023 17:32:34 +0800 Subject: [PATCH] =?UTF-8?q?BUG=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=9E=81?= =?UTF-8?q?=E5=85=89=E6=8E=A8=E9=80=81=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 14 +++ app/src/main/AndroidManifest.xml | 40 +++++-- .../com/cmx/wanhui/activity/LoginActivity.kt | 6 +- .../com/cmx/wanhui/activity/MainActivity.kt | 3 + .../com/cmx/wanhui/activity/MyApplication.kt | 3 + .../java/com/cmx/wanhui/constant/Events.kt | 1 + .../java/com/cmx/wanhui/model/LoginRes.kt | 1 + .../cmx/wanhui/service/MyJpushReceiver.java | 105 ++++++++++++++++++ .../com/cmx/wanhui/service/MyJpushService.kt | 7 ++ .../java/com/cmx/wanhui/ui/BaseFragment.kt | 9 +- .../java/com/cmx/wanhui/ui/HomeFragment.java | 15 --- app/src/main/res/layout/activity_login.xml | 2 - app/src/main/res/values/colors.xml | 2 + app/src/main/res/values/themes.xml | 6 +- 14 files changed, 180 insertions(+), 34 deletions(-) create mode 100644 app/src/main/java/com/cmx/wanhui/service/MyJpushReceiver.java create mode 100644 app/src/main/java/com/cmx/wanhui/service/MyJpushService.kt diff --git a/app/build.gradle b/app/build.gradle index 7513cdf..6612b85 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,6 +19,16 @@ android { versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + ndk { + // 设置支持的SO库架构 + abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a' + } + + manifestPlaceholders = [ + JPUSH_PKGNAME: applicationId, + JPUSH_APPKEY : "2d2ceb987c93daf0a175f684", //JPush 上注册的包名对应的 Appkey. + JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可. + ] } android.applicationVariants.all { variant -> @@ -40,6 +50,7 @@ android { buildFeatures { viewBinding true } + } @@ -73,5 +84,8 @@ dependencies { implementation 'com.github.nanchen2251:CompressHelper:1.0.5' implementation 'com.google.zxing:core:3.4.0' implementation 'com.journeyapps:zxing-android-embedded:3.6.0' +// 此处以JPush 5.0.0 版本为例,5.0.0 版本开始可以自动拉取 JCore 包,无需另外配置 + implementation 'cn.jiguang.sdk:jpush:5.0.0' + } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8a32774..60915ff 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,8 +6,7 @@ - - + @@ -24,7 +23,6 @@ - @@ -48,30 +46,56 @@ android:theme="@style/Theme.AfricanFinance" android:usesCleartextTraffic="true" tools:targetApi="31"> + - + android:screenOrientation="portrait" + android:windowSoftInputMode="stateAlwaysHidden|adjustResize"> + - + android:screenOrientation="portrait" + android:windowSoftInputMode="stateAlwaysHidden|adjustResize" /> - + + + + + + + + + + + + + + + + + + = 0) { + if (!TextUtils.isEmpty(notificationExtras)) { + //Apollo.emit(Events.JPUSH_INVITATION_MESSAGE, jpushInvitationNoticeData); + } + if (bind != null) { + bind.unbind(); + } + } + + @Override + public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) { + super.onAliasOperatorResult(context, jPushMessage); + Log.e("onAliasOperatorResult: ", "onAliasOperatorResult"); + } +} diff --git a/app/src/main/java/com/cmx/wanhui/service/MyJpushService.kt b/app/src/main/java/com/cmx/wanhui/service/MyJpushService.kt new file mode 100644 index 0000000..8f3b5e6 --- /dev/null +++ b/app/src/main/java/com/cmx/wanhui/service/MyJpushService.kt @@ -0,0 +1,7 @@ +package com.cmx.wanhui.service + +import cn.jpush.android.service.JCommonService + +class MyJpushService : JCommonService() { + +} \ No newline at end of file diff --git a/app/src/main/java/com/cmx/wanhui/ui/BaseFragment.kt b/app/src/main/java/com/cmx/wanhui/ui/BaseFragment.kt index 0268cc6..b88888d 100644 --- a/app/src/main/java/com/cmx/wanhui/ui/BaseFragment.kt +++ b/app/src/main/java/com/cmx/wanhui/ui/BaseFragment.kt @@ -29,9 +29,8 @@ open class BaseFragment : Fragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + requireActivity().window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR mBaseLoadingDialog = BaseLoadingDialog(activity) - MyUtils.setFullscreen(requireActivity(), false, false) - MyUtils.setAndroidNativeLightStatusBar(requireActivity(), true) mApolloBinder = Apollo.bind(this) } @@ -40,14 +39,14 @@ open class BaseFragment : Fragment() { * 相关属性设置 */ fun setWebView(webView: WebView) { - val webSettings = webView!!.settings + val webSettings = webView.settings webSettings.javaScriptEnabled = true webSettings.cacheMode = WebSettings.LOAD_NO_CACHE webSettings.domStorageEnabled = true webSettings.allowFileAccess = true //文件访问 webSettings.allowFileAccessFromFileURLs = true - webView!!.addJavascriptInterface(AndroidtoJs(), "AndroidtoJs") - webView!!.webViewClient = object : WebViewClient() { + webView.addJavascriptInterface(AndroidtoJs(), "AndroidtoJs") + webView.webViewClient = object : WebViewClient() { override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { super.onPageStarted(view, url, favicon) showDialog() diff --git a/app/src/main/java/com/cmx/wanhui/ui/HomeFragment.java b/app/src/main/java/com/cmx/wanhui/ui/HomeFragment.java index 5938d1f..98bc8a0 100644 --- a/app/src/main/java/com/cmx/wanhui/ui/HomeFragment.java +++ b/app/src/main/java/com/cmx/wanhui/ui/HomeFragment.java @@ -1,6 +1,5 @@ package com.cmx.wanhui.ui; -import static com.cmx.wanhui.constant.Events.SERVER_URL; import android.app.Activity; import android.content.ClipData; @@ -15,30 +14,17 @@ import android.view.View; import android.view.ViewGroup; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; -import android.webkit.WebResourceError; -import android.webkit.WebResourceRequest; -import android.webkit.WebSettings; import android.webkit.WebView; -import android.webkit.WebViewClient; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; -import androidx.lifecycle.ViewModelProvider; -import com.cmx.wanhui.activity.LoginActivity; import com.cmx.wanhui.constant.Events; import com.cmx.wanhui.databinding.FragmentHomeBinding; import com.cmx.wanhui.model.QRBean; -import com.cmx.wanhui.utils.AndroidtoJs; import com.cmx.wanhui.utils.L; -import com.cmx.wanhui.utils.MyUtils; -import com.cmx.wanhui.view.BaseLoadingDialog; -import com.cmx.wanhui.view.ConfirmDialog; import com.google.gson.Gson; import com.lsxiao.apollo.core.Apollo; import com.lsxiao.apollo.core.annotations.Receive; -import com.lsxiao.apollo.core.contract.ApolloBinder; import java.io.File; import java.io.IOException; @@ -133,7 +119,6 @@ public class HomeFragment extends BaseFragment { return imageFile; } - @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode != INPUT_FILE_REQUEST_CODE || mUploadMessage == null) { diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 7f9b9f8..65e1c5e 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -33,7 +33,6 @@ android:hint="请输入用户名" android:paddingStart="10dip" android:singleLine="true" - android:text="wanhui" android:textColorHint="#919191" android:textSize="16sp" /> @@ -52,7 +51,6 @@ android:inputType="textPassword" android:paddingStart="10dip" android:singleLine="true" - android:text="123456" android:textColorHint="#919191" android:textSize="16sp" /> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index d8ac4df..05d378b 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -11,4 +11,6 @@ #ff00be47 #1890FF + #FAFAFA + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index cc4e391..409618e 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -2,9 +2,9 @@