├── .gitignore
├── .idea
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── .travis.yml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── objectbox-models
│ └── default.json
├── proguard-rules.pro
├── release
│ └── output.json
└── src
│ ├── androidTest
│ └── java
│ │ └── ir
│ │ └── textmining
│ │ └── app
│ │ └── ExampleInstrumentedTest.java
│ ├── debug
│ └── google-services.json
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── fonts
│ │ │ └── Vazir.ttf
│ ├── java
│ │ └── ir
│ │ │ └── textmining
│ │ │ └── app
│ │ │ ├── listener
│ │ │ ├── SelectTagEventListener.java
│ │ │ └── SettingsEventListener.java
│ │ │ ├── model
│ │ │ ├── AuthInfo.java
│ │ │ ├── NerStandardTagsItem.java
│ │ │ ├── ResponseMessage.java
│ │ │ ├── Sentence.java
│ │ │ ├── TagInfo.java
│ │ │ ├── TagsLegend.java
│ │ │ └── WordsItem.java
│ │ │ ├── service
│ │ │ └── APIService.java
│ │ │ ├── ui
│ │ │ ├── activity
│ │ │ │ ├── AppIntroActivity.java
│ │ │ │ ├── BaseActivity.java
│ │ │ │ ├── LauncherActivity.java
│ │ │ │ └── MainActivity.java
│ │ │ └── fragment
│ │ │ │ ├── AboutFragment.java
│ │ │ │ ├── SelectTagFragment.java
│ │ │ │ ├── SettingsFragment.java
│ │ │ │ └── TagLegendFragment.java
│ │ │ └── util
│ │ │ ├── AppUtil.java
│ │ │ ├── Constant.java
│ │ │ ├── LocaleManager.java
│ │ │ ├── MyApplication.java
│ │ │ ├── RetrofitUtil.java
│ │ │ └── SettingsManager.java
│ └── res
│ │ ├── drawable-ldrtl
│ │ └── ic_navigate_next_black_24dp.xml
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_close_black_24dp.xml
│ │ ├── ic_code_black_24dp.xml
│ │ ├── ic_exit_to_app_black_24dp.xml
│ │ ├── ic_info_outline_black_24dp.xml
│ │ ├── ic_logo.png
│ │ ├── ic_menu_black_24dp.xml
│ │ ├── ic_navigate_next_black_24dp.xml
│ │ ├── ic_settings_black_24dp.xml
│ │ ├── ic_sync_black_24dp.xml
│ │ ├── ic_web_black_24dp.xml
│ │ ├── page_1.png
│ │ ├── page_2.png
│ │ ├── page_3.png
│ │ ├── page_4.png
│ │ └── page_5.png
│ │ ├── layout
│ │ ├── activity_launcher.xml
│ │ ├── activity_main.xml
│ │ ├── content_main.xml
│ │ ├── dialog_full_screen_loading.xml
│ │ ├── fragment_about.xml
│ │ ├── fragment_select_tag.xml
│ │ ├── fragment_settings.xml
│ │ ├── fragment_tag_legend.xml
│ │ ├── item_chip.xml
│ │ ├── item_skeleton.xml
│ │ ├── item_tag_info.xml
│ │ └── item_tag_legend.xml
│ │ ├── menu
│ │ └── navigation.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-ldpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-fa
│ │ └── strings.xml
│ │ ├── values-night
│ │ ├── colors.xml
│ │ └── styles.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── ir
│ └── textmining
│ └── app
│ └── ExampleUnitTest.java
├── assets
└── screenshot.png
├── build.gradle
├── encrypt.tar.enc
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/android
3 | # Edit at https://www.gitignore.io/?templates=android
4 |
5 | ### Android ###
6 | # Built application files
7 | *.apk
8 | *.ap_
9 | *.aab
10 |
11 | # Files for the ART/Dalvik VM
12 | *.dex
13 |
14 | # Java class files
15 | *.class
16 |
17 | # Generated files
18 | bin/
19 | gen/
20 | out/
21 |
22 | # Gradle files
23 | .gradle/
24 | build/
25 |
26 | # Local configuration file (sdk path, etc)
27 | local.properties
28 |
29 | # Proguard folder generated by Eclipse
30 | proguard/
31 |
32 | # Log Files
33 | *.log
34 |
35 | # Android Studio Navigation editor temp files
36 | .navigation/
37 |
38 | # Android Studio captures folder
39 | captures/
40 |
41 | # IntelliJ
42 | *.iml
43 | .idea/workspace.xml
44 | .idea/tasks.xml
45 | .idea/gradle.xml
46 | .idea/assetWizardSettings.xml
47 | .idea/dictionaries
48 | .idea/libraries
49 | .idea/caches
50 |
51 | # Keystore files
52 | # Uncomment the following lines if you do not want to check your keystore files in.
53 | *.jks
54 | #*.keystore
55 |
56 | # External native build folder generated in Android Studio 2.2 and later
57 | .externalNativeBuild
58 |
59 | # Google Services (e.g. APIs or Firebase)
60 | app/src/release/google-services.json
61 |
62 | # Freeline
63 | freeline.py
64 | freeline/
65 | freeline_project_description.json
66 |
67 | # fastlane
68 | fastlane/report.xml
69 | fastlane/Preview.html
70 | fastlane/screenshots
71 | fastlane/test_output
72 | fastlane/readme.md
73 |
74 | ### Android Patch ###
75 | gen-external-apklibs
76 |
77 | # End of https://www.gitignore.io/api/android
78 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.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 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | jdk: oraclejdk8
3 | android:
4 | components:
5 | - tools
6 | - platform-tools
7 | - build-tools-28.0.3
8 | - android-28
9 | licenses:
10 | - ".+"
11 | before_install:
12 | - openssl aes-256-cbc -K $encrypted_413ff43c2836_key -iv $encrypted_413ff43c2836_iv
13 | -in encrypt.tar.enc -out encrypt.tar -d
14 | - tar xvf encrypt.tar
15 | - yes | sdkmanager "platforms;android-28"
16 | - yes | sdkmanager "build-tools;28.0.3"
17 | sudo: required
18 | install: true
19 | before_script:
20 | - chmod +x gradlew
21 | script:
22 | - "./gradlew assembleRelease --stacktrace"
23 | deploy:
24 | provider: releases
25 | skip_cleanup: true
26 | overwrite: true
27 | api_key:
28 | secure: UCRWawnW0UeH5RGEEf7Fwj9NN+GOrP4FygGGje6oSIKjbrQaJa8DhiF8ELJbElZD/4xHFcoud2M3OQxRGRkJqxbkhxCrPPrs6TMyT6FzU1UZi4932YCrgvWsWVyMA//edl7FlSFcAgjUd7XRCkZWQXjBjRjXL/3N1B+e4BSnGFTskOfjSOpx8LVZp6MkelbwM5tN/9UP7WT/N9fP12jzo8UgEfUGYriewPSlg8RGhoWps67L3zt/QVhRfboVtRn7dxE7IaApBHbfFrAF4wbYMjZ7cd+nlEi63g77/6IdjRwWvD28gC4TVVD3Kz1Nvlm+ndE0GK33/V2nAi+J4ir3g6swIq0m6IYij91EXFKsGZiznpJdLIW47si5Yrm73eDL+D5rEgjW95i+ksKvIlz+EH1CVny/pLFbmibjQWOIlfXd+xdqvre48kNT0GGC5RCuHRtq+FC84mz44jYvl0Ve/mXs2Xy3g6KdWnc1uewhiu5lMUQvTml/a/3SDFeudxfEOrW0jMllaTciQ7BlO+co4tanP4LmycoenkW179dagIC/MT6hFVxa2Ao1qV3yMmJo+Q/4dJUA9+oN5O78nL/CfJ93xqgCzAk6B44vbbU4VKk9JP83mMj5rVaIyeFv0ankIIFSlxPHADW77WK53uIN2KmKVgTY9yP2MwmfL/OhAJY=
29 | file_glob: true
30 | file: app/build/outputs/apk/release/PersianNER*.apk
31 | on:
32 | repo: Text-Mining/android-app
33 | tags: true
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # فارسییار
4 |
5 | [](https://travis-ci.org/Text-Mining/android-app)
6 | [](https://cafebazaar.ir/app/ir.textmining.app/?l=fa)
7 |
8 | اپلیکیشن اندروید: برنامه برچسبزنی پیکرههای پردازش متن
9 |
10 |
11 |
12 |
13 | **نیازمندیها**
14 | - Android Studio 3.3.0
15 | - JDK 8
16 | - Android SDK Build tools 28.0.3
17 | - Supports API Level +17
18 | - Support libraries with androidx v1.0.0
19 |
20 | **کتابخانهها**
21 | - [Support libraries]: appcompat / recyclerview / constraintlayout
22 | - [Material Design 2]: MaterialCardView / MaterialButton / Bottom App Bars
23 | - [FastAdapter]: The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction
24 | - [AndroidUtilCode]: is a powerful & easy to use library for Android.
25 | - [Calligraphy3]: Custom fonts in Android the easy way
26 | - Square [Retrofit] / [Okhttp] / [Logging-Interceptor]
27 | - Firebase Core / Crashlytics / Messaging
28 | - [ButterKnife]: Bind Android views and callbacks to fields and methods.
29 |
30 | [Support libraries]: https://developer.android.com/jetpack/androidx/
31 | [Material Design 2]: https://material.io/develop/android/
32 | [FastAdapter]: https://github.com/mikepenz/FastAdapter
33 | [AndroidUtilCode]: https://github.com/Blankj/AndroidUtilCode
34 | [Calligraphy3]: https://github.com/InflationX/Calligraphy
35 | [Retrofit]: https://github.com/square/retrofit
36 | [Okhttp]: https://github.com/square/okhttp
37 | [Logging-Interceptor]: https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor
38 | [ButterKnife]: https://github.com/JakeWharton/butterknife
39 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'io.objectbox'
3 | apply plugin: 'io.fabric'
4 |
5 | def versionMajor = 1
6 | def versionMinor = 4
7 | def versionPatch = 0
8 | android {
9 | compileSdkVersion 28
10 | defaultConfig {
11 | applicationId "ir.textmining.app"
12 | minSdkVersion 17
13 | targetSdkVersion 28
14 | versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
15 | versionName "${versionMajor}.${versionMinor}.${versionPatch}"
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | vectorDrawables.useSupportLibrary = true
18 | }
19 | signingConfigs {
20 | release
21 | }
22 | buildTypes {
23 | release {
24 | signingConfig signingConfigs.release
25 | minifyEnabled true
26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27 | }
28 | debug{
29 | minifyEnabled false
30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
31 | }
32 | }
33 | def isRunningOnTravis = System.getenv("CI") == "true"
34 |
35 | if (isRunningOnTravis) {
36 | // configure keystore
37 | signingConfigs.release.storeFile = file("../PersianNER-Keystore.jks")
38 | signingConfigs.release.storePassword = System.getenv("keystore_password")
39 | signingConfigs.release.keyAlias = System.getenv("keystore_alias")
40 | signingConfigs.release.keyPassword = System.getenv("keystore_alias_password")
41 | }
42 | compileOptions {
43 | sourceCompatibility JavaVersion.VERSION_1_8
44 | targetCompatibility JavaVersion.VERSION_1_8
45 | }
46 |
47 | }
48 |
49 | dependencies {
50 | implementation fileTree(dir: 'libs', include: ['*.jar'])
51 | implementation 'androidx.appcompat:appcompat:1.0.2'
52 | implementation 'com.google.android.material:material:1.0.0'
53 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
54 | testImplementation 'junit:junit:4.12'
55 | androidTestImplementation 'androidx.test:runner:1.1.1'
56 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
57 |
58 | implementation 'com.squareup.retrofit2:retrofit:2.4.0'
59 | implementation "com.squareup.retrofit2:converter-gson:2.4.0"
60 | //use in development
61 | implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
62 |
63 | implementation 'com.github.bkhezry:prefser:v2.2.1-rx2'
64 |
65 | implementation 'com.github.ybq:Android-SpinKit:1.2.0'
66 |
67 | implementation 'io.github.inflationx:viewpump:1.0.0'
68 | implementation 'io.github.inflationx:calligraphy3:3.1.0'
69 |
70 | implementation 'com.mikepenz:fastadapter:3.3.1'
71 |
72 | implementation 'com.ethanhua:skeleton:1.1.2'
73 | implementation 'io.supercharge:shimmerlayout:2.1.0'
74 |
75 | implementation 'com.blankj:utilcode:1.23.4'
76 |
77 | implementation 'com.google.firebase:firebase-core:16.0.8'
78 | implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
79 | implementation 'com.google.firebase:firebase-messaging:17.4.0'
80 |
81 | implementation 'com.auth0.android:jwtdecode:1.2.0'
82 |
83 | implementation 'com.github.AppIntro:AppIntro:5.1.0'
84 |
85 | //ButterKnife
86 | implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
87 | annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
88 |
89 | }
90 | apply plugin: 'com.google.gms.google-services'
91 |
92 | android.applicationVariants.all { variant ->
93 | def appName = "PersianNER"
94 | variant.outputs.all { output ->
95 | def newApkName
96 | newApkName = "${appName}-${output.baseName}-${variant.versionName}.apk"
97 | output.outputFileName = new File(newApkName)
98 | }
99 | }
--------------------------------------------------------------------------------
/app/objectbox-models/default.json:
--------------------------------------------------------------------------------
1 | {
2 | "_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.",
3 | "_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.",
4 | "_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
5 | "entities": [
6 | {
7 | "id": "1:4388683412944882030",
8 | "lastPropertyId": "6:5774960738473344108",
9 | "name": "NerStandardTagsItem",
10 | "properties": [
11 | {
12 | "id": "1:8645834800257752287",
13 | "name": "id"
14 | },
15 | {
16 | "id": "2:1608456692480793391",
17 | "name": "persianName"
18 | },
19 | {
20 | "id": "3:338344431682293288",
21 | "name": "description"
22 | },
23 | {
24 | "id": "4:4009587252163662968",
25 | "name": "shortcut"
26 | },
27 | {
28 | "id": "5:4854243414368885519",
29 | "name": "color"
30 | },
31 | {
32 | "id": "6:5774960738473344108",
33 | "name": "title"
34 | }
35 | ],
36 | "relations": []
37 | }
38 | ],
39 | "lastEntityId": "1:4388683412944882030",
40 | "lastIndexId": "0:0",
41 | "lastRelationId": "0:0",
42 | "lastSequenceId": "0:0",
43 | "modelVersion": 4,
44 | "modelVersionParserMinimum": 4,
45 | "retiredEntityUids": [],
46 | "retiredIndexUids": [],
47 | "retiredPropertyUids": [],
48 | "retiredRelationUids": [],
49 | "version": 1
50 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
23 | -keepattributes SourceFile,LineNumberTable
24 | #retrofit2
25 | -dontwarn retrofit2.**
26 | -keep class retrofit2.** { *; }
27 |
28 | #okhttp3
29 | -keepattributes Signature
30 | -keepattributes *Annotation*
31 | -keep class okhttp3.** { *; }
32 | -keep interface okhttp3.** { *; }
33 | -dontwarn okhttp3.**
34 | -dontwarn okio.**
35 |
36 | #butterknife
37 | -keep public class * implements butterknife.Unbinder { public (...); }
38 | -keep class butterknife.*
39 | -keepclasseswithmembernames class * { @butterknife.* ; }
40 | -keepclasseswithmembernames class * { @butterknife.* ; }
41 |
42 | #calligraphy
43 | -keep class uk.co.chrisjenx.calligraphy.* { *; }
44 | -keep class uk.co.chrisjenx.calligraphy.*$* { *; }
45 |
46 | -dontwarn org.gradle.**
47 |
48 | #fabric crashlytics
49 | -keepattributes SourceFile,LineNumberTable
50 | -keep class com.crashlytics.** { *; }
51 | -dontwarn com.crashlytics.**
52 |
53 | -keep class ir.textmining.app.model.** { *; }
54 | -keep class ir.textmining.app.service.** { *; }
55 |
56 |
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":10200,"versionName":"1.2.0","enabled":true,"outputFile":"PersianNER-release-1.2.0.apk","fullName":"release","baseName":"release"},"path":"PersianNER-release-1.2.0.apk","properties":{}}]
--------------------------------------------------------------------------------
/app/src/androidTest/java/ir/textmining/app/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.InstrumentationRegistry;
6 | import androidx.test.runner.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.assertEquals;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getTargetContext();
24 |
25 | assertEquals("com.github.bkhezry.persianner", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/debug/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "816104641782",
4 | "firebase_url": "https://persianner-dev.firebaseio.com",
5 | "project_id": "persianner-dev",
6 | "storage_bucket": "persianner-dev.appspot.com"
7 | },
8 | "client": [
9 | {
10 | "client_info": {
11 | "mobilesdk_app_id": "1:816104641782:android:57aae06b9b324095",
12 | "android_client_info": {
13 | "package_name": "ir.textmining.app"
14 | }
15 | },
16 | "oauth_client": [
17 | {
18 | "client_id": "816104641782-vgpa3mraiplj60vqocqduhmvnt85ms2t.apps.googleusercontent.com",
19 | "client_type": 3
20 | }
21 | ],
22 | "api_key": [
23 | {
24 | "current_key": "AIzaSyBMevfHzF2_pZqx6PWxET0PBubjPET6lrc"
25 | }
26 | ],
27 | "services": {
28 | "analytics_service": {
29 | "status": 1
30 | },
31 | "appinvite_service": {
32 | "status": 1,
33 | "other_platform_oauth_client": []
34 | },
35 | "ads_service": {
36 | "status": 2
37 | }
38 | }
39 | }
40 | ],
41 | "configuration_version": "1"
42 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Vazir.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/assets/fonts/Vazir.ttf
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/listener/SelectTagEventListener.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.listener;
2 |
3 | public interface SelectTagEventListener {
4 | void tagSuccessEvent(String tagTitle);
5 |
6 | void tokenInvalidEvent();
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/listener/SettingsEventListener.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.listener;
2 |
3 | public interface SettingsEventListener {
4 | void signOut();
5 | }
6 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/model/AuthInfo.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class AuthInfo {
6 |
7 | @SerializedName("token")
8 | private String token;
9 | private String email;
10 | private Long createTimestamp;
11 | private Long currentTimestamp;
12 | private Long expireTimestamp;
13 |
14 | public String getToken() {
15 | return token;
16 | }
17 |
18 | public void setToken(String token) {
19 | this.token = token;
20 | }
21 |
22 | public String getEmail() {
23 | return email;
24 | }
25 |
26 | public void setEmail(String email) {
27 | this.email = email;
28 | }
29 |
30 | public Long getCreateTimestamp() {
31 | return createTimestamp;
32 | }
33 |
34 | public void setCreateTimestamp(Long createTimestamp) {
35 | this.createTimestamp = createTimestamp;
36 | }
37 |
38 | public Long getCurrentTimestamp() {
39 | return currentTimestamp;
40 | }
41 |
42 | public void setCurrentTimestamp(Long currentTimestamp) {
43 | this.currentTimestamp = currentTimestamp;
44 | }
45 |
46 | public Long getExpireTimestamp() {
47 | return expireTimestamp;
48 | }
49 |
50 | public void setExpireTimestamp(Long expireTimestamp) {
51 | this.expireTimestamp = expireTimestamp;
52 | }
53 | }
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/model/NerStandardTagsItem.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.model;
2 |
3 | import android.graphics.Color;
4 | import android.view.View;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.appcompat.widget.AppCompatTextView;
8 |
9 | import com.google.android.material.card.MaterialCardView;
10 | import com.google.gson.annotations.SerializedName;
11 | import com.mikepenz.fastadapter.FastAdapter;
12 | import com.mikepenz.fastadapter.items.AbstractItem;
13 |
14 | import java.util.List;
15 |
16 | import butterknife.BindView;
17 | import butterknife.ButterKnife;
18 | import io.objectbox.annotation.Entity;
19 | import io.objectbox.annotation.Id;
20 | import ir.textmining.app.R;
21 |
22 | @Entity
23 | public class NerStandardTagsItem extends AbstractItem {
24 |
25 | @Id
26 | private Long id;
27 |
28 | @SerializedName("PersianName")
29 | private String persianName;
30 |
31 | @SerializedName("Description")
32 | private String description;
33 |
34 | @SerializedName("Shortcut")
35 | private String shortcut;
36 |
37 | @SerializedName("Color")
38 | private String color;
39 |
40 | @SerializedName("Title")
41 | private String title;
42 |
43 | public Long getId() {
44 | return id;
45 | }
46 |
47 | public void setId(Long id) {
48 | this.id = id;
49 | }
50 |
51 | public String getPersianName() {
52 | return persianName;
53 | }
54 |
55 | public void setPersianName(String persianName) {
56 | this.persianName = persianName;
57 | }
58 |
59 | public String getDescription() {
60 | return description;
61 | }
62 |
63 | public void setDescription(String description) {
64 | this.description = description;
65 | }
66 |
67 | public String getShortcut() {
68 | return shortcut;
69 | }
70 |
71 | public void setShortcut(String shortcut) {
72 | this.shortcut = shortcut;
73 | }
74 |
75 | public String getColor() {
76 | return color;
77 | }
78 |
79 | public void setColor(String color) {
80 | this.color = color;
81 | }
82 |
83 | public String getTitle() {
84 | return title;
85 | }
86 |
87 | public void setTitle(String title) {
88 | this.title = title;
89 | }
90 |
91 | @NonNull
92 | @Override
93 | public MyViewHolder getViewHolder(@NonNull View view) {
94 | return new MyViewHolder(view);
95 | }
96 |
97 | @Override
98 | public int getType() {
99 | return R.id.fastadapter_item_adapter;
100 | }
101 |
102 | @Override
103 | public int getLayoutRes() {
104 | return R.layout.item_tag_info;
105 | }
106 |
107 |
108 | protected static class MyViewHolder extends FastAdapter.ViewHolder {
109 | View view;
110 | @BindView(R.id.title_text_view)
111 | AppCompatTextView titleTextView;
112 | @BindView(R.id.card_view)
113 | MaterialCardView cardView;
114 |
115 | MyViewHolder(View view) {
116 | super(view);
117 | ButterKnife.bind(this, view);
118 | this.view = view;
119 | }
120 |
121 | @Override
122 | public void bindView(@NonNull NerStandardTagsItem item, @NonNull List payloads) {
123 | titleTextView.setText(String.format("%s \n %s", item.getTitle(), item.getPersianName()));
124 | cardView.setCardBackgroundColor(Color.parseColor(item.getColor()));
125 | if (item.getTitle().equals("O")) {
126 | titleTextView.setTextColor(Color.BLACK);
127 | }
128 | }
129 |
130 | @Override
131 | public void unbindView(@NonNull NerStandardTagsItem item) {
132 | titleTextView.setText(null);
133 | }
134 |
135 | }
136 | }
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/model/ResponseMessage.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class ResponseMessage {
6 | @SerializedName("message")
7 | private String message;
8 |
9 | public String getMessage() {
10 | return message;
11 | }
12 |
13 | public void setMessage(String message) {
14 | this.message = message;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/model/Sentence.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.util.List;
6 |
7 | public class Sentence {
8 |
9 | @SerializedName("words")
10 | private List words;
11 |
12 | @SerializedName("sentenceId")
13 | private String sentenceId;
14 |
15 | public List getWords() {
16 | return words;
17 | }
18 |
19 | public void setWords(List words) {
20 | this.words = words;
21 | }
22 |
23 | public String getSentenceId() {
24 | return sentenceId;
25 | }
26 |
27 | public void setSentenceId(String sentenceId) {
28 | this.sentenceId = sentenceId;
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/model/TagInfo.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.util.List;
6 |
7 | public class TagInfo {
8 |
9 | @SerializedName("NerStandardTags")
10 | private List nerStandardTags;
11 |
12 | public List getNerStandardTags() {
13 | return nerStandardTags;
14 | }
15 |
16 | public void setNerStandardTags(List nerStandardTags) {
17 | this.nerStandardTags = nerStandardTags;
18 | }
19 | }
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/model/TagsLegend.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.model;
2 |
3 | import android.graphics.Color;
4 | import android.view.View;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.appcompat.widget.AppCompatTextView;
8 |
9 | import com.google.android.material.card.MaterialCardView;
10 | import com.google.gson.annotations.SerializedName;
11 | import com.mikepenz.fastadapter.FastAdapter;
12 | import com.mikepenz.fastadapter.items.AbstractItem;
13 |
14 | import java.util.List;
15 |
16 | import butterknife.BindView;
17 | import butterknife.ButterKnife;
18 | import ir.textmining.app.R;
19 |
20 | public class TagsLegend extends AbstractItem {
21 |
22 | private Long id;
23 |
24 | @SerializedName("PersianName")
25 | private String persianName;
26 |
27 | @SerializedName("Description")
28 | private String description;
29 |
30 | @SerializedName("Shortcut")
31 | private String shortcut;
32 |
33 | @SerializedName("Color")
34 | private String color;
35 |
36 | @SerializedName("Title")
37 | private String title;
38 |
39 | public Long getId() {
40 | return id;
41 | }
42 |
43 | public void setId(Long id) {
44 | this.id = id;
45 | }
46 |
47 | public String getPersianName() {
48 | return persianName;
49 | }
50 |
51 | public void setPersianName(String persianName) {
52 | this.persianName = persianName;
53 | }
54 |
55 | public String getDescription() {
56 | return description;
57 | }
58 |
59 | public void setDescription(String description) {
60 | this.description = description;
61 | }
62 |
63 | public String getShortcut() {
64 | return shortcut;
65 | }
66 |
67 | public void setShortcut(String shortcut) {
68 | this.shortcut = shortcut;
69 | }
70 |
71 | public String getColor() {
72 | return color;
73 | }
74 |
75 | public void setColor(String color) {
76 | this.color = color;
77 | }
78 |
79 | public String getTitle() {
80 | return title;
81 | }
82 |
83 | public void setTitle(String title) {
84 | this.title = title;
85 | }
86 |
87 | @NonNull
88 | @Override
89 | public MyViewHolder getViewHolder(@NonNull View view) {
90 | return new MyViewHolder(view);
91 | }
92 |
93 | @Override
94 | public int getType() {
95 | return R.id.fastadapter_item_adapter;
96 | }
97 |
98 | @Override
99 | public int getLayoutRes() {
100 | return R.layout.item_tag_legend;
101 | }
102 |
103 |
104 | protected static class MyViewHolder extends FastAdapter.ViewHolder {
105 | View view;
106 | @BindView(R.id.title_text_view)
107 | AppCompatTextView titleTextView;
108 | @BindView(R.id.description_text_view)
109 | AppCompatTextView descriptionTextView;
110 | @BindView(R.id.card_view)
111 | MaterialCardView cardView;
112 |
113 | MyViewHolder(View view) {
114 | super(view);
115 | ButterKnife.bind(this, view);
116 | this.view = view;
117 | }
118 |
119 | @Override
120 | public void bindView(@NonNull TagsLegend item, @NonNull List payloads) {
121 | titleTextView.setText(String.format("%s", item.getPersianName()));
122 | cardView.setCardBackgroundColor(Color.parseColor(item.getColor()));
123 | descriptionTextView.setText(item.getDescription());
124 | if (item.getTitle().equals("O")) {
125 | titleTextView.setTextColor(Color.BLACK);
126 | descriptionTextView.setTextColor(Color.BLACK);
127 | } else {
128 | titleTextView.setTextColor(Color.WHITE);
129 | descriptionTextView.setTextColor(Color.WHITE);
130 | }
131 | }
132 |
133 | @Override
134 | public void unbindView(@NonNull TagsLegend item) {
135 | titleTextView.setText(null);
136 | }
137 |
138 | }
139 | }
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/model/WordsItem.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class WordsItem {
6 |
7 | @SerializedName("WordId")
8 | private String wordId;
9 |
10 | @SerializedName("Word")
11 | private String word;
12 |
13 | @SerializedName("WordOrder")
14 | private int wordOrder;
15 |
16 | @SerializedName("Tag")
17 | private String tag;
18 |
19 | @SerializedName("NerTagId")
20 | private String nerTagId;
21 |
22 | public String getWordId() {
23 | return wordId;
24 | }
25 |
26 | public void setWordId(String wordId) {
27 | this.wordId = wordId;
28 | }
29 |
30 | public String getWord() {
31 | return word;
32 | }
33 |
34 | public void setWord(String word) {
35 | this.word = word;
36 | }
37 |
38 | public int getWordOrder() {
39 | return wordOrder;
40 | }
41 |
42 | public void setWordOrder(int wordOrder) {
43 | this.wordOrder = wordOrder;
44 | }
45 |
46 | public String getTag() {
47 | return tag;
48 | }
49 |
50 | public void setTag(String tag) {
51 | this.tag = tag;
52 | }
53 |
54 | public String getNerTagId() {
55 | return nerTagId;
56 | }
57 |
58 | public void setNerTagId(String nerTagId) {
59 | this.nerTagId = nerTagId;
60 | }
61 | }
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/service/APIService.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.service;
2 |
3 | import ir.textmining.app.model.AuthInfo;
4 | import ir.textmining.app.model.ResponseMessage;
5 | import ir.textmining.app.model.Sentence;
6 | import ir.textmining.app.model.TagInfo;
7 | import retrofit2.Call;
8 | import retrofit2.http.Field;
9 | import retrofit2.http.FormUrlEncoded;
10 | import retrofit2.http.GET;
11 | import retrofit2.http.POST;
12 |
13 | public interface APIService {
14 |
15 | @POST("auth/login")
16 | @FormUrlEncoded
17 | Call signIn(@Field("Email") String email,
18 | @Field("Password") String password);
19 |
20 | @GET("ner/GetRandomSentence")
21 | Call randomSentence();
22 |
23 |
24 | @GET("ner/standardtags")
25 | Call tags();
26 |
27 |
28 | @POST("ner/TagWord")
29 | @FormUrlEncoded
30 | Call tagWord(@Field("SentenceId") String sentenceId,
31 | @Field("WordId") String WordId,
32 | @Field("UserTag") String userTag);
33 |
34 | @POST("auth/register")
35 | @FormUrlEncoded
36 | Call signUp(@Field("Email") String email,
37 | @Field("Password") String password,
38 | @Field("ConfirmPassword") String confirmPassword);
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/ui/activity/AppIntroActivity.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.ui.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.graphics.Color;
6 | import android.os.Bundle;
7 |
8 | import com.github.paolorotolo.appintro.AppIntro2;
9 | import com.github.paolorotolo.appintro.AppIntroFragment;
10 | import com.github.paolorotolo.appintro.model.SliderPage;
11 | import com.github.pwittchen.prefser.library.rx2.Prefser;
12 |
13 | import androidx.fragment.app.Fragment;
14 | import io.github.inflationx.viewpump.ViewPumpContextWrapper;
15 | import ir.textmining.app.R;
16 | import ir.textmining.app.util.Constant;
17 | import ir.textmining.app.util.MyApplication;
18 |
19 | public class AppIntroActivity extends AppIntro2 {
20 | private Prefser prefser;
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | prefser = new Prefser(this);
26 | setIndicatorColor(Color.BLACK, getResources().getColor(R.color.grey_90));
27 | SliderPage sliderPage1 = new SliderPage();
28 | sliderPage1.setTitle(getString(R.string.title_1_label));
29 | sliderPage1.setDescription(getString(R.string.desc_1_label));
30 | sliderPage1.setImageDrawable(R.drawable.page_1);
31 | sliderPage1.setTitleColor(Color.BLACK);
32 | sliderPage1.setDescColor(Color.BLACK);
33 | sliderPage1.setBgColor(getResources().getColor(R.color.grey_10));
34 | addSlide(AppIntroFragment.newInstance(sliderPage1));
35 | SliderPage sliderPage2 = new SliderPage();
36 | sliderPage2.setTitle(getString(R.string.title_2_label));
37 | sliderPage2.setDescription(getString(R.string.desc_2_label));
38 | sliderPage2.setImageDrawable(R.drawable.page_2);
39 | sliderPage2.setTitleColor(Color.BLACK);
40 | sliderPage2.setDescColor(Color.BLACK);
41 | sliderPage2.setBgColor(getResources().getColor(R.color.grey_10));
42 | addSlide(AppIntroFragment.newInstance(sliderPage2));
43 | SliderPage sliderPage3 = new SliderPage();
44 | sliderPage3.setTitle(getString(R.string.title_3_label));
45 | sliderPage3.setDescription(getString(R.string.desc_3_label));
46 | sliderPage3.setImageDrawable(R.drawable.page_3);
47 | sliderPage3.setTitleColor(Color.BLACK);
48 | sliderPage3.setDescColor(Color.BLACK);
49 | sliderPage3.setBgColor(getResources().getColor(R.color.grey_10));
50 | addSlide(AppIntroFragment.newInstance(sliderPage3));
51 | SliderPage sliderPage4 = new SliderPage();
52 | sliderPage4.setTitle(getString(R.string.title_4_label));
53 | sliderPage4.setDescription(getString(R.string.desc_4_label));
54 | sliderPage4.setImageDrawable(R.drawable.page_4);
55 | sliderPage4.setTitleColor(Color.BLACK);
56 | sliderPage4.setDescColor(Color.BLACK);
57 | sliderPage4.setBgColor(getResources().getColor(R.color.grey_10));
58 | addSlide(AppIntroFragment.newInstance(sliderPage4));
59 | SliderPage sliderPage5 = new SliderPage();
60 | sliderPage5.setTitle(getString(R.string.title_5_label));
61 | sliderPage5.setDescription(getString(R.string.desc_5_label));
62 | sliderPage5.setImageDrawable(R.drawable.page_5);
63 | sliderPage5.setTitleColor(Color.BLACK);
64 | sliderPage5.setDescColor(Color.BLACK);
65 | sliderPage5.setBgColor(getResources().getColor(R.color.grey_10));
66 | addSlide(AppIntroFragment.newInstance(sliderPage5));
67 | showSkipButton(false);
68 | }
69 |
70 | @Override
71 | public void onDonePressed(Fragment currentFragment) {
72 | super.onDonePressed(currentFragment);
73 | if (!prefser.get(Constant.APP_INTRO, Boolean.class, false)) {
74 | prefser.put(Constant.APP_INTRO, true);
75 | startActivity(new Intent(this, MainActivity.class));
76 | finish();
77 | } else {
78 | finish();
79 | }
80 | }
81 |
82 | @Override
83 | protected void attachBaseContext(Context base) {
84 | Context newContext = MyApplication.localeManager.setLocale(base);
85 | super.attachBaseContext(ViewPumpContextWrapper.wrap(newContext));
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/ui/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.ui.activity;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.appcompat.app.AppCompatActivity;
6 |
7 | import io.github.inflationx.viewpump.ViewPumpContextWrapper;
8 | import ir.textmining.app.util.MyApplication;
9 |
10 | public class BaseActivity extends AppCompatActivity {
11 |
12 | @Override
13 | protected void attachBaseContext(Context base) {
14 | Context newContext = MyApplication.localeManager.setLocale(base);
15 | super.attachBaseContext(ViewPumpContextWrapper.wrap(newContext));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/ui/activity/LauncherActivity.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.ui.activity;
2 |
3 | import android.app.Dialog;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.text.TextUtils;
7 | import android.text.method.PasswordTransformationMethod;
8 | import android.util.Patterns;
9 | import android.view.View;
10 | import android.widget.LinearLayout;
11 |
12 | import com.auth0.android.jwt.JWT;
13 | import com.blankj.utilcode.util.NetworkUtils;
14 | import com.blankj.utilcode.util.SnackbarUtils;
15 | import com.github.pwittchen.prefser.library.rx2.Prefser;
16 | import com.google.android.material.button.MaterialButton;
17 | import com.google.android.material.card.MaterialCardView;
18 | import com.google.android.material.textfield.TextInputEditText;
19 |
20 | import androidx.annotation.NonNull;
21 | import androidx.appcompat.widget.AppCompatTextView;
22 | import butterknife.BindView;
23 | import butterknife.ButterKnife;
24 | import butterknife.OnClick;
25 | import io.objectbox.Box;
26 | import io.objectbox.BoxStore;
27 | import ir.textmining.app.R;
28 | import ir.textmining.app.model.AuthInfo;
29 | import ir.textmining.app.model.NerStandardTagsItem;
30 | import ir.textmining.app.model.ResponseMessage;
31 | import ir.textmining.app.model.TagInfo;
32 | import ir.textmining.app.service.APIService;
33 | import ir.textmining.app.util.AppUtil;
34 | import ir.textmining.app.util.Constant;
35 | import ir.textmining.app.util.MyApplication;
36 | import ir.textmining.app.util.RetrofitUtil;
37 | import retrofit2.Call;
38 | import retrofit2.Callback;
39 | import retrofit2.Response;
40 |
41 | import static android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD;
42 |
43 | public class LauncherActivity extends BaseActivity {
44 |
45 | @BindView(R.id.email_edit_text)
46 | TextInputEditText emailEditText;
47 | @BindView(R.id.password_edit_text)
48 | TextInputEditText passwordEditText;
49 | @BindView(R.id.sign_in_layout)
50 | MaterialCardView signInLayout;
51 | @BindView(R.id.no_internet_layout)
52 | MaterialCardView noInternetLayout;
53 | @BindView(R.id.title_text_view)
54 | AppCompatTextView titleTextView;
55 | @BindView(R.id.new_user_layout)
56 | LinearLayout newUserLayout;
57 | @BindView(R.id.has_account_layout)
58 | LinearLayout hasAccountLayout;
59 | @BindView(R.id.sign_in_button)
60 | MaterialButton signInButton;
61 | @BindView(R.id.sign_up_button)
62 | MaterialButton signUpButton;
63 | private Prefser prefser;
64 | private Dialog loadingDialog;
65 | private APIService apiService;
66 | private Box tagsItemBox;
67 |
68 | @Override
69 | protected void onCreate(Bundle savedInstanceState) {
70 | super.onCreate(savedInstanceState);
71 | setContentView(R.layout.activity_launcher);
72 | ButterKnife.bind(this);
73 | initVariables();
74 | getTokenInvalidEvent();
75 | checkInternetConnection();
76 | }
77 |
78 | private void getTokenInvalidEvent() {
79 | if (getIntent() != null) {
80 | boolean isTokenInvalid = getIntent().getBooleanExtra(Constant.TOKEN_INVALID, false);
81 | if (isTokenInvalid) {
82 | tokenInvalid();
83 | }
84 | }
85 | }
86 |
87 | private void initVariables() {
88 | passwordEditText.setInputType(TYPE_TEXT_VARIATION_PASSWORD);
89 | passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
90 | prefser = new Prefser(this);
91 | loadingDialog = AppUtil.getLoadingDialog(this);
92 | apiService = RetrofitUtil.getRetrofit("").create(APIService.class);
93 | BoxStore boxStore = MyApplication.getBoxStore();
94 | tagsItemBox = boxStore.boxFor(NerStandardTagsItem.class);
95 | }
96 |
97 | @OnClick(R.id.retry_button)
98 | void checkInternetConnection() {
99 | if (NetworkUtils.isConnected()) {
100 | showSignInLayout();
101 | checkAuthInfo();
102 | } else {
103 | signInLayout.setVisibility(View.GONE);
104 | showNoInternetLayout();
105 | }
106 | }
107 |
108 | private void showSignInLayout() {
109 | signInLayout.setVisibility(View.VISIBLE);
110 | noInternetLayout.setVisibility(View.GONE);
111 | }
112 |
113 | private void requestGetTags() {
114 | loadingDialog.show();
115 | Call call = apiService.tags();
116 | call.enqueue(new Callback() {
117 | @Override
118 | public void onResponse(@NonNull Call call, @NonNull Response response) {
119 | loadingDialog.dismiss();
120 | if (response.isSuccessful()) {
121 | TagInfo tagInfo = response.body();
122 | if (tagInfo != null) {
123 | storeTags(tagInfo);
124 | startMainActivity();
125 | }
126 | } else if (response.code() == 401) {
127 | tokenInvalid();
128 | }
129 | }
130 |
131 | @Override
132 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
133 | showNoInternetLayout();
134 | loadingDialog.dismiss();
135 | t.printStackTrace();
136 |
137 | }
138 | });
139 | }
140 |
141 | private void tokenInvalid() {
142 | prefser.remove(Constant.AUTH_INFO);
143 | showNoInternetLayout();
144 | AppUtil.showSnackbar(signInLayout, getString(R.string.sign_in_again_message), LauncherActivity.this, SnackbarUtils.LENGTH_INDEFINITE);
145 | }
146 |
147 | private void storeTags(TagInfo tagInfo) {
148 | tagsItemBox.removeAll();
149 | tagsItemBox.put(tagInfo.getNerStandardTags());
150 | }
151 |
152 | private void checkAuthInfo() {
153 | if (prefser.contains(Constant.AUTH_INFO)) {
154 | AuthInfo authInfo = prefser.get(Constant.AUTH_INFO, AuthInfo.class, null);
155 | if (!AppUtil.isTokenExpire(authInfo)) {
156 | hideLayouts();
157 | if (NetworkUtils.isConnected()) {
158 | requestGetTags();
159 | } else {
160 | showNoInternetLayout();
161 | }
162 | }
163 | }
164 | }
165 |
166 | private void showNoInternetLayout() {
167 | noInternetLayout.setVisibility(View.VISIBLE);
168 | AppUtil.showSnackbar(noInternetLayout, getString(R.string.no_internet_label), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
169 | }
170 |
171 | private void hideLayouts() {
172 | noInternetLayout.setVisibility(View.GONE);
173 | signInLayout.setVisibility(View.GONE);
174 | }
175 |
176 | @OnClick({R.id.sign_in_button, R.id.sign_up_button})
177 | public void handleButtonClick(View view) {
178 | switch (view.getId()) {
179 | case R.id.sign_in_button:
180 | signIn(view);
181 | break;
182 | case R.id.sign_up_button:
183 | signUp(view);
184 | break;
185 | }
186 | }
187 |
188 | private void signIn(View view) {
189 | if (NetworkUtils.isConnected()) {
190 | requestSignIn(view);
191 | } else {
192 | AppUtil.showSnackbar(view, getString(R.string.no_internet_label), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
193 | }
194 | }
195 |
196 | private void requestSignIn(View view) {
197 | String email = emailEditText.getText().toString();
198 | String password = passwordEditText.getText().toString();
199 | if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) {
200 | if (Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
201 | loadingDialog.show();
202 | Call call = apiService.signIn(email, password);
203 | call.enqueue(new Callback() {
204 | @Override
205 | public void onResponse(@NonNull Call call, @NonNull Response response) {
206 | loadingDialog.dismiss();
207 | if (response.isSuccessful()) {
208 | AuthInfo authInfo = response.body();
209 | handleAuthInfo(authInfo, email);
210 | } else {
211 | AppUtil.showSnackbar(view, getString(R.string.email_password_incorrect_label), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
212 | }
213 | }
214 |
215 | @Override
216 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
217 | AppUtil.showSnackbar(view, getString(R.string.retry_request_message), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
218 | loadingDialog.dismiss();
219 | t.printStackTrace();
220 | }
221 | });
222 | } else {
223 | AppUtil.showSnackbar(view, getString(R.string.email_incorrect_label), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
224 | }
225 | } else {
226 | AppUtil.showSnackbar(view, getString(R.string.no_email_password_label), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
227 | }
228 | }
229 |
230 | private void handleAuthInfo(AuthInfo authInfo, String email) {
231 | authInfo.setEmail(email);
232 | JWT jwt = new JWT(authInfo.getToken());
233 | if (jwt.getExpiresAt() != null && jwt.getNotBefore() != null) {
234 | Long expireTimestamp = jwt.getExpiresAt().getTime();
235 | Long createTimestamp = jwt.getNotBefore().getTime();
236 | authInfo.setCreateTimestamp(createTimestamp);
237 | authInfo.setExpireTimestamp(expireTimestamp);
238 | authInfo.setCurrentTimestamp(System.currentTimeMillis());
239 | storeAuthInfo(authInfo);
240 | hideLayouts();
241 | requestGetTags();
242 | } else {
243 | AppUtil.showSnackbar(titleTextView, getString(R.string.token_invalid_message), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
244 | }
245 | }
246 |
247 | private void storeAuthInfo(AuthInfo authInfo) {
248 | prefser.put(Constant.AUTH_INFO, authInfo);
249 | }
250 |
251 | private void startMainActivity() {
252 | if (prefser.get(Constant.APP_INTRO, Boolean.class, false)) {
253 | startActivity(new Intent(this, MainActivity.class));
254 | finish();
255 | } else {
256 | startActivity(new Intent(this, AppIntroActivity.class));
257 | finish();
258 | }
259 | }
260 |
261 | private void signUp(View view) {
262 | String email = emailEditText.getText().toString();
263 | String password = passwordEditText.getText().toString();
264 | if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) {
265 | if (Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
266 | loadingDialog.show();
267 | Call call = apiService.signUp(email, password, password);
268 | call.enqueue(new Callback() {
269 | @Override
270 | public void onResponse(@NonNull Call call, @NonNull Response response) {
271 | loadingDialog.dismiss();
272 | if (response.isSuccessful()) {
273 | AppUtil.showSnackbar(view, getString(R.string.sign_up_success_message), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
274 | signInLayout();
275 | } else if (response.code() == 400) {
276 | AppUtil.showSnackbar(view, getString(R.string.duplicate_email_message), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
277 | }
278 | }
279 |
280 | @Override
281 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
282 | AppUtil.showSnackbar(view, getString(R.string.retry_request_message), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
283 | loadingDialog.dismiss();
284 | t.printStackTrace();
285 | }
286 | });
287 |
288 | } else {
289 | AppUtil.showSnackbar(view, getString(R.string.email_incorrect_label), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
290 | }
291 | } else {
292 | AppUtil.showSnackbar(view, getString(R.string.no_email_password_label), LauncherActivity.this, SnackbarUtils.LENGTH_LONG);
293 | }
294 | }
295 |
296 | @OnClick({R.id.sign_up, R.id.sign_in})
297 | public void handleTypeOfUserLayout(View view) {
298 | switch (view.getId()) {
299 | case R.id.sign_up:
300 | signUPLayout();
301 | break;
302 | case R.id.sign_in:
303 | signInLayout();
304 | break;
305 | }
306 | }
307 |
308 | private void signUPLayout() {
309 | titleTextView.setText(getString(R.string.sign_up_label));
310 | newUserLayout.setVisibility(View.VISIBLE);
311 | signUpButton.setVisibility(View.VISIBLE);
312 | hasAccountLayout.setVisibility(View.GONE);
313 | signInButton.setVisibility(View.GONE);
314 | }
315 |
316 | private void signInLayout() {
317 | titleTextView.setText(getString(R.string.sign_in_label));
318 | hasAccountLayout.setVisibility(View.VISIBLE);
319 | signInButton.setVisibility(View.VISIBLE);
320 | newUserLayout.setVisibility(View.GONE);
321 | signUpButton.setVisibility(View.GONE);
322 | passwordEditText.setText(null);
323 | }
324 | }
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/ui/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.ui.activity;
2 |
3 | import android.content.Intent;
4 | import android.content.res.ColorStateList;
5 | import android.graphics.Color;
6 | import android.os.Bundle;
7 | import android.view.MenuItem;
8 | import android.view.View;
9 |
10 | import com.blankj.utilcode.util.NetworkUtils;
11 | import com.blankj.utilcode.util.SnackbarUtils;
12 | import com.ethanhua.skeleton.Skeleton;
13 | import com.ethanhua.skeleton.SkeletonScreen;
14 | import com.github.pwittchen.prefser.library.rx2.Prefser;
15 | import com.google.android.gms.tasks.OnCompleteListener;
16 | import com.google.android.gms.tasks.Task;
17 | import com.google.android.material.bottomappbar.BottomAppBar;
18 | import com.google.android.material.bottomsheet.BottomSheetBehavior;
19 | import com.google.android.material.chip.Chip;
20 | import com.google.android.material.chip.ChipGroup;
21 | import com.google.android.material.navigation.NavigationView;
22 | import com.google.firebase.messaging.FirebaseMessaging;
23 |
24 | import androidx.annotation.NonNull;
25 | import androidx.coordinatorlayout.widget.CoordinatorLayout;
26 | import butterknife.BindView;
27 | import butterknife.ButterKnife;
28 | import butterknife.OnClick;
29 | import io.objectbox.Box;
30 | import io.objectbox.BoxStore;
31 | import ir.textmining.app.R;
32 | import ir.textmining.app.listener.SelectTagEventListener;
33 | import ir.textmining.app.listener.SettingsEventListener;
34 | import ir.textmining.app.model.AuthInfo;
35 | import ir.textmining.app.model.NerStandardTagsItem;
36 | import ir.textmining.app.model.Sentence;
37 | import ir.textmining.app.model.WordsItem;
38 | import ir.textmining.app.service.APIService;
39 | import ir.textmining.app.ui.fragment.AboutFragment;
40 | import ir.textmining.app.ui.fragment.SelectTagFragment;
41 | import ir.textmining.app.ui.fragment.SettingsFragment;
42 | import ir.textmining.app.ui.fragment.TagLegendFragment;
43 | import ir.textmining.app.util.AppUtil;
44 | import ir.textmining.app.util.Constant;
45 | import ir.textmining.app.util.MyApplication;
46 | import ir.textmining.app.util.RetrofitUtil;
47 | import retrofit2.Call;
48 | import retrofit2.Callback;
49 | import retrofit2.Response;
50 |
51 | public class MainActivity extends BaseActivity implements SettingsEventListener {
52 |
53 | @BindView(R.id.chip_group)
54 | ChipGroup chipGroup;
55 | @BindView(R.id.coordinatorLayout)
56 | CoordinatorLayout coordinatorLayout;
57 | @BindView(R.id.bar)
58 | BottomAppBar bar;
59 | @BindView(R.id.navigation_view)
60 | NavigationView navigationView;
61 | private BottomSheetBehavior bottomDrawerBehavior;
62 | private AuthInfo authInfo;
63 | private Box tagsItemBox;
64 | private SkeletonScreen skeletonScreen;
65 |
66 | @Override
67 | protected void onCreate(Bundle savedInstanceState) {
68 | super.onCreate(savedInstanceState);
69 | setContentView(R.layout.activity_main);
70 | ButterKnife.bind(this);
71 | subscribeFirebaseTopic();
72 | setSupportActionBar(bar);
73 | initBottomNavigationView();
74 | initVariables();
75 | getSentence();
76 | }
77 |
78 | private void subscribeFirebaseTopic() {
79 | FirebaseMessaging.getInstance().subscribeToTopic("update_app")
80 | .addOnCompleteListener(new OnCompleteListener() {
81 | @Override
82 | public void onComplete(@NonNull Task task) {
83 |
84 | }
85 | });
86 | }
87 |
88 | private void initBottomNavigationView() {
89 | View bottomDrawer = coordinatorLayout.findViewById(R.id.bottom_drawer);
90 | bottomDrawerBehavior = BottomSheetBehavior.from(bottomDrawer);
91 | bottomDrawerBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
92 | bar.setNavigationOnClickListener(
93 | new View.OnClickListener() {
94 | @Override
95 | public void onClick(View v) {
96 | bottomDrawerBehavior.setState(BottomSheetBehavior.STATE_HALF_EXPANDED);
97 | }
98 | });
99 | bar.setNavigationIcon(R.drawable.ic_menu_black_24dp);
100 | navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
101 | @Override
102 | public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
103 | if (menuItem.getItemId() == R.id.about_item) {
104 | showAboutFragment();
105 | } else if (menuItem.getItemId() == R.id.settings_item) {
106 | showSettingsFragment();
107 | } else if (menuItem.getItemId() == R.id.app_intro_item) {
108 | startActivity(new Intent(MainActivity.this, AppIntroActivity.class));
109 | }
110 | hideBottomDrawer();
111 | return false;
112 | }
113 | });
114 |
115 | }
116 |
117 | private void showAboutFragment() {
118 | AppUtil.showFragment(new AboutFragment(), getSupportFragmentManager());
119 | }
120 |
121 | private void showSettingsFragment() {
122 | SettingsFragment settingsFragment = new SettingsFragment();
123 | AppUtil.showFragment(settingsFragment, getSupportFragmentManager());
124 | }
125 |
126 | private void hideBottomDrawer() {
127 | bottomDrawerBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
128 | }
129 |
130 | private void initVariables() {
131 | Prefser prefser = new Prefser(this);
132 | authInfo = prefser.get(Constant.AUTH_INFO, AuthInfo.class, null);
133 | BoxStore boxStore = MyApplication.getBoxStore();
134 | tagsItemBox = boxStore.boxFor(NerStandardTagsItem.class);
135 | }
136 |
137 | private void getSentence() {
138 | if (NetworkUtils.isConnected()) {
139 | requestGetSentence();
140 | } else {
141 | AppUtil.showSnackbar(coordinatorLayout, getString(R.string.no_internet_label), this, SnackbarUtils.LENGTH_LONG);
142 | }
143 | }
144 |
145 | private void requestGetSentence() {
146 | showSkeleton();
147 | APIService apiService = RetrofitUtil.getRetrofit(authInfo.getToken()).create(APIService.class);
148 | Call call = apiService.randomSentence();
149 | call.enqueue(new Callback() {
150 | @Override
151 | public void onResponse(@NonNull Call call, @NonNull Response response) {
152 | skeletonScreen.hide();
153 | if (response.isSuccessful()) {
154 | Sentence sentence = response.body();
155 | if (sentence != null) {
156 | if (sentence.getWords().size() == 0) {
157 | getSentence();
158 | } else {
159 | handleSentence(sentence);
160 | }
161 | }
162 | } else if (response.code() == 401) {
163 | tokenInvalid();
164 | }
165 | }
166 |
167 | @Override
168 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
169 | skeletonScreen.hide();
170 | t.printStackTrace();
171 | AppUtil.showSnackbar(chipGroup, getString(R.string.retry_request_message), MainActivity.this, SnackbarUtils.LENGTH_LONG);
172 | }
173 | });
174 | }
175 |
176 | private void tokenInvalid() {
177 | Intent intent = new Intent(this, LauncherActivity.class);
178 | intent.putExtra(Constant.TOKEN_INVALID, true);
179 | startActivity(intent);
180 | finish();
181 | }
182 |
183 | private void handleSentence(Sentence sentence) {
184 | chipGroup.removeAllViews();
185 | for (WordsItem wordsItem : sentence.getWords()) {
186 | Chip chip = generateClip(wordsItem, sentence.getSentenceId());
187 | chipGroup.addView(chip);
188 | }
189 | }
190 |
191 | private Chip generateClip(WordsItem wordsItem, String sentenceId) {
192 | Chip chip =
193 | (Chip) getLayoutInflater().inflate(R.layout.item_chip, chipGroup, false);
194 | chip.setText(wordsItem.getWord());
195 | chip.setChipBackgroundColor(ColorStateList.valueOf(Color.parseColor(AppUtil.colorHexString(wordsItem.getTag(), tagsItemBox))));
196 | if (!wordsItem.getTag().equals("O")) {
197 | chip.setTextColor(Color.WHITE);
198 | }
199 | chip.setOnClickListener(new View.OnClickListener() {
200 | @Override
201 | public void onClick(View v) {
202 | selectTagFragment(chip, wordsItem, sentenceId);
203 | }
204 | });
205 | return chip;
206 | }
207 |
208 | private void selectTagFragment(Chip chip, WordsItem wordsItem, String sentenceId) {
209 | SelectTagFragment fragment = new SelectTagFragment();
210 | fragment.setWordData(wordsItem, sentenceId);
211 | fragment.setListener(new SelectTagEventListener() {
212 | @Override
213 | public void tagSuccessEvent(String tagTitle) {
214 | AppUtil.showSnackbar(chipGroup, getString(R.string.tag_success_message), MainActivity.this, SnackbarUtils.LENGTH_LONG);
215 | wordsItem.setTag(tagTitle);
216 | chip.setChipBackgroundColor(ColorStateList.valueOf(Color.parseColor(AppUtil.colorHexString(tagTitle, tagsItemBox))));
217 | if (!tagTitle.equals("O")) {
218 | chip.setTextColor(Color.WHITE);
219 | } else {
220 | chip.setTextColor(Color.BLACK);
221 | }
222 | }
223 |
224 | @Override
225 | public void tokenInvalidEvent() {
226 | tokenInvalid();
227 | }
228 | });
229 | AppUtil.showFragment(fragment, getSupportFragmentManager());
230 | }
231 |
232 | @OnClick(R.id.next_sentence_button)
233 | public void nextSentence() {
234 | getSentence();
235 | }
236 |
237 | @OnClick(R.id.legend_button)
238 | public void showLegend() {
239 | AppUtil.showFragment(new TagLegendFragment(), getSupportFragmentManager());
240 | }
241 |
242 | private void showSkeleton() {
243 | skeletonScreen = Skeleton.bind(chipGroup)
244 | .shimmer(true)
245 | .angle(0)
246 | .color(R.color.shimmer_color)
247 | .load(R.layout.item_skeleton)
248 | .show();
249 | }
250 |
251 | @Override
252 | public void signOut() {
253 | tokenInvalid();
254 | }
255 | }
256 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/ui/fragment/AboutFragment.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.ui.fragment;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.content.ActivityNotFoundException;
6 | import android.content.Intent;
7 | import android.content.pm.PackageManager;
8 | import android.net.Uri;
9 | import android.os.Bundle;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.Window;
14 | import android.view.WindowManager;
15 |
16 | import com.blankj.utilcode.util.SnackbarUtils;
17 |
18 | import androidx.annotation.NonNull;
19 | import androidx.appcompat.widget.AppCompatTextView;
20 | import androidx.fragment.app.DialogFragment;
21 | import butterknife.BindView;
22 | import butterknife.ButterKnife;
23 | import butterknife.OnClick;
24 | import ir.textmining.app.R;
25 | import ir.textmining.app.util.AppUtil;
26 | import ir.textmining.app.util.Constant;
27 |
28 | public class AboutFragment extends DialogFragment {
29 | @BindView(R.id.title)
30 | AppCompatTextView title;
31 | @BindView(R.id.version_app_text_view)
32 | AppCompatTextView versionAppTextView;
33 | private Activity activity;
34 |
35 | @Override
36 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
37 | Bundle savedInstanceState) {
38 | View view = inflater.inflate(R.layout.fragment_about,
39 | container, false);
40 | ButterKnife.bind(this, view);
41 | activity = getActivity();
42 | setAppVersion();
43 | return view;
44 | }
45 |
46 | private void setAppVersion() {
47 | String versionName = "";
48 | try {
49 | versionName = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionName;
50 | } catch (PackageManager.NameNotFoundException e) {
51 | e.printStackTrace();
52 | }
53 | versionAppTextView.setText(versionName);
54 | }
55 |
56 | @NonNull
57 | @Override
58 | public Dialog onCreateDialog(Bundle savedInstanceState) {
59 | Dialog dialog = super.onCreateDialog(savedInstanceState);
60 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
61 | dialog.setCancelable(true);
62 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
63 | lp.copyFrom(dialog.getWindow().getAttributes());
64 | lp.width = WindowManager.LayoutParams.MATCH_PARENT;
65 | lp.height = WindowManager.LayoutParams.MATCH_PARENT;
66 | dialog.getWindow().setAttributes(lp);
67 | return dialog;
68 | }
69 |
70 | @OnClick(R.id.close_button)
71 | void close() {
72 | dismiss();
73 | if (getFragmentManager() != null) {
74 | getFragmentManager().popBackStack();
75 | }
76 | }
77 |
78 | @OnClick({R.id.source_code_layout, R.id.website_layout, R.id.developer_layout, R.id.designer_layout})
79 | void handleLayoutClick(View view) {
80 | switch (view.getId()) {
81 | case R.id.source_code_layout:
82 | startBrowser(Constant.GITHUB_URL, view);
83 | break;
84 | case R.id.website_layout:
85 | startBrowser(Constant.WEB_SITE_URL, view);
86 | break;
87 | case R.id.developer_layout:
88 | startBrowser(Constant.DEVELOPER_URL, view);
89 | case R.id.designer_layout:
90 | startBrowser(Constant.DESIGNER_URL, view);
91 | break;
92 | }
93 | }
94 |
95 | private void startBrowser(String url, View view) {
96 | try {
97 | Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
98 | startActivity(browserIntent);
99 | } catch (ActivityNotFoundException e) {
100 | AppUtil.showSnackbar(view, getString(R.string.browser_not_found_label), activity, SnackbarUtils.LENGTH_INDEFINITE);
101 | e.printStackTrace();
102 | }
103 |
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/ui/fragment/SelectTagFragment.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.ui.fragment;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.os.Bundle;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.view.Window;
10 | import android.view.WindowManager;
11 |
12 | import androidx.annotation.NonNull;
13 | import androidx.appcompat.widget.AppCompatTextView;
14 | import androidx.fragment.app.DialogFragment;
15 | import androidx.recyclerview.widget.DefaultItemAnimator;
16 | import androidx.recyclerview.widget.GridLayoutManager;
17 | import androidx.recyclerview.widget.RecyclerView;
18 |
19 | import com.blankj.utilcode.util.NetworkUtils;
20 | import com.blankj.utilcode.util.SnackbarUtils;
21 | import com.github.pwittchen.prefser.library.rx2.Prefser;
22 | import com.mikepenz.fastadapter.FastAdapter;
23 | import com.mikepenz.fastadapter.IAdapter;
24 | import com.mikepenz.fastadapter.adapters.ItemAdapter;
25 | import com.mikepenz.fastadapter.listeners.OnClickListener;
26 |
27 | import java.util.List;
28 |
29 | import javax.annotation.Nullable;
30 |
31 | import butterknife.BindView;
32 | import butterknife.ButterKnife;
33 | import butterknife.OnClick;
34 | import io.objectbox.Box;
35 | import io.objectbox.BoxStore;
36 | import ir.textmining.app.R;
37 | import ir.textmining.app.listener.SelectTagEventListener;
38 | import ir.textmining.app.model.AuthInfo;
39 | import ir.textmining.app.model.NerStandardTagsItem;
40 | import ir.textmining.app.model.ResponseMessage;
41 | import ir.textmining.app.model.WordsItem;
42 | import ir.textmining.app.service.APIService;
43 | import ir.textmining.app.util.AppUtil;
44 | import ir.textmining.app.util.Constant;
45 | import ir.textmining.app.util.MyApplication;
46 | import ir.textmining.app.util.RetrofitUtil;
47 | import retrofit2.Call;
48 | import retrofit2.Callback;
49 | import retrofit2.Response;
50 |
51 | public class SelectTagFragment extends DialogFragment {
52 | @BindView(R.id.title)
53 | AppCompatTextView title;
54 | @BindView(R.id.recyclerView)
55 | RecyclerView recyclerView;
56 | private WordsItem wordsItem;
57 | private String sentenceId;
58 | private Box tagsItemBox;
59 | private FastAdapter mFastAdapter;
60 | private ItemAdapter mItemAdapter;
61 | private AuthInfo authInfo;
62 | private SelectTagEventListener listener;
63 | private Dialog loadingDialog;
64 | private Activity activity;
65 |
66 |
67 | @Override
68 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
69 | Bundle savedInstanceState) {
70 | View view = inflater.inflate(R.layout.fragment_select_tag,
71 | container, false);
72 | ButterKnife.bind(this, view);
73 | initVariables();
74 | setUpRecyclerView();
75 | handleTagItems();
76 | return view;
77 | }
78 |
79 | private void initVariables() {
80 | activity = getActivity();
81 | BoxStore boxStore = MyApplication.getBoxStore();
82 | tagsItemBox = boxStore.boxFor(NerStandardTagsItem.class);
83 | Prefser prefser = new Prefser(activity);
84 | authInfo = prefser.get(Constant.AUTH_INFO, AuthInfo.class, null);
85 | loadingDialog = AppUtil.getLoadingDialog(activity);
86 | }
87 |
88 | private void setUpRecyclerView() {
89 | RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 2);
90 | recyclerView.setLayoutManager(mLayoutManager);
91 | recyclerView.setItemAnimator(new DefaultItemAnimator());
92 | mItemAdapter = new ItemAdapter<>();
93 | mFastAdapter = FastAdapter.with(mItemAdapter);
94 | recyclerView.setAdapter(mFastAdapter);
95 | mFastAdapter.withOnClickListener(new OnClickListener() {
96 | @Override
97 | public boolean onClick(@Nullable View v, @NonNull IAdapter adapter, @NonNull NerStandardTagsItem item, int position) {
98 | submitTag(item);
99 | return true;
100 | }
101 | });
102 | }
103 |
104 | private void submitTag(NerStandardTagsItem item) {
105 | if (NetworkUtils.isConnected()) {
106 | requestSubmitTag(item);
107 | } else {
108 | AppUtil.showSnackbar(title, getString(R.string.no_internet_label), activity, SnackbarUtils.LENGTH_LONG);
109 | }
110 | }
111 |
112 | private void requestSubmitTag(NerStandardTagsItem item) {
113 | loadingDialog.show();
114 | APIService apiService = RetrofitUtil.getRetrofit(authInfo.getToken()).create(APIService.class);
115 | Call call = apiService.tagWord(sentenceId, wordsItem.getWordId(), item.getTitle());
116 | call.enqueue(new Callback() {
117 | @Override
118 | public void onResponse(@NonNull Call call, @NonNull Response response) {
119 | loadingDialog.dismiss();
120 | if (response.isSuccessful()) {
121 | returnResult(item);
122 | } else if (response.code() == 401) {
123 | tokenInvalid();
124 | }
125 | }
126 |
127 | @Override
128 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
129 | loadingDialog.dismiss();
130 | AppUtil.showSnackbar(recyclerView, getString(R.string.retry_request_message), activity, SnackbarUtils.LENGTH_LONG);
131 | t.printStackTrace();
132 | }
133 | });
134 | }
135 |
136 | private void returnResult(NerStandardTagsItem item) {
137 | if (listener != null) {
138 | listener.tagSuccessEvent(item.getTitle());
139 | close();
140 | }
141 | }
142 |
143 | private void tokenInvalid() {
144 | if (listener != null) {
145 | listener.tokenInvalidEvent();
146 | }
147 | }
148 |
149 | private void handleTagItems() {
150 | List tagsItems = tagsItemBox.getAll();
151 | mItemAdapter.clear();
152 | mItemAdapter.add(tagsItems);
153 | }
154 |
155 | @NonNull
156 | @Override
157 | public Dialog onCreateDialog(Bundle savedInstanceState) {
158 | Dialog dialog = super.onCreateDialog(savedInstanceState);
159 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
160 | dialog.setCancelable(true);
161 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
162 | lp.copyFrom(dialog.getWindow().getAttributes());
163 | lp.width = WindowManager.LayoutParams.MATCH_PARENT;
164 | lp.height = WindowManager.LayoutParams.MATCH_PARENT;
165 | dialog.getWindow().setAttributes(lp);
166 | return dialog;
167 | }
168 |
169 |
170 | public void setWordData(WordsItem wordsItem, String sentenceId) {
171 | this.wordsItem = wordsItem;
172 | this.sentenceId = sentenceId;
173 | }
174 |
175 | public void setListener(SelectTagEventListener selectTagEventListener) {
176 | this.listener = selectTagEventListener;
177 | }
178 |
179 | @OnClick(R.id.close_button)
180 | void close() {
181 | dismiss();
182 | if (getFragmentManager() != null) {
183 | getFragmentManager().popBackStack();
184 | }
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/ui/fragment/SettingsFragment.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.ui.fragment;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.view.Window;
11 | import android.view.WindowManager;
12 | import android.widget.CompoundButton;
13 |
14 | import androidx.annotation.NonNull;
15 | import androidx.appcompat.app.AppCompatDelegate;
16 | import androidx.appcompat.widget.AppCompatTextView;
17 | import androidx.appcompat.widget.SwitchCompat;
18 | import androidx.fragment.app.DialogFragment;
19 |
20 | import com.github.pwittchen.prefser.library.rx2.Prefser;
21 |
22 | import butterknife.BindView;
23 | import butterknife.ButterKnife;
24 | import butterknife.OnClick;
25 | import ir.textmining.app.R;
26 | import ir.textmining.app.listener.SettingsEventListener;
27 | import ir.textmining.app.model.AuthInfo;
28 | import ir.textmining.app.util.Constant;
29 | import ir.textmining.app.util.SettingsManager;
30 |
31 | public class SettingsFragment extends DialogFragment {
32 | @BindView(R.id.email_text_view)
33 | AppCompatTextView emailTextView;
34 | @BindView(R.id.dark_theme_switch)
35 | SwitchCompat darkThemeSwitch;
36 | private Activity activity;
37 | private SharedPreferences prefs;
38 |
39 | @Override
40 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
41 | Bundle savedInstanceState) {
42 | View view = inflater.inflate(R.layout.fragment_settings,
43 | container, false);
44 | ButterKnife.bind(this, view);
45 | initVariables();
46 | setSwitchButtonListener();
47 | return view;
48 | }
49 |
50 |
51 | private void setSwitchButtonListener() {
52 | darkThemeSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
53 | @Override
54 | public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
55 |
56 | SettingsManager.getInstance(activity).setDarkThemeEnabled(checked);
57 | if (checked)
58 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
59 | else
60 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
61 | activity.recreate();
62 |
63 | }
64 | });
65 | }
66 |
67 | private void initVariables() {
68 | activity = getActivity();
69 | Prefser prefser = new Prefser(activity);
70 | AuthInfo authInfo = prefser.get(Constant.AUTH_INFO, AuthInfo.class, null);
71 | if (authInfo != null) {
72 | emailTextView.setText(authInfo.getEmail());
73 | }
74 | darkThemeSwitch.setChecked(SettingsManager.getInstance(activity).isDarkThemeEnabled());
75 | }
76 |
77 | @NonNull
78 | @Override
79 | public Dialog onCreateDialog(Bundle savedInstanceState) {
80 | Dialog dialog = super.onCreateDialog(savedInstanceState);
81 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
82 | dialog.setCancelable(true);
83 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
84 | lp.copyFrom(dialog.getWindow().getAttributes());
85 | lp.width = WindowManager.LayoutParams.MATCH_PARENT;
86 | lp.height = WindowManager.LayoutParams.MATCH_PARENT;
87 | dialog.getWindow().setAttributes(lp);
88 | return dialog;
89 | }
90 |
91 | @OnClick(R.id.close_button)
92 | void close() {
93 | dismiss();
94 | if (getFragmentManager() != null) {
95 | getFragmentManager().popBackStack();
96 | }
97 | }
98 |
99 | @OnClick(R.id.sign_out_button)
100 | void signOut() {
101 | if (activity != null && activity instanceof SettingsEventListener) {
102 | ((SettingsEventListener)activity).signOut();
103 | close();
104 | }
105 | }
106 |
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/ui/fragment/TagLegendFragment.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.ui.fragment;
2 |
3 | import android.app.Dialog;
4 | import android.os.Bundle;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.view.Window;
9 | import android.view.WindowManager;
10 |
11 | import androidx.annotation.NonNull;
12 | import androidx.appcompat.widget.AppCompatTextView;
13 | import androidx.fragment.app.DialogFragment;
14 | import androidx.recyclerview.widget.DefaultItemAnimator;
15 | import androidx.recyclerview.widget.GridLayoutManager;
16 | import androidx.recyclerview.widget.RecyclerView;
17 |
18 | import com.mikepenz.fastadapter.FastAdapter;
19 | import com.mikepenz.fastadapter.adapters.ItemAdapter;
20 |
21 | import java.util.List;
22 |
23 | import butterknife.BindView;
24 | import butterknife.ButterKnife;
25 | import butterknife.OnClick;
26 | import io.objectbox.Box;
27 | import io.objectbox.BoxStore;
28 | import ir.textmining.app.R;
29 | import ir.textmining.app.model.NerStandardTagsItem;
30 | import ir.textmining.app.model.TagsLegend;
31 | import ir.textmining.app.util.AppUtil;
32 | import ir.textmining.app.util.MyApplication;
33 |
34 | public class TagLegendFragment extends DialogFragment {
35 | @BindView(R.id.title)
36 | AppCompatTextView title;
37 | @BindView(R.id.recyclerView)
38 | RecyclerView recyclerView;
39 | private Box tagsItemBox;
40 | private FastAdapter mFastAdapter;
41 | private ItemAdapter mItemAdapter;
42 |
43 |
44 | @Override
45 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
46 | Bundle savedInstanceState) {
47 | View view = inflater.inflate(R.layout.fragment_tag_legend,
48 | container, false);
49 | ButterKnife.bind(this, view);
50 | initVariables();
51 | setUpRecyclerView();
52 | handleTagItems();
53 | return view;
54 | }
55 |
56 | private void initVariables() {
57 | BoxStore boxStore = MyApplication.getBoxStore();
58 | tagsItemBox = boxStore.boxFor(NerStandardTagsItem.class);
59 | }
60 |
61 | private void setUpRecyclerView() {
62 | RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getActivity(), 1);
63 | recyclerView.setLayoutManager(mLayoutManager);
64 | recyclerView.setItemAnimator(new DefaultItemAnimator());
65 | mItemAdapter = new ItemAdapter<>();
66 | mFastAdapter = FastAdapter.with(mItemAdapter);
67 | recyclerView.setAdapter(mFastAdapter);
68 | }
69 |
70 | private void handleTagItems() {
71 | List tagsItems = tagsItemBox.getAll();
72 | mItemAdapter.clear();
73 | mItemAdapter.add(AppUtil.convertToTagsLegend(tagsItems));
74 | }
75 |
76 | @NonNull
77 | @Override
78 | public Dialog onCreateDialog(Bundle savedInstanceState) {
79 | Dialog dialog = super.onCreateDialog(savedInstanceState);
80 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
81 | dialog.setCancelable(true);
82 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
83 | lp.copyFrom(dialog.getWindow().getAttributes());
84 | lp.width = WindowManager.LayoutParams.MATCH_PARENT;
85 | lp.height = WindowManager.LayoutParams.MATCH_PARENT;
86 | dialog.getWindow().setAttributes(lp);
87 | return dialog;
88 | }
89 |
90 | @OnClick(R.id.close_button)
91 | void close() {
92 | dismiss();
93 | if (getFragmentManager() != null) {
94 | getFragmentManager().popBackStack();
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/util/AppUtil.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.util;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.graphics.Color;
6 | import android.os.Build;
7 | import android.os.Handler;
8 | import android.view.View;
9 | import android.view.Window;
10 | import android.view.WindowManager;
11 |
12 | import androidx.fragment.app.Fragment;
13 | import androidx.fragment.app.FragmentManager;
14 | import androidx.fragment.app.FragmentTransaction;
15 |
16 | import com.blankj.utilcode.util.SnackbarUtils;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | import io.objectbox.Box;
22 | import ir.textmining.app.R;
23 | import ir.textmining.app.model.AuthInfo;
24 | import ir.textmining.app.model.NerStandardTagsItem;
25 | import ir.textmining.app.model.NerStandardTagsItem_;
26 | import ir.textmining.app.model.TagsLegend;
27 |
28 | public class AppUtil {
29 |
30 | public static boolean isTokenExpire(AuthInfo authInfo) {
31 | Long currentTimeMillis = System.currentTimeMillis();
32 | Long currentDiff = currentTimeMillis - authInfo.getCurrentTimestamp();
33 | Long timeDiff = authInfo.getExpireTimestamp() - authInfo.getCreateTimestamp();
34 | return currentDiff > timeDiff;
35 | }
36 |
37 | public static Dialog getLoadingDialog(Context context) {
38 | Dialog dialog = new Dialog(context);
39 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
40 | dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
41 | dialog.setContentView(R.layout.dialog_full_screen_loading);
42 | dialog.setCancelable(false);
43 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
44 | lp.copyFrom(dialog.getWindow().getAttributes());
45 | lp.width = WindowManager.LayoutParams.MATCH_PARENT;
46 | lp.height = WindowManager.LayoutParams.MATCH_PARENT;
47 | dialog.getWindow().setAttributes(lp);
48 | return dialog;
49 | }
50 |
51 | public static String colorHexString(String tagTitle, Box tagsItemBox) {
52 | NerStandardTagsItem tagItem = tagsItemBox.query().equal(NerStandardTagsItem_.title, tagTitle).build().findFirst();
53 | if (tagItem != null) {
54 | return tagItem.getColor();
55 | } else {
56 | return "#ffffff";
57 | }
58 | }
59 |
60 | public static void showFragment(Fragment fragment, FragmentManager fragmentManager) {
61 | FragmentTransaction transaction = fragmentManager.beginTransaction();
62 | transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
63 | transaction.add(android.R.id.content, fragment).addToBackStack(null).commit();
64 | }
65 |
66 | static boolean isAtLeastVersion(int version) {
67 | return Build.VERSION.SDK_INT >= version;
68 | }
69 |
70 | public static void showSnackbar(View view, String message, Context context, int duration) {
71 | final Handler handler = new Handler();
72 | handler.postDelayed(new Runnable() {
73 | @Override
74 | public void run() {
75 | SnackbarUtils.with(view)
76 | .setBottomMargin(20)
77 | .setMessage(message)
78 | .setMessageColor(Color.WHITE)
79 | .setBgColor(context.getResources().getColor(R.color.colorAccent))
80 | .setDuration(duration)
81 | .setAction(context.getString(R.string.ok_label), Color.YELLOW, new View.OnClickListener() {
82 | @Override
83 | public void onClick(View v) {
84 | }
85 | })
86 | .show();
87 | }
88 | }, 100);
89 | }
90 |
91 | public static List convertToTagsLegend(List tagsItems) {
92 | List tagsLegends = new ArrayList<>();
93 | for (NerStandardTagsItem item : tagsItems) {
94 | TagsLegend tagsLegend = new TagsLegend();
95 | tagsLegend.setColor(item.getColor());
96 | tagsLegend.setDescription(item.getDescription());
97 | tagsLegend.setId(item.getId());
98 | tagsLegend.setPersianName(item.getPersianName());
99 | tagsLegend.setShortcut(item.getShortcut());
100 | tagsLegend.setTitle(item.getTitle());
101 | tagsLegends.add(tagsLegend);
102 | }
103 | return tagsLegends;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/util/Constant.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.util;
2 |
3 | public class Constant {
4 | public static final String BASE_URL = "https://app.text-mining.ir/api/";
5 | public static final String AUTH_INFO = "auth-info";
6 | public static final String LANGUAGE = "language";
7 | public static final String DARK_THEME = "dark-theme";
8 | public static final String GITHUB_URL = "https://github.com/Text-Mining/";
9 | public static final String WEB_SITE_URL = "https://app.text-mining.ir/";
10 | public static final String DEVELOPER_URL = "https://twitter.com/bkhezry";
11 | public static final String TOKEN_INVALID = "token-invalid";
12 | public static final String DESIGNER_URL = "https://twitter.com/mirMasoud_";
13 | public static final String APP_INTRO = "app-intro";
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/util/LocaleManager.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.util;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.content.res.Configuration;
7 | import android.content.res.Resources;
8 | import android.preference.PreferenceManager;
9 |
10 | import java.util.Locale;
11 |
12 | import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
13 | import static android.os.Build.VERSION_CODES.N;
14 |
15 | public class LocaleManager {
16 | public static final String LANGUAGE_ENGLISH = "en";
17 | public static final String LANGUAGE_PERSIAN = "fa";
18 | private final SharedPreferences prefs;
19 |
20 | LocaleManager(Context context) {
21 | prefs = PreferenceManager.getDefaultSharedPreferences(context);
22 | }
23 |
24 | public static Locale getLocale(Resources res) {
25 | Configuration config = res.getConfiguration();
26 | return AppUtil.isAtLeastVersion(N) ? config.getLocales().get(0) : config.locale;
27 | }
28 |
29 | public Context setLocale(Context c) {
30 | return updateResources(c, getLanguage());
31 | }
32 |
33 | public Context setNewLocale(Context c, String language) {
34 | persistLanguage(language);
35 | return updateResources(c, language);
36 | }
37 |
38 | public String getLanguage() {
39 | return prefs.getString(Constant.LANGUAGE, LANGUAGE_PERSIAN);
40 | }
41 |
42 | @SuppressLint("ApplySharedPref")
43 | private void persistLanguage(String language) {
44 | prefs.edit().putString(Constant.LANGUAGE, language).commit();
45 | }
46 |
47 | private Context updateResources(Context context, String language) {
48 | Locale locale = new Locale(language);
49 | Locale.setDefault(locale);
50 |
51 | Resources res = context.getResources();
52 | Configuration config = new Configuration(res.getConfiguration());
53 | if (AppUtil.isAtLeastVersion(JELLY_BEAN_MR1)) {
54 | config.setLocale(locale);
55 | context = context.createConfigurationContext(config);
56 | } else {
57 | config.locale = locale;
58 | res.updateConfiguration(config, res.getDisplayMetrics());
59 | }
60 | return context;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/util/MyApplication.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.util;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.content.res.Configuration;
6 |
7 | import androidx.appcompat.app.AppCompatDelegate;
8 | import io.github.inflationx.calligraphy3.CalligraphyConfig;
9 | import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
10 | import io.github.inflationx.viewpump.ViewPump;
11 | import io.objectbox.BoxStore;
12 | import io.objectbox.android.AndroidObjectBrowser;
13 | import io.objectbox.android.BuildConfig;
14 | import ir.textmining.app.R;
15 | import ir.textmining.app.model.MyObjectBox;
16 |
17 | public class MyApplication extends Application {
18 | public static LocaleManager localeManager;
19 | private static BoxStore boxStore;
20 |
21 | public static BoxStore getBoxStore() {
22 | return boxStore;
23 | }
24 |
25 | @Override
26 | public void onCreate() {
27 | super.onCreate();
28 | ViewPump.init(ViewPump.builder()
29 | .addInterceptor(new CalligraphyInterceptor(
30 | new CalligraphyConfig.Builder()
31 | .setDefaultFontPath("fonts/Vazir.ttf")
32 | .setFontAttrId(R.attr.fontPath)
33 | .build()))
34 | .build());
35 | createBoxStore();
36 |
37 | if(SettingsManager.getInstance(this).isDarkThemeEnabled())
38 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
39 | else
40 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
41 | }
42 |
43 | private void createBoxStore() {
44 | boxStore = MyObjectBox.builder().androidContext(MyApplication.this).build();
45 | if (BuildConfig.DEBUG) {
46 | new AndroidObjectBrowser(boxStore).start(this);
47 | }
48 | }
49 |
50 | @Override
51 | protected void attachBaseContext(Context base) {
52 | localeManager = new LocaleManager(base);
53 | super.attachBaseContext(localeManager.setLocale(base));
54 | }
55 |
56 | @Override
57 | public void onConfigurationChanged(Configuration newConfig) {
58 | super.onConfigurationChanged(newConfig);
59 | localeManager.setLocale(this);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/util/RetrofitUtil.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.util;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import java.io.IOException;
6 |
7 | import okhttp3.Interceptor;
8 | import okhttp3.OkHttpClient;
9 | import okhttp3.Request;
10 | import okhttp3.Response;
11 | import okhttp3.logging.HttpLoggingInterceptor;
12 | import retrofit2.Retrofit;
13 | import retrofit2.converter.gson.GsonConverterFactory;
14 |
15 | public class RetrofitUtil {
16 |
17 | public static Retrofit getRetrofit(String token) {
18 | return new Retrofit.Builder().baseUrl(Constant.BASE_URL)
19 | .client(getHeader(token))
20 | .addConverterFactory(GsonConverterFactory.create())
21 | .build();
22 | }
23 |
24 | private static OkHttpClient getHeader(final String authorizationValue) {
25 | //delete this interceptor in released app
26 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
27 | interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
28 | //end interceptor
29 | return new OkHttpClient.Builder()
30 | //.addInterceptor(interceptor)
31 | .addNetworkInterceptor(
32 | new Interceptor() {
33 | @Override
34 | public Response intercept(@NonNull Chain chain) throws IOException {
35 | Request request = null;
36 | if (authorizationValue != null) {
37 | Request original = chain.request();
38 | // Request customization: add request headers
39 | Request.Builder requestBuilder = original.newBuilder()
40 | .addHeader("Authorization", "Bearer " + authorizationValue)
41 | .addHeader("Content-Type", "application/x-www-form-urlencoded");
42 |
43 | request = requestBuilder.build();
44 | }
45 | assert request != null;
46 | return chain.proceed(request);
47 | }
48 | })
49 | .build();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/ir/textmining/app/util/SettingsManager.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app.util;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.preference.PreferenceManager;
6 |
7 | public class SettingsManager {
8 |
9 | private static SettingsManager instance = null;
10 | private SharedPreferences prefs;
11 | SharedPreferences.Editor editor;
12 |
13 | private SettingsManager(Context context) {
14 | prefs = PreferenceManager.getDefaultSharedPreferences(context);
15 | editor = prefs.edit();
16 | }
17 |
18 | public static SettingsManager getInstance(Context context) {
19 |
20 | if (instance == null) {
21 | instance = new SettingsManager(context);
22 | }
23 |
24 | return instance;
25 | }
26 |
27 | public boolean isDarkThemeEnabled() {
28 | return prefs.getBoolean(Constant.DARK_THEME, false);
29 | }
30 |
31 | public void setDarkThemeEnabled(boolean state) {
32 | editor.putBoolean(Constant.DARK_THEME, state).commit();
33 | }
34 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldrtl/ic_navigate_next_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_code_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_exit_to_app_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_info_outline_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/drawable/ic_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_navigate_next_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_settings_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_sync_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_web_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/page_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/drawable/page_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/page_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/drawable/page_2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/page_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/drawable/page_3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/page_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/drawable/page_4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/page_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/drawable/page_5.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
17 |
18 |
25 |
26 |
27 |
34 |
35 |
40 |
41 |
51 |
52 |
59 |
60 |
71 |
72 |
73 |
74 |
77 |
78 |
86 |
87 |
97 |
98 |
99 |
100 |
103 |
104 |
114 |
115 |
126 |
127 |
135 |
136 |
141 |
142 |
145 |
146 |
156 |
157 |
158 |
159 |
168 |
169 |
174 |
175 |
178 |
179 |
189 |
190 |
191 |
192 |
193 |
194 |
201 |
202 |
209 |
210 |
216 |
217 |
220 |
221 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
24 |
25 |
30 |
31 |
32 |
33 |
41 |
42 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
19 |
20 |
31 |
32 |
35 |
36 |
46 |
47 |
48 |
54 |
55 |
63 |
64 |
70 |
71 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_full_screen_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
23 |
24 |
28 |
29 |
36 |
37 |
45 |
46 |
53 |
54 |
55 |
61 |
62 |
67 |
68 |
74 |
75 |
80 |
81 |
90 |
91 |
94 |
95 |
101 |
102 |
105 |
106 |
110 |
111 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
130 |
131 |
134 |
135 |
140 |
141 |
144 |
145 |
149 |
150 |
156 |
157 |
163 |
164 |
165 |
166 |
167 |
168 |
179 |
180 |
183 |
184 |
189 |
190 |
193 |
194 |
199 |
200 |
201 |
202 |
213 |
214 |
217 |
218 |
223 |
224 |
227 |
228 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
244 |
245 |
252 |
253 |
259 |
260 |
270 |
271 |
282 |
283 |
286 |
287 |
291 |
292 |
297 |
298 |
304 |
305 |
306 |
307 |
308 |
309 |
319 |
320 |
331 |
332 |
335 |
336 |
340 |
341 |
346 |
347 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
366 |
367 |
375 |
376 |
382 |
383 |
393 |
394 |
402 |
403 |
406 |
407 |
411 |
412 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
433 |
434 |
435 |
436 |
437 |
438 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_select_tag.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
23 |
24 |
28 |
29 |
36 |
37 |
45 |
46 |
53 |
54 |
55 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
23 |
24 |
28 |
29 |
36 |
37 |
45 |
46 |
53 |
54 |
55 |
61 |
62 |
67 |
68 |
74 |
75 |
80 |
81 |
90 |
91 |
97 |
98 |
105 |
106 |
110 |
111 |
112 |
113 |
116 |
117 |
123 |
124 |
127 |
128 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_tag_legend.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
23 |
24 |
28 |
29 |
36 |
37 |
45 |
46 |
53 |
54 |
55 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_chip.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_skeleton.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_tag_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_tag_legend.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
24 |
25 |
33 |
34 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
12 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/mipmap-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-fa/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | فارسییار
3 | ورود
4 | ایمیل
5 | رمزعبور
6 | کاربر جدید؟
7 | ثبتنام
8 | جمله
9 | جمله بعدی
10 | انتخاب برچسب
11 | تنظیمات
12 | درباره
13 | باشه
14 | ارتباط اینترنتی خود را چک کنید
15 | ایمیل یا رمزعبور اشتباه است
16 | لطفا ایمیل معتبر وارد نمایید
17 | ایمیل و رمزعبور را وارد نمایید
18 | تلاش مجدد
19 | نسخه برنامه
20 | توسعهدهنده
21 | بهروز خضری
22 | در دنیای امروز، برای پردازش هر چه بهتر متون به زبان فارسی، نیازمند اطلاعاتی هستیم که به عنوان ورودی به الگوریتمهای هوش مصنوعی و یادگیری عمیق بدهیم. ما، اطلاعات ویکی پدیا فارسی را دریافت و برچسب گذاری کردیم. این اطلاعات، شامل ۲۵ میلیون کلمه در قالب حدود ۱ میلیون جمله است. این اطلاعات به صورت اپن سورس در مخزن Persian NER در دسترس کسب و کارها و پژوهشگران است. با کمک به بهبود برچسبها و اصلاح اشتباهات، به بزرگترین پیکره متنی اطلاعات برچسبگذاری شده فارسی کمک کنید.
23 | زبان فارسی، نیازمند یاری آنلاین شماست
24 | وبسایت
25 | سورس برنامه در گیتهاب
26 | برنامه مرورگر یافت نشد
27 | برچسب با موفقیت ثبت شد
28 | خطایی در حین درخواست روی داد. دوباره تلاش کنید
29 | لطفا دوباره وارد شوید
30 | حسابکاربری دارید؟
31 | ثبتنام با موفقیت انجام شد. لطفا وارد شوید
32 | ایمیل وارد شده قبلا ثبتنام کرده است
33 | خروج از حسابکاربری
34 | توکن نامعتبر است. لطفا این خطا را به ما اطلاع دهید
35 | راهنمای تگها
36 | راهنما
37 | حالت شب
38 | روند تگگذاری
39 | طراح
40 | مسعود میرزمانی
41 | به فارسیيار خوشامدید!
42 | در فارسییار، نقش کلمات را در اطلاعات یک میلیون جمله از ویکیپدیا فارسی مشخص کنید تا نسل بعدی نرمافزارها با کمک هوش مصنوعی، فارسی را بهتر بفهمند. خروجی پروژه به صورت رایگان و بازمتن برای پژوهشگران و کسبوکارها و همه مردم در دسترس است.
43 | چطور کمک کنیم؟
44 | بعد از ثبتنام و ورود، به صورت تصادفی یک جمله به شما نمایش داده میشود، کافی است بر اساس راهنما، کلمات آن جمله را برچسبگذاری کنید.
45 | چه چیزی کسب میکنید؟
46 | حتی اگر در اصلاح یک برچسب هم همکاری کنید نام شما در میان مشارکتکنندگان این پروژه درج میشود. پروژهای که زیربنای ساخت دستیارهای صوتی یا سایر نرمافزارها با قابلیت درک زبان فارسی است.
47 | چطور برچسب بزنیم؟
48 | کافی است روی کلمه مورد نظر بزنید و نوع کلمه (اسم شخص، سازمان، مکان، رویداد یا تاریخ و زمان) را مشخص کنید
49 | راهنمای برچسبها
50 | راهنمای انواع برچسبها با مثال در اپلیکیشن قابل مطالعه است.
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | @color/grey_60
5 | @color/grey_20
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #039be5
4 | #e6e6e6
5 | #cccccc
6 | #80000000
7 | #666666
8 | #eeeeee
9 | #263238
10 | #141d26
11 |
12 | @color/grey_10
13 | @color/grey_20
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 5dp
3 | 10dp
4 | 15dp
5 | 20dp
6 | 35dp
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | فارسییار
3 | Sign In
4 | Email
5 | Password
6 | New user?
7 | Sign Up
8 | Sentence
9 | Next Sentence
10 | Select word tag
11 | Settings
12 | About
13 | OK
14 | Please check internet connection
15 | Email or password incorrect
16 | Please enter correct email address.
17 | Please enter email and password.
18 | Retry
19 | App Version
20 | Developer
21 | Behrouz Khezry
22 | \@bkhezry
23 | در دنیای امروز، برای پردازش هر چه بهتر متون به زبان فارسی، نیازمند اطلاعاتی هستیم که به عنوان ورودی به الگوریتمهای هوش مصنوعی و یادگیری عمیق بدهیم. ما، اطلاعات ویکی پدیا فارسی را دریافت و برچسب گذاری کردیم. این اطلاعات، شامل ۲۵ میلیون کلمه در قالب حدود ۱ میلیون جمله است. این اطلاعات به صورت اپن سورس در مخزن Persian NER در دسترس کسب و کارها و پژوهشگران است. با کمک به بهبود برچسبها و اصلاح اشتباهات، به بزرگترین پیکره متنی اطلاعات برچسبگذاری شده فارسی کمک کنید.
24 | Description
25 | Website
26 | Source Code
27 | Browser not found
28 | Tag submit success
29 | Error occur during request. Try again
30 | Please sign in again
31 | Have an account?
32 | Sign up success. Please sign in
33 | This email is duplicate
34 | Sign Out
35 | Token is invalid. please contact administrator
36 | Tags Legend
37 | Legend
38 | Night Mode
39 | App Intro
40 | Designer
41 | Masoud Mirzamani
42 | \@mirMasoud_
43 | به فارسیيار خوشامدید!
44 | در فارسییار، نقش کلمات را در اطلاعات یک میلیون جمله از ویکیپدیا فارسی مشخص کنید تا نسل بعدی نرمافزارها با کمک هوش مصنوعی، فارسی را بهتر بفهمند. خروجی پروژه به صورت رایگان و بازمتن برای پژوهشگران و کسبوکارها و همه مردم در دسترس است.
45 | چطور کمک کنیم؟
46 | بعد از ثبتنام و ورود، به صورت تصادفی یک جمله به شما نمایش داده میشود، کافی است بر اساس راهنما، کلمات آن جمله را برچسبگذاری کنید.
47 | چه چیزی کسب میکنید؟
48 | حتی اگر در اصلاح یک برچسب هم همکاری کنید نام شما در میان مشارکتکنندگان این پروژه درج میشود. پروژهای که زیربنای ساخت دستیارهای صوتی یا سایر نرمافزارها با قابلیت درک زبان فارسی است.
49 | چطور برچسب بزنیم؟
50 | کافی است روی کلمه مورد نظر بزنید و نوع کلمه (اسم شخص، سازمان، مکان، رویداد یا تاریخ و زمان) را مشخص کنید
51 | راهنمای برچسبها
52 | راهنمای انواع برچسبها با مثال در اپلیکیشن قابل مطالعه است.
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/test/java/ir/textmining/app/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package ir.textmining.app;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/assets/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/assets/screenshot.png
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 | maven {
8 | url 'https://maven.fabric.io/public'
9 | }
10 | }
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:3.3.2'
13 | classpath "io.objectbox:objectbox-gradle-plugin:2.3.1"
14 | classpath 'com.google.gms:google-services:4.2.0'
15 | classpath 'io.fabric.tools:gradle:1.27.1'
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | google()
24 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
25 | jcenter()
26 | maven { url 'https://jitpack.io' }
27 |
28 | }
29 | }
30 |
31 | task clean(type: Delete) {
32 | delete rootProject.buildDir
33 | }
34 |
--------------------------------------------------------------------------------
/encrypt.tar.enc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/encrypt.tar.enc
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | android.jetifier.blacklist=butterknife-compiler
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Text-Mining/android-app/21594af52f53d75d8147ae29eefcf0546734097a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jan 27 14:30:30 IRST 2019
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-4.10.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------