From 8dc6d2dd2d0c3f4f906f65ab37a63c664983d5fc Mon Sep 17 00:00:00 2001 From: Wenbin Date: Sun, 8 Sep 2019 14:22:09 +0800 Subject: [PATCH] Enable multiple ARE instances in one page --- ARE/app/build.gradle | 5 +- ARE/app/src/main/AndroidManifest.xml | 31 ++- .../are/demo/ARE_MultiInstanceActivity.kt | 31 +++ .../com/chinalwb/are/demo/IndexActivity.java | 3 + .../res/layout/activity_are__full_bottom.xml | 1 + .../res/layout/activity_are__min_bottom.xml | 1 + .../layout/activity_are__multi_instance.xml | 119 +++++++++++ .../src/main/res/layout/activity_index.xml | 7 + ARE/app/src/main/res/values/colors.xml | 5 + .../java/com/chinalwb/are/AREditText.java | 189 ++++++------------ .../main/java/com/chinalwb/are/AREditor.java | 47 ++++- .../are/styles/ARE_ABS_Dynamic_Style.java | 4 - .../are/styles/ARE_ABS_FreeStyle.java | 29 +-- .../chinalwb/are/styles/ARE_ABS_Style.java | 19 +- .../chinalwb/are/styles/ARE_Alignment.java | 4 +- .../java/com/chinalwb/are/styles/ARE_At.java | 10 +- .../are/styles/ARE_BackgroundColor.java | 15 +- .../com/chinalwb/are/styles/ARE_Bold.java | 12 +- .../com/chinalwb/are/styles/ARE_Emoji.java | 14 +- .../chinalwb/are/styles/ARE_FontColor.java | 24 +-- .../com/chinalwb/are/styles/ARE_FontSize.java | 13 +- .../com/chinalwb/are/styles/ARE_Fontface.java | 5 +- .../java/com/chinalwb/are/styles/ARE_Hr.java | 8 +- .../chinalwb/are/styles/ARE_IndentLeft.java | 7 +- .../chinalwb/are/styles/ARE_IndentRight.java | 6 +- .../com/chinalwb/are/styles/ARE_Italic.java | 21 +- .../com/chinalwb/are/styles/ARE_Link.java | 12 +- .../chinalwb/are/styles/ARE_ListBullet.java | 4 +- .../chinalwb/are/styles/ARE_ListNumber.java | 4 +- .../com/chinalwb/are/styles/ARE_Quote.java | 1 - .../are/styles/ARE_Strikethrough.java | 15 +- .../chinalwb/are/styles/ARE_Subscript.java | 7 + .../chinalwb/are/styles/ARE_Superscript.java | 7 + .../chinalwb/are/styles/ARE_Underline.java | 22 +- .../are/styles/toolbar/ARE_Toolbar.java | 64 +++--- .../toolitems/styles/ARE_Style_Alignment.java | 3 +- .../styles/toolitems/styles/ARE_Style_At.java | 7 +- .../toolitems/styles/ARE_Style_FontColor.java | 5 + .../toolitems/styles/ARE_Style_FontSize.java | 5 + .../styles/toolitems/styles/ARE_Style_Hr.java | 6 - .../toolitems/styles/ARE_Style_Link.java | 13 +- .../styles/ARE_Style_ListBullet.java | 11 +- .../toolitems/styles/ARE_Style_Subscript.java | 6 + .../styles/ARE_Style_Superscript.java | 6 + ARE/are/src/main/res/layout/are_toolbar.xml | 1 + ARE/are/src/main/res/values/attrs.xml | 1 + ARE/build.gradle | 8 +- ARE/local.properties | 7 +- 48 files changed, 507 insertions(+), 338 deletions(-) create mode 100644 ARE/app/src/main/java/com/chinalwb/are/demo/ARE_MultiInstanceActivity.kt create mode 100644 ARE/app/src/main/res/layout/activity_are__multi_instance.xml diff --git a/ARE/app/build.gradle b/ARE/app/build.gradle index ff52219..492fccd 100644 --- a/ARE/app/build.gradle +++ b/ARE/app/build.gradle @@ -1,4 +1,6 @@ apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 26 @@ -21,6 +23,7 @@ dependencies { implementation 'com.android.support:design:27.1.1' // implementation 'com.android.support:appcompat-v7:26.1.0' implementation project(':are') - implementation 'com.github.bumptech.glide:glide:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.9.0' // implementation 'com.github.chinalwb:are:0.1.6' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } diff --git a/ARE/app/src/main/AndroidManifest.xml b/ARE/app/src/main/AndroidManifest.xml index 72c0ef7..dbd0ab0 100644 --- a/ARE/app/src/main/AndroidManifest.xml +++ b/ARE/app/src/main/AndroidManifest.xml @@ -13,13 +13,15 @@ - + @@ -36,19 +38,28 @@ + android:label="@string/title_activity_are__full_bottom" + android:windowSoftInputMode="adjustResize" /> + android:label="@string/title_activity_are__full_top" + android:windowSoftInputMode="adjustResize" /> - - - + android:label="@string/title_activity_are__min_bottom" + android:windowSoftInputMode="adjustResize" /> + + + \ No newline at end of file diff --git a/ARE/app/src/main/java/com/chinalwb/are/demo/ARE_MultiInstanceActivity.kt b/ARE/app/src/main/java/com/chinalwb/are/demo/ARE_MultiInstanceActivity.kt new file mode 100644 index 0000000..e4a7b24 --- /dev/null +++ b/ARE/app/src/main/java/com/chinalwb/are/demo/ARE_MultiInstanceActivity.kt @@ -0,0 +1,31 @@ +package com.chinalwb.are.demo + +import android.content.Intent +import android.support.v7.app.AppCompatActivity +import android.os.Bundle +import com.chinalwb.are.AREditor +import kotlinx.android.synthetic.main.activity_are__multi_instance.* +import kotlinx.android.synthetic.main.activity_main.* + +class ARE_MultiInstanceActivity : AppCompatActivity() { + + var activeARE : AREditor? = null + + private val areFocusChangeListener = AREditor.ARE_FocusChangeListener { arEditor, hasFocus -> if (hasFocus && arEditor != null) activeARE = arEditor } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_are__multi_instance) + + are_1.setAreFocusChangeListener(areFocusChangeListener) + are_2.setAreFocusChangeListener(areFocusChangeListener) + are_3.setAreFocusChangeListener(areFocusChangeListener) + are_4.setAreFocusChangeListener(areFocusChangeListener) + + activeARE = are_1 + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + this.activeARE?.onActivityResult(requestCode, resultCode, data) + } +} diff --git a/ARE/app/src/main/java/com/chinalwb/are/demo/IndexActivity.java b/ARE/app/src/main/java/com/chinalwb/are/demo/IndexActivity.java index 03d2d69..80363e5 100644 --- a/ARE/app/src/main/java/com/chinalwb/are/demo/IndexActivity.java +++ b/ARE/app/src/main/java/com/chinalwb/are/demo/IndexActivity.java @@ -41,6 +41,9 @@ private void initViews() { Button minHideButton = this.findViewById(R.id.minHideButton); openPage(minHideButton, ARE_MinHideActivity.class); + + Button multipleInstanceButton = this.findViewById(R.id.multiInstanceButton); + openPage(multipleInstanceButton, ARE_MultiInstanceActivity.class); } private void openPage(Button button, final Class activity) { diff --git a/ARE/app/src/main/res/layout/activity_are__full_bottom.xml b/ARE/app/src/main/res/layout/activity_are__full_bottom.xml index 594afde..31973bd 100644 --- a/ARE/app/src/main/res/layout/activity_are__full_bottom.xml +++ b/ARE/app/src/main/res/layout/activity_are__full_bottom.xml @@ -12,6 +12,7 @@ are:expandMode="FULL" are:hideToolbar="false" are:toolbarAlignment="BOTTOM" + are:useEmoji="true" /> diff --git a/ARE/app/src/main/res/layout/activity_are__min_bottom.xml b/ARE/app/src/main/res/layout/activity_are__min_bottom.xml index 9312f9f..227049f 100644 --- a/ARE/app/src/main/res/layout/activity_are__min_bottom.xml +++ b/ARE/app/src/main/res/layout/activity_are__min_bottom.xml @@ -28,6 +28,7 @@ are:expandMode="MIN" are:hideToolbar="false" are:toolbarAlignment="BOTTOM" + are:useEmoji="true" android:visibility="visible" /> diff --git a/ARE/app/src/main/res/layout/activity_are__multi_instance.xml b/ARE/app/src/main/res/layout/activity_are__multi_instance.xml new file mode 100644 index 0000000..e02dd81 --- /dev/null +++ b/ARE/app/src/main/res/layout/activity_are__multi_instance.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ARE/app/src/main/res/layout/activity_index.xml b/ARE/app/src/main/res/layout/activity_index.xml index 691fb10..b26b031 100644 --- a/ARE/app/src/main/res/layout/activity_index.xml +++ b/ARE/app/src/main/res/layout/activity_index.xml @@ -50,6 +50,13 @@ android:textAllCaps="false" android:text="AREditor Min Hide"/> +