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"/>
+
+
#F67eF2
#e74c3c
#27ae60
+
+ #DCEDC8
+ #AED581
+ #7CB342
+ #33691E
\ No newline at end of file
diff --git a/ARE/are/src/main/java/com/chinalwb/are/AREditText.java b/ARE/are/src/main/java/com/chinalwb/are/AREditText.java
index 13cf664..667df03 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/AREditText.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/AREditText.java
@@ -2,14 +2,12 @@
import android.annotation.TargetApi;
import android.content.ClipData;
-import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
-import android.media.Image;
+import android.graphics.Typeface;
import android.os.Build;
import android.support.v7.widget.AppCompatEditText;
import android.text.Editable;
-import android.text.Layout;
import android.text.Selection;
import android.text.Spannable;
import android.text.Spanned;
@@ -21,13 +19,9 @@
import android.text.style.StyleSpan;
import android.util.AttributeSet;
import android.util.TypedValue;
-import android.view.ActionMode;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
-import android.widget.Toast;
import com.chinalwb.are.android.inner.Html;
import com.chinalwb.are.events.AREMovementMethod;
@@ -64,9 +58,9 @@ public class AREditText extends AppCompatEditText {
private static boolean MONITORING = true;
- private ARE_Toolbar sToolbar;
+ private ARE_Toolbar mFixedToolbar;
- private static List sStylesList = new ArrayList<>();
+ private List mToolbarStylesList = new ArrayList<>();
private Context mContext;
@@ -84,10 +78,6 @@ public AREditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mContext = context;
initGlobalValues();
- sToolbar = ARE_Toolbar.getInstance();
- if (sToolbar != null) {
- sStylesList = sToolbar.getStylesList();
- }
init();
setupListener();
}
@@ -99,6 +89,7 @@ private void initGlobalValues() {
}
private void init() {
+ useSoftwareLayerOnAndroid8();
// this.setMovementMethod(new AREMovementMethod());
this.setFocusableInTouchMode(true);
this.setBackgroundColor(Color.WHITE);
@@ -108,67 +99,6 @@ private void init() {
padding = Util.getPixelByDp(mContext, padding);
this.setPadding(padding, padding, padding, padding);
this.setTextSize(TypedValue.COMPLEX_UNIT_SP, Constants.DEFAULT_FONT_SIZE);
-// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-// this.setCustomInsertionActionModeCallback(new ActionMode.Callback() {
-// @Override
-// public boolean onCreateActionMode(ActionMode mode, Menu menu) {
-// return true;
-// }
-//
-// @Override
-// public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
-// return false;
-// }
-//
-// @Override
-// public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
-// ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
-// ClipData clip = clipboard.getPrimaryClip();
-// switch (item.getItemId()) {
-// case android.R.id.paste:
-// paste(clip);
-// return true;
-// default:
-// return false;
-// }
-// }
-//
-// @Override
-// public void onDestroyActionMode(ActionMode mode) {
-//
-// }
-// });
-// }
-//
-// this.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
-// @Override
-// public boolean onCreateActionMode(ActionMode mode, Menu menu) {
-// return true;
-// }
-//
-// @Override
-// public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
-// return false;
-// }
-//
-// @Override
-// public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
-// ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
-// ClipData clip = clipboard.getPrimaryClip();
-// switch (item.getItemId()) {
-// case android.R.id.paste:
-// paste(clip);
-// return true;
-// default:
-// return false;
-// }
-// }
-//
-// @Override
-// public void onDestroyActionMode(ActionMode mode) {
-// // Do nothing
-// }
-// });
}
private void paste(ClipData clip) {
@@ -284,7 +214,7 @@ public void afterTextChanged(Editable s) {
Util.log("User deletes: start == " + startPos + " endPos == " + endPos);
}
- for (IARE_Style style : sStylesList) {
+ for (IARE_Style style : mToolbarStylesList) {
style.applyStyle(s, startPos, endPos);
}
}
@@ -294,34 +224,44 @@ public void afterTextChanged(Editable s) {
}
public void setToolbar(IARE_Toolbar toolbar) {
- sStylesList.clear();
+ mToolbarStylesList.clear();
this.mToolbar = toolbar;
this.mToolbar.setEditText(this);
List toolItems = toolbar.getToolItems();
for (IARE_ToolItem toolItem : toolItems) {
IARE_Style style = toolItem.getStyle();
- sStylesList.add(style);
+ mToolbarStylesList.add(style);
}
}
+ /**
+ * Sets the fixed items toolbar to this EditText.
+ */
+ public void setFixedToolbar(ARE_Toolbar fixedToolbar) {
+ mFixedToolbar = fixedToolbar;
+ if (mFixedToolbar != null) {
+ mToolbarStylesList = mFixedToolbar.getStylesList();
+ }
+ }
+
@Override
public void onSelectionChanged(int selStart, int selEnd) {
- if (mToolbar == null) {
+ if (mToolbar != null) {
+ List toolItems = mToolbar.getToolItems();
+ for (IARE_ToolItem toolItem : toolItems) {
+ toolItem.onSelectionChanged(selStart, selEnd);
+ }
return;
}
- List toolItems = mToolbar.getToolItems();
- for (IARE_ToolItem toolItem : toolItems) {
- toolItem.onSelectionChanged(selStart, selEnd);
- }
- if (sToolbar == null) {
+ if (mFixedToolbar == null) {
return;
}
boolean boldExists = false;
boolean italicsExists = false;
boolean underlinedExists = false;
- boolean striketrhoughExists = false;
+ boolean strikethroughExists = false;
boolean subscriptExists = false;
boolean superscriptExists = false;
boolean backgroundColorExists = false;
@@ -335,20 +275,20 @@ public void onSelectionChanged(int selStart, int selEnd) {
if (selStart > 0 && selStart == selEnd) {
CharacterStyle[] styleSpans = editable.getSpans(selStart - 1, selStart, CharacterStyle.class);
- for (int i = 0; i < styleSpans.length; i++) {
- if (styleSpans[i] instanceof StyleSpan) {
- if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.BOLD) {
+ for (CharacterStyle styleSpan : styleSpans) {
+ if (styleSpan instanceof StyleSpan) {
+ if (((StyleSpan) styleSpan).getStyle() == Typeface.BOLD) {
boldExists = true;
- } else if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.ITALIC) {
+ } else if (((StyleSpan) styleSpan).getStyle() == Typeface.ITALIC) {
italicsExists = true;
- } else if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.BOLD_ITALIC) {
+ } else if (((StyleSpan) styleSpan).getStyle() == Typeface.BOLD_ITALIC) {
// TODO
}
- } else if (styleSpans[i] instanceof AreUnderlineSpan) {
+ } else if (styleSpan instanceof AreUnderlineSpan) {
underlinedExists = true;
- } else if (styleSpans[i] instanceof StrikethroughSpan) {
- striketrhoughExists = true;
- } else if (styleSpans[i] instanceof BackgroundColorSpan) {
+ } else if (styleSpan instanceof StrikethroughSpan) {
+ strikethroughExists = true;
+ } else if (styleSpan instanceof BackgroundColorSpan) {
backgroundColorExists = true;
}
}
@@ -372,39 +312,38 @@ public void onSelectionChanged(int selStart, int selEnd) {
// Selection is a range
CharacterStyle[] styleSpans = editable.getSpans(selStart, selEnd, CharacterStyle.class);
- for (int i = 0; i < styleSpans.length; i++) {
-
- if (styleSpans[i] instanceof StyleSpan) {
- if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.BOLD) {
- if (editable.getSpanStart(styleSpans[i]) <= selStart
- && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
+ for (CharacterStyle styleSpan : styleSpans) {
+ if (styleSpan instanceof StyleSpan) {
+ if (((StyleSpan) styleSpan).getStyle() == Typeface.BOLD) {
+ if (editable.getSpanStart(styleSpan) <= selStart
+ && editable.getSpanEnd(styleSpan) >= selEnd) {
boldExists = true;
}
- } else if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.ITALIC) {
- if (editable.getSpanStart(styleSpans[i]) <= selStart
- && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
+ } else if (((StyleSpan) styleSpan).getStyle() == Typeface.ITALIC) {
+ if (editable.getSpanStart(styleSpan) <= selStart
+ && editable.getSpanEnd(styleSpan) >= selEnd) {
italicsExists = true;
}
- } else if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.BOLD_ITALIC) {
- if (editable.getSpanStart(styleSpans[i]) <= selStart
- && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
+ } else if (((StyleSpan) styleSpan).getStyle() == Typeface.BOLD_ITALIC) {
+ if (editable.getSpanStart(styleSpan) <= selStart
+ && editable.getSpanEnd(styleSpan) >= selEnd) {
italicsExists = true;
boldExists = true;
}
}
- } else if (styleSpans[i] instanceof AreUnderlineSpan) {
- if (editable.getSpanStart(styleSpans[i]) <= selStart
- && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
+ } else if (styleSpan instanceof AreUnderlineSpan) {
+ if (editable.getSpanStart(styleSpan) <= selStart
+ && editable.getSpanEnd(styleSpan) >= selEnd) {
underlinedExists = true;
}
- } else if (styleSpans[i] instanceof StrikethroughSpan) {
- if (editable.getSpanStart(styleSpans[i]) <= selStart
- && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
- striketrhoughExists = true;
+ } else if (styleSpan instanceof StrikethroughSpan) {
+ if (editable.getSpanStart(styleSpan) <= selStart
+ && editable.getSpanEnd(styleSpan) >= selEnd) {
+ strikethroughExists = true;
}
- } else if (styleSpans[i] instanceof BackgroundColorSpan) {
- if (editable.getSpanStart(styleSpans[i]) <= selStart
- && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
+ } else if (styleSpan instanceof BackgroundColorSpan) {
+ if (editable.getSpanStart(styleSpan) <= selStart
+ && editable.getSpanEnd(styleSpan) >= selEnd) {
backgroundColorExists = true;
}
}
@@ -437,14 +376,14 @@ public void onSelectionChanged(int selStart, int selEnd) {
//
// Set style checked status
- ARE_Helper.updateCheckStatus(sToolbar.getBoldStyle(), boldExists);
- ARE_Helper.updateCheckStatus(sToolbar.getItalicStyle(), italicsExists);
- ARE_Helper.updateCheckStatus(sToolbar.getUnderlineStyle(), underlinedExists);
- ARE_Helper.updateCheckStatus(sToolbar.getStrikethroughStyle(), striketrhoughExists);
- ARE_Helper.updateCheckStatus(sToolbar.getSubscriptStyle(), subscriptExists);
- ARE_Helper.updateCheckStatus(sToolbar.getSuperscriptStyle(), superscriptExists);
- ARE_Helper.updateCheckStatus(sToolbar.getBackgroundColoStyle(), backgroundColorExists);
- ARE_Helper.updateCheckStatus(sToolbar.getQuoteStyle(), quoteExists);
+ ARE_Helper.updateCheckStatus(mFixedToolbar.getBoldStyle(), boldExists);
+ ARE_Helper.updateCheckStatus(mFixedToolbar.getItalicStyle(), italicsExists);
+ ARE_Helper.updateCheckStatus(mFixedToolbar.getUnderlineStyle(), underlinedExists);
+ ARE_Helper.updateCheckStatus(mFixedToolbar.getStrikethroughStyle(), strikethroughExists);
+ ARE_Helper.updateCheckStatus(mFixedToolbar.getSubscriptStyle(), subscriptExists);
+ ARE_Helper.updateCheckStatus(mFixedToolbar.getSuperscriptStyle(), superscriptExists);
+ ARE_Helper.updateCheckStatus(mFixedToolbar.getBackgroundColoStyle(), backgroundColorExists);
+ ARE_Helper.updateCheckStatus(mFixedToolbar.getQuoteStyle(), quoteExists);
} // #End of method:: onSelectionChanged
/**
@@ -458,9 +397,9 @@ public void fromHtml(String html) {
Html.ImageGetter imageGetter = new AreImageGetter(mContext, this);
Html.TagHandler tagHandler = new AreTagHandler();
Spanned spanned = Html.fromHtml(html, Html.FROM_HTML_SEPARATOR_LINE_BREAK_PARAGRAPH, imageGetter, tagHandler);
- AREditText.stopMonitor();
+ stopMonitor();
this.getEditableText().append(spanned);
- AREditText.startMonitor();
+ startMonitor();
}
public String getHtml() {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/AREditor.java b/ARE/are/src/main/java/com/chinalwb/are/AREditor.java
index d93fa0c..3e87e19 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/AREditor.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/AREditor.java
@@ -4,9 +4,11 @@
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Color;
+import android.support.v4.widget.NestedScrollView;
import android.text.Editable;
import android.text.Spanned;
import android.util.AttributeSet;
+import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
@@ -75,7 +77,7 @@ public enum ExpandMode {
/**
* The scroll view out of AREditText.
*/
- private ScrollView mAreScrollView;
+ private NestedScrollView mAreScrollView;
/**
* The are editor.
@@ -97,6 +99,11 @@ public enum ExpandMode {
*/
private boolean mHideToolbar = false;
+ /**
+ * By default, no emoji
+ */
+ private boolean mUseEmoji = false;
+
/*
* --------------------------------------------
* Constructors Area
@@ -145,18 +152,19 @@ public AREditor(Context context, AttributeSet attrs, int defStyleAttr) {
* Initialization.
*/
private void init(AttributeSet attrs) {
- initGlobal();
initAttrs(attrs);
+ initGlobal();
doLayout();
-
} // # End of init()
private void initGlobal() {
this.mToolbar = new ARE_Toolbar(mContext);
this.mToolbar.setId(R.id.are_toolbar);
+ this.mToolbar.setUseEmoji(mUseEmoji);
- this.mAreScrollView = new ScrollView(mContext);
+ this.mAreScrollView = new NestedScrollView(mContext);
+ mAreScrollView.setFitsSystemWindows(true);
this.mAreScrollView.setId(R.id.are_scrollview);
}
@@ -174,10 +182,12 @@ private void initAttrs(AttributeSet attrs) {
// Sets hide toolbar
this.mHideToolbar = ta.getBoolean(R.styleable.are_hideToolbar, mHideToolbar);
+ // Use emoji or not
+ this.mUseEmoji = ta.getBoolean(R.styleable.are_useEmoji, false);
ta.recycle();
}
- private void addToolbar(boolean isBelow, int belowId, boolean isFull) {
+ private void addToolbar(boolean isBelow, int belowId) {
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
if (mExpandMode == ExpandMode.FULL) {
@@ -215,6 +225,7 @@ private void addEditText(boolean isBelow, int belowId) {
LayoutParams editTextLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, height);
mAreScrollView.addView(mAre, editTextLayoutParams);
this.mToolbar.setEditText(mAre);
+ this.mAre.setFixedToolbar(mToolbar);
if (mExpandMode == ExpandMode.FULL) {
mAreScrollView.setBackgroundColor(Color.WHITE);
@@ -235,11 +246,11 @@ private void doLayout() {
// EditText
// Toolbar
addEditText(false, -1);
- addToolbar(true, mAreScrollView.getId(), true);
+ addToolbar(true, mAreScrollView.getId());
} else {
// Toolbar is up, so EditText is below
// EditText is below
- addToolbar(false, -1, false);
+ addToolbar(false, -1);
addEditText(true, mToolbar.getId());
}
}
@@ -333,4 +344,26 @@ public void setImageStrategy(ImageStrategy imageStrategy) {
this.mAre.setImageStrategy(imageStrategy);
}
+ /**
+ * Focus change callback interface.
+ */
+ public interface ARE_FocusChangeListener {
+ void onFocusChanged(AREditor arEditor, boolean hasFocus);
+ }
+
+ private ARE_FocusChangeListener mFocusListener;
+
+ public void setAreFocusChangeListener(ARE_FocusChangeListener listener) {
+ this.mFocusListener = listener;
+ }
+
+ @Override
+ public boolean onInterceptTouchEvent(MotionEvent ev) {
+ if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ if (null != mFocusListener) {
+ mFocusListener.onFocusChanged(this, true);
+ }
+ }
+ return super.onInterceptTouchEvent(ev);
+ }
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_Dynamic_Style.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_Dynamic_Style.java
index 84bde27..bb29412 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_Dynamic_Style.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_Dynamic_Style.java
@@ -17,10 +17,6 @@
*/
public abstract class ARE_ABS_Dynamic_Style extends ARE_ABS_Style {
- public ARE_ABS_Dynamic_Style() {
- super();
- }
-
public ARE_ABS_Dynamic_Style(Context context) {
super(context);
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_FreeStyle.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_FreeStyle.java
index ca9dac9..8491f04 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_FreeStyle.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_FreeStyle.java
@@ -1,36 +1,39 @@
package com.chinalwb.are.styles;
import android.content.Context;
-import android.text.Editable;
-import android.text.Spanned;
import android.widget.EditText;
-import com.chinalwb.are.Util;
import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
-import java.lang.reflect.ParameterizedType;
-
public abstract class ARE_ABS_FreeStyle implements IARE_Style {
protected Context mContext;
+ protected ARE_Toolbar mToolbar;
+ protected EditText mEditText;
public ARE_ABS_FreeStyle(Context context) {
mContext = context;
- if (mContext == null) {
- this.mContext = ARE_Toolbar.getInstance().getContext();
- }
}
- public ARE_ABS_FreeStyle() {
- this.mContext = ARE_Toolbar.getInstance().getContext();
+ public ARE_ABS_FreeStyle(ARE_Toolbar toolbar) {
+ this.mToolbar = toolbar;
+ if (null != toolbar) {
+ this.mContext = toolbar.getContext();
+ this.mEditText = toolbar.getEditText();
+ }
}
-
+
@Override
public EditText getEditText() {
- return ARE_Toolbar.getInstance().getEditText();
+ if (null != mEditText) {
+ return mEditText;
+ }
+ if (null != mToolbar) {
+ return mToolbar.getEditText();
+ }
+ return null;
}
-
// Dummy implementation
@Override
public boolean getIsChecked() {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_Style.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_Style.java
index 984d1f2..be2a9b7 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_Style.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ABS_Style.java
@@ -1,14 +1,11 @@
package com.chinalwb.are.styles;
-import com.chinalwb.are.Util;
-import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
-
import android.content.Context;
import android.text.Editable;
import android.text.Spanned;
-import android.text.style.ForegroundColorSpan;
import android.util.Log;
-import android.widget.EditText;
+
+import com.chinalwb.are.Util;
import java.lang.reflect.ParameterizedType;
@@ -18,23 +15,11 @@ public abstract class ARE_ABS_Style implements IARE_Style {
protected Class clazzE;
- public ARE_ABS_Style() {
- this(null);
- }
-
public ARE_ABS_Style(Context context) {
mContext = context;
- if (mContext == null) {
- this.mContext = ARE_Toolbar.getInstance().getContext();
- }
clazzE = (Class) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
}
- @Override
- public EditText getEditText() {
- return ARE_Toolbar.getInstance().getEditText();
- }
-
@Override
public void applyStyle(Editable editable, int start, int end) {
if (getIsChecked()) {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Alignment.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Alignment.java
index d0bcfee..54c1a22 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Alignment.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Alignment.java
@@ -13,6 +13,7 @@
import com.chinalwb.are.Constants;
import com.chinalwb.are.Util;
+import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
public class ARE_Alignment extends ARE_ABS_FreeStyle {
@@ -20,7 +21,8 @@ public class ARE_Alignment extends ARE_ABS_FreeStyle {
private Alignment mAlignment;
- public ARE_Alignment(ImageView imageView, Alignment alignment) {
+ public ARE_Alignment(ImageView imageView, Alignment alignment, ARE_Toolbar toolbar) {
+ super(toolbar);
this.mAlignmentImageView = imageView;
this.mAlignment = alignment;
setListenerForImageView(this.mAlignmentImageView);
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_At.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_At.java
index 4a2a44f..aca7d4a 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_At.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_At.java
@@ -5,10 +5,10 @@
import android.graphics.Color;
import android.text.Editable;
import android.text.Spanned;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
-import com.chinalwb.are.Util;
import com.chinalwb.are.activities.Are_AtPickerActivity;
import com.chinalwb.are.models.AtItem;
import com.chinalwb.are.spans.AreAtSpan;
@@ -25,13 +25,10 @@ public class ARE_At extends ARE_ABS_FreeStyle {
private AREditText mEditText;
- public ARE_At() {
-
+ public ARE_At(ARE_Toolbar toolbar) {
+ super(toolbar);
}
- /**
- * @param editText
- */
public void setEditText(AREditText editText) {
this.mEditText = editText;
}
@@ -120,4 +117,5 @@ public void setChecked(boolean isChecked) {
// TODO Auto-generated method stub
}
+
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_BackgroundColor.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_BackgroundColor.java
index e888932..0261ea9 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_BackgroundColor.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_BackgroundColor.java
@@ -1,16 +1,13 @@
package com.chinalwb.are.styles;
-import android.text.Editable;
-import android.text.Spanned;
import android.text.style.BackgroundColorSpan;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
-import com.chinalwb.are.Util;
-import com.chinalwb.are.spans.AreUnderlineSpan;
public class ARE_BackgroundColor extends ARE_ABS_Style {
@@ -26,19 +23,21 @@ public class ARE_BackgroundColor extends ARE_ABS_Style {
* @param backgroundImage
*/
public ARE_BackgroundColor(ImageView backgroundImage, int backgroundColor) {
+ super(backgroundImage.getContext());
this.mBackgroundImageView = backgroundImage;
this.mColor = backgroundColor;
setListenerForImageView(this.mBackgroundImageView);
}
- /**
- *
- * @param editText
- */
public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
+
@Override
public void setListenerForImageView(final ImageView imageView) {
imageView.setOnClickListener(new OnClickListener() {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Bold.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Bold.java
index 9cb2c04..9107e9f 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Bold.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Bold.java
@@ -1,15 +1,11 @@
package com.chinalwb.are.styles;
-import android.graphics.Typeface;
-import android.text.Editable;
-import android.text.Spanned;
-import android.text.style.StyleSpan;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
-import com.chinalwb.are.Util;
import com.chinalwb.are.spans.AreBoldSpan;
public class ARE_Bold extends ARE_ABS_Style {
@@ -24,6 +20,7 @@ public class ARE_Bold extends ARE_ABS_Style {
* @param boldImage
*/
public ARE_Bold(ImageView boldImage) {
+ super(boldImage.getContext());
this.mBoldImageView = boldImage;
setListenerForImageView(this.mBoldImageView);
}
@@ -35,6 +32,11 @@ public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
+
@Override
public void setListenerForImageView(final ImageView imageView) {
imageView.setOnClickListener(new OnClickListener() {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Emoji.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Emoji.java
index c011032..821634a 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Emoji.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Emoji.java
@@ -30,6 +30,10 @@ public class ARE_Emoji extends ARE_ABS_FreeStyle {
private ImageView mEmojiImageView;
+ public ARE_Emoji(ARE_Toolbar toolbar) {
+ super(toolbar);
+ }
+
private AdapterView.OnItemClickListener listenerA = new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
@@ -50,7 +54,7 @@ public void onItemClick(AdapterView> parent, View view, int position, long id)
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
int resId = ((EmojiGridViewAdapter.ViewHolder) view.getTag()).resId;
- ARE_Toolbar.getInstance().getImageStyle().insertImage(resId, AreImageSpan.ImageType.RES);
+ mToolbar.getImageStyle().insertImage(resId, AreImageSpan.ImageType.RES);
}
};
@@ -58,7 +62,8 @@ public void onItemClick(AdapterView> parent, View view, int position, long id)
*
* @param emojiImageView
*/
- public ARE_Emoji(ImageView emojiImageView) {
+ public ARE_Emoji(ImageView emojiImageView, ARE_Toolbar toolbar) {
+ super(toolbar);
this.mEmojiImageView = emojiImageView;
initEmojiPanel();
setListenerForImageView(this.mEmojiImageView);
@@ -71,7 +76,7 @@ private void initEmojiPanel() {
ArrayList emojiGroups = initEmojiGroups();
EmojiPagerAdapter adapter = new EmojiPagerAdapter(mContext, emojiGroups, fragmentManager);
emojiPanel.setAdapter(adapter);
- ARE_Toolbar.getInstance().setEmojiPanel(emojiPanel);
+ mToolbar.setEmojiPanel(emojiPanel);
}
private ArrayList initEmojiGroups() {
@@ -197,7 +202,7 @@ private void showEmojiPanel() {
// Hide keyboard
// Get keyboard height
// Show emoji panel
- ARE_Toolbar.getInstance().toggleEmojiPanel(true);
+ mToolbar.toggleEmojiPanel(true);
}
@NonNull
@@ -241,4 +246,5 @@ private void logAllEmojiSpans(Editable editable) {
Util.log("List All: " + " :: start == " + ss + ", end == " + se);
}
}
+
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_FontColor.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_FontColor.java
index 2b87033..bff113d 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_FontColor.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_FontColor.java
@@ -1,29 +1,24 @@
package com.chinalwb.are.styles;
-import android.graphics.Color;
import android.text.Editable;
-import android.text.Spannable;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
-import android.text.style.AbsoluteSizeSpan;
import android.text.style.ForegroundColorSpan;
-import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
-import com.chinalwb.are.Constants;
import com.chinalwb.are.Util;
+import com.chinalwb.are.colorpicker.ColorPickerListener;
import com.chinalwb.are.spans.AreForegroundColorSpan;
import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
-import com.chinalwb.are.colorpicker.ColorPickerListener;
public class ARE_FontColor extends ARE_ABS_Dynamic_Style {
private ImageView mFontColorImageView;
+ private ARE_Toolbar mToolbar;
+
private AREditText mEditText;
private int mColor = -1;
@@ -45,13 +40,10 @@ public void onPickColor(int color) {
};
-
- /**
- *
- * @param fontColorImage
- */
- public ARE_FontColor(ImageView fontColorImage) {
+ public ARE_FontColor(ImageView fontColorImage, ARE_Toolbar toolbar) {
+ super(fontColorImage.getContext());
this.mFontColorImageView = fontColorImage;
+ this.mToolbar = toolbar;
setListenerForImageView(this.mFontColorImageView);
}
@@ -68,7 +60,7 @@ public void setListenerForImageView(final ImageView imageView) {
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- ARE_Toolbar.getInstance().toggleColorPalette(mColorPickerListener);
+ mToolbar.toggleColorPalette(mColorPickerListener);
}
});
}
@@ -126,6 +118,6 @@ protected AreForegroundColorSpan newSpan(int color) {
@Override
protected void featureChangedHook(int lastSpanColor) {
mColor = lastSpanColor;
- ARE_Toolbar.getInstance().setColorPaletteColor(mColor);
+ mToolbar.setColorPaletteColor(mColor);
}
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_FontSize.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_FontSize.java
index a66dd5b..5089f08 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_FontSize.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_FontSize.java
@@ -26,6 +26,8 @@ public class ARE_FontSize extends ARE_ABS_Dynamic_Style impleme
private ImageView mFontsizeImageView;
+ private ARE_Toolbar mToolbar;
+
private AREditText mEditText;
private int mSize = Constants.DEFAULT_FONT_SIZE;
@@ -39,7 +41,9 @@ public class ARE_FontSize extends ARE_ABS_Dynamic_Style impleme
/**
* @param fontSizeImage
*/
- public ARE_FontSize(ImageView fontSizeImage) {
+ public ARE_FontSize(ImageView fontSizeImage, ARE_Toolbar toolbar) {
+ super(fontSizeImage.getContext());
+ this.mToolbar = toolbar;
this.mFontsizeImageView = fontSizeImage;
setListenerForImageView(this.mFontsizeImageView);
}
@@ -52,6 +56,10 @@ public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
@Override
public void setListenerForImageView(final ImageView imageView) {
@@ -68,7 +76,8 @@ private void showFontsizePickerWindow() {
mFontPickerWindow = new FontsizePickerWindow(mContext, this);
}
mFontPickerWindow.setFontSize(mSize);
- mFontPickerWindow.showAsDropDown(ARE_Toolbar.getInstance(),0, 0);
+ int yOff = 0 - Util.getPixelByDp(mContext, 150);
+ mFontPickerWindow.showAsDropDown(mFontsizeImageView,0, yOff);
}
@Override
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Fontface.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Fontface.java
index f04f2a7..87da3f4 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Fontface.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Fontface.java
@@ -12,6 +12,7 @@
import com.chinalwb.are.Constants;
import com.chinalwb.are.spans.MyTypefaceSpan;
+import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
public class ARE_Fontface extends ARE_ABS_FreeStyle {
@@ -21,7 +22,8 @@ public class ARE_Fontface extends ARE_ABS_FreeStyle {
*
* @param fontSizeImage
*/
- public ARE_Fontface(ImageView fontSizeImage) {
+ public ARE_Fontface(ImageView fontSizeImage, ARE_Toolbar toolbar) {
+ super(toolbar);
this.mFontfaceImageView = fontSizeImage;
setListenerForImageView(this.mFontfaceImageView);
}
@@ -66,5 +68,4 @@ public ImageView getImageView() {
public void setChecked(boolean isChecked) {
// Do nothing.
}
-
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Hr.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Hr.java
index 9756174..da54c5b 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Hr.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Hr.java
@@ -8,21 +8,21 @@
import android.text.Spanned;
import android.text.style.AlignmentSpan;
import android.view.View;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
import com.chinalwb.are.Constants;
import com.chinalwb.are.spans.AreAtSpan;
import com.chinalwb.are.spans.AreHrSpan;
+import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
public class ARE_Hr extends ARE_ABS_FreeStyle {
private AREditText mEditText;
- private ImageView mImageView;
-
- public ARE_Hr(ImageView imageView) {
- mImageView = imageView;
+ public ARE_Hr(ImageView imageView, ARE_Toolbar toolbar) {
+ super(toolbar);
setListenerForImageView(imageView);
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_IndentLeft.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_IndentLeft.java
index 0bf906e..2b0c1ac 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_IndentLeft.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_IndentLeft.java
@@ -9,11 +9,13 @@
import com.chinalwb.are.Util;
import com.chinalwb.are.spans.AreLeadingMarginSpan;
+import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
public class ARE_IndentLeft extends ARE_ABS_FreeStyle {
- public ARE_IndentLeft(ImageView atImageView) {
- setListenerForImageView(atImageView);
+ public ARE_IndentLeft(ImageView indentImageView, ARE_Toolbar toolbar) {
+ super(toolbar);
+ setListenerForImageView(indentImageView);
}
@Override
@@ -62,5 +64,4 @@ public void setChecked(boolean isChecked) {
// TODO Auto-generated method stub
}
-
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_IndentRight.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_IndentRight.java
index 9c0fca1..a2c118a 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_IndentRight.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_IndentRight.java
@@ -11,11 +11,13 @@
import com.chinalwb.are.Constants;
import com.chinalwb.are.Util;
import com.chinalwb.are.spans.AreLeadingMarginSpan;
+import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
public class ARE_IndentRight extends ARE_ABS_FreeStyle {
- public ARE_IndentRight(ImageView atImageView) {
- setListenerForImageView(atImageView);
+ public ARE_IndentRight(ImageView indentImageView, ARE_Toolbar toolbar) {
+ super(toolbar);
+ setListenerForImageView(indentImageView);
}
@Override
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Italic.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Italic.java
index 7928bb0..b69827e 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Italic.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Italic.java
@@ -1,16 +1,13 @@
package com.chinalwb.are.styles;
-import android.graphics.Typeface;
-import android.text.Editable;
-import android.text.Spanned;
-import android.text.style.StyleSpan;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
-import com.chinalwb.are.Util;
import com.chinalwb.are.spans.AreItalicSpan;
+import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
public class ARE_Italic extends ARE_ABS_Style {
@@ -20,23 +17,21 @@ public class ARE_Italic extends ARE_ABS_Style {
private AREditText mEditText;
- /**
- *
- * @param italicImage
- */
public ARE_Italic(ImageView italicImage) {
+ super(italicImage.getContext());
this.mItalicImageView = italicImage;
setListenerForImageView(this.mItalicImageView);
}
- /**
- *
- * @param editText
- */
public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
+
@Override
public void setListenerForImageView(final ImageView imageView) {
imageView.setOnClickListener(new OnClickListener() {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Link.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Link.java
index feed92e..d83ad4a 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Link.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Link.java
@@ -15,6 +15,7 @@
import com.chinalwb.are.AREditText;
import com.chinalwb.are.R;
import com.chinalwb.are.spans.AreUrlSpan;
+import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
import org.w3c.dom.Text;
@@ -25,20 +26,17 @@
public class ARE_Link extends ARE_ABS_FreeStyle {
- public static final String HTTP = "http://";
- public static final String HTTPS = "https://";
+ private static final String HTTP = "http://";
+ private static final String HTTPS = "https://";
private ImageView mLinkImageView;
private AREditText mEditText;
- public ARE_Link(ImageView imageView) {
+ public ARE_Link(ImageView imageView, ARE_Toolbar toolbar) {
+ super(toolbar);
this.mLinkImageView = imageView;
setListenerForImageView(imageView);
}
- /**
- *
- * @param editText
- */
public void setEditText(AREditText editText) {
this.mEditText = editText;
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ListBullet.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ListBullet.java
index aa33706..70b663d 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ListBullet.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ListBullet.java
@@ -12,6 +12,7 @@
import com.chinalwb.are.Util;
import com.chinalwb.are.spans.ListBulletSpan;
import com.chinalwb.are.spans.ListNumberSpan;
+import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
/**
* All Rights Reserved.
@@ -23,7 +24,8 @@ public class ARE_ListBullet extends ARE_ABS_FreeStyle {
private ImageView mListBulletImageView;
- public ARE_ListBullet(ImageView imageView) {
+ public ARE_ListBullet(ImageView imageView, ARE_Toolbar toolbar) {
+ super(toolbar);
this.mListBulletImageView = imageView;
setListenerForImageView(this.mListBulletImageView);
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ListNumber.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ListNumber.java
index 22cd5bf..e6f5b3f 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ListNumber.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_ListNumber.java
@@ -12,6 +12,7 @@
import com.chinalwb.are.Util;
import com.chinalwb.are.spans.ListBulletSpan;
import com.chinalwb.are.spans.ListNumberSpan;
+import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
import java.util.List;
@@ -26,7 +27,8 @@ public class ARE_ListNumber extends ARE_ABS_FreeStyle {
private boolean toMergeForward = false;
- public ARE_ListNumber(ImageView imageView) {
+ public ARE_ListNumber(ImageView imageView, ARE_Toolbar toolbar) {
+ super(toolbar);
this.mListNumberImageView = imageView;
setListenerForImageView(this.mListNumberImageView);
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Quote.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Quote.java
index a5eb36b..707777b 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Quote.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Quote.java
@@ -110,7 +110,6 @@ private void removeQuote() {
if (quoteSpans == null || quoteSpans.length == 0) {
quoteSpans = editable.getSpans(start, end, AreQuoteSpan.class);
if (quoteSpans != null && quoteSpans.length == 0) {
- editable.removeSpan(quoteSpans[0]);
return;
}
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Strikethrough.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Strikethrough.java
index a65d217..bfd9d86 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Strikethrough.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Strikethrough.java
@@ -5,6 +5,7 @@
import android.text.style.StrikethroughSpan;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
@@ -18,12 +19,9 @@ public class ARE_Strikethrough extends ARE_ABS_Style {
private AREditText mEditText;
- /**
- *
- * @param StrikethroughImage
- */
- public ARE_Strikethrough(ImageView StrikethroughImage) {
- this.mStrikethroughImageView = StrikethroughImage;
+ public ARE_Strikethrough(ImageView strikethroughImage) {
+ super(strikethroughImage.getContext());
+ this.mStrikethroughImageView = strikethroughImage;
setListenerForImageView(this.mStrikethroughImageView);
}
@@ -35,6 +33,11 @@ public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
+
@Override
public void setListenerForImageView(final ImageView imageView) {
imageView.setOnClickListener(new OnClickListener() {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Subscript.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Subscript.java
index f3f74dd..a9b8d32 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Subscript.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Subscript.java
@@ -1,6 +1,7 @@
package com.chinalwb.are.styles;
import android.view.View;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
@@ -19,6 +20,7 @@ public class ARE_Subscript extends ARE_ABS_Style {
* @param imageView image view
*/
public ARE_Subscript(ImageView imageView) {
+ super(imageView.getContext());
this.mSubscriptImage = imageView;
setListenerForImageView(this.mSubscriptImage);
}
@@ -30,6 +32,11 @@ public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
+
@Override
public void setListenerForImageView(final ImageView imageView) {
imageView.setOnClickListener(new View.OnClickListener() {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Superscript.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Superscript.java
index e4f9305..01d8da0 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Superscript.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Superscript.java
@@ -1,6 +1,7 @@
package com.chinalwb.are.styles;
import android.view.View;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
@@ -22,6 +23,7 @@ public class ARE_Superscript extends ARE_ABS_Style {
* @param imageView
*/
public ARE_Superscript(ImageView imageView) {
+ super(imageView.getContext());
this.mSuperscriptImage = imageView;
setListenerForImageView(this.mSuperscriptImage);
}
@@ -33,6 +35,11 @@ public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
+
@Override
public void setListenerForImageView(final ImageView imageView) {
imageView.setOnClickListener(new View.OnClickListener() {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Underline.java b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Underline.java
index b0953ca..232cc2e 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Underline.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/ARE_Underline.java
@@ -1,13 +1,11 @@
package com.chinalwb.are.styles;
-import android.text.Editable;
-import android.text.Spanned;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
-import com.chinalwb.are.Util;
import com.chinalwb.are.spans.AreUnderlineSpan;
public class ARE_Underline extends ARE_ABS_Style {
@@ -18,23 +16,21 @@ public class ARE_Underline extends ARE_ABS_Style {
private AREditText mEditText;
- /**
- *
- * @param UnderlineImage
- */
- public ARE_Underline(ImageView UnderlineImage) {
- this.mUnderlineImageView = UnderlineImage;
+ public ARE_Underline(ImageView imageView) {
+ super(imageView.getContext());
+ this.mUnderlineImageView = imageView;
setListenerForImageView(this.mUnderlineImageView);
}
- /**
- *
- * @param editText
- */
public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
+
@Override
public void setListenerForImageView(final ImageView imageView) {
imageView.setOnClickListener(new OnClickListener() {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/toolbar/ARE_Toolbar.java b/ARE/are/src/main/java/com/chinalwb/are/styles/toolbar/ARE_Toolbar.java
index 51fe604..4fc2e2c 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/toolbar/ARE_Toolbar.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/toolbar/ARE_Toolbar.java
@@ -22,6 +22,8 @@
import com.chinalwb.are.R;
import com.chinalwb.are.Util;
import com.chinalwb.are.activities.Are_VideoPlayerActivity;
+import com.chinalwb.are.colorpicker.ColorPickerListener;
+import com.chinalwb.are.colorpicker.ColorPickerView;
import com.chinalwb.are.models.AtItem;
import com.chinalwb.are.spans.AreImageSpan;
import com.chinalwb.are.styles.ARE_Alignment;
@@ -47,23 +49,17 @@
import com.chinalwb.are.styles.ARE_Underline;
import com.chinalwb.are.styles.ARE_Video;
import com.chinalwb.are.styles.IARE_Style;
-import com.chinalwb.are.styles.toolitems.IARE_ToolItem;
-import com.chinalwb.are.colorpicker.ColorPickerListener;
-import com.chinalwb.are.colorpicker.ColorPickerView;
import java.util.ArrayList;
import java.util.List;
+/**
+ * A fixed toolbar, for including only static tool items.
+ * Not friendly for extending.
+ * See {@link IARE_Toolbar} and {@link ARE_ToolbarDefault} for more info about dynamic toolbar.
+ */
public class ARE_Toolbar extends LinearLayout {
- public void addToolItem(IARE_ToolItem toolItem) {
- View view = null ; // toolItem.getView();
- // addView to toolbar
- // add tool item to a collection
- }
-
- private static ARE_Toolbar sInstance;
-
/**
* Request code for selecting an image.
*/
@@ -92,7 +88,7 @@ public void addToolItem(IARE_ToolItem toolItem) {
/**
* Supported styles list.
*/
- private ArrayList mStylesList = new ArrayList();
+ private ArrayList mStylesList = new ArrayList<>();
/**
* Video Style
@@ -355,7 +351,6 @@ public ARE_Toolbar(Context context, AttributeSet attrs) {
public ARE_Toolbar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mContext = (Activity) context;
- sInstance = this;
init();
}
@@ -432,30 +427,30 @@ private void initViews() {
*
*/
private void initStyles() {
- this.mEmojiStyle = new ARE_Emoji(this.mEmojiImageView);
- this.mFontsizeStyle = new ARE_FontSize(this.mFontsizeImageView);
- this.mFontfaceStyle = new ARE_Fontface(this.mFontfaceImageView);
+ this.mEmojiStyle = new ARE_Emoji(this.mEmojiImageView, this);
+ this.mFontsizeStyle = new ARE_FontSize(this.mFontsizeImageView, this);
+ this.mFontfaceStyle = new ARE_Fontface(this.mFontfaceImageView, this);
this.mBoldStyle = new ARE_Bold(this.mBoldImageView);
this.mItalicStyle = new ARE_Italic(this.mItalicImageView);
this.mUnderlineStyle = new ARE_Underline(this.mUnderlineImageView);
this.mStrikethroughStyle = new ARE_Strikethrough(this.mStrikethroughImageView);
- this.mHrStyle = new ARE_Hr(this.mHrImageView);
+ this.mHrStyle = new ARE_Hr(this.mHrImageView, this);
this.mSubscriptStyle = new ARE_Subscript(this.mSubscriptImageView);
this.mSuperscriptStyle = new ARE_Superscript(this.mSuperscriptImageView);
this.mQuoteStyle = new ARE_Quote(this.mQuoteImageView);
- this.mFontColorStyle = new ARE_FontColor(this.mFontColorImageView);
+ this.mFontColorStyle = new ARE_FontColor(this.mFontColorImageView, this);
this.mBackgroundColoStyle = new ARE_BackgroundColor(this.mBackgroundImageView, Color.YELLOW);
- this.mLinkStyle = new ARE_Link(this.mLinkImageView);
- this.mListNumberStyle = new ARE_ListNumber(this.mRteListNumber);
- this.mListBulletStyle = new ARE_ListBullet(this.mRteListBullet);
- this.mIndentRightStyle = new ARE_IndentRight(this.mRteIndentRight);
- this.mIndentLeftStyle = new ARE_IndentLeft(this.mRteIndentLeft);
- this.mAlignLeft = new ARE_Alignment(this.mRteAlignLeft, Alignment.ALIGN_NORMAL);
- this.mAlignCenter = new ARE_Alignment(this.mRteAlignCenter, Alignment.ALIGN_CENTER);
- this.mAlignRight = new ARE_Alignment(this.mRteAlignRight, Alignment.ALIGN_OPPOSITE);
+ this.mLinkStyle = new ARE_Link(this.mLinkImageView, this);
+ this.mListNumberStyle = new ARE_ListNumber(this.mRteListNumber, this);
+ this.mListBulletStyle = new ARE_ListBullet(this.mRteListBullet, this);
+ this.mIndentRightStyle = new ARE_IndentRight(this.mRteIndentRight, this);
+ this.mIndentLeftStyle = new ARE_IndentLeft(this.mRteIndentLeft, this);
+ this.mAlignLeft = new ARE_Alignment(this.mRteAlignLeft, Alignment.ALIGN_NORMAL, this);
+ this.mAlignCenter = new ARE_Alignment(this.mRteAlignCenter, Alignment.ALIGN_CENTER, this);
+ this.mAlignRight = new ARE_Alignment(this.mRteAlignRight, Alignment.ALIGN_OPPOSITE, this);
this.mImageStyle = new ARE_Image(this.mRteInsertImage);
this.mVideoStyle = new ARE_Video(this.mRteInsertVideo);
- this.mAtStyle = new ARE_At();
+ this.mAtStyle = new ARE_At(this);
this.mStylesList.add(this.mEmojiStyle);
this.mStylesList.add(this.mFontsizeStyle);
@@ -483,9 +478,12 @@ private void initStyles() {
this.mStylesList.add(this.mAtStyle);
}
-
- public static ARE_Toolbar getInstance() {
- return sInstance;
+ public void setUseEmoji(boolean useEmoji) {
+ if (useEmoji) {
+ mEmojiImageView.setVisibility(View.VISIBLE);
+ } else {
+ mEmojiImageView.setVisibility(View.GONE);
+ }
}
public void setEditText(AREditText editText) {
@@ -557,12 +555,6 @@ public ARE_Image getImageStyle() {
return mImageStyle;
}
- public ARE_Video getVideoStyle() { return mVideoStyle; }
-
- public ARE_At getmAtStyle() {
- return mAtStyle;
- }
-
public List getStylesList() {
return this.mStylesList;
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Alignment.java b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Alignment.java
index 410fe47..2fddc91 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Alignment.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Alignment.java
@@ -124,11 +124,10 @@ private void markLineAsAlignmentSpan(Alignment alignment) {
EditText editText = getEditText();
int currentLine = Util.getCurrentCursorLine(editText);
int start = Util.getThisLineStart(editText, currentLine);
- int end = Util.getThisLineEnd(editText, currentLine);
Editable editable = editText.getText();
editable.insert(start, Constants.ZERO_WIDTH_SPACE_STR);
start = Util.getThisLineStart(editText, currentLine);
- end = Util.getThisLineEnd(editText, currentLine);
+ int end = Util.getThisLineEnd(editText, currentLine);
if (end < 1) {
return;
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_At.java b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_At.java
index 1c76304..9b75203 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_At.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_At.java
@@ -5,6 +5,7 @@
import android.graphics.Color;
import android.text.Editable;
import android.text.Spanned;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
@@ -13,7 +14,6 @@
import com.chinalwb.are.spans.AreAtSpan;
import com.chinalwb.are.strategies.AtStrategy;
import com.chinalwb.are.styles.ARE_ABS_FreeStyle;
-import com.chinalwb.are.styles.toolbar.ARE_Toolbar;
public class ARE_Style_At extends ARE_ABS_FreeStyle {
@@ -91,4 +91,9 @@ public void setChecked(boolean isChecked) {
// TODO Auto-generated method stub
}
+
+ @Override
+ public EditText getEditText() {
+ return this.mEditText;
+ }
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_FontColor.java b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_FontColor.java
index 0331c77..cda7be3 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_FontColor.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_FontColor.java
@@ -2,6 +2,7 @@
import android.text.Editable;
import android.view.View;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
@@ -41,6 +42,10 @@ public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
@Override
public void setListenerForImageView(final ImageView imageView) {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_FontSize.java b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_FontSize.java
index 749ec6f..322bc1b 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_FontSize.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_FontSize.java
@@ -2,6 +2,7 @@
import android.text.Editable;
import android.view.View;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
@@ -46,6 +47,10 @@ public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
@Override
public void setListenerForImageView(final ImageView imageView) {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Hr.java b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Hr.java
index fe01e52..35357db 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Hr.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Hr.java
@@ -16,12 +16,9 @@ public class ARE_Style_Hr extends ARE_ABS_FreeStyle {
private AREditText mEditText;
- private ImageView mImageView;
-
public ARE_Style_Hr(AREditText editText, ImageView imageView) {
super(editText.getContext());
this.mEditText = editText;
- mImageView = imageView;
setListenerForImageView(imageView);
}
@@ -30,9 +27,6 @@ public EditText getEditText() {
return this.mEditText;
}
- /**
- * @param editText
- */
public void setEditText(AREditText editText) {
this.mEditText = editText;
}
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Link.java b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Link.java
index f97034b..e7f112d 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Link.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Link.java
@@ -1,5 +1,6 @@
package com.chinalwb.are.styles.toolitems.styles;
+import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
@@ -23,8 +24,8 @@
public class ARE_Style_Link extends ARE_ABS_FreeStyle {
- public static final String HTTP = "http://";
- public static final String HTTPS = "https://";
+ private static final String HTTP = "http://";
+ private static final String HTTPS = "https://";
private ImageView mLinkImageView;
private AREditText mEditText;
@@ -40,10 +41,6 @@ public EditText getEditText() {
return this.mEditText;
}
- /**
- *
- * @param editText
- */
public void setEditText(AREditText editText) {
this.mEditText = editText;
}
@@ -68,13 +65,13 @@ private void openLinkDialog() {
builder.setTitle(R.string.are_link_title);
LayoutInflater layoutInflater = activity.getLayoutInflater();
- final View areInsertLinkView = layoutInflater.inflate(R.layout.are_link_insert, null);
+ @SuppressLint("InflateParams") final View areInsertLinkView = layoutInflater.inflate(R.layout.are_link_insert, null);
builder.setView(areInsertLinkView)
// Add the buttons
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
- EditText editText = (EditText) areInsertLinkView.findViewById(R.id.are_insert_link_edit);
+ EditText editText = areInsertLinkView.findViewById(R.id.are_insert_link_edit);
String url = editText.getText().toString();
if (TextUtils.isEmpty(url)) {
dialog.dismiss();
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_ListBullet.java b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_ListBullet.java
index 7f8b3cf..e1989ca 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_ListBullet.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_ListBullet.java
@@ -26,13 +26,10 @@ public class ARE_Style_ListBullet extends ARE_ABS_FreeStyle {
private AREditText mEditText;
- private ImageView mListBulletImageView;
-
public ARE_Style_ListBullet(AREditText editText, ImageView imageView) {
super(editText.getContext());
this.mEditText = editText;
- this.mListBulletImageView = imageView;
- setListenerForImageView(this.mListBulletImageView);
+ setListenerForImageView(imageView);
}
@Override
@@ -166,7 +163,6 @@ public void onClick(View v) {
//
// Case 1
makeLineAsBullet();
- return;
}
} else {
//
@@ -183,8 +179,7 @@ public void onClick(View v) {
@Override
public void applyStyle(Editable editable, int start, int end) {
logAllBulletListItems(editable);
- ListBulletSpan[] listSpans = editable.getSpans(start, end,
- ListBulletSpan.class);
+ ListBulletSpan[] listSpans = editable.getSpans(start, end, ListBulletSpan.class);
if (null == listSpans || listSpans.length == 0) {
return;
}
@@ -261,7 +256,7 @@ public void applyStyle(Editable editable, int start, int end) {
} else {
//
// User deletes
- ListBulletSpan theFirstSpan = listSpans[0];
+ ListBulletSpan theFirstSpan = null;
if (listSpans.length > 0) {
FindFirstAndLastBulletSpan findFirstAndLastBulletSpan = new FindFirstAndLastBulletSpan(editable, listSpans).invoke();
theFirstSpan = findFirstAndLastBulletSpan.getFirstTargetSpan();
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Subscript.java b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Subscript.java
index 4a32e84..0185c2c 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Subscript.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Subscript.java
@@ -1,6 +1,7 @@
package com.chinalwb.are.styles.toolitems.styles;
import android.view.View;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
@@ -38,6 +39,11 @@ public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
+
@Override
public void setListenerForImageView(final ImageView imageView) {
imageView.setOnClickListener(new View.OnClickListener() {
diff --git a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Superscript.java b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Superscript.java
index d7845fb..fb81564 100644
--- a/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Superscript.java
+++ b/ARE/are/src/main/java/com/chinalwb/are/styles/toolitems/styles/ARE_Style_Superscript.java
@@ -1,6 +1,7 @@
package com.chinalwb.are.styles.toolitems.styles;
import android.view.View;
+import android.widget.EditText;
import android.widget.ImageView;
import com.chinalwb.are.AREditText;
@@ -41,6 +42,11 @@ public void setEditText(AREditText editText) {
this.mEditText = editText;
}
+ @Override
+ public EditText getEditText() {
+ return mEditText;
+ }
+
@Override
public void setListenerForImageView(final ImageView imageView) {
imageView.setOnClickListener(new View.OnClickListener() {
diff --git a/ARE/are/src/main/res/layout/are_toolbar.xml b/ARE/are/src/main/res/layout/are_toolbar.xml
index b904417..12cdb98 100644
--- a/ARE/are/src/main/res/layout/are_toolbar.xml
+++ b/ARE/are/src/main/res/layout/are_toolbar.xml
@@ -35,6 +35,7 @@
android:layout_height="40dp"
android:padding="5dp"
android:src="@drawable/emoji"
+ android:visibility="gone"
/>
+
diff --git a/ARE/build.gradle b/ARE/build.gradle
index 02fc55f..8814250 100644
--- a/ARE/build.gradle
+++ b/ARE/build.gradle
@@ -1,16 +1,20 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
-buildscript {
+buildscript {
+ ext.kotlin_version = '1.3.31'
+
repositories {
+ maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
- }
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
}
allprojects {
repositories {
+ maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
jcenter()
google()
}
diff --git a/ARE/local.properties b/ARE/local.properties
index 27f065e..16d3ec4 100644
--- a/ARE/local.properties
+++ b/ARE/local.properties
@@ -2,6 +2,7 @@
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
-#
-#Sun Jan 14 19:51:17 CST 2018
-sdk.dir=/Users/wliu/Library/Android/sdk
+# For customization when using a Version Control System, please read the
+# header note.
+#Tue Sep 03 11:27:38 CST 2019
+sdk.dir=/Users/mac/Library/Android/sdk