| @@ -6,6 +6,7 @@ | |||||
| <GradleProjectSettings> | <GradleProjectSettings> | ||||
| <option name="delegatedBuild" value="true" /> | <option name="delegatedBuild" value="true" /> | ||||
| <option name="testRunner" value="PLATFORM" /> | <option name="testRunner" value="PLATFORM" /> | ||||
| <option name="disableWrapperSourceDistributionNotification" value="true" /> | |||||
| <option name="distributionType" value="DEFAULT_WRAPPED" /> | <option name="distributionType" value="DEFAULT_WRAPPED" /> | ||||
| <option name="externalProjectPath" value="$PROJECT_DIR$" /> | <option name="externalProjectPath" value="$PROJECT_DIR$" /> | ||||
| <option name="modules"> | <option name="modules"> | ||||
| @@ -21,5 +21,10 @@ | |||||
| <option name="name" value="Google" /> | <option name="name" value="Google" /> | ||||
| <option name="url" value="https://dl.google.com/dl/android/maven2/" /> | <option name="url" value="https://dl.google.com/dl/android/maven2/" /> | ||||
| </remote-repository> | </remote-repository> | ||||
| <remote-repository> | |||||
| <option name="id" value="maven" /> | |||||
| <option name="name" value="maven" /> | |||||
| <option name="url" value="https://jitpack.io" /> | |||||
| </remote-repository> | |||||
| </component> | </component> | ||||
| </project> | </project> | ||||
| @@ -5,12 +5,12 @@ apply plugin: 'kotlin-android' | |||||
| apply plugin: 'kotlin-android-extensions' | apply plugin: 'kotlin-android-extensions' | ||||
| android { | android { | ||||
| compileSdkVersion 29 | |||||
| buildToolsVersion "29.0.3" | |||||
| compileSdkVersion 30 | |||||
| buildToolsVersion "31.0.0 rc1" | |||||
| defaultConfig { | defaultConfig { | ||||
| applicationId "com.yzx.webebook" | applicationId "com.yzx.webebook" | ||||
| minSdkVersion 26 | minSdkVersion 26 | ||||
| targetSdkVersion 29 | |||||
| targetSdkVersion 30 | |||||
| versionCode 2 | versionCode 2 | ||||
| versionName "2.0" | versionName "2.0" | ||||
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||||
| @@ -77,6 +77,6 @@ dependencies { | |||||
| implementation 'com.blankj:utilcodex:1.30.5' | implementation 'com.blankj:utilcodex:1.30.5' | ||||
| implementation 'com.google.code.gson:gson:2.8.6' | implementation 'com.google.code.gson:gson:2.8.6' | ||||
| annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' | annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' | ||||
| implementation 'com.github.AlexLiuSheng:CheckVersionLib:2.4.1_androidx' | |||||
| } | } | ||||
| @@ -3,6 +3,7 @@ package com.yzx.webebook.activity | |||||
| import android.annotation.SuppressLint | import android.annotation.SuppressLint | ||||
| import android.app.Activity | import android.app.Activity | ||||
| import android.app.AlertDialog | import android.app.AlertDialog | ||||
| import android.app.Dialog | |||||
| import android.content.Intent | import android.content.Intent | ||||
| import android.net.http.SslError | import android.net.http.SslError | ||||
| import android.os.Build | import android.os.Build | ||||
| @@ -12,13 +13,18 @@ import android.view.View | |||||
| import android.view.ViewGroup | import android.view.ViewGroup | ||||
| import android.webkit.* | import android.webkit.* | ||||
| import android.widget.LinearLayout | import android.widget.LinearLayout | ||||
| import android.widget.TextView | |||||
| import androidx.annotation.RequiresApi | import androidx.annotation.RequiresApi | ||||
| import com.allenliu.versionchecklib.v2.AllenVersionChecker | |||||
| import com.allenliu.versionchecklib.v2.builder.UIData | |||||
| import com.yzx.webebook.MainActivity | import com.yzx.webebook.MainActivity | ||||
| import com.yzx.webebook.R | import com.yzx.webebook.R | ||||
| import com.yzx.webebook.activity.base.BaseActivity | import com.yzx.webebook.activity.base.BaseActivity | ||||
| import com.yzx.webebook.presenter.base.BasePresenter | import com.yzx.webebook.presenter.base.BasePresenter | ||||
| import com.yzx.webebook.widget.BaseDialog | |||||
| import kotlinx.android.synthetic.main.activity_web.* | import kotlinx.android.synthetic.main.activity_web.* | ||||
| import org.jetbrains.anko.ctx | import org.jetbrains.anko.ctx | ||||
| import org.jetbrains.anko.find | |||||
| import org.jetbrains.anko.startActivity | import org.jetbrains.anko.startActivity | ||||
| import org.jetbrains.anko.toast | import org.jetbrains.anko.toast | ||||
| import org.json.JSONObject | import org.json.JSONObject | ||||
| @@ -55,6 +61,33 @@ class WebActivity : BaseActivity<BasePresenter<*>>() { | |||||
| url = intent?.getStringExtra("link") ?: "https://m.qbjjyyun.net/" | url = intent?.getStringExtra("link") ?: "https://m.qbjjyyun.net/" | ||||
| this.initData() | this.initData() | ||||
| } | } | ||||
| private fun checkVersion(): Unit { | |||||
| val url = | |||||
| "https://filea.oa.qbjjyyun.net/edufile/download?uniqueKey=22de6670beaa78a822ae4a95bdb2c6f5" | |||||
| AllenVersionChecker | |||||
| .getInstance() | |||||
| .downloadOnly( | |||||
| UIData.create() | |||||
| .setTitle("检测到新版本") | |||||
| .setContent("1.优化了笔记的体验\n2.解决了若干已知bug\n") | |||||
| .setDownloadUrl(url) | |||||
| ) | |||||
| .setCustomVersionDialogListener { context, versionBundle -> | |||||
| val dialog = BaseDialog(context, R.style.BaseDialog, R.layout.version_dialog) | |||||
| val title = dialog.find<TextView>(R.id.tv_title) | |||||
| title.text = "检测到新版本" | |||||
| val content = dialog.find<TextView>(R.id.tv_msg) | |||||
| content.text = "1.优化了笔记的体验\n2.解决了若干已知bug\n" | |||||
| dialog.window?.setDimAmount(0.1f) | |||||
| val cancelBtn = dialog.find<View>(R.id.cancel_btn) | |||||
| //cancelBtn.visibility = View.GONE | |||||
| return@setCustomVersionDialogListener dialog | |||||
| } | |||||
| .executeMission(this) | |||||
| } | |||||
| @SuppressLint("SetJavaScriptEnabled") | @SuppressLint("SetJavaScriptEnabled") | ||||
| override fun initView() { | override fun initView() { | ||||
| url = intent?.getStringExtra("link") ?: "https://m.qbjjyyun.net/" | url = intent?.getStringExtra("link") ?: "https://m.qbjjyyun.net/" | ||||
| @@ -170,6 +203,7 @@ class WebActivity : BaseActivity<BasePresenter<*>>() { | |||||
| override fun initData() { | override fun initData() { | ||||
| webView.loadUrl(url) | webView.loadUrl(url) | ||||
| // checkVersion() | |||||
| } | } | ||||
| override fun initPresenter(): BasePresenter<*>? { | override fun initPresenter(): BasePresenter<*>? { | ||||
| @@ -197,12 +231,13 @@ class WebActivity : BaseActivity<BasePresenter<*>>() { | |||||
| override fun onDestroy() { | override fun onDestroy() { | ||||
| super.onDestroy() | super.onDestroy() | ||||
| webView.apply { | webView.apply { | ||||
| webViewClient = null | |||||
| // webViewClient = null | |||||
| webChromeClient = null | webChromeClient = null | ||||
| (parent as ViewGroup).removeView(webView) | (parent as ViewGroup).removeView(webView) | ||||
| removeAllViews() | removeAllViews() | ||||
| destroy() | destroy() | ||||
| } | } | ||||
| AllenVersionChecker.getInstance().cancelAllMission() | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -233,7 +268,7 @@ class WebActivity : BaseActivity<BasePresenter<*>>() { | |||||
| } | } | ||||
| if (requestCode == NoteActivity.REQ_CODE && resultCode == Activity.RESULT_OK) { | if (requestCode == NoteActivity.REQ_CODE && resultCode == Activity.RESULT_OK) { | ||||
| val json = data?.getStringExtra("note_info")?:"" | |||||
| val json = data?.getStringExtra("note_info") ?: "" | |||||
| evaluateJavascript("onImageUploadSuccess", json) | evaluateJavascript("onImageUploadSuccess", json) | ||||
| } | } | ||||
| } | } | ||||
| @@ -273,10 +308,10 @@ class YzxJavascriptInterface(var ctx: Activity) { | |||||
| @JavascriptInterface | @JavascriptInterface | ||||
| fun notePage( | fun notePage( | ||||
| title: String, | title: String, | ||||
| note_info:String, | |||||
| can_add_page:Int=1 | |||||
| note_info: String, | |||||
| can_add_page: Int = 1 | |||||
| ) { | ) { | ||||
| NoteActivity.active(ctx, title, note_info ,can_add_page) | |||||
| NoteActivity.active(ctx, title, note_info, can_add_page) | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -287,9 +322,9 @@ class YzxJavascriptInterface(var ctx: Activity) { | |||||
| @JavascriptInterface | @JavascriptInterface | ||||
| fun notePage( | fun notePage( | ||||
| title: String, | title: String, | ||||
| note_info:String | |||||
| note_info: String | |||||
| ) { | ) { | ||||
| NoteActivity.active(ctx, title, note_info ,1) | |||||
| NoteActivity.active(ctx, title, note_info, 1) | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -0,0 +1,16 @@ | |||||
| package com.yzx.webebook.widget | |||||
| import android.app.Dialog | |||||
| import android.content.Context | |||||
| class BaseDialog(context: Context, themeResId: Int, res: Int) : Dialog(context, themeResId) { | |||||
| private var res: Int = 0 | |||||
| init { | |||||
| setContentView(res) | |||||
| this.res = res | |||||
| setCanceledOnTouchOutside(false) | |||||
| setCancelable(false) | |||||
| window?.setDimAmount(0f) | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,5 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <shape xmlns:android="http://schemas.android.com/apk/res/android"> | |||||
| <corners android:radius="5dp"></corners> | |||||
| <solid android:color="#000"></solid> | |||||
| </shape> | |||||
| @@ -0,0 +1,6 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <shape xmlns:android="http://schemas.android.com/apk/res/android"> | |||||
| <corners android:radius="5dp"></corners> | |||||
| <solid android:color="#fff"></solid> | |||||
| <stroke android:color="#000" android:width="1px"></stroke> | |||||
| </shape> | |||||
| @@ -0,0 +1,80 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:background="@android:color/transparent" | |||||
| android:orientation="vertical"> | |||||
| <LinearLayout | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:orientation="vertical"> | |||||
| <ImageView | |||||
| android:layout_width="300dp" | |||||
| android:layout_height="150dp" | |||||
| android:background="@drawable/custom_bg" | |||||
| android:scaleType="centerCrop" /> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:background="@android:color/white" | |||||
| android:orientation="vertical" | |||||
| android:padding="15dp"> | |||||
| <TextView | |||||
| android:id="@+id/tv_title" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_gravity="center_horizontal" | |||||
| android:layout_marginTop="10dp" | |||||
| android:text="@string/update_title" | |||||
| android:textColor="@android:color/black" | |||||
| android:textSize="13sp" /> | |||||
| <TextView | |||||
| android:id="@+id/tv_msg" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_marginTop="10dp" | |||||
| android:text="@string/updatecontent" | |||||
| android:textColor="#666" | |||||
| android:textSize="12sp" /> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:orientation="horizontal"> | |||||
| <FrameLayout | |||||
| android:id="@+id/cancel_btn" | |||||
| android:layout_width="0dp" | |||||
| android:layout_weight="1" | |||||
| android:layout_marginEnd="15dp" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@id/versionchecklib_version_dialog_cancel" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="35dp" | |||||
| android:layout_marginTop="10dp" | |||||
| android:layout_weight="1" | |||||
| android:background="@drawable/shape_corner_plain" | |||||
| android:text="取消" | |||||
| android:textColor="@android:color/black" /> | |||||
| </FrameLayout> | |||||
| <Button | |||||
| android:id="@id/versionchecklib_version_dialog_commit" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="35dp" | |||||
| android:layout_marginTop="10dp" | |||||
| android:layout_weight="1" | |||||
| android:background="@drawable/shape_corner" | |||||
| android:text="立即升级" | |||||
| android:textColor="@android:color/white" /> | |||||
| </LinearLayout> | |||||
| </LinearLayout> | |||||
| </LinearLayout> | |||||
| </LinearLayout> | |||||
| @@ -1,3 +1,5 @@ | |||||
| <resources> | <resources> | ||||
| <string name="app_name">云智学</string> | <string name="app_name">云智学</string> | ||||
| <string name="update_title">检测到新版本</string> | |||||
| <string name="updatecontent">解决了若干bug</string> | |||||
| </resources> | </resources> | ||||
| @@ -8,5 +8,14 @@ | |||||
| <item name="colorAccent">@color/colorAccent</item> | <item name="colorAccent">@color/colorAccent</item> | ||||
| <item name="android:windowBackground">@color/backgroundColor</item> | <item name="android:windowBackground">@color/backgroundColor</item> | ||||
| </style> | </style> | ||||
| <style name="BaseDialog" parent="android:Theme.Light"> | |||||
| <item name="android:windowFrame">@null</item> | |||||
| <item name="android:windowNoTitle">true</item> | |||||
| <item name="android:windowBackground">@android:color/transparent</item> | |||||
| <item name="android:background">@android:color/transparent</item> | |||||
| <item name="android:windowIsFloating">true</item> | |||||
| <item name="android:windowContentOverlay">@null</item> | |||||
| <item name="android:backgroundDimEnabled">true</item> | |||||
| <item name="android:backgroundDimAmount">0.1</item> | |||||
| </style> | |||||
| </resources> | </resources> | ||||
| @@ -20,7 +20,7 @@ allprojects { | |||||
| repositories { | repositories { | ||||
| google() | google() | ||||
| jcenter() | jcenter() | ||||
| maven { url 'https://jitpack.io' } | |||||
| } | } | ||||
| } | } | ||||