├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── e1.png
│ │ │ │ ├── e10.png
│ │ │ │ ├── e11.png
│ │ │ │ ├── e12.png
│ │ │ │ ├── e13.png
│ │ │ │ ├── e14.png
│ │ │ │ ├── e15.png
│ │ │ │ ├── e16.png
│ │ │ │ ├── e17.png
│ │ │ │ ├── e18.png
│ │ │ │ ├── e19.png
│ │ │ │ ├── e2.png
│ │ │ │ ├── e20.png
│ │ │ │ ├── e21.png
│ │ │ │ ├── e22.png
│ │ │ │ ├── e23.png
│ │ │ │ ├── e24.png
│ │ │ │ ├── e25.png
│ │ │ │ ├── e26.png
│ │ │ │ ├── e27.png
│ │ │ │ ├── e28.png
│ │ │ │ ├── e29.png
│ │ │ │ ├── e3.png
│ │ │ │ ├── e30.png
│ │ │ │ ├── e31.png
│ │ │ │ ├── e32.png
│ │ │ │ ├── e33.png
│ │ │ │ ├── e34.png
│ │ │ │ ├── e35.png
│ │ │ │ ├── e36.png
│ │ │ │ ├── e37.png
│ │ │ │ ├── e38.png
│ │ │ │ ├── e39.png
│ │ │ │ ├── e4.png
│ │ │ │ ├── e40.png
│ │ │ │ ├── e41.png
│ │ │ │ ├── e42.png
│ │ │ │ ├── e43.png
│ │ │ │ ├── e44.png
│ │ │ │ ├── e45.png
│ │ │ │ ├── e46.png
│ │ │ │ ├── e47.png
│ │ │ │ ├── e48.png
│ │ │ │ ├── e49.png
│ │ │ │ ├── e5.png
│ │ │ │ ├── e50.png
│ │ │ │ ├── e51.png
│ │ │ │ ├── e52.png
│ │ │ │ ├── e53.png
│ │ │ │ ├── e54.png
│ │ │ │ ├── e55.png
│ │ │ │ ├── e56.png
│ │ │ │ ├── e57.png
│ │ │ │ ├── e58.png
│ │ │ │ ├── e59.png
│ │ │ │ ├── e6.png
│ │ │ │ ├── e60.png
│ │ │ │ ├── e61.png
│ │ │ │ ├── e62.png
│ │ │ │ ├── e63.png
│ │ │ │ ├── e7.png
│ │ │ │ ├── e8.png
│ │ │ │ ├── e9.png
│ │ │ │ ├── ly2.jpg
│ │ │ │ ├── gxx1.png
│ │ │ │ ├── gxx2.png
│ │ │ │ ├── gxx3.png
│ │ │ │ ├── gxx4.png
│ │ │ │ ├── gxx5.png
│ │ │ │ ├── gxx6.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── publish_at_d3x.png
│ │ │ │ ├── publish_face_n3x.png
│ │ │ │ ├── delete_expression.png
│ │ │ │ ├── page_indicator_focused.png
│ │ │ │ └── page_indicator_unfocused.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ └── layout
│ │ │ │ ├── activity_user_list.xml
│ │ │ │ ├── user_list_item.xml
│ │ │ │ ├── smile_image_row_expression.xml
│ │ │ │ ├── expression_gridview.xml
│ │ │ │ ├── layout_emoji_container.xml
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── mryu
│ │ │ │ └── richeditor
│ │ │ │ ├── model
│ │ │ │ ├── UserModel.java
│ │ │ │ └── InsertModel.java
│ │ │ │ ├── RichEditor
│ │ │ │ ├── widget
│ │ │ │ │ ├── LockGridView.java
│ │ │ │ │ └── EmojiLayout.java
│ │ │ │ ├── adapter
│ │ │ │ │ ├── ExpressionPagerAdapter.java
│ │ │ │ │ └── SmileImageExpressionAdapter.java
│ │ │ │ ├── Util
│ │ │ │ │ └── ScreenUtils.java
│ │ │ │ └── RichEditor.java
│ │ │ │ ├── UserListActivity.java
│ │ │ │ ├── StockListActivity.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── mryu
│ │ │ └── richeditor
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── mryu
│ │ └── richeditor
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── .idea
├── copyright
│ └── profiles_settings.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RichEditor
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e10.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e11.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e12.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e13.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e14.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e15.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e16.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e17.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e17.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e18.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e19.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e20.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e21.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e21.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e22.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e22.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e23.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e23.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e24.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e25.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e25.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e26.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e26.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e27.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e27.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e28.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e28.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e29.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e30.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e30.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e31.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e31.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e32.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e33.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e33.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e34.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e34.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e35.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e35.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e36.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e36.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e37.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e37.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e38.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e38.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e39.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e39.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e40.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e41.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e41.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e42.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e42.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e43.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e43.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e44.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e44.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e45.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e45.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e46.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e46.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e47.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e47.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e48.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e49.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e49.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e5.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e50.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e51.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e51.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e52.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e52.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e53.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e53.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e54.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e54.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e55.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e55.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e56.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e56.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e57.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e58.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e59.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e59.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e6.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e60.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e61.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e61.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e62.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e62.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e63.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e63.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e7.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e8.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/e9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/e9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ly2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/ly2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/gxx1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/gxx1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/gxx2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/gxx2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/gxx3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/gxx3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/gxx4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/gxx4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/gxx5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/gxx5.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/gxx6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/gxx6.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/publish_at_d3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/publish_at_d3x.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/publish_face_n3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/publish_face_n3x.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/delete_expression.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/delete_expression.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/page_indicator_focused.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/page_indicator_focused.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/page_indicator_unfocused.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/change9326/RichEditor/HEAD/app/src/main/res/drawable-xxhdpi/page_indicator_unfocused.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jun 13 10:55:15 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #FFFFFF
8 | #EFEFEF
9 | #f77500
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_user_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/user_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/test/java/com/mryu/richeditor/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.mryu.richeditor;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/smile_image_row_expression.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/model/UserModel.java:
--------------------------------------------------------------------------------
1 | package com.mryu.richeditor.model;
2 |
3 | import java.io.Serializable;
4 |
5 |
6 | public class UserModel implements Serializable {
7 |
8 | private String user_name;
9 |
10 | private String user_id;
11 |
12 | public String getUser_name() {
13 | return user_name;
14 | }
15 |
16 | public void setUser_name(String user_name) {
17 | this.user_name = user_name;
18 | }
19 |
20 | public String getUser_id() {
21 | return user_id;
22 | }
23 |
24 | public void setUser_id(String user_id) {
25 | this.user_id = user_id;
26 | }
27 |
28 | @Override
29 | public String toString() {
30 | return this.user_name;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/mryu/richeditor/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.mryu.richeditor;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.mryu.richeditor", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/expression_gridview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Work\2017\DevSoft\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.mryu.richeditor"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.3.1'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | testCompile 'junit:junit:4.12'
30 | //依赖注入
31 | compile 'com.jakewharton:butterknife:8.5.1'
32 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_emoji_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
21 |
22 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/RichEditor/widget/LockGridView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.mryu.richeditor.RichEditor.widget;
15 |
16 | import android.content.Context;
17 | import android.util.AttributeSet;
18 | import android.widget.GridView;
19 |
20 | public class LockGridView extends GridView {
21 |
22 | public LockGridView(Context context) {
23 | super(context);
24 | }
25 |
26 | public LockGridView(Context context, AttributeSet attrs) {
27 | super(context, attrs);
28 | }
29 |
30 |
31 | @Override
32 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
33 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
34 | super.onMeasure(widthMeasureSpec, expandSpec);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/model/InsertModel.java:
--------------------------------------------------------------------------------
1 | package com.mryu.richeditor.model;
2 |
3 | /**
4 | * Created by MryU93 on 2017/6/15.
5 | * Desc:
6 | */
7 |
8 | public class InsertModel {
9 | private String insertRule;
10 | private String insertContent;
11 | private String insertColor;
12 |
13 | public InsertModel(String insertRule, String insertContent, String insertColor) {
14 | this.insertRule = insertRule;
15 | this.insertContent = insertContent;
16 | this.insertColor = insertColor;
17 | }
18 |
19 | public String getInsertRule() {
20 | return insertRule;
21 | }
22 |
23 | public void setInsertRule(String insertRule) {
24 | this.insertRule = insertRule;
25 | }
26 |
27 | public String getInsertContent() {
28 | return insertContent;
29 | }
30 |
31 | public void setInsertContent(String insertContent) {
32 | this.insertContent = insertContent;
33 | }
34 |
35 | public String getInsertColor() {
36 | return insertColor;
37 | }
38 |
39 | public void setInsertColor(String insertColor) {
40 | this.insertColor = insertColor;
41 | }
42 |
43 | @Override
44 | public String toString() {
45 | return "InsertModel{" +
46 | "insertRule='" + insertRule + '\'' +
47 | ", insertContent='" + insertContent + '\'' +
48 | ", insertColor='" + insertColor + '\'' +
49 | '}';
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/RichEditor/adapter/ExpressionPagerAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.mryu.richeditor.RichEditor.adapter;
15 |
16 | import android.support.v4.view.PagerAdapter;
17 | import android.support.v4.view.ViewPager;
18 | import android.view.View;
19 |
20 | import java.util.List;
21 |
22 | public class ExpressionPagerAdapter extends PagerAdapter {
23 |
24 | private List views;
25 |
26 | public ExpressionPagerAdapter(List views) {
27 | this.views = views;
28 | }
29 |
30 | @Override
31 | public int getCount() {
32 | return views.size();
33 | }
34 |
35 | @Override
36 | public boolean isViewFromObject(View arg0, Object arg1) {
37 | return arg0 == arg1;
38 | }
39 |
40 | @Override
41 | public Object instantiateItem(View arg0, int arg1) {
42 | ((ViewPager) arg0).addView(views.get(arg1));
43 | return views.get(arg1);
44 | }
45 |
46 | @Override
47 | public void destroyItem(View arg0, int arg1, Object arg2) {
48 | ((ViewPager) arg0).removeView(views.get(arg1));
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/RichEditor/adapter/SmileImageExpressionAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package com.mryu.richeditor.RichEditor.adapter;
15 |
16 | import android.content.Context;
17 | import android.view.View;
18 | import android.view.ViewGroup;
19 | import android.widget.ArrayAdapter;
20 | import android.widget.ImageView;
21 |
22 | import com.mryu.richeditor.R;
23 | import com.mryu.richeditor.RichEditor.RichEditor;
24 |
25 | import java.util.List;
26 |
27 |
28 | public class SmileImageExpressionAdapter extends ArrayAdapter {
29 |
30 | public SmileImageExpressionAdapter(Context context, int textViewResourceId, List objects) {
31 | super(context, textViewResourceId, objects);
32 | }
33 |
34 |
35 | @Override
36 | public View getView(int position, View convertView, ViewGroup parent) {
37 | if (convertView == null) {
38 | convertView = View.inflate(getContext(), R.layout.smile_image_row_expression, null);
39 | }
40 |
41 | ImageView imageView = (ImageView) convertView.findViewById(R.id.iv_expression);
42 |
43 | String filename = getItem(position);
44 | int resId = RichEditor.ParseIconResId(filename);
45 | imageView.setImageResource(resId);
46 | return convertView;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/UserListActivity.java:
--------------------------------------------------------------------------------
1 | package com.mryu.richeditor;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.AdapterView;
9 | import android.widget.ArrayAdapter;
10 | import android.widget.ListView;
11 |
12 | import com.mryu.richeditor.model.UserModel;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | import butterknife.BindView;
18 | import butterknife.ButterKnife;
19 |
20 | /**
21 | * Created by MryU93 on 2017/6/13.
22 | * Desc:
23 | */
24 |
25 | public class UserListActivity extends AppCompatActivity {
26 |
27 | public final static String DATA = "data";
28 |
29 | @BindView(R.id.user_list)
30 | ListView userList;
31 |
32 | private List data = new ArrayList<>();
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_user_list);
38 | ButterKnife.bind(this);
39 |
40 | for (int i = 0; i < 50; i++) {
41 | UserModel userModel = new UserModel();
42 | userModel.setUser_name("小明" + i);
43 | userModel.setUser_id(i * 30 + "");
44 | data.add(userModel);
45 | }
46 |
47 | ArrayAdapter adapter = new ArrayAdapter(this, R.layout.user_list_item, data);
48 | userList.setAdapter(adapter);
49 | userList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
50 | @Override
51 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
52 | Intent intent = new Intent();
53 | intent.putExtra(DATA, data.get(position));
54 | setResult(Activity.RESULT_OK, intent);
55 | finish();
56 | }
57 | });
58 |
59 | }
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/StockListActivity.java:
--------------------------------------------------------------------------------
1 | package com.mryu.richeditor;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.AdapterView;
9 | import android.widget.ArrayAdapter;
10 | import android.widget.ListView;
11 |
12 | import com.mryu.richeditor.model.UserModel;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | import butterknife.BindView;
18 | import butterknife.ButterKnife;
19 |
20 | /**
21 | * Created by MryU93 on 2017/6/13.
22 | * Desc:
23 | */
24 |
25 | public class StockListActivity extends AppCompatActivity {
26 |
27 | public final static String DATA = "data";
28 |
29 | @BindView(R.id.user_list)
30 | ListView userList;
31 |
32 | private List data = new ArrayList<>();
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_user_list);
38 | ButterKnife.bind(this);
39 |
40 | for (int i = 0; i < 50; i++) {
41 | UserModel userModel = new UserModel();
42 | userModel.setUser_name("股票代码" + i);
43 | userModel.setUser_id(i * 30 + "");
44 | data.add(userModel);
45 | }
46 |
47 | ArrayAdapter adapter = new ArrayAdapter(this, R.layout.user_list_item, data);
48 | userList.setAdapter(adapter);
49 | userList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
50 | @Override
51 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
52 | Intent intent = new Intent();
53 | intent.putExtra(DATA, data.get(position));
54 | setResult(Activity.RESULT_OK, intent);
55 | finish();
56 | }
57 | });
58 |
59 | }
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/RichEditor/Util/ScreenUtils.java:
--------------------------------------------------------------------------------
1 | package com.mryu.richeditor.RichEditor.Util;
2 |
3 | import android.content.Context;
4 | import android.util.DisplayMetrics;
5 | import android.view.WindowManager;
6 |
7 | /**
8 | * Created by MryU93 on 2017/6/13.
9 | * Desc:
10 | */
11 |
12 | public class ScreenUtils {
13 |
14 | /**
15 | * sp转为px
16 | */
17 | public static int sp2px(Context context, float spValue) {
18 | float fontScale = context.getResources().getDisplayMetrics().density;
19 | return (int) (spValue * fontScale + 0.5f);
20 | }
21 |
22 | /**
23 | * px转为sp
24 | */
25 | public static int px2sp(Context context, float pxValue) {
26 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
27 | return (int) (pxValue / fontScale + 0.5f);
28 | }
29 |
30 | /**
31 | * dip转为PX
32 | */
33 | public static int dip2px(Context context, float dipValue) {
34 | float fontScale = context.getResources().getDisplayMetrics().density;
35 | return (int) (dipValue * fontScale + 0.5f);
36 | }
37 |
38 | /**
39 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
40 | */
41 | public static int px2dip(Context context, float pxValue) {
42 | final float scale = context.getResources().getDisplayMetrics().density;
43 | return (int) (pxValue / scale + 0.5f);
44 | }
45 |
46 | /**
47 | * 获取屏幕的宽度px
48 | *
49 | * @param context 上下文
50 | * @return 屏幕宽px
51 | */
52 | public static int getScreenWidth(Context context) {
53 | WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
54 | DisplayMetrics outMetrics = new DisplayMetrics();// 创建了一张白纸
55 | windowManager.getDefaultDisplay().getMetrics(outMetrics);// 给白纸设置宽高
56 | return outMetrics.widthPixels;
57 | }
58 |
59 | /**
60 | * 获取屏幕的高度px
61 | *
62 | * @param context 上下文
63 | * @return 屏幕高px
64 | */
65 | public static int getScreenHeight(Context context) {
66 | WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
67 | DisplayMetrics outMetrics = new DisplayMetrics();// 创建了一张白纸
68 | windowManager.getDefaultDisplay().getMetrics(outMetrics);// 给白纸设置宽高
69 | return outMetrics.heightPixels;
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
20 |
31 |
32 |
42 |
43 |
53 |
54 |
65 |
66 |
72 |
73 |
79 |
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.mryu.richeditor;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.RelativeLayout;
9 | import android.widget.TextView;
10 |
11 | import com.mryu.richeditor.RichEditor.RichEditor;
12 | import com.mryu.richeditor.RichEditor.widget.EmojiLayout;
13 | import com.mryu.richeditor.model.InsertModel;
14 | import com.mryu.richeditor.model.UserModel;
15 |
16 | import butterknife.BindView;
17 | import butterknife.ButterKnife;
18 | import butterknife.OnClick;
19 |
20 | public class MainActivity extends AppCompatActivity {
21 |
22 | public final static int REQUEST_USER_CODE_CLICK = 2222;
23 | public final static int REQUEST_STOCK_CODE_CLICK = 3333;
24 | @BindView(R.id.richEditor)
25 | RichEditor richEditor;
26 | @BindView(R.id.activity_main)
27 | RelativeLayout activityMain;
28 | @BindView(R.id.btn_at)
29 | Button btnAt;
30 | @BindView(R.id.btn_topic)
31 | Button btnTopic;
32 | @BindView(R.id.btn_get1)
33 | Button btnGet1;
34 | @BindView(R.id.tv_content)
35 | TextView tvContent;
36 | @BindView(R.id.btn_emoji)
37 | Button btnEmoji;
38 | @BindView(R.id.emojiLayout)
39 | EmojiLayout emojiLayout;
40 |
41 | @Override
42 | protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 | setContentView(R.layout.activity_main);
45 | ButterKnife.bind(this);
46 | emojiLayout.setEditTextSmile(richEditor);
47 |
48 | }
49 |
50 |
51 | @OnClick({R.id.btn_at, R.id.btn_topic, R.id.btn_get1, R.id.btn_emoji, R.id.activity_main})
52 | public void onClick(View view) {
53 | switch (view.getId()) {
54 | case R.id.btn_at:
55 | startActivityForResult(new Intent(MainActivity.this, UserListActivity.class), REQUEST_USER_CODE_CLICK);
56 | break;
57 | case R.id.btn_topic:
58 | startActivityForResult(new Intent(MainActivity.this, StockListActivity.class), REQUEST_STOCK_CODE_CLICK);
59 | break;
60 | case R.id.btn_get1:
61 | tvContent.setText(richEditor.getRichContent());
62 | break;
63 | case R.id.btn_emoji:
64 | emojiLayout.hideKeyboard();
65 | if (emojiLayout.getVisibility() == View.VISIBLE) {
66 | emojiLayout.setVisibility(View.GONE);
67 | } else {
68 | emojiLayout.setVisibility(View.VISIBLE);
69 | }
70 | break;
71 | case R.id.activity_main:
72 | emojiLayout.setVisibility(View.GONE);
73 | break;
74 | }
75 | }
76 |
77 | @Override
78 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
79 | super.onActivityResult(requestCode, resultCode, data);
80 | if (resultCode == RESULT_OK) {
81 | switch (requestCode) {
82 | case REQUEST_USER_CODE_CLICK:
83 | UserModel userModel = (UserModel) data.getSerializableExtra(UserListActivity.DATA);
84 | richEditor.insertSpecialStr(new InsertModel("@", userModel.getUser_name(), "#f77500"));
85 | break;
86 | case REQUEST_STOCK_CODE_CLICK:
87 | UserModel stockModel = (UserModel) data.getSerializableExtra(StockListActivity.DATA);
88 | richEditor.insertSpecialStr(new InsertModel("#", stockModel.getUser_name(), "#f77500"));
89 | break;
90 | }
91 | }
92 |
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ##RichEditor
2 | 类似新浪微博EditText,可@某人,#插入话题,表情。
3 |
4 | 
5 |
6 | ###实现思路
7 | 1. 在光标处插入特殊字符
8 |
9 | //将特殊字符插入到EditText 中显示
10 | int index = getSelectionStart();//光标位置
11 | Editable editable = getText();//原先内容
12 | SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(editable);
13 | Spanned htmlText = Html.fromHtml(String.format(String.format("" + insertContent + "", insertColor)));
14 | spannableStringBuilder.insert(index, htmlText);
15 | spannableStringBuilder.insert(index + htmlText.length(), "\b");
16 | setText(spannableStringBuilder);
17 | setSelection(index + htmlText.length() + 1);
18 | 2. 实现特殊字符选中删除效果
19 |
20 | /**
21 | * 监听删除键
22 | * 1.光标在话题后面,将整个话题内容删除
23 | * 2.光标在普通文字后面,删除一个字符
24 | *
25 | */
26 | this.setOnKeyListener(new View.OnKeyListener() {
27 | @Override
28 | public boolean onKey(View v, int keyCode, KeyEvent event) {
29 | if (keyCode == KeyEvent.KEYCODE_DEL && event.getAction() == KeyEvent.ACTION_DOWN) {
30 |
31 | int selectionStart = getSelectionStart();
32 | int selectionEnd = getSelectionEnd();
33 |
34 | /**
35 | * 如果光标起始和结束不在同一位置,删除文本
36 | */
37 | if (selectionStart != selectionEnd) {
38 | // 查询文本是否属于目标对象,若是移除列表数据
39 | String tagetText = getText().toString().substring(
40 | selectionStart, selectionEnd);
41 | for (int i = 0; i < insertModelList.size(); i++) {
42 | InsertModel object = insertModelList.get(i);
43 | if (tagetText.equals(object.getInsertContent())) {
44 | insertModelList.remove(object);
45 | }
46 | }
47 | return false;
48 | }
49 |
50 |
51 | int lastPos = 0;
52 | Editable editable = getText();
53 | // 遍历判断光标的位置
54 | for (int i = 0; i < insertModelList.size(); i++) {
55 | String objectText = insertModelList.get(i).getInsertContent();
56 | lastPos = getText().toString().indexOf(objectText, lastPos);
57 | if (lastPos != -1) {
58 | if (selectionStart != 0 && selectionStart >= lastPos && selectionStart <= (lastPos + objectText.length())) {
59 | // 选中话题
60 | setSelection(lastPos, lastPos + objectText.length());
61 | // 设置背景色
62 | editable.setSpan(new BackgroundColorSpan(BACKGROUND_COLOR), lastPos, lastPos + objectText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
63 | return true;
64 | }
65 | }
66 | lastPos += objectText.length();
67 | }
68 | }
69 |
70 | return false;
71 | }
72 | });
73 | 3. 设置点击特殊字符光标自动移动到特殊字符之后
74 |
75 | /**
76 | * 监听光标的位置,若光标处于话题内容中间则移动光标到话题结束位置
77 | *
78 | */
79 | @Override
80 | protected void onSelectionChanged(int selStart, int selEnd) {
81 | super.onSelectionChanged(selStart, selEnd);
82 | if (insertModelList == null || insertModelList.size() == 0)
83 | return;
84 | int startPostion = 0;
85 | int endPostion = 0;
86 | String insertContent = "";
87 | for (int i = 0; i < insertModelList.size(); i++) {
88 | insertContent = insertModelList.get(i).getInsertContent();
89 | startPostion = getText().toString().indexOf(insertContent);
90 | endPostion = startPostion + insertContent.length();
91 | if (startPostion != -1 && selStart > startPostion
92 | && selStart <= endPostion) {// 若光标处于话题内容中间则移动光标到话题结束位置
93 | setSelection(endPostion);
94 | }
95 | }}
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/RichEditor/widget/EmojiLayout.java:
--------------------------------------------------------------------------------
1 | package com.mryu.richeditor.RichEditor.widget;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.support.v4.view.ViewPager;
6 | import android.util.AttributeSet;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.view.WindowManager;
11 | import android.view.inputmethod.InputMethodManager;
12 | import android.widget.AdapterView;
13 | import android.widget.EditText;
14 | import android.widget.ImageView;
15 | import android.widget.LinearLayout;
16 |
17 | import com.mryu.richeditor.R;
18 | import com.mryu.richeditor.RichEditor.RichEditor;
19 | import com.mryu.richeditor.RichEditor.Util.ScreenUtils;
20 | import com.mryu.richeditor.RichEditor.adapter.ExpressionPagerAdapter;
21 | import com.mryu.richeditor.RichEditor.adapter.SmileImageExpressionAdapter;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | import butterknife.BindView;
27 | import butterknife.ButterKnife;
28 |
29 | /**
30 | * Created by MryU93 on 2017/6/15.
31 | * Desc:
32 | */
33 |
34 | public class EmojiLayout extends LinearLayout {
35 |
36 | private static int[] IMG_LIST = new int[]{
37 | R.drawable.e1, R.drawable.e2, R.drawable.e3, R.drawable.e4, R.drawable.e5, R.drawable.e6,
38 | R.drawable.e7, R.drawable.e8, R.drawable.e9, R.drawable.e10, R.drawable.e11, R.drawable.e12,
39 | R.drawable.e13, R.drawable.e14, R.drawable.e15, R.drawable.e16, R.drawable.e17, R.drawable.e18,
40 | R.drawable.e19, R.drawable.e20, R.drawable.e21, R.drawable.e22, R.drawable.e23, R.drawable.e24,
41 | R.drawable.e25, R.drawable.e26, R.drawable.e27, R.drawable.e28, R.drawable.e29, R.drawable.e30, R.drawable.e31,
42 | R.drawable.e32, R.drawable.e33, R.drawable.e34, R.drawable.e35, R.drawable.e36, R.drawable.e37,
43 | };
44 |
45 | @BindView(R.id.edittext_bar_vPager)
46 | ViewPager edittextBarVPager;
47 | @BindView(R.id.edittext_bar_viewGroup_face)
48 | LinearLayout edittextBarViewGroupFace;
49 | @BindView(R.id.edittext_bar_ll_face_container)
50 | LinearLayout edittextBarLlFaceContainer;
51 | @BindView(R.id.edittext_bar_more)
52 | LinearLayout edittextBarMore;
53 |
54 | private RichEditor editTextEmoji;
55 | private List reslist = new ArrayList<>();
56 | private ImageView[] imageFaceViews;
57 |
58 | public EmojiLayout(Context context) {
59 | super(context);
60 | init(context);
61 | }
62 |
63 | public EmojiLayout(Context context, AttributeSet attrs) {
64 | super(context, attrs);
65 | init(context);
66 | }
67 |
68 | public EmojiLayout(Context context, AttributeSet attrs, int defStyleAttr) {
69 | super(context, attrs, defStyleAttr);
70 | init(context);
71 | }
72 |
73 |
74 | private void init(Context context) {
75 | View view = LayoutInflater.from(context).inflate(R.layout.layout_emoji_container, this, true);
76 | if (isInEditMode())
77 | return;
78 | ButterKnife.bind(this, view);
79 | initViews();
80 |
81 | }
82 |
83 |
84 | /**
85 | * 初始化View
86 | */
87 | private void initViews() {
88 | int size = ScreenUtils.dip2px(getContext(), 5);
89 | int marginSize = ScreenUtils.dip2px(getContext(), 5);
90 | // 表情list
91 | List smile = new ArrayList<>();
92 | for (int i = 1; i <= IMG_LIST.length; i++) {
93 | smile.add("[e" + i + "]");
94 | }
95 | reslist.addAll(smile);
96 | // 初始化表情viewpager
97 | List views = new ArrayList<>();
98 | int gridChildSize = (int) Math.ceil((double) reslist.size() / (double) 21);
99 | for (int i = 1; i <= gridChildSize; i++) {
100 | views.add(getGridChildView(i));
101 | }
102 | ImageView imageViewFace;
103 | imageFaceViews = new ImageView[views.size()];
104 | for (int i = 0; i < views.size(); i++) {
105 | LayoutParams margin = new LayoutParams(size, size);
106 | margin.setMargins(marginSize, 0, 0, 0);
107 | imageViewFace = new ImageView(getContext());
108 | imageViewFace.setLayoutParams(new ViewGroup.LayoutParams(size, size));
109 | imageFaceViews[i] = imageViewFace;
110 | if (i == 0) {
111 | imageFaceViews[i].setBackgroundResource(R.drawable.page_indicator_focused);
112 | } else {
113 | imageFaceViews[i].setBackgroundResource(R.drawable.page_indicator_unfocused);
114 | }
115 | edittextBarViewGroupFace.addView(imageFaceViews[i], margin);
116 | }
117 | edittextBarVPager.setAdapter(new ExpressionPagerAdapter(views));
118 | edittextBarVPager.addOnPageChangeListener(new GuidePageChangeListener());
119 |
120 | }
121 |
122 | /**
123 | * 获取表情的gridview的子view
124 | */
125 | private View getGridChildView(int i) {
126 | View view = View.inflate(getContext(), R.layout.expression_gridview, null);
127 | LockGridView gv = (LockGridView) view.findViewById(R.id.gridview);
128 | List list = new ArrayList<>();
129 | int startInd = (i - 1) * 21;
130 | if ((startInd + 21) >= reslist.size()) {
131 | list.addAll(reslist.subList(startInd, startInd + (reslist.size() - startInd)));
132 | } else {
133 | list.addAll(reslist.subList(startInd, startInd + 21));
134 | }
135 | final SmileImageExpressionAdapter smileImageExpressionAdapter = new SmileImageExpressionAdapter(getContext(), 1, list);
136 | gv.setAdapter(smileImageExpressionAdapter);
137 | gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
138 |
139 | @Override
140 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
141 | String filename = smileImageExpressionAdapter.getItem(position);
142 | editTextEmoji.insertIcon(filename);
143 | }
144 | });
145 | return view;
146 | }
147 |
148 | class GuidePageChangeListener implements ViewPager.OnPageChangeListener {
149 |
150 | @Override
151 | public void onPageScrollStateChanged(int arg0) {
152 | }
153 |
154 | @Override
155 | public void onPageScrolled(int arg0, float arg1, int arg2) {
156 |
157 | }
158 |
159 | @Override
160 | public void onPageSelected(int arg0) {
161 |
162 | for (int i = 0; i < imageFaceViews.length; i++) {
163 | imageFaceViews[arg0].setBackgroundResource(R.drawable.page_indicator_focused);
164 |
165 | if (arg0 != i) {
166 | imageFaceViews[i].setBackgroundResource(R.drawable.page_indicator_unfocused);
167 | }
168 | }
169 | }
170 | }
171 |
172 | /**
173 | * 隐藏软键盘
174 | */
175 | public void hideKeyboard() {
176 | Activity context = (Activity) getContext();
177 | if (context.getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
178 | if (context.getCurrentFocus() != null) {
179 | ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)).
180 | hideSoftInputFromWindow(context.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
181 | }
182 | }
183 | }
184 |
185 | /**
186 | * 显示键盘
187 | */
188 | public void showKeyboard() {
189 | editTextEmoji.requestFocus();
190 | InputMethodManager inputManager =
191 | (InputMethodManager) editTextEmoji.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
192 | inputManager.showSoftInput(editTextEmoji, 0);
193 | }
194 |
195 |
196 | public EditText getEditTextSmile() {
197 | return editTextEmoji;
198 | }
199 |
200 | public void setEditTextSmile(RichEditor editTextSmile) {
201 | this.editTextEmoji = editTextSmile;
202 | editTextSmile.setOnClickListener(new OnClickListener() {
203 | @Override
204 | public void onClick(View v) {
205 | setVisibility(GONE);
206 | }
207 | });
208 | }
209 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mryu/richeditor/RichEditor/RichEditor.java:
--------------------------------------------------------------------------------
1 | package com.mryu.richeditor.RichEditor;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.Drawable;
6 | import android.support.v4.content.ContextCompat;
7 | import android.support.v7.widget.AppCompatEditText;
8 | import android.text.Editable;
9 | import android.text.Html;
10 | import android.text.InputFilter;
11 | import android.text.Spannable;
12 | import android.text.SpannableString;
13 | import android.text.SpannableStringBuilder;
14 | import android.text.Spanned;
15 | import android.text.TextUtils;
16 | import android.text.TextWatcher;
17 | import android.text.style.BackgroundColorSpan;
18 | import android.text.style.ImageSpan;
19 | import android.util.AttributeSet;
20 | import android.view.KeyEvent;
21 | import android.view.MotionEvent;
22 | import android.view.View;
23 | import android.widget.Toast;
24 |
25 | import com.mryu.richeditor.RichEditor.Util.ScreenUtils;
26 | import com.mryu.richeditor.model.InsertModel;
27 |
28 | import java.util.ArrayList;
29 | import java.util.List;
30 |
31 | /**
32 | * Created by MryU93 on 2017/6/13.
33 | *
34 | * Desc:
35 | */
36 |
37 | public class RichEditor extends AppCompatEditText {
38 |
39 | private static String TAG = "RichEditor";
40 | private int size;
41 | private int maxLength = 2000;
42 | private List insertModelList = new ArrayList<>();
43 | private static final int BACKGROUND_COLOR = Color.parseColor("#FFDEAD"); // 默认,话题背景高亮颜色
44 | private static Context mContext;
45 |
46 | public RichEditor(Context context) {
47 | super(context);
48 | this.mContext = context;
49 | initView();
50 | }
51 |
52 | public RichEditor(Context context, AttributeSet attrs) {
53 | super(context, attrs);
54 | this.mContext = context;
55 | if (isInEditMode())
56 | return;
57 | InputFilter[] filters = {new InputFilter.LengthFilter(maxLength)};
58 | setFilters(filters);
59 | size = ScreenUtils.dip2px(context, 20);
60 | initView();
61 | }
62 |
63 | public static int ParseIconResId(String name) {
64 | name = name.substring(1, name.length() - 1);
65 | int resId = mContext.getResources().getIdentifier(name, "drawable", mContext.getPackageName());
66 | return resId;
67 | }
68 |
69 | public void insertIcon(String name) {
70 | String curString = getText().toString();
71 | if ((curString.length() + name.length()) > maxLength) {
72 | return;
73 | }
74 | Drawable drawable = ContextCompat.getDrawable(mContext, ParseIconResId(name));
75 |
76 | if (drawable == null)
77 | return;
78 | drawable.setBounds(0, 0, size, size);//这里设置图片的大小
79 | ImageSpan imageSpan = new ImageSpan(drawable);
80 | SpannableString spannableString = new SpannableString(name);
81 | spannableString.setSpan(imageSpan, 0, spannableString.length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
82 | int index = Math.max(getSelectionStart(), 0);
83 | SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(getText());
84 | spannableStringBuilder.insert(index, spannableString);
85 |
86 | setText(spannableStringBuilder);
87 | setSelection(index + spannableString.length());
88 | }
89 |
90 |
91 | /**
92 | * 初始化控件,一些监听
93 | */
94 | private void initView() {
95 |
96 | this.addTextChangedListener(new TextWatcher() {
97 | @Override
98 | public void beforeTextChanged(CharSequence s, int start, int count,
99 | int after) {
100 | }
101 |
102 | @Override
103 | public void onTextChanged(CharSequence s, int start, int before,
104 | int count) {
105 | }
106 |
107 | @Override
108 | public void afterTextChanged(Editable s) {
109 | resolveDeleteSpecialStr();
110 | }
111 | });
112 |
113 | /**
114 | * 监听删除键
115 | * 1.光标在话题后面,将整个话题内容删除
116 | * 2.光标在普通文字后面,删除一个字符
117 | *
118 | */
119 | this.setOnKeyListener(new View.OnKeyListener() {
120 | @Override
121 | public boolean onKey(View v, int keyCode, KeyEvent event) {
122 | if (keyCode == KeyEvent.KEYCODE_DEL && event.getAction() == KeyEvent.ACTION_DOWN) {
123 |
124 | int selectionStart = getSelectionStart();
125 | int selectionEnd = getSelectionEnd();
126 |
127 | /**
128 | * 如果光标起始和结束不在同一位置,删除文本
129 | */
130 | if (selectionStart != selectionEnd) {
131 | // 查询文本是否属于目标对象,若是移除列表数据
132 | String tagetText = getText().toString().substring(
133 | selectionStart, selectionEnd);
134 | for (int i = 0; i < insertModelList.size(); i++) {
135 | InsertModel object = insertModelList.get(i);
136 | if (tagetText.equals(object.getInsertContent())) {
137 | insertModelList.remove(object);
138 | }
139 | }
140 | return false;
141 | }
142 |
143 |
144 | int lastPos = 0;
145 | Editable editable = getText();
146 | // 遍历判断光标的位置
147 | for (int i = 0; i < insertModelList.size(); i++) {
148 | String objectText = insertModelList.get(i).getInsertContent();
149 | lastPos = getText().toString().indexOf(objectText, lastPos);
150 | if (lastPos != -1) {
151 | if (selectionStart != 0 && selectionStart >= lastPos && selectionStart <= (lastPos + objectText.length())) {
152 | // 选中话题
153 | setSelection(lastPos, lastPos + objectText.length());
154 | // 设置背景色
155 | editable.setSpan(new BackgroundColorSpan(BACKGROUND_COLOR), lastPos, lastPos + objectText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
156 | return true;
157 | }
158 | }
159 | lastPos += objectText.length();
160 | }
161 | }
162 |
163 | return false;
164 | }
165 | });
166 | }
167 |
168 | /**
169 | * 监听光标的位置,若光标处于话题内容中间则移动光标到话题结束位置
170 | */
171 | @Override
172 | protected void onSelectionChanged(int selStart, int selEnd) {
173 | super.onSelectionChanged(selStart, selEnd);
174 | if (insertModelList == null || insertModelList.size() == 0)
175 | return;
176 | int startPostion = 0;
177 | int endPostion = 0;
178 | String insertContent = "";
179 | for (int i = 0; i < insertModelList.size(); i++) {
180 | insertContent = insertModelList.get(i).getInsertContent();
181 | startPostion = getText().toString().indexOf(insertContent);
182 | endPostion = startPostion + insertContent.length();
183 | if (startPostion != -1 && selStart > startPostion
184 | && selStart <= endPostion) {// 若光标处于话题内容中间则移动光标到话题结束位置
185 | setSelection(endPostion);
186 | }
187 | }
188 | }
189 |
190 | /**
191 | * @param insertModel 插入对象
192 | */
193 | public void insertSpecialStr(InsertModel insertModel) {
194 | if (insertModel == null)
195 | return;
196 | //避免插入相同的数据
197 | for (InsertModel model : insertModelList) {
198 | if ((model.getInsertContent().replace(model.getInsertRule(), "")).equals(insertModel.getInsertContent()) && model.getInsertRule().equals(insertModel.getInsertRule())) {
199 | Toast.makeText(mContext, "不可重复插入", Toast.LENGTH_LONG).show();
200 | return;
201 | }
202 | }
203 | String insertRule = insertModel.getInsertRule();
204 | String insertContent = insertModel.getInsertContent();
205 | String insertColor = insertModel.getInsertColor();
206 | if (TextUtils.isEmpty(insertRule) || TextUtils.isEmpty(insertContent))
207 | return;
208 | if (insertRule.equals("@"))
209 | insertContent = insertRule + insertContent;
210 | else
211 | insertContent = insertRule + insertContent + insertRule;
212 | insertModel.setInsertContent(insertContent);
213 |
214 | insertModelList.add(insertModel);
215 |
216 | //将特殊字符插入到EditText 中显示
217 | int index = getSelectionStart();//光标位置
218 | Editable editable = getText();//原先内容
219 | SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(editable);
220 | Spanned htmlText = Html.fromHtml(String.format(String.format("" + insertContent + "", insertColor)));
221 | spannableStringBuilder.insert(index, htmlText);
222 | spannableStringBuilder.insert(index + htmlText.length(), "\b");
223 | setText(spannableStringBuilder);
224 | setSelection(index + htmlText.length() + 1);
225 | }
226 |
227 | /**
228 | * 获取普通文本内容
229 | */
230 | public String getRichContent() {
231 | String content = getText().toString();
232 | if (insertModelList != null && insertModelList.size() > 0) {
233 | for (int i = 0; i < insertModelList.size(); i++) {
234 | InsertModel inertModel = insertModelList.get(i);
235 | content = content.replace(inertModel.getInsertContent(), "");
236 | }
237 | }
238 | return content.trim();
239 | }
240 |
241 | /**
242 | * 获取特殊字符列表
243 | */
244 | public List getRichInsertList() {
245 | List objectsList = new ArrayList<>();
246 | if (insertModelList != null && insertModelList.size() > 0) {
247 | for (int i = 0; i < insertModelList.size(); i++) {
248 | InsertModel inertModel = insertModelList.get(i);
249 | objectsList.add(new InsertModel(inertModel.getInsertRule(), inertModel.getInsertContent().replace(inertModel.getInsertRule(), ""), inertModel.getInsertColor()));
250 | }
251 | }
252 | return objectsList;
253 | }
254 |
255 |
256 | /**
257 | * 删除缓存列表
258 | */
259 | private void resolveDeleteSpecialStr() {
260 | String tagetText = getText().toString();
261 | if (TextUtils.isEmpty(tagetText)) {
262 | insertModelList.clear();
263 | return;
264 | }
265 | for (int i = 0; i < insertModelList.size(); i++) {
266 | InsertModel object = insertModelList.get(i);
267 | if (tagetText.indexOf(object.getInsertContent()) == -1) {
268 | insertModelList.remove(object);
269 | }
270 | }
271 | }
272 |
273 |
274 | private boolean isRequest = false;
275 |
276 | public boolean isRequest() {
277 | return isRequest;
278 | }
279 |
280 | //是否可以点击滑动
281 | public void setIsRequest(boolean isRequest) {
282 | this.isRequest = isRequest;
283 | }
284 |
285 |
286 | public int getEditTextMaxLength() {
287 | return maxLength;
288 | }
289 |
290 | //最大可输入长度
291 | public void setEditTextMaxLength(int maxLength) {
292 | this.maxLength = maxLength;
293 | }
294 |
295 |
296 | @Override
297 | public boolean onTouchEvent(MotionEvent event) {
298 | getParent().requestDisallowInterceptTouchEvent(isRequest);
299 | switch (event.getAction() & MotionEvent.ACTION_MASK) {
300 | case MotionEvent.ACTION_UP:
301 | getParent().requestDisallowInterceptTouchEvent(false);
302 | break;
303 | }
304 | return super.onTouchEvent(event);
305 | }
306 | }
307 |
--------------------------------------------------------------------------------