雷云 5 лет назад
Родитель
Сommit
108943aa56
17 измененных файлов: 1108 добавлений и 8 удалений
  1. +2
    -0
      app/build.gradle
  2. +71
    -0
      app/proguard-rules.pro
  3. +1
    -0
      app/src/main/AndroidManifest.xml
  4. +2
    -0
      app/src/main/java/com/yzx/webebook/App.kt
  5. +29
    -8
      app/src/main/java/com/yzx/webebook/MainActivity.kt
  6. +646
    -0
      app/src/main/java/com/yzx/webebook/activity/NoteActivity.kt
  7. +18
    -0
      app/src/main/java/com/yzx/webebook/activity/WebActivity.kt
  8. +7
    -0
      app/src/main/java/com/yzx/webebook/model/Note.kt
  9. +6
    -0
      app/src/main/res/drawable/save_bg.xml
  10. +22
    -0
      app/src/main/res/layout/activity_book.xml
  11. +5
    -0
      app/src/main/res/layout/activity_main.xml
  12. +206
    -0
      app/src/main/res/layout/activity_note.xml
  13. Двоичные данные
      app/src/main/res/mipmap-xhdpi/ic_book_add.png
  14. Двоичные данные
      app/src/main/res/mipmap-xhdpi/ic_book_init.png
  15. Двоичные данные
      app/src/main/res/mipmap-xhdpi/ic_page_left.png
  16. Двоичные данные
      app/src/main/res/mipmap-xhdpi/ic_page_right.png
  17. +93
    -0
      proguard-rules.pro

+ 2
- 0
app/build.gradle Просмотреть файл

@@ -74,6 +74,8 @@ dependencies {
implementation files('libs/wenote.jar')
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.lzy.net:okgo:3.0.4'
implementation 'com.blankj:utilcodex:1.30.5'
implementation 'com.google.code.gson:gson:2.8.6'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'




+ 71
- 0
app/proguard-rules.pro Просмотреть файл

@@ -19,3 +19,74 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-flattenpackagehierarchy
-allowaccessmodification
-keepattributes Exceptions,InnerClasses,Signature,SourceFile,LineNumberTable
-dontskipnonpubliclibraryclassmembers
-ignorewarnings
#kotlin
-keep class kotlin.Metadata { *; }
-dontwarn kotlin.**
-keepclassmembers class **$WhenMappings {
<fields>;
}
-keepclassmembers class kotlin.Metadata {
public <methods>;
}
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep class **.R$* {*;}
-keepclassmembers enum * { *;}




#Gson
-keepclassmembers public class com.google.gson.**
-keepclassmembers public class com.google.gson.** {public private protected *;}
-keepclassmembers public class com.project.mocha_patient.login.SignResponseData { private *; }
-keepclassmembers class sun.misc.Unsafe { *; }
-keep @interface com.google.gson.annotations.SerializedName
-keepclassmembers class * {
@com.google.gson.annotations.SerializedName <fields>;
}

#bean
-keep class com.yzx.webebook.model.** { *; }
-keep class com.yzx.webebook.model.Note { *; }
-keep class com.yzx.webebook.model.UploadBean { *; }
-keep class com.yzx.webebook.model.UploadContent { *; }

-keep class **$Properties {*;}

#Glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
# for DexGuard only
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
-dontwarn com.bumptech.glide.**


# ProGuard configurations for Bugtags
-keepattributes LineNumberTable,SourceFile
-dontwarn com.bugtags.library.**
-dontwarn io.bugtags.**
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient

+ 1
- 0
app/src/main/AndroidManifest.xml Просмотреть файл

@@ -21,6 +21,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.NoteActivity"></activity>
<activity
android:name=".activity.WebActivity"
android:configChanges="orientation|keyboard"


+ 2
- 0
app/src/main/java/com/yzx/webebook/App.kt Просмотреть файл

@@ -1,6 +1,7 @@
package com.yzx.webebook

import android.app.Application
import com.blankj.utilcode.util.Utils
import com.lzy.okgo.OkGo

class App: Application() {
@@ -8,5 +9,6 @@ class App: Application() {
override fun onCreate() {
super.onCreate()
OkGo.getInstance().init(this)
Utils.init(this)
}
}

+ 29
- 8
app/src/main/java/com/yzx/webebook/MainActivity.kt Просмотреть файл

@@ -3,8 +3,10 @@ package com.yzx.webebook
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.text.TextUtils
import com.bumptech.glide.Glide
import com.yzx.webebook.activity.BookActivity
import com.yzx.webebook.activity.NoteActivity
import com.yzx.webebook.activity.WebActivity
import com.yzx.webebook.activity.base.BaseActivity
import com.yzx.webebook.presenter.base.BasePresenter
@@ -36,10 +38,20 @@ class MainActivity : BaseActivity<BasePresenter<*>>() {
WebActivity.active(this, editText.text.toString())
}
btn4.setOnClickListener {
BookActivity.active(this,"教育云空间","f04be754f6cb3f6168f582403a514c39","filec","",1,1)
BookActivity.active(
this,
"教育云空间",
"f04be754f6cb3f6168f582403a514c39",
"filec",
"",
1,
1
)
}
btn5.setOnClickListener {
BookActivity.active(this,"教育云空间(无图)","","","",2,2)
// BookActivity.active(this,"教育云空间(无图)","","","",2,2)
val json =""
NoteActivity.active(this, "测试笔记写字", json)
}

/*OkGo.post<String>("https://fileupload.oa.qbjjyyun.net/edufile/fileUpload")
@@ -75,16 +87,25 @@ class MainActivity : BaseActivity<BasePresenter<*>>() {
override fun initPresenter(): BasePresenter<*>? = null

@SuppressLint("SetTextI18n")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(requestCode==BookActivity.REQ_CODE&&resultCode== Activity.RESULT_OK){
if (requestCode == BookActivity.REQ_CODE && resultCode == Activity.RESULT_OK) {
val mKey = data?.getStringExtra("key")
val mIdentity = data?.getStringExtra("identity")

val url = "https://$mIdentity.oa.qbjjyyun.net/edufile/imageView?uniqueKey=$mKey"
Glide.with(this)
.load(url)
.into(testImageView)
if(!TextUtils.isEmpty(mKey)&&!TextUtils.isEmpty(mIdentity)){

val url = "https://$mIdentity.oa.qbjjyyun.net/edufile/imageView?uniqueKey=$mKey"
Glide.with(this)
.load(url)
.into(testImageView)
}
val json = data?.getStringExtra("note_info")?:""
backInfo.text = json
}
if (requestCode == NoteActivity.REQ_CODE && resultCode == Activity.RESULT_OK) {
val json = data?.getStringExtra("note_info")?:""
backInfo.text = json
}
}
}

+ 646
- 0
app/src/main/java/com/yzx/webebook/activity/NoteActivity.kt Просмотреть файл

@@ -0,0 +1,646 @@
package com.yzx.webebook.activity

import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.ActivityInfo
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.os.Handler
import android.os.Message
import android.text.TextUtils
import android.util.Log
import android.view.KeyEvent
import android.view.View
import android.widget.Toast
import com.blankj.utilcode.util.FileUtils
import com.blankj.utilcode.util.GsonUtils
import com.blankj.utilcode.util.ImageUtils
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.target.Target
import com.bumptech.glide.request.transition.Transition
import com.google.gson.Gson
import com.lzy.okgo.OkGo
import com.lzy.okgo.callback.StringCallback
import com.lzy.okgo.model.Response
import com.wetao.note.NotePageInfo
import com.wetao.note.WeNoteView
import com.wetao.note.WePoint
import com.yzx.webebook.R
import com.yzx.webebook.activity.base.BaseActivity
import com.yzx.webebook.model.Note
import com.yzx.webebook.presenter.base.BasePresenter
import kotlinx.android.synthetic.main.activity_note.*
import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast
import org.json.JSONArray
import org.json.JSONObject
import java.io.File
import java.util.*
import kotlin.system.exitProcess


/**
* 笔记页面
*/
class NoteActivity : BaseActivity<BasePresenter<*>>() {

private val mBGDrawableList = intArrayOf(
R.drawable.background0,
R.drawable.background1,
R.drawable.background2,
R.drawable.background3,
R.drawable.background4,
R.drawable.background5,
R.drawable.background6,
R.drawable.background7,
R.drawable.background8,
R.drawable.background9,
R.drawable.background10
)
private var mBgId = 0
private var mWePointList = mutableListOf<WePoint>()
private var mHandler = Handler()
private var mScreenH = 0
private var mScreenW = 0
private val MSG_SAVE_END = 2001
private var mNotePageInfo: NotePageInfo? = null
private var notList = mutableListOf<Note>()
private var currKey = ""
private var currIndex = 0
val TAG = "NoteActivity"


companion object {
const val NOTE_FOLDER_DIR = "/mnt/sdcard/ebook/"
const val REQ_CODE = 0x98
fun active(act: Activity, title: String, noteInfo: String) {
act.startActivityForResult<NoteActivity>(
REQ_CODE,
"note_info" to noteInfo,
"title" to title
)
}
}

override val inflateId: Int
get() = R.layout.activity_note

override fun initView() {
checkPermission()
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT

mScreenH = resources.displayMetrics.heightPixels
mScreenW = resources.displayMetrics.widthPixels

//背景
new_init.setOnClickListener {
note_view.setEnable(false)
mBgId++
if (mBgId >= mBGDrawableList.size) {
mBgId = 0
}
note_view.updateBackground(mBGDrawableList[mBgId])
val note = notList[currIndex]
note.BGid = mBgId
}
//清除
new_clear.setOnClickListener {
note_view.clear();
}
//笔
pen.setOnClickListener {
if (note_view.isEraserEnable) {
note_view.isEraserEnable = false
pen.setCompoundDrawablesWithIntrinsicBounds(
0,
R.mipmap.ic_book_pen_select,
0,
0
)
new_eraser.setCompoundDrawablesWithIntrinsicBounds(
0,
R.mipmap.ic_book_rubber,
0,
0
)
}
}
//橡皮
new_eraser.setOnClickListener {
if (!note_view.isEraserEnable) {
note_view.isEraserEnable = true
pen.setCompoundDrawablesWithIntrinsicBounds(0, R.mipmap.ic_book_pen, 0, 0)
new_eraser.setCompoundDrawablesWithIntrinsicBounds(
0,
R.mipmap.ic_book_rubber_select,
0,
0
)
}
}
//加纸
new_add.setOnClickListener {
notList.add(Note())
tv_page_index.text = "${currIndex + 1}/${notList.size}"
indexBox.visibility = if (notList.size > 1) {
View.VISIBLE
} else {
View.GONE
}
}
//title
btnBack.setOnClickListener { onBackPressed() }
titleTv.text = intent.getStringExtra("title")

//初始化笔记
mWePointList.clear()

//屏幕初始化
val filter = IntentFilter()
filter.addAction(SCREEN_ON)
filter.addAction(SCREEN_OFF)
if (mReceiver != null) {
registerReceiver(mReceiver, filter)
}

btnPre.setOnClickListener {
if (currIndex - 1 >= 0) {
ImageUtils.save(
note_view.currentNoteBitmap,
"${NOTE_FOLDER_DIR}/${currKey}.png",
Bitmap.CompressFormat.PNG
)
loadImage(currIndex - 1)
}
}

btnNext.setOnClickListener {
if (currIndex + 1 < notList.size) {
ImageUtils.save(
note_view.currentNoteBitmap,
"${NOTE_FOLDER_DIR}/${currKey}.png",
Bitmap.CompressFormat.PNG
)
loadImage(currIndex + 1)
}
}

saveBtn.setOnClickListener {
saveTip.visibility = View.VISIBLE
saveTip.text = "保存中..."
ImageUtils.save(
note_view.currentNoteBitmap,
"${NOTE_FOLDER_DIR}/${currKey}.png",
Bitmap.CompressFormat.PNG
)
save(0)
}
}


@SuppressLint("SetTextI18n")
override fun initData() {
val json = intent.getStringExtra("note_info")
notList.clear()
if (!TextUtils.isEmpty(json)) {
val jsonArray = JSONArray(json)
if (jsonArray.length() > 0) {
for (index in 0 until jsonArray.length()) {
val jsonObj: JSONObject? = jsonArray?.opt(index) as JSONObject
val identity = jsonObj?.getString("identity");
val key = jsonObj?.getString("key")
val bgId = jsonObj?.getInt("BGid")
val note = Note()
note.BGid = bgId ?: 0
note.identity = identity ?: ""
note.key = key ?: ""
notList.add(note)
}
} else {
notList.add(Note())
}
} else {
notList.add(Note())
}

Log.d(TAG, "初始化开始note_view")
note_view.post {
Log.d(TAG, "初始化开始note_view.post")
mHandler.post(mRunnable)
}

tv_page_index.text = "1/${notList.size}"
indexBox.visibility = if (notList.size > 1) {
View.VISIBLE
} else {
View.GONE
}
}

private fun loadImage(index: Int = 0) {
val note = notList[index]
val identity = note.identity
val key = note.key
val bgId = note.BGid
if (TextUtils.isEmpty(key)) {
note.key = Date().time.toString()
note_view.showExistPage(
"",
mBGDrawableList[0]
)
currKey = note.key
currIndex = index
mBgId = bgId
tv_page_index.text = "${index + 1}/${notList.size}"
return
}
val path = "${NOTE_FOLDER_DIR}/${key}.png"
if (FileUtils.isFileExists(path)) {
if (mNotePageInfo == null) {
return
}
mBgId = bgId ?: 0
note_view.showExistPage(
path,
mBGDrawableList[mBgId]
)
currKey = key
currIndex = index

tv_page_index.text = "${index + 1}/${notList.size}"
} else {
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(identity)) {
saveTip.visibility = View.VISIBLE
saveTip.text = "加载中..."
val url = "https://${identity}.oa.qbjjyyun.net/edufile/imageView?uniqueKey=${key}"
val customTarget: CustomTarget<Drawable> = object : CustomTarget<Drawable>() {

override fun onLoadCleared(placeholder: Drawable?) {}
override fun onLoadFailed(errorDrawable: Drawable?) {
toast("文档加载失败!")
saveTip.visibility = View.GONE
}

override fun onResourceReady(
resource: Drawable,
transition: Transition<in Drawable>?
) {
val bmp = ImageUtils.drawable2Bitmap(resource)

ImageUtils.save(bmp, path, Bitmap.CompressFormat.PNG)
if (FileUtils.isFileExists(path)) {
if (mNotePageInfo == null) {
return
}
mBgId = bgId ?: 0
note_view.showExistPage(
path,
mBGDrawableList[mBgId]
)
currKey = key
currIndex = index

tv_page_index.text = "${index + 1}/${notList.size}"
}
saveTip.visibility = View.GONE
}
}
Glide.with(this)
.load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.override(
Target.SIZE_ORIGINAL,
Target.SIZE_ORIGINAL
)
.into(customTarget)
} else {
note.key = Date().time.toString()
note_view.showExistPage(
"",
mBGDrawableList[0]
)
currKey = note.key
currIndex = index
mBgId = bgId ?: 0
tv_page_index.text = "${index + 1}/${notList.size}"
}
}
}

private fun save(index: Int) {
val item = notList[index]
val path = "${NOTE_FOLDER_DIR}/${item.key}.png"

if (!TextUtils.isEmpty(item.key)) {
if (FileUtils.isFileExists(path)) { //存在就上传
OkGo.post<String>("https://fileupload.oa.qbjjyyun.net/edufile/fileUpload")
.tag(this)
.params("token", "0fc58a8df03c46d3f85b1047c4693cf6")
.params("user", Date().time)
.params("file", File(path))
.execute(object : StringCallback() {
override fun onSuccess(response: Response<String>) {
try {
val json = response.body()
Log.d("onSuccess", response.body())
val jsonObject = JSONObject(json)
val content = jsonObject.optString("content")
Log.d("onSuccess,content", content)
val contentObject = JSONObject(content)
val key = contentObject.optString("key")
val identity = contentObject.optString("identity")
Log.d("onSuccess,identity", identity)
Log.d("onSuccess,key", key)
item.key = key
item.identity = identity
FileUtils.copy(path, "${NOTE_FOLDER_DIR}/${key}.png")
if (index == notList.size - 1) {
saveTip.visibility = View.GONE
toast("保存成功!")
backToH5()
} else {
save(index + 1)
}
} catch (e: Exception) {
}
}

override fun onError(response: Response<String>) {
super.onError(response)
toast("保存失败!")
}

override fun onFinish() {
super.onFinish()
saveTip.visibility = View.GONE
}
})
} else {
if (index == notList.size - 1) {
saveTip.visibility = View.GONE
toast("保存成功!")
backToH5()
} else {
save(index + 1)
}
}

} else {
if (index == notList.size - 1) {
saveTip.visibility = View.GONE
toast("保存成功!")
backToH5()
} else {
save(index + 1)
}
}

}

private fun backToH5() {
val intent = Intent()
Log.d(TAG + "--------1------->", copyList().toString())
Log.d(TAG + "---------2------>", Gson().toJson(copyList()))
Log.d(TAG + "---------3------>", GsonUtils.toJson(notList))
intent.putExtra("note_info", GsonUtils.toJson(copyList()))
setResult(Activity.RESULT_OK, intent)
onBackPressed()
}

private fun copyList(): MutableList<Note> {
val list = mutableListOf<Note>()
notList.forEach {
if(!TextUtils.isEmpty(it.key)&&!TextUtils.isEmpty(it.identity)){
val item = Note()
item.key = it.key
item.identity = it.identity
item.BGid = it.BGid
list.add(item)
}
}
return list
}

data class CopyNote(val key: String, val identity: String, val BGid: Int)

override fun initPresenter(): BasePresenter<*>? = null

private fun checkPermission() {
var isGranted = true
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
//如果没有写sd卡权限
isGranted = false
}
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
isGranted = false
}
Log.i("cbs", "isGranted == $isGranted")
if (!isGranted) {
requestPermissions(
arrayOf(
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
),
102
)
}
}

override fun onResume() {
note_view.setEnable(true)
note_view.setSleepMode(true)
super.onResume()
}

override fun onPause() {
note_view.setEnable(false)
super.onPause()
}

override fun onDestroy() {
//mView.exitView();
mHandler.removeCallbacks(mRunnable)
note_view.exitNative()
if (mReceiver != null) {
unregisterReceiver(mReceiver)
mReceiver = null
}
super.onDestroy()
}

override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK) {
note_view.exitNative()
if (mReceiver != null) {
unregisterReceiver(mReceiver)
mReceiver = null
}
finish()
return true
}
return super.onKeyDown(keyCode, event)
}

val SCREEN_ON = "android.intent.action.SCREEN_ON"
val SCREEN_OFF = "android.intent.action.SCREEN_OFF"
private var mReceiver: BroadcastReceiver? = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
// 屏幕唤醒
if (SCREEN_ON == intent.action) {
note_view.setSleepMode(true)
} else if (SCREEN_OFF == intent.action) {
note_view.setSleepMode(true)
}
}
}

private val mRunnable: Runnable = object : Runnable {
override fun run() {
Log.d(TAG, "初始化开始-------------》");
var count = 0
while (note_view.height <= 0) {
try {
Thread.sleep(50)
} catch (e: InterruptedException) {
e.printStackTrace()
}
if (count++ > 40) {
Log.d(TAG, "Flash test : ++++++++ removeCallbacks");
mHandler.removeCallbacks(this)
exitProcess(0)
}
}
//note_view.initNative(new Rect(mScreenW, mScreenH - note_view.getHeight(), 0, mScreenH), SAVE_PIC_PATH);
Log.d(
TAG,
"Flash test : ++++++++ mView.getHeight() = " + note_view.height + ", count = " + count
);
note_view.initNative(
Rect(
mScreenW,
mScreenH - note_view.height,
0,
mScreenH
)
)
note_view.setTouchEventHander(mPointHandler)
Log.d(TAG, "Flash test : ++++++ mRunnable() start loader notepageinfo");
if (mNotePageInfo == null) {
mNotePageInfo = getNotePageInfo(NOTE_FOLDER_DIR)
}
if (mNotePageInfo == null) {
Log.d(TAG, "Flash test : +++++ no note, so init a page");
initPage()
}
initNoteView()
loadImage(0)

Log.d(TAG, "初始化结束-------------》");
}
}

private fun initNoteView() {
//写字板初始化
note_view.background = null
note_view.penWidth = 3
note_view.isEraserEnable = false
note_view.eraserWidth = 20
}

override fun finish() {
note_view.exitNative()
if (mReceiver != null) {
unregisterReceiver(mReceiver)
mReceiver = null
}
super.finish()
}

override fun onBackPressed() {
note_view.exitNative()
if (mReceiver != null) {
unregisterReceiver(mReceiver)
mReceiver = null
}
super.onBackPressed()
}

private fun initPage(): Boolean {
var file = File(NOTE_FOLDER_DIR)
if (!file.exists()) {
if (!FileUtils.createOrExistsDir(file)) {
return false
}
}
var notePath: String? = null
file = File("$NOTE_FOLDER_DIR/${currKey}.png")
if (file.exists()) {
notePath = "$NOTE_FOLDER_DIR/${currKey}.png"
}
mNotePageInfo = NotePageInfo(notePath, mBgId)
return true
}

private fun loadOldPage() {
if (mNotePageInfo == null) {
return
}
mBgId = mNotePageInfo?.drwId ?: 0
note_view.showExistPage(
mNotePageInfo?.notePath,
mBGDrawableList[mBgId]
)
}

//从笔记文件夹中读取当前笔记的页面信息
private fun getNotePageInfo(path: String): NotePageInfo? {

var file = File(path)
if (!file.exists()) {
return null
}
file.listFiles() ?: return null
val info = NotePageInfo(null, 0)
val notePath = "$path/${currKey}.png"
file = File(notePath)
if (file.exists()) {
info.notePath = notePath
}
info.drwId = 0 //Integer.parseInt(drwId);
return info
}

private val mPointHandler: Handler = @SuppressLint("HandlerLeak")
object : Handler() {
override fun handleMessage(msg: Message) {
val what = msg.what
//同步获取的笔记点坐标信息msg
if (what == WeNoteView.TOUCH_EVENT) {
val point = msg.obj as WePoint
mWePointList.add(point)
}

//保存笔记结束msg
if (what == MSG_SAVE_END) {
val status = msg.arg1
if (status > 0) { //保存成功
Toast.makeText(applicationContext, "保存成功!", Toast.LENGTH_SHORT).show();
} else { //保存失败
Toast.makeText(applicationContext, "保存失败!", Toast.LENGTH_SHORT)
.show();
}
}
}
}
}

+ 18
- 0
app/src/main/java/com/yzx/webebook/activity/WebActivity.kt Просмотреть файл

@@ -231,6 +231,11 @@ class WebActivity : BaseActivity<BasePresenter<*>>() {
obj.put("type", data?.getIntExtra("type", 1))
evaluateJavascript("onImageUploadSuccess", obj.toString())
}

if (requestCode == NoteActivity.REQ_CODE && resultCode == Activity.RESULT_OK) {
val json = data?.getStringExtra("note_info")?:""
evaluateJavascript("onImageUploadSuccess", json)
}
}

}
@@ -259,6 +264,19 @@ class YzxJavascriptInterface(var ctx: Activity) {
BookActivity.active(ctx, title, key, identity, name, index, type)
}

/**
* 跳转到笔记页面
* @param title 展示的title
* @param note_info 笔记得json,新的笔记 传"" ,老的笔记 传 [{"BGid":0,"identity":"fileb","key":"a92511a457cdc444bb274e5dee29c487"}]
*/
@JavascriptInterface
fun notePage(
title: String,
note_info:String
) {
NoteActivity.active(ctx, title, note_info)
}

/**
* 提示
*/


+ 7
- 0
app/src/main/java/com/yzx/webebook/model/Note.kt Просмотреть файл

@@ -0,0 +1,7 @@
package com.yzx.webebook.model

class Note {
var key:String = ""
var identity:String = ""
var BGid:Int = 0
}

+ 6
- 0
app/src/main/res/drawable/save_bg.xml Просмотреть файл

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#33000000"/>
<stroke android:color="#000" android:width="@dimen/d_1"/>
<corners android:radius="@dimen/d_5"/>
</shape>

+ 22
- 0
app/src/main/res/layout/activity_book.xml Просмотреть файл

@@ -159,6 +159,28 @@
android:textColor="#000"
android:paddingVertical="10dp"/>

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/new_init"
android:layout_width="118px"
android:layout_height="match_parent"
android:text="样式"
android:textAlignment="center"
android:drawableTop="@mipmap/ic_book_init"
android:drawablePadding="5dp"
android:textColor="#000"
android:paddingVertical="10dp"/>

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/new_add"
android:layout_width="118px"
android:layout_height="match_parent"
android:text="加纸"
android:textAlignment="center"
android:drawableTop="@mipmap/ic_book_add"
android:drawablePadding="5dp"
android:textColor="#000"
android:paddingVertical="10dp"/>

<Button
android:id="@+id/delete"
android:layout_width="0dp"


+ 5
- 0
app/src/main/res/layout/activity_main.xml Просмотреть файл

@@ -95,4 +95,9 @@
android:adjustViewBounds="true"
android:visibility="visible"
android:scaleType="fitXY"/>

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/backInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.appcompat.widget.LinearLayoutCompat>

+ 206
- 0
app/src/main/res/layout/activity_note.xml Просмотреть файл

@@ -0,0 +1,206 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffffff"
android:orientation="vertical">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="@dimen/title_height"
android:background="@color/white">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/btnBack"
android:layout_width="@dimen/title_height"
android:layout_height="@dimen/title_height"
android:background="?attr/selectableItemBackground"
android:scaleType="centerInside"
android:src="@mipmap/ic_back_def" />

<ImageView
android:id="@+id/btnClose"
android:layout_width="@dimen/title_height"
android:layout_height="@dimen/title_height"
android:layout_toEndOf="@+id/btnBack"
android:background="?attr/selectableItemBackground"
android:scaleType="centerInside"
android:src="@mipmap/ic_close"
android:visibility="gone" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/titleTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginStart="96dp"
android:layout_marginEnd="96dp"
android:gravity="center"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="@dimen/title_text_size" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/saveBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="@drawable/btn_select"
android:paddingHorizontal="15dp"
android:drawableLeft="@mipmap/icon_save_btn"
android:drawablePadding="5dp"
android:textSize="@dimen/title_text_size"
android:text="保存" />


<ProgressBar
android:id="@+id/progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:max="100"
android:progress="0"
android:progressDrawable="@drawable/progress_horizontal"
android:visibility="visible" />

<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_alignParentBottom="true"
android:background="#000"/>
</RelativeLayout>
</com.google.android.material.appbar.AppBarLayout>

<LinearLayout
android:id="@+id/bottom_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:divider="@drawable/linearlayout_vertical_divider"
android:showDividers="middle|end"
android:orientation="horizontal">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/pen"
android:layout_width="118px"
android:layout_height="match_parent"
android:text="笔"
android:textAlignment="center"
android:drawableTop="@mipmap/ic_book_pen_select"
android:drawablePadding="5dp"
android:textColor="#000"
android:paddingVertical="10dp"/>

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/new_eraser"
android:layout_width="118px"
android:layout_height="match_parent"
android:text="橡皮"
android:textAlignment="center"
android:drawableTop="@mipmap/ic_book_rubber"
android:drawablePadding="5dp"
android:textColor="#000"
android:paddingVertical="10dp"/>

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/new_clear"
android:layout_width="118px"
android:layout_height="match_parent"
android:text="清除"
android:textAlignment="center"
android:drawableTop="@mipmap/ic_book_clear"
android:drawablePadding="5dp"
android:textColor="#000"
android:paddingVertical="10dp"/>

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/new_init"
android:layout_width="118px"
android:layout_height="match_parent"
android:text="样式"
android:textAlignment="center"
android:drawableTop="@mipmap/ic_book_init"
android:drawablePadding="5dp"
android:textColor="#000"
android:paddingVertical="10dp"/>

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/new_add"
android:layout_width="118px"
android:layout_height="match_parent"
android:text="加纸"
android:textAlignment="center"
android:drawableTop="@mipmap/ic_book_add"
android:drawablePadding="5dp"
android:textColor="#000"
android:paddingVertical="10dp"/>

<androidx.appcompat.widget.AppCompatTextView
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="match_parent"
android:textAlignment="center"
android:drawablePadding="5dp"
android:textColor="#000"
android:paddingVertical="10dp"/>
<LinearLayout
android:id="@+id/indexBox"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center">
<ImageView
android:id="@+id/btnPre"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@mipmap/ic_page_left"
android:paddingHorizontal="@dimen/d_15"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_page_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1/3"
android:gravity="center"
android:drawablePadding="5dp"
android:textColor="#000"
android:layout_gravity="center_vertical"
android:paddingVertical="10dp"/>
<ImageView
android:id="@+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@mipmap/ic_page_right"
android:paddingHorizontal="@dimen/d_15"/>
</LinearLayout>
</LinearLayout>

<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ff000000" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.wetao.note.WeNoteView
android:id="@+id/note_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffffff" />

<TextView
android:id="@+id/saveTip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="保存中..."
android:padding="@dimen/d_10"
android:textColor="@color/white"
android:background="@drawable/save_bg"
android:layout_centerInParent="true"
android:visibility="gone"/>
</RelativeLayout>
</LinearLayout>

Двоичные данные
app/src/main/res/mipmap-xhdpi/ic_book_add.png Просмотреть файл

До После
Ширина: 32  |  Высота: 32  |  Размер: 640 B

Двоичные данные
app/src/main/res/mipmap-xhdpi/ic_book_init.png Просмотреть файл

До После
Ширина: 32  |  Высота: 32  |  Размер: 309 B

Двоичные данные
app/src/main/res/mipmap-xhdpi/ic_page_left.png Просмотреть файл

До После
Ширина: 36  |  Высота: 36  |  Размер: 651 B

Двоичные данные
app/src/main/res/mipmap-xhdpi/ic_page_right.png Просмотреть файл

До После
Ширина: 36  |  Высота: 36  |  Размер: 611 B

+ 93
- 0
proguard-rules.pro Просмотреть файл

@@ -0,0 +1,93 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-flattenpackagehierarchy
-allowaccessmodification
-keepattributes Exceptions,InnerClasses,Signature,SourceFile,LineNumberTable
-dontskipnonpubliclibraryclassmembers
-ignorewarnings
#kotlin
-keep class kotlin.Metadata { *; }
-dontwarn kotlin.**
-keepclassmembers class **$WhenMappings {
<fields>;
}
-keepclassmembers class kotlin.Metadata {
public <methods>;
}
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep class **.R$* {*;}
-keepclassmembers enum * { *;}




#Gson
-keepclassmembers public class com.google.gson.**
-keepclassmembers public class com.google.gson.** {public private protected *;}
-keepclassmembers public class com.project.mocha_patient.login.SignResponseData { private *; }
-keepclassmembers class sun.misc.Unsafe { *; }
-keep @interface com.google.gson.annotations.SerializedName
-keepclassmembers class * {
@com.google.gson.annotations.SerializedName <fields>;
}

#bean
-keep class com.yzx.webebook.model.** { *; }
-keep class com.yzx.webebook.model.Note { *; }
-keep class com.yzx.webebook.model.ac { *; }
-keep class com.yzx.webebook.model.UploadBean { *; }
-keep class com.yzx.webebook.model.UploadContent { *; }

-keep class **$Properties {*;}

#Glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
# for DexGuard only
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
-dontwarn com.bumptech.glide.**


# ProGuard configurations for Bugtags
-keepattributes LineNumberTable,SourceFile
-dontwarn com.bugtags.library.**
-dontwarn io.bugtags.**
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient

Загрузка…
Отмена
Сохранить