Compare commits
63 Commits
Author | SHA1 | Date | |
---|---|---|---|
f448e3dcad | |||
d448a06d95 | |||
b6950e5238 | |||
17a4958a65 | |||
0928e936d7 | |||
a29011c6a2 | |||
c09fc4988a | |||
39ac49b258 | |||
cd55f946f0 | |||
b529f81115 | |||
e6109ef36d | |||
e00fcd846a | |||
060c86c090 | |||
26f54280a1 | |||
8a7923cba7 | |||
673b9f564c | |||
d1be03956c | |||
caa437d5e3 | |||
25036ce5d2 | |||
a8a34ccc7a | |||
f87e8020d8 | |||
4d67e63db4 | |||
3561dde19f | |||
9c48dec54d | |||
3d72d68e14 | |||
47b24470e6 | |||
1db6a3294b | |||
500dc019c1 | |||
e2aff890d7 | |||
cdfc2cfb9e | |||
f135508745 | |||
3e5e94790e | |||
62aace4b91 | |||
2412245a9f | |||
e872069093 | |||
5672208fd0 | |||
7379e9945d | |||
815417bf11 | |||
95fc5e1e9a | |||
f285d47a0b | |||
2483968f11 | |||
d0fde4e791 | |||
c7c2ac2a11 | |||
4f79ea0156 | |||
22943ca9cd | |||
5a10127c1c | |||
7de29687eb | |||
1a95475140 | |||
d2265aecae | |||
626746be8b | |||
f21f23c1f0 | |||
5005fcc5b5 | |||
008e446b93 | |||
50e0142f6c | |||
42640f2d1c | |||
4a8ee2ea96 | |||
acc55e3433 | |||
e267aa5100 | |||
5e41469452 | |||
55473701b8 | |||
546346ff48 | |||
4f0091f151 | |||
37367e142f |
10
.drone.yml
10
.drone.yml
@ -26,6 +26,12 @@ steps:
|
||||
# depends_on: [ clone ]
|
||||
# commands:
|
||||
# - /opt/intellij/bin/idea.sh inspect/format ...
|
||||
#
|
||||
# - name: do-or-check-formatting
|
||||
# image: dlsniper/docker-intellij
|
||||
# depends_on: [ clone ]
|
||||
# commands:
|
||||
# - /opt/intellij/bin/idea.sh format -s .idea/codeStyles/Project.xml -m *.java app/src/main/java
|
||||
|
||||
trigger:
|
||||
event:
|
||||
@ -65,7 +71,7 @@ steps:
|
||||
- name: sign
|
||||
image: nextcloudci/android:android-49
|
||||
environment:
|
||||
TOKEN:
|
||||
BOT_TOKEN:
|
||||
from_secret: BOT_TOKEN
|
||||
KS_PASS:
|
||||
from_secret: KS_PASS
|
||||
@ -88,7 +94,7 @@ steps:
|
||||
PLUGIN_FILE: 'signed.apk'
|
||||
PLUGIN_TIMEOUT: 180
|
||||
PLUGIN_ATTEMPTS: 5
|
||||
PLUGIN_DESTINATION: 'https://cloud.swatian.com/remote.php/dav/files/GitNexBot/GitNex-Builds/latest.apk'
|
||||
PLUGIN_DESTINATION: 'https://cloud.swatian.com/remote.php/dav/files/GitNexBot/gitnex/builds/latest.apk'
|
||||
PLUGIN_CUSTOM_ARGUMENTS: '--progress-bar'
|
||||
|
||||
trigger:
|
||||
|
@ -4,14 +4,22 @@ end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
max_line_length = 150
|
||||
|
||||
[*.java]
|
||||
indent_style = tab
|
||||
max_line_length = 220
|
||||
line_comment = //
|
||||
block_comment_start = /*
|
||||
block_comment = *
|
||||
block_comment_end = */
|
||||
|
||||
[*.json]
|
||||
indent_size = 2
|
||||
|
||||
[{*.yml,*.yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
||||
|
63
.gitlab-ci.yml
Normal file
63
.gitlab-ci.yml
Normal file
@ -0,0 +1,63 @@
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
- sign
|
||||
- publish
|
||||
|
||||
test:
|
||||
image: nextcloudci/android:android-49
|
||||
stage: test
|
||||
script:
|
||||
- ./gradlew test
|
||||
|
||||
build:
|
||||
image: nextcloudci/android:android-49
|
||||
stage: build
|
||||
only:
|
||||
- master
|
||||
script:
|
||||
- ./gradlew build
|
||||
artifacts:
|
||||
paths:
|
||||
- app/build/outputs/
|
||||
expire_in: 15 minutes
|
||||
|
||||
sign:
|
||||
image: nextcloudci/android:android-49
|
||||
stage: sign
|
||||
only:
|
||||
- master
|
||||
variables:
|
||||
OUTPUT: "signed.apk"
|
||||
GITEA: "https://gitea.com"
|
||||
KS_FILE: "ci_keystore.jks"
|
||||
script:
|
||||
- ./scripts/sign-build.sh
|
||||
artifacts:
|
||||
paths:
|
||||
- signed.apk
|
||||
expire_in: 15 minutes
|
||||
|
||||
latest:
|
||||
image: tutum/curl
|
||||
stage: publish
|
||||
only:
|
||||
- master
|
||||
variables:
|
||||
WEBDAV_USERNAME: "GitNexBot"
|
||||
PLUGIN_FILE: "signed.apk"
|
||||
PLUGIN_DESTINATION: "https://cloud.swatian.com/remote.php/dav/files/GitNexBot/gitnex/builds/latest.apk"
|
||||
script:
|
||||
- curl -T "$PLUGIN_FILE" -u "$WEBDAV_USERNAME":"$WEBDAV_PASSWORD" "$PLUGIN_DESTINATION"
|
||||
|
||||
release:
|
||||
image: tutum/curl
|
||||
stage: publish
|
||||
only:
|
||||
- tags
|
||||
variables:
|
||||
WEBDAV_USERNAME: "GitNexBot"
|
||||
PLUGIN_FILE: "signed.apk"
|
||||
script:
|
||||
- "[[ $CI_COMMIT_REF_NAME == *'-rc'* ]] && echo 'Upload blocked. Build seems to be a release candidate.' && exit 0"
|
||||
- curl -T "$PLUGIN_FILE" -u "$WEBDAV_USERNAME":"$WEBDAV_PASSWORD" 'https://cloud.swatian.com/remote.php/dav/files/GitNexBot/gitnex/releases/'"$CI_COMMIT_REF_NAME"'.apk'
|
10
.idea/codeStyles/Project.xml
generated
10
.idea/codeStyles/Project.xml
generated
@ -29,6 +29,7 @@
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
|
||||
@ -36,8 +37,13 @@
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SYNCHRONIZED_PARENTHESES" value="false" />
|
||||
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="1" />
|
||||
<option name="THROWS_LIST_WRAP" value="1" />
|
||||
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
|
||||
<option name="TERNARY_OPERATION_WRAP" value="1" />
|
||||
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="WRAP_ON_TYPING" value="1" />
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="SMART_TABS" value="true" />
|
||||
@ -156,4 +162,4 @@
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
</component>
|
@ -1,2 +1,2 @@
|
||||
# Changelog
|
||||
[Check out the release notes](https://gitea.com/gitnex/GitNex/releases)
|
||||
[Check out the release notes](https://codeberg.org/gitnex/GitNex/releases)
|
||||
|
@ -10,7 +10,7 @@ Please ask if you are not sure about the scope of work to be submitted to avoid
|
||||
**Code Standards**
|
||||
Please follow the code standards, this will help other developers to understand your code too.
|
||||
It also helps maintaining the code afterwards.
|
||||
It is documented in the Wiki: [Code-Standards](https://gitea.com/gitnex/GitNex/wiki/Code-Standards)
|
||||
It is documented in the Wiki: [Code-Standards](https://codeberg.org/gitnex/GitNex/wiki/Code-Standards)
|
||||
|
||||
**How to submit a PR**
|
||||
Fork this repository. Pull the forked repository from your namespace to your local machine. Create new branch and work on the bug/feature/enhancement you would like to submit. Push it to your forked version. From there create Pull Request(PR) against **master** branch.
|
||||
|
@ -3,6 +3,7 @@ This part lists all PUBLIC individuals having contributed content to the code.
|
||||
|
||||
* M M Arif (mmarif)
|
||||
* 6543
|
||||
* opyale
|
||||
* Unpublished
|
||||
|
||||
# Translators
|
||||
|
63
LICENSE
63
LICENSE
@ -1,7 +1,7 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
@ -620,55 +620,18 @@ copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
GitNex is an Android client/application for Gitea.
|
||||
Copyright (C) 2019 The GitNex Authors
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
Mastalab is a Mastodon client for Android devices
|
||||
Copyright (C) 2017 Thomas Schneider
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
Mastalab Copyright (C) 2017 Thomas Schneider
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
35
README.md
35
README.md
@ -1,4 +1,4 @@
|
||||
[](https://www.gnu.org/licenses/gpl-3.0) [](https://gitea.com/gitnex/GitNex/releases) [](https://drone.gitea.com/gitnex/GitNex) [](https://crowdin.com/project/gitnex) [](https://discord.gg/FbSS4rf)
|
||||
[](https://www.gnu.org/licenses/gpl-3.0) [](https://codeberg.org/gitnex/GitNex/releases) [](https://crowdin.com/project/gitnex) [](https://discord.gg/FbSS4rf)
|
||||
|
||||
[<img alt="Become a Patroen" src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" height="40"/>](https://www.patreon.com/mmarif) [<img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg" height="40"/>](https://liberapay.com/mmarif/donate)
|
||||
|
||||
@ -11,14 +11,12 @@ GitNex is licensed under GPLv3 License. See the LICENSE file for the full licens
|
||||
## Downloads
|
||||
[<img alt='Get it on F-droid' src='https://gitlab.com/fdroid/artwork/raw/master/badge/get-it-on.png' height="80"/>](https://f-droid.org/en/packages/org.mian.gitnex/)
|
||||
[<img alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' height="80"/>](https://play.google.com/store/apps/details?id=org.mian.gitnex)
|
||||
[<img alt='Download APK' src='https://gitnex.com/img/download-apk.png' height="80"/>](https://cloud.swatian.com/s/QoDFzMxmnf2FfYw)
|
||||
|
||||
Download latest build from master: [https://cloud.swatian.com/s/Cq592xGEfnsGAAW](https://cloud.swatian.com/s/Cq592xGEfnsGAAW)
|
||||
[<img alt='Download builds and releases' src='assets/apk-badge.png' height="82"/>](https://cloud.swatian.com/s/DN7E5xxtaw4fRbE)
|
||||
|
||||
## Note about Gitea version
|
||||
Please make sure that you are on latest stable release or later for better app experience.
|
||||
|
||||
Check the versions [compatibility page](https://gitea.com/gitnex/GitNex/wiki/Compatibility) which lists all the supported versions with compatibility ratio.
|
||||
Check the versions [compatibility page](https://codeberg.org/gitnex/GitNex/wiki/Compatibility) which lists all the supported versions with compatibility ratio.
|
||||
|
||||
## Build from source
|
||||
Option 1 - Download the source code, open it in Android Studio and build it there.
|
||||
@ -26,47 +24,50 @@ Option 1 - Download the source code, open it in Android Studio and build it ther
|
||||
Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew build`.
|
||||
|
||||
## Features
|
||||
- Repositories / issues/ org list
|
||||
- File and directory browser
|
||||
- File viewer
|
||||
- Create files
|
||||
- Explore repositories
|
||||
- Issues list
|
||||
- Pull requests
|
||||
- Merge pull request
|
||||
- [MANY MORE](https://gitea.com/gitnex/GitNex/wiki/Features)
|
||||
- Files diff for PRs
|
||||
- Notifications
|
||||
- Drafts
|
||||
- [MANY MORE](https://codeberg.org/gitnex/GitNex/wiki/Features)
|
||||
|
||||
## Contributing
|
||||
[CONTRIBUTING](https://gitea.com/gitnex/GitNex/src/branch/master/CONTRIBUTING.md)
|
||||
[CONTRIBUTING](https://codeberg.org/gitnex/GitNex/src/branch/master/CONTRIBUTING.md)
|
||||
|
||||
## Translation
|
||||
Help us translate GitNex to your native language.
|
||||
|
||||
We use [Crowdin](https://crowdin.com/project/gitnex) for translation. If your language is not listed, please request [here](https://gitea.com/gitnex/GitNex/issues) to add it to the project.
|
||||
We use [Crowdin](https://crowdin.com/project/gitnex) for translation. If your language is not listed, please request [here](https://codeberg.org/gitnex/GitNex/issues) to add it to the project.
|
||||
|
||||
**Link: https://crowdin.com/project/GitNex**
|
||||
|
||||
## Screenshots:
|
||||
|
||||
<img src="https://gitea.com/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/001.png" alt="001.png" width="200"/> | <img src="https://gitea.com/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/002.png" alt="002.png" width="200"/> | <img src="https://gitea.com/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/003.png" alt="003.png" width="200"/> | <img src="https://gitea.com/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/004.png" alt="004.png" width="200"/>
|
||||
<img src="https://codeberg.org/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/001.png" alt="001.png" width="200"/> | <img src="https://codeberg.org/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/002.png" alt="002.png" width="200"/> | <img src="https://codeberg.org/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/003.png" alt="003.png" width="200"/> | <img src="https://codeberg.org/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/004.png" alt="004.png" width="200"/>
|
||||
---|---|---|---
|
||||
<img src="https://gitea.com/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/005.png" alt="005.png" width="200"/> | <img src="https://gitea.com/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/006.png" alt="006.png" width="200"/> | <img src="https://gitea.com/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/007.png" alt="007.png" width="200"/> | <img src="https://gitea.com/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/008.png" alt="008.png" width="200"/>
|
||||
<img src="https://codeberg.org/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/005.png" alt="005.png" width="200"/> | <img src="https://codeberg.org/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/006.png" alt="006.png" width="200"/> | <img src="https://codeberg.org/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/007.png" alt="007.png" width="200"/> | <img src="https://codeberg.org/gitnex/GitNex/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/008.png" alt="008.png" width="200"/>
|
||||
|
||||
|
||||
## FAQ
|
||||
[Faq](https://gitea.com/gitnex/GitNex/wiki/FAQ)
|
||||
[Faq](https://codeberg.org/gitnex/GitNex/wiki/FAQ)
|
||||
|
||||
## Links
|
||||
[Website](https://gitnex.com)
|
||||
|
||||
[Wiki](https://gitea.com/gitnex/GitNex/wiki/Home)
|
||||
[Wiki](https://codeberg.org/gitnex/GitNex/wiki/Home)
|
||||
|
||||
[Website Repository](https://gitlab.com/mmarif4u/gitnex-website)
|
||||
|
||||
[Troubleshoot Guide](https://gitea.com/gitnex/GitNex/wiki/Troubleshoot-Guide)
|
||||
[Troubleshoot Guide](https://codeberg.org/gitnex/GitNex/wiki/Troubleshoot-Guide)
|
||||
|
||||
## Thanks
|
||||
Thanks to all the open source libraries, contributors and donators.
|
||||
|
||||
Open source libraries
|
||||
#### Open source libraries
|
||||
- Retrofit
|
||||
- Gson
|
||||
- Okhttp
|
||||
@ -87,5 +88,7 @@ Open source libraries
|
||||
- Droidsonroids.gif/android-gif-drawable
|
||||
- Barteksc/AndroidPdfViewer
|
||||
- Ge0rg/MemorizingTrustManager
|
||||
- Dimezis/BlurView
|
||||
- mikaelhg/urlbuilder
|
||||
|
||||
[Follow me on Fediverse - mastodon.social/@mmarif](https://mastodon.social/@mmarif)
|
||||
|
@ -6,12 +6,12 @@ android {
|
||||
applicationId "org.mian.gitnex"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 295
|
||||
versionName "3.0.0-rc1"
|
||||
versionCode 301
|
||||
versionName "3.0.1"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
viewBinding {
|
||||
enabled = true
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
@ -36,27 +36,29 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def lifecycle_version = "2.2.0"
|
||||
def markwon_version = '4.3.1'
|
||||
def lifecycle_version = "2.3.0-alpha05"
|
||||
def markwon_version = "4.4.0"
|
||||
def work_version = "2.4.0"
|
||||
def acra = "5.5.0"
|
||||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation "androidx.appcompat:appcompat:1.2.0-rc01"
|
||||
implementation "com.google.android.material:material:1.2.0-beta01"
|
||||
implementation "androidx.appcompat:appcompat:1.3.0-alpha01"
|
||||
implementation "com.google.android.material:material:1.3.0-alpha01"
|
||||
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
|
||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||
testImplementation "junit:junit:4.13"
|
||||
androidTestImplementation "androidx.test:runner:1.2.0"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
|
||||
implementation "com.github.vihtarb:tooltip:0.2.0"
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.7.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.8.0'
|
||||
implementation "com.google.code.gson:gson:2.8.6"
|
||||
implementation "com.squareup.picasso:picasso:2.71828"
|
||||
implementation "com.amulyakhare:com.amulyakhare.textdrawable:1.0.1"
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.8.1'
|
||||
implementation 'com.squareup.retrofit2:converter-scalars:2.8.1'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.7.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.8.0'
|
||||
implementation 'org.ocpsoft.prettytime:prettytime:4.0.5.Final'
|
||||
implementation "com.vdurmont:emoji-java:5.1.1"
|
||||
implementation "com.pes.materialcolorpicker:library:1.2.5"
|
||||
@ -77,14 +79,18 @@ dependencies {
|
||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.19"
|
||||
implementation "com.hendraanggrian.appcompat:socialview:0.2"
|
||||
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
||||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
||||
implementation "commons-io:commons-io:20030203.000550"
|
||||
implementation "org.apache.commons:commons-lang3:3.10"
|
||||
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
||||
implementation "com.github.barteksc:android-pdf-viewer:3.2.0-beta.1"
|
||||
implementation "ch.acra:acra-mail:$acra"
|
||||
implementation "ch.acra:acra-limiter:$acra"
|
||||
implementation "ch.acra:acra-notification:$acra"
|
||||
implementation "androidx.room:room-runtime:2.2.5"
|
||||
annotationProcessor "androidx.room:room-compiler:2.2.5"
|
||||
implementation "androidx.work:work-runtime:$work_version"
|
||||
implementation "com.eightbitlab:blurview:1.6.3"
|
||||
implementation "io.mikael:urlbuilder:2.0.9"
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
package="org.mian.gitnex">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
@ -11,9 +12,11 @@
|
||||
android:icon="@mipmap/app_logo"
|
||||
android:label="@string/app_name"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:resizeableActivity="true"
|
||||
android:roundIcon="@mipmap/app_logo_round"
|
||||
android:supportsRtl="true"
|
||||
tools:targetApi="n">
|
||||
|
||||
<activity android:name=".activities.MergePullRequestActivity" />
|
||||
<activity
|
||||
android:name=".activities.FileViewActivity"
|
||||
@ -58,7 +61,7 @@
|
||||
android:name=".activities.RepoDetailActivity"
|
||||
android:label="@string/title_activity_repo_detail"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity android:name=".activities.MainActivity" android:theme="@android:style/Theme.NoTitleBar">
|
||||
<activity android:name=".activities.MainActivity" android:theme="@android:style/Theme.NoTitleBar" android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@ -80,6 +83,13 @@
|
||||
<activity android:name=".activities.SettingsTranslationActivity" />
|
||||
<activity android:name=".activities.SettingsReportsActivity" />
|
||||
<activity android:name=".activities.AddNewTeamMemberActivity" />
|
||||
<activity android:name=".activities.SettingsDraftsActivity" />
|
||||
|
||||
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
|
||||
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
|
||||
<!-- Version >= 3.0. DeX Dual Mode support -->
|
||||
<meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
@ -2,16 +2,16 @@ package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.AddCollaboratorToRepositoryActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.Permission;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import androidx.annotation.NonNull;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
@ -9,10 +9,10 @@ import org.mian.gitnex.activities.ReplyToIssueActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.IssueComments;
|
||||
import org.mian.gitnex.models.UpdateIssueState;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -203,7 +203,7 @@ public class IssueActions {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.info(ctx, ctx.getString(R.string.subscribtionError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.subscriptionError));
|
||||
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ public class IssueActions {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.info(ctx, ctx.getString(R.string.unsubscribtionError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.unsubscriptionError));
|
||||
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ public class IssueActions {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.info(ctx, ctx.getString(R.string.unsubscribtionError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.unsubscriptionError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Milestones;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
@ -0,0 +1,59 @@
|
||||
package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.NotificationThread;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
|
||||
/**
|
||||
* Author opyale
|
||||
*/
|
||||
|
||||
public class NotificationsActions {
|
||||
|
||||
public enum NotificationStatus {READ, UNREAD, PINNED}
|
||||
|
||||
private TinyDB tinyDB;
|
||||
private Context context;
|
||||
private String instanceUrl;
|
||||
private String instanceToken;
|
||||
|
||||
public NotificationsActions(Context context) {
|
||||
|
||||
this.context = context;
|
||||
this.tinyDB = new TinyDB(context);
|
||||
|
||||
String loginUid = tinyDB.getString("loginUid");
|
||||
|
||||
instanceUrl = tinyDB.getString("instanceUrl");
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
}
|
||||
|
||||
public void setNotificationStatus(NotificationThread notificationThread, NotificationStatus notificationStatus) throws IOException {
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface()
|
||||
.markNotificationThreadAsRead(instanceToken, notificationThread.getId(), notificationStatus.name());
|
||||
|
||||
if(!call.execute().isSuccessful()) {
|
||||
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setAllNotificationsRead(Date date) throws IOException {
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface()
|
||||
.markNotificationThreadsAsRead(instanceToken, AppUtil.getTimestampFromDate(context, date), true,
|
||||
new String[]{"unread", "pinned"}, "read");
|
||||
|
||||
return call.execute().isSuccessful();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -8,8 +8,8 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
@ -8,8 +8,8 @@ import org.mian.gitnex.activities.AddNewTeamMemberActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
@ -1,30 +1,29 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserSearchAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.models.UserSearch;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.models.UserSearch;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
|
@ -18,9 +18,9 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserSearchForTeamMemberAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.models.UserSearch;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -96,7 +96,7 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
if(!addNewTeamMember.getText().toString().equals("")) {
|
||||
if(!addNewTeamMember.getText().toString().equals("") && addNewTeamMember.getText().toString().length() > 1) {
|
||||
|
||||
adapter = new UserSearchForTeamMemberAdapter(dataList, ctx, Integer.parseInt(teamId));
|
||||
loadUserSearchList(instanceUrl, instanceToken, addNewTeamMember.getText().toString(), loginUid, teamId);
|
||||
|
@ -1,23 +1,23 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.MultiSelectDialog;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import org.mian.gitnex.models.MultiSelectModel;
|
||||
import org.mian.gitnex.models.UpdateIssueAssignees;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -139,7 +139,7 @@ public class AddRemoveAssigneesActivity extends BaseActivity {
|
||||
.multiSelectList(listOfCollaborators)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
Log.i("selectedNames", String.valueOf(selectedNames));
|
||||
|
||||
@ -167,7 +167,7 @@ public class AddRemoveAssigneesActivity extends BaseActivity {
|
||||
.multiSelectList(listOfCollaborators)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
updateIssueAssignees(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, loginUid, issueIndex, selectedNames);
|
||||
tinyDb.putBoolean("singleIssueUpdate", true);
|
||||
|
@ -1,25 +1,25 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.MultiSelectDialog;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Labels;
|
||||
import org.mian.gitnex.models.MultiSelectModel;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -128,7 +128,7 @@ public class AddRemoveLabelsActivity extends BaseActivity {
|
||||
.multiSelectList(listOfLabels)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
String labelIds = selectedIds.toString();
|
||||
int[] integers;
|
||||
@ -169,7 +169,7 @@ public class AddRemoveLabelsActivity extends BaseActivity {
|
||||
.multiSelectList(listOfLabels)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
String labelIds = selectedIds.toString();
|
||||
int[] integers;
|
||||
|
@ -1,13 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@ -19,16 +11,20 @@ import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.AdminGetUsersAdapter;
|
||||
import org.mian.gitnex.fragments.BottomSheetAdminUsersFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -79,18 +75,12 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
||||
DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
AdminGetUsersViewModel.loadUsersList(ctx, instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken));
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
AdminGetUsersViewModel.loadUsersList(ctx, instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken));
|
||||
|
||||
}, 500));
|
||||
|
||||
fetchDataAsync(ctx, instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken));
|
||||
|
||||
@ -98,25 +88,24 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
||||
|
||||
private void fetchDataAsync(Context ctx, String instanceUrl, String instanceToken) {
|
||||
|
||||
AdminGetUsersViewModel usersModel = ViewModelProviders.of(this).get(AdminGetUsersViewModel.class);
|
||||
AdminGetUsersViewModel usersModel = new ViewModelProvider(this).get(AdminGetUsersViewModel.class);
|
||||
|
||||
usersModel.getUsersList(ctx, instanceUrl, instanceToken).observe(this, new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> usersListMain) {
|
||||
adapter = new AdminGetUsersAdapter(ctx, usersListMain);
|
||||
if(adapter.getItemCount() > 0) {
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noDataUsers.setVisibility(View.GONE);
|
||||
searchFilter = true;
|
||||
}
|
||||
else {
|
||||
//adapter.notifyDataSetChanged();
|
||||
//mRecyclerView.setAdapter(adapter);
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
noDataUsers.setVisibility(View.VISIBLE);
|
||||
}
|
||||
usersModel.getUsersList(ctx, instanceUrl, instanceToken).observe(this, usersListMain -> {
|
||||
|
||||
adapter = new AdminGetUsersAdapter(ctx, usersListMain);
|
||||
if(adapter.getItemCount() > 0) {
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noDataUsers.setVisibility(View.GONE);
|
||||
searchFilter = true;
|
||||
}
|
||||
else {
|
||||
//adapter.notifyDataSetChanged();
|
||||
//mRecyclerView.setAdapter(adapter);
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
noDataUsers.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@ -127,37 +116,36 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
||||
final MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(searchFilter) {
|
||||
new Handler().postDelayed(() -> {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
if(searchFilter) {
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) { return true; }
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
adapter.getFilter().filter(newText);
|
||||
return false;
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
adapter.getFilter().filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}, 500);
|
||||
|
||||
return true;
|
||||
@ -194,12 +182,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import org.acra.ACRA;
|
||||
@ -10,10 +11,11 @@ import org.acra.config.LimiterConfigurationBuilder;
|
||||
import org.acra.config.MailSenderConfigurationBuilder;
|
||||
import org.acra.data.StringFormat;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FontsOverride;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.notifications.NotificationsMaster;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -26,10 +28,13 @@ import org.mian.gitnex.util.TinyDB;
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
private Context appCtx;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
appCtx = getApplicationContext();
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
switch(tinyDb.getInt("themeId")) {
|
||||
|
||||
@ -83,11 +88,17 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
// enabling counter badges by default
|
||||
if(tinyDb.getString("enableCounterBadgesInit").isEmpty()) {
|
||||
tinyDb.putBoolean("enableCounterBadges", true);
|
||||
tinyDb.putString("enableCounterBadgesInit", "yes");
|
||||
}
|
||||
if(tinyDb.getInt("pollingDelayMinutes") == 0) {
|
||||
tinyDb.putInt("pollingDelayMinutes", 15);
|
||||
}
|
||||
|
||||
NotificationsMaster.hireWorker(appCtx);
|
||||
|
||||
// enabling counter badges by default
|
||||
if(tinyDb.getString("enableCounterBadgesInit").isEmpty()) {
|
||||
tinyDb.putBoolean("enableCounterBadges", true);
|
||||
tinyDb.putString("enableCounterBadgesInit", "yes");
|
||||
}
|
||||
|
||||
// enable crash reports by default
|
||||
if(tinyDb.getString("crashReportingEnabledInit").isEmpty()) {
|
||||
@ -103,6 +114,17 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
tinyDb.putString("cacheSizeImagesStr", getResources().getString(R.string.cacheSizeImagesSelectionSelectedText));
|
||||
}
|
||||
|
||||
// enable comment drafts by default
|
||||
if(tinyDb.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
|
||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
|
||||
tinyDb.putString("draftsCommentsDeletionEnabledInit", "yes");
|
||||
}
|
||||
|
||||
if(!tinyDb.getString("instanceUrlWithProtocol").endsWith("/")) {
|
||||
|
||||
tinyDb.putString("instanceUrlWithProtocol", tinyDb.getString("instanceUrlWithProtocol") + "/");
|
||||
}
|
||||
|
||||
if (tinyDb.getBoolean("crashReportingEnabled")) {
|
||||
|
||||
CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
|
||||
|
@ -23,11 +23,10 @@ import org.mian.gitnex.adapters.CommitsAdapter;
|
||||
import org.mian.gitnex.clients.AppApiService;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.interfaces.ApiInterface;
|
||||
import org.mian.gitnex.models.Commits;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -102,7 +101,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName);
|
||||
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
|
||||
}, 200));
|
||||
@ -113,7 +112,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
if(commitsList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (commitsList.size() + resultLimit) / resultLimit;
|
||||
loadMore(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, branchName);
|
||||
loadMore(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, branchName, resultLimit);
|
||||
|
||||
}
|
||||
|
||||
@ -124,13 +123,13 @@ public class CommitsActivity extends BaseActivity {
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
api = AppApiService.createService(ApiInterface.class, instanceUrl, ctx);
|
||||
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName);
|
||||
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName, resultLimit);
|
||||
|
||||
}
|
||||
|
||||
private void loadInitial(String token, String repoOwner, String repoName, String branchName) {
|
||||
private void loadInitial(String token, String repoOwner, String repoName, String branchName, int resultLimit) {
|
||||
|
||||
Call<List<Commits>> call = api.getRepositoryCommits(token, repoOwner, repoName, 1, branchName);
|
||||
Call<List<Commits>> call = api.getRepositoryCommits(token, repoOwner, repoName, 1, branchName, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Commits>>() {
|
||||
|
||||
@ -175,13 +174,13 @@ public class CommitsActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void loadMore(String token, String repoOwner, String repoName, final int page, String branchName) {
|
||||
private void loadMore(String token, String repoOwner, String repoName, final int page, String branchName, int resultLimit) {
|
||||
|
||||
//add loading progress view
|
||||
commitsList.add(new Commits("load"));
|
||||
adapter.notifyItemInserted((commitsList.size() - 1));
|
||||
|
||||
Call<List<Commits>> call = api.getRepositoryCommits(token, repoOwner, repoName, page, branchName);
|
||||
Call<List<Commits>> call = api.getRepositoryCommits(token, repoOwner, repoName, page, branchName, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Commits>>() {
|
||||
|
||||
@ -204,7 +203,6 @@ public class CommitsActivity extends BaseActivity {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.info(ctx, getString(R.string.noMoreData));
|
||||
adapter.setMoreDataAvailable(false);
|
||||
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.NewFile;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -61,7 +61,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -146,7 +146,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
private void processNewFile() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
@ -1,9 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
@ -19,6 +15,7 @@ import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.hendraanggrian.appcompat.socialview.Mention;
|
||||
import com.hendraanggrian.appcompat.widget.MentionArrayAdapter;
|
||||
@ -26,22 +23,25 @@ import com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.MultiSelectDialog;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.CreateIssue;
|
||||
import org.mian.gitnex.models.Labels;
|
||||
import org.mian.gitnex.models.Milestones;
|
||||
import org.mian.gitnex.models.MultiSelectModel;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -82,7 +82,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -153,7 +153,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
|
||||
private void processNewIssue() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
@ -444,7 +444,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
.multiSelectList(listOfAssignees)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
assigneesList.setText(dataString);
|
||||
|
||||
@ -507,7 +507,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
.multiSelectList(listOfLabels)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
newIssueLabels.setText(dataString.trim());
|
||||
labelsIdHolder.setText(selectedIds.toString());
|
||||
|
@ -1,10 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
@ -16,19 +11,24 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
|
||||
import com.pes.androidmaterialcolorpickerdialog.ColorPickerCallback;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.CreateLabel;
|
||||
import org.mian.gitnex.models.Labels;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -73,7 +73,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
colorPicker = findViewById(R.id.colorPicker);
|
||||
@ -154,7 +154,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
private void processUpdateLabel() {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
@ -202,7 +202,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
private void processCreateLabel() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
@ -446,4 +446,4 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
@ -14,16 +11,19 @@ import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Milestones;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.Calendar;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -50,7 +50,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -92,7 +92,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
private void processNewMilestone() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
|
@ -1,8 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
@ -13,14 +10,17 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -48,7 +48,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -80,7 +80,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
|
||||
private void processCreateNewUser() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
@ -3,21 +3,21 @@ package org.mian.gitnex.activities;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserOrganizations;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -47,7 +47,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -97,7 +97,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
|
||||
private void processNewOrganization() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
@ -1,8 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
@ -17,17 +14,20 @@ import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.Releases;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -60,7 +60,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -125,7 +125,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
private void processNewRelease() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
@ -4,7 +4,6 @@ import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
@ -15,15 +14,16 @@ import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.OrgOwner;
|
||||
import org.mian.gitnex.models.OrganizationRepository;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -64,7 +64,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
@ -124,7 +124,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
private void processNewRepo() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
@ -1,30 +1,30 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Teams;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import android.util.Log;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -78,7 +78,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -256,7 +256,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final String orgName = tinyDb.getString("orgName");;
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
String newTeamName = teamName.getText().toString();
|
||||
String newTeamDesc = teamDesc.getText().toString();
|
||||
String newTeamPermission = teamPermission.getText().toString().toLowerCase();
|
||||
|
@ -1,9 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
@ -20,6 +16,7 @@ import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.hendraanggrian.appcompat.socialview.Mention;
|
||||
import com.hendraanggrian.appcompat.widget.MentionArrayAdapter;
|
||||
@ -27,21 +24,24 @@ import com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.CreateIssue;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import org.mian.gitnex.models.Milestones;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -121,7 +121,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
if(!tinyDb.getString("issueNumber").isEmpty()) {
|
||||
|
||||
if(tinyDb.getString("issueType").equals("pr")) {
|
||||
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
toolbar_title.setText(getString(R.string.editPrNavHeader, String.valueOf(issueIndex)));
|
||||
}
|
||||
else {
|
||||
@ -196,7 +196,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
private void processEditIssue() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
@ -266,7 +266,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
if(tinyDb.getString("issueType").equals("pr")) {
|
||||
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
Toasty.info(ctx, getString(R.string.editPrSuccessMessage));
|
||||
}
|
||||
else {
|
||||
|
@ -10,17 +10,17 @@ import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.FilesDiffAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ParseDiff;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.FileDiffView;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
@ -32,191 +32,150 @@ import retrofit2.Callback;
|
||||
|
||||
public class FileDiffActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView toolbar_title;
|
||||
private ListView mListView;
|
||||
private ProgressBar mProgressBar;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView toolbarTitle;
|
||||
private ListView mListView;
|
||||
private ProgressBar mProgressBar;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_file_diff;
|
||||
}
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
return R.layout.activity_file_diff;
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
toolbar_title = findViewById(R.id.toolbar_title);
|
||||
mListView = findViewById(R.id.listView);
|
||||
mProgressBar = findViewById(R.id.progress_bar);
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
mListView.setDivider(null);
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
toolbarTitle = findViewById(R.id.toolbar_title);
|
||||
mListView = findViewById(R.id.listView);
|
||||
mProgressBar = findViewById(R.id.progress_bar);
|
||||
|
||||
toolbar_title.setText(R.string.processingText);
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
mListView.setDivider(null);
|
||||
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
toolbarTitle.setText(R.string.processingText);
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
String pullIndex = tinyDb.getString("issueNumber");
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
getPullDiffContent(tinyDb.getString("instanceUrlWithProtocol"), repoOwner, repoName, pullIndex);
|
||||
String pullIndex = tinyDb.getString("issueNumber");
|
||||
|
||||
}
|
||||
boolean apiCall = true;
|
||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
||||
private void getPullDiffContent(String instanceUrl, String owner, String repo, String filename) {
|
||||
// fallback for old gitea instances
|
||||
if(new Version(tinyDb.getString("giteaVersion")).less("1.13.0")) {
|
||||
apiCall = false;
|
||||
instanceUrl = tinyDb.getString("instanceUrlWithProtocol");
|
||||
}
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getWebInterface()
|
||||
.getPullDiffContent(owner, repo, filename);
|
||||
getPullDiffContent(instanceUrl, repoOwner, repoName, pullIndex, instanceToken, apiCall);
|
||||
|
||||
call.enqueue(new Callback<ResponseBody>() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull retrofit2.Response<ResponseBody> response) {
|
||||
private void getPullDiffContent(String instanceUrl, String owner, String repo, String pullIndex, String token, boolean apiCall) {
|
||||
|
||||
if (response.code() == 200) {
|
||||
Call<ResponseBody> call;
|
||||
if(apiCall) {
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getPullDiffContent(token, owner, repo, pullIndex);
|
||||
}
|
||||
else {
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getWebInterface().getPullDiffContent(owner, repo, pullIndex);
|
||||
}
|
||||
|
||||
try {
|
||||
assert response.body() != null;
|
||||
call.enqueue(new Callback<ResponseBody>() {
|
||||
|
||||
AppUtil appUtil = new AppUtil();
|
||||
List<FileDiffView> fileContentsArray = new ArrayList<>();
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull retrofit2.Response<ResponseBody> response) {
|
||||
|
||||
String[] lines = response.body().string().split("diff");
|
||||
if(response.code() == 200) {
|
||||
|
||||
if(lines.length > 0) {
|
||||
try {
|
||||
assert response.body() != null;
|
||||
|
||||
for (int i = 1; i < lines.length; i++) {
|
||||
AppUtil appUtil = new AppUtil();
|
||||
List<FileDiffView> fileContentsArray = ParseDiff.getFileDiffViewArray(response.body().string());
|
||||
|
||||
if(lines[i].contains("@@ -")) {
|
||||
int filesCount = fileContentsArray.size();
|
||||
if(filesCount > 1) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.fileDiffViewHeader, Integer.toString(filesCount)));
|
||||
}
|
||||
else {
|
||||
toolbarTitle.setText(getResources().getString(R.string.fileDiffViewHeaderSingle, Integer.toString(filesCount)));
|
||||
}
|
||||
|
||||
String[] level2nd = lines[i].split("@@ -"); // main content part of single diff view
|
||||
FilesDiffAdapter adapter = new FilesDiffAdapter(ctx, fileContentsArray);
|
||||
mListView.setAdapter(adapter);
|
||||
|
||||
String[] fileName_ = level2nd[0].split("\\+\\+\\+ b/"); // filename part
|
||||
String fileNameFinal = fileName_[1];
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
|
||||
String[] fileContents_ = level2nd[1].split("@@"); // file info / content part
|
||||
String fileInfoFinal = fileContents_[0];
|
||||
StringBuilder fileContentsFinal = new StringBuilder(fileContents_[1]);
|
||||
}
|
||||
catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(level2nd.length > 2) {
|
||||
for (int j = 2; j < level2nd.length; j++) {
|
||||
fileContentsFinal.append(level2nd[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
String fileExtension = FileUtils.getExtension(fileNameFinal);
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
|
||||
String fileContentsFinalWithBlankLines = fileContentsFinal.toString().replaceAll( ".*@@.*", "" );
|
||||
String fileContentsFinalWithoutBlankLines = fileContentsFinal.toString().replaceAll( ".*@@.*(\r?\n|\r)?", "" );
|
||||
fileContentsFinalWithoutBlankLines = fileContentsFinalWithoutBlankLines.replaceAll( ".*\\ No newline at end of file.*(\r?\n|\r)?", "" );
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
fileContentsArray.add(new FileDiffView(fileNameFinal, appUtil.imageExtension(fileExtension), fileInfoFinal, fileContentsFinalWithoutBlankLines));
|
||||
}
|
||||
else {
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
String[] getFileName = lines[i].split("--git a/");
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
String[] getFileName_ = getFileName[1].split("b/");
|
||||
String getFileNameFinal = getFileName_[0].trim();
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
String[] binaryFile = getFileName_[1].split("GIT binary patch");
|
||||
String binaryFileRaw = binaryFile[1].substring(binaryFile[1].indexOf('\n')+1);
|
||||
String binaryFileFinal = binaryFile[1].substring(binaryFileRaw.indexOf('\n')+1);
|
||||
}
|
||||
else {
|
||||
|
||||
String fileExtension = FileUtils.getExtension(getFileNameFinal);
|
||||
Toasty.info(ctx, getString(R.string.labelGeneralError));
|
||||
|
||||
if(appUtil.imageExtension(FileUtils.getExtension(getFileNameFinal))) {
|
||||
}
|
||||
|
||||
fileContentsArray.add(new FileDiffView(getFileNameFinal, appUtil.imageExtension(fileExtension), "", binaryFileFinal));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int filesCount = fileContentsArray.size();
|
||||
if(filesCount > 1) {
|
||||
toolbar_title.setText(getResources().getString(R.string.fileDiffViewHeader, Integer.toString(filesCount)));
|
||||
}
|
||||
else {
|
||||
toolbar_title.setText(getResources().getString(R.string.fileDiffViewHeaderSingle, Integer.toString(filesCount)));
|
||||
}
|
||||
private void initCloseListener() {
|
||||
|
||||
FilesDiffAdapter adapter = new FilesDiffAdapter(ctx, fileContentsArray);
|
||||
mListView.setAdapter(adapter);
|
||||
onClickListener = new View.OnClickListener() {
|
||||
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.info(ctx, getString(R.string.labelGeneralError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
getIntent().removeExtra("singleFileName");
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
getIntent().removeExtra("singleFileName");
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -31,12 +31,12 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetFileViewerFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.highlightjs.HighlightJsView;
|
||||
import org.mian.gitnex.helpers.highlightjs.models.Theme;
|
||||
import org.mian.gitnex.models.Files;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -83,6 +83,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoBranch = tinyDb.getString("repoBranch");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
@ -125,15 +126,15 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
toolbar_title.setText(singleFileName);
|
||||
|
||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName);
|
||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||
|
||||
}
|
||||
|
||||
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename) {
|
||||
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename, String ref) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
Call<Files> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getSingleFileContents(token, owner, repo, filename);
|
||||
Call<Files> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getSingleFileContents(token, owner, repo, filename, ref);
|
||||
|
||||
call.enqueue(new Callback<Files>() {
|
||||
|
||||
@ -378,4 +379,4 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,7 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@ -41,24 +39,23 @@ import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetSingleIssueFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.UserMentions;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.IssueComments;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.IssueCommentsViewModel;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
@ -191,7 +188,9 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, ctx);
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
|
||||
}, 500));
|
||||
|
||||
@ -265,7 +264,9 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
if(tinyDb.getBoolean("commentPosted")) {
|
||||
scrollViewComments.post(() -> {
|
||||
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, ctx);
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
|
||||
new Handler().postDelayed(() -> scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN), 1000);
|
||||
|
||||
@ -277,7 +278,9 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
if(tinyDb.getBoolean("commentEdited")) {
|
||||
scrollViewComments.post(() -> {
|
||||
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, ctx);
|
||||
IssueCommentsViewModel
|
||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
tinyDb.putBoolean("commentEdited", false);
|
||||
|
||||
});
|
||||
@ -315,12 +318,11 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
|
||||
IssueCommentsViewModel issueCommentsModel = new ViewModelProvider(this).get(IssueCommentsViewModel.class);
|
||||
|
||||
issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), owner, repo, index, ctx).observe(this, new Observer<List<IssueComments>>() {
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nullable List<IssueComments> issueCommentsMain) {
|
||||
issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), owner, repo, index, ctx)
|
||||
.observe(this, issueCommentsMain -> {
|
||||
|
||||
assert issueCommentsMain != null;
|
||||
|
||||
if(issueCommentsMain.size() > 0) {
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -328,15 +330,15 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
adapter = new IssueCommentsAdapter(ctx, issueCommentsMain);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void getSingleIssue(String instanceUrl, String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
Call<Issues> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
Call<Issues> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
||||
.getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
|
||||
@ -348,43 +350,47 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
Issues singleIssue = response.body();
|
||||
assert singleIssue != null;
|
||||
|
||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create()).usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create())
|
||||
.usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
|
||||
final int resourceId = ctx.getResources()
|
||||
.getIdentifier(raw.substring("drawable://".length()), "drawable", ctx.getPackageName());
|
||||
|
||||
final Drawable drawable = ctx.getDrawable(resourceId);
|
||||
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(ctx.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(ctx.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
|
||||
})).usePlugin(new AbstractMarkwonPlugin() {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
|
||||
final int resourceId = ctx.getResources().getIdentifier(raw.substring("drawable://".length()), "drawable", ctx.getPackageName());
|
||||
|
||||
final Drawable drawable = ctx.getDrawable(resourceId);
|
||||
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
builder.codeTextColor(tinyDb.getInt("codeBlockColor")).codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
|
||||
.linkColor(getResources().getColor(R.color.lightBlue));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(ctx.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(ctx.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
|
||||
})).usePlugin(new AbstractMarkwonPlugin() {
|
||||
|
||||
@Override
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
|
||||
builder.codeTextColor(tinyDb.getInt("codeBlockColor")).codeBackgroundColor(tinyDb.getInt("codeBlockBackground")).linkColor(getResources().getColor(R.color.lightBlue));
|
||||
}
|
||||
}).usePlugin(TablePlugin.create(ctx)).usePlugin(TaskListPlugin.create(ctx)).usePlugin(HtmlPlugin.create()).usePlugin(StrikethroughPlugin.create()).usePlugin(LinkifyPlugin.create()).build();
|
||||
}).usePlugin(TablePlugin.create(ctx)).usePlugin(TaskListPlugin.create(ctx)).usePlugin(HtmlPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create()).usePlugin(LinkifyPlugin.create()).build();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
@ -392,8 +398,10 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
tinyDb.putString("issueState", singleIssue.getState());
|
||||
tinyDb.putString("issueTitle", singleIssue.getTitle());
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(singleIssue.getUser().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + appCtx.getResources().getColor(R.color.lightGray) + "'>" + appCtx.getResources().getString(R.string.hash) + singleIssue.getNumber() + "</font>";
|
||||
PicassoService.getInstance(ctx).get().load(singleIssue.getUser().getAvatar_url()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + appCtx.getResources().getColor(R.color.lightGray) + "'>" + appCtx.getResources()
|
||||
.getString(R.string.hash) + singleIssue.getNumber() + "</font>";
|
||||
issueTitle.setText(Html.fromHtml(issueNumber_ + " " + singleIssue.getTitle()));
|
||||
String cleanIssueDescription = singleIssue.getBody().trim();
|
||||
Spanned bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(cleanIssueDescription));
|
||||
@ -410,15 +418,19 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
|
||||
ImageView assigneesView = new ImageView(ctx);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(singleIssue.getAssignees().get(i).getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(100, 100).centerCrop().into(assigneesView);
|
||||
PicassoService.getInstance(ctx).get().load(singleIssue.getAssignees().get(i).getAvatar_url())
|
||||
.placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(100, 100).centerCrop()
|
||||
.into(assigneesView);
|
||||
|
||||
assigneesLayout.addView(assigneesView);
|
||||
assigneesView.setLayoutParams(params1);
|
||||
if(!singleIssue.getAssignees().get(i).getFull_name().equals("")) {
|
||||
assigneesView.setOnClickListener(new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getFull_name()), ctx));
|
||||
assigneesView.setOnClickListener(
|
||||
new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getFull_name()), ctx));
|
||||
}
|
||||
else {
|
||||
assigneesView.setOnClickListener(new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getLogin()), ctx));
|
||||
assigneesView.setOnClickListener(
|
||||
new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getLogin()), ctx));
|
||||
}
|
||||
|
||||
}
|
||||
@ -427,12 +439,13 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
assigneesScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(singleIssue.getLabels() != null) {
|
||||
labelsScrollView.setVisibility(View.VISIBLE);
|
||||
int width = 25;
|
||||
|
||||
for(int i = 0; i < singleIssue.getLabels().size(); i++) {
|
||||
|
||||
String labelColor = singleIssue.getLabels().get(i).getColor();
|
||||
@ -444,9 +457,15 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
labelsLayout.setGravity(Gravity.START | Gravity.TOP);
|
||||
labelsView.setLayoutParams(params);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(30).width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, 30, 15)).height(50).endConfig().buildRoundRect(labelName, color, 10);
|
||||
labelsView.setImageDrawable(drawable);
|
||||
int height = AppUtil.getPixelsFromDensity(ctx, 25);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(ctx, 15);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT)
|
||||
.textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(ctx, 10)))
|
||||
.height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 5));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
labelsLayout.addView(labelsView);
|
||||
|
||||
}
|
||||
@ -461,7 +480,8 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
|
||||
String dueDate = formatter.format(singleIssue.getDue_date());
|
||||
issueDueDate.setText(dueDate);
|
||||
issueDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getDue_date()), ctx));
|
||||
issueDueDate
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getDue_date()), ctx));
|
||||
}
|
||||
else if(timeFormat.equals("normal1")) {
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale));
|
||||
@ -481,7 +501,8 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
|
||||
issueModified.setVisibility(View.VISIBLE);
|
||||
issueModified.setText(edited);
|
||||
issueModified.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getUpdated_at()), ctx));
|
||||
issueModified
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getUpdated_at()), ctx));
|
||||
}
|
||||
else {
|
||||
issueModified.setVisibility(View.INVISIBLE);
|
||||
@ -508,7 +529,8 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
issueCreatedTime.setVisibility(View.VISIBLE);
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), ctx));
|
||||
issueCreatedTime
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), ctx));
|
||||
}
|
||||
|
||||
if(singleIssue.getMilestone() != null) {
|
||||
@ -519,10 +541,12 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
if(!singleIssue.getUser().getFull_name().equals("")) {
|
||||
assigneeAvatar.setOnClickListener(new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getFull_name(), ctx));
|
||||
assigneeAvatar.setOnClickListener(
|
||||
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getFull_name(), ctx));
|
||||
}
|
||||
else {
|
||||
assigneeAvatar.setOnClickListener(new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getLogin(), ctx));
|
||||
assigneeAvatar.setOnClickListener(
|
||||
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getLogin(), ctx));
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
@ -531,7 +555,10 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), getResources().getString(R.string.alertDialogTokenRevokedMessage), getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
|
||||
}
|
||||
|
||||
@ -547,7 +574,8 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
Call<WatchInfo> call2 = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkIssueWatchStatus(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
Call<WatchInfo> call2 = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
||||
.checkIssueWatchStatus(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
call2.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,39 +12,50 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.squareup.picasso.NetworkPolicy;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.fragments.AboutFragment;
|
||||
import org.mian.gitnex.fragments.AdministrationFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetDraftsFragment;
|
||||
import org.mian.gitnex.fragments.DraftsFragment;
|
||||
import org.mian.gitnex.fragments.ExploreRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.MyRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.NotificationsFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationsFragment;
|
||||
import org.mian.gitnex.fragments.ProfileFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.SettingsFragment;
|
||||
import org.mian.gitnex.fragments.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.UserAccountsFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.ChangeLog;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.GiteaVersion;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.Objects;
|
||||
import eightbitlab.com.blurview.BlurView;
|
||||
import eightbitlab.com.blurview.RenderScriptBlur;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -52,12 +63,15 @@ import retrofit2.Callback;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener {
|
||||
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, BottomSheetDraftsFragment.BottomSheetListener {
|
||||
|
||||
private DrawerLayout drawer;
|
||||
private BlurView blurView;
|
||||
private TextView userFullName;
|
||||
private TextView userEmail;
|
||||
private ImageView userAvatar;
|
||||
private ImageView userAvatarBackground;
|
||||
private ViewGroup navHeaderFrame;
|
||||
private TextView toolbarTitle;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
@ -77,7 +91,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
tinyDb.putBoolean("noConnection", false);
|
||||
//userAvatar = findViewById(R.id.userAvatar);
|
||||
|
||||
Intent mainIntent = getIntent();
|
||||
String launchFragment = mainIntent.getStringExtra("launchFragment");
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
@ -100,13 +116,16 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
tinyDb.putInt("homeScreenId", 0);
|
||||
}
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
if(!tinyDb.getBoolean("loggedInMode")) {
|
||||
logout(this, ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
String accountName = loginUid + "@" + instanceUrl;
|
||||
getAccountData(accountName);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
|
||||
@ -131,6 +150,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
Fragment fragmentById = fm.findFragmentById(R.id.fragment_container);
|
||||
|
||||
if(fragmentById instanceof SettingsFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
|
||||
}
|
||||
@ -146,15 +166,24 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
else if(fragmentById instanceof ExploreRepositoriesFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
||||
}
|
||||
else if(fragmentById instanceof NotificationsFragment) {
|
||||
toolbarTitle.setText(R.string.pageTitleNotifications);
|
||||
}
|
||||
else if(fragmentById instanceof ProfileFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||
}
|
||||
else if(fragmentById instanceof AboutFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAbout));
|
||||
}
|
||||
else if(fragmentById instanceof DraftsFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
}
|
||||
else if(fragmentById instanceof AdministrationFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
||||
}
|
||||
else if(fragmentById instanceof UserAccountsFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
||||
}
|
||||
|
||||
drawer = findViewById(R.id.drawer_layout);
|
||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
@ -162,16 +191,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
final View hView = navigationView.getHeaderView(0);
|
||||
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
toggle.getDrawerArrowDrawable().setColor(getResources().getColor(R.color.darkGreen));
|
||||
|
||||
drawer.addDrawerListener(toggle);
|
||||
|
||||
drawer.addDrawerListener(new DrawerLayout.DrawerListener() {
|
||||
|
||||
@Override
|
||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerOpened(@NonNull View drawerView) {
|
||||
|
||||
@ -184,77 +207,162 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
String userFullNameNav = tinyDb.getString("userFullname");
|
||||
String userAvatarNav = tinyDb.getString("userAvatar");
|
||||
|
||||
blurView = hView.findViewById(R.id.blurView);
|
||||
userEmail = hView.findViewById(R.id.userEmail);
|
||||
userFullName = hView.findViewById(R.id.userFullname);
|
||||
userAvatar = hView.findViewById(R.id.userAvatar);
|
||||
userAvatarBackground = hView.findViewById(R.id.userAvatarBackground);
|
||||
navHeaderFrame = hView.findViewById(R.id.navHeaderFrame);
|
||||
|
||||
userEmail.setTypeface(myTypeface);
|
||||
userFullName.setTypeface(myTypeface);
|
||||
|
||||
String currentVersion = tinyDb.getString("giteaVersion");
|
||||
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(tinyDb.getBoolean("userIsAdmin"));
|
||||
navigationView.getMenu().findItem(R.id.nav_notifications).setVisible(new Version(currentVersion).higherOrEqual("1.12.3"));
|
||||
|
||||
if(!userEmailNav.equals("")) {
|
||||
userEmail.setText(userEmailNav);
|
||||
userEmail.setTypeface(myTypeface);
|
||||
}
|
||||
|
||||
userFullName = hView.findViewById(R.id.userFullname);
|
||||
if(!userFullNameNav.equals("")) {
|
||||
userFullName.setText(userFullNameNav);
|
||||
userFullName.setTypeface(myTypeface);
|
||||
}
|
||||
|
||||
userAvatar = hView.findViewById(R.id.userAvatar);
|
||||
if(!userAvatarNav.equals("")) {
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).networkPolicy(NetworkPolicy.OFFLINE).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(160, 160).centerCrop().into(userAvatar);
|
||||
|
||||
PicassoService.getInstance(ctx).get()
|
||||
.load(userAvatarNav)
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0))
|
||||
.resize(160, 160)
|
||||
.centerCrop().into(userAvatar);
|
||||
|
||||
PicassoService.getInstance(ctx).get()
|
||||
.load(userAvatarNav)
|
||||
.into(userAvatarBackground, new com.squareup.picasso.Callback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
int textColor = new ColorInverter().getImageViewContrastColor(userAvatarBackground);
|
||||
|
||||
userFullName.setTextColor(textColor);
|
||||
userEmail.setTextColor(textColor);
|
||||
|
||||
blurView.setupWith(navHeaderFrame)
|
||||
.setBlurAlgorithm(new RenderScriptBlur(ctx))
|
||||
.setBlurRadius(5)
|
||||
.setHasFixedTransformationMatrix(false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
userAvatar.setOnClickListener(new View.OnClickListener() {
|
||||
userAvatar.setOnClickListener(v -> {
|
||||
|
||||
public void onClick(View v) {
|
||||
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
||||
drawer.closeDrawers();
|
||||
}
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed(@NonNull View drawerView) {
|
||||
// Called when a drawer has settled in a completely closed state.
|
||||
}
|
||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {}
|
||||
|
||||
@Override
|
||||
public void onDrawerStateChanged(int newState) {
|
||||
// Called when the drawer motion state changes. The new state will be one of STATE_IDLE, STATE_DRAGGING or STATE_SETTLING.
|
||||
}
|
||||
public void onDrawerClosed(@NonNull View drawerView) {}
|
||||
|
||||
@Override
|
||||
public void onDrawerStateChanged(int newState) {}
|
||||
|
||||
});
|
||||
|
||||
ImageView userAccounts = hView.findViewById(R.id.userAccounts);
|
||||
userAccounts.setOnClickListener(v -> {
|
||||
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new UserAccountsFragment()).commit();
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
|
||||
toggle.syncState();
|
||||
toolbar.setNavigationIcon(R.drawable.ic_menu);
|
||||
|
||||
if(launchFragment != null) {
|
||||
|
||||
mainIntent.removeExtra("launchFragment");
|
||||
|
||||
switch(launchFragment) {
|
||||
|
||||
case "drafts":
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
||||
return;
|
||||
|
||||
case "notifications":
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_notifications);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(savedInstanceState == null) {
|
||||
if(tinyDb.getInt("homeScreenId") == 0) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_home);
|
||||
}
|
||||
else if(tinyDb.getInt("homeScreenId") == 1) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_starred_repos);
|
||||
}
|
||||
else if(tinyDb.getInt("homeScreenId") == 2) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_organizations);
|
||||
}
|
||||
else if(tinyDb.getInt("homeScreenId") == 3) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleRepositories));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_repositories);
|
||||
}
|
||||
else if(tinyDb.getInt("homeScreenId") == 4) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_profile);
|
||||
}
|
||||
else {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_home);
|
||||
|
||||
switch(tinyDb.getInt("homeScreenId")) {
|
||||
|
||||
case 1:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_starred_repos);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_organizations);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleRepositories));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_repositories);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_profile);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreRepositoriesFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_explore);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
||||
break;
|
||||
|
||||
default:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_home);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +377,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
else {
|
||||
|
||||
displayUserInfo(instanceUrl, instanceToken, loginUid);
|
||||
loadUserInfo(instanceUrl, instanceToken, loginUid);
|
||||
giteaVersion(instanceUrl);
|
||||
tinyDb.putBoolean("noConnection", false);
|
||||
|
||||
@ -277,25 +385,75 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
// Changelog popup
|
||||
int versionCode = 0;
|
||||
|
||||
try {
|
||||
|
||||
PackageInfo packageInfo = appCtx.getPackageManager().getPackageInfo(appCtx.getPackageName(), 0);
|
||||
versionCode = packageInfo.versionCode;
|
||||
}
|
||||
catch(PackageManager.NameNotFoundException e) {
|
||||
|
||||
Log.e("changelogDialog", Objects.requireNonNull(e.getMessage()));
|
||||
}
|
||||
|
||||
if(versionCode > tinyDb.getInt("versionCode")) {
|
||||
|
||||
tinyDb.putInt("versionCode", versionCode);
|
||||
tinyDb.putBoolean("versionFlag", true);
|
||||
|
||||
ChangeLog changelogDialog = new ChangeLog(this);
|
||||
changelogDialog.showDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public void setActionBarTitle(@NonNull String title) {
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(title);
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
|
||||
if("deleteDrafts".equals(text)) {
|
||||
|
||||
if(currentActiveAccountId > 0) {
|
||||
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
DraftsFragment frag = (DraftsFragment) fm.findFragmentById(R.id.fragment_container);
|
||||
|
||||
if(frag != null) {
|
||||
|
||||
new AlertDialog.Builder(ctx).setTitle(R.string.deleteAllDrafts).setIcon(R.drawable.ic_delete).setCancelable(false).setMessage(R.string.deleteAllDraftsDialogMessage).setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
frag.deleteAllDrafts(currentActiveAccountId);
|
||||
dialog.dismiss();
|
||||
|
||||
}).setNegativeButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).show();
|
||||
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void getAccountData(String accountName) {
|
||||
|
||||
UserAccountsApi accountData = new UserAccountsApi(ctx);
|
||||
UserAccount data = accountData.getAccountData(accountName);
|
||||
|
||||
if(data != null) {
|
||||
TinyDB tinyDb = new TinyDB(ctx.getApplicationContext());
|
||||
tinyDb.putInt("currentActiveAccountId", data.getAccountId());
|
||||
}
|
||||
else {
|
||||
AlertDialogs.forceLogoutDialog(ctx, getResources().getString(R.string.forceLogoutDialogHeader), getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -314,46 +472,66 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
|
||||
|
||||
switch(menuItem.getItemId()) {
|
||||
|
||||
case R.id.nav_home:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_organizations:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_profile:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_repositories:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleRepositories));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
|
||||
|
||||
break;
|
||||
|
||||
case R.id.nav_settings:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_logout:
|
||||
logout(this, ctx);
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
break;
|
||||
|
||||
case R.id.nav_about:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAbout));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AboutFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_rate_app:
|
||||
rateThisApp();
|
||||
break;
|
||||
|
||||
case R.id.nav_starred_repos:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_explore:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreRepositoriesFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_notifications:
|
||||
toolbarTitle.setText(R.string.pageTitleNotifications);
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_comments_draft:
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_administration:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AdministrationFragment()).commit();
|
||||
@ -387,6 +565,21 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
int id = item.getItemId();
|
||||
|
||||
if(id == R.id.genericMenu) {
|
||||
BottomSheetDraftsFragment bottomSheet = new BottomSheetDraftsFragment();
|
||||
bottomSheet.show(getSupportFragmentManager(), "draftsBottomSheet");
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
}
|
||||
|
||||
private void giteaVersion(final String instanceUrl) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
@ -408,29 +601,24 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
tinyDb.putString("giteaVersion", version.getVersion());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-version", t.toString());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void displayUserInfo(String instanceUrl, String token, String loginUid) {
|
||||
private void loadUserInfo(String instanceUrl, String token, String loginUid) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserInfo(Authorization.returnAuthentication(ctx, loginUid, token));
|
||||
|
||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
final View hView = navigationView.getHeaderView(0);
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
||||
@Override
|
||||
@ -443,12 +631,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
if(response.code() == 200) {
|
||||
|
||||
assert userDetails != null;
|
||||
|
||||
if(userDetails.getIs_admin() != null) {
|
||||
tinyDb.putBoolean("userIsAdmin", userDetails.getIs_admin());
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(userDetails.getIs_admin());
|
||||
}
|
||||
|
||||
tinyDb.putString("userLogin", userDetails.getLogin());
|
||||
tinyDb.putInt("userId", userDetails.getId());
|
||||
|
||||
if(!userDetails.getFullname().equals("")) {
|
||||
tinyDb.putString("userFullname", userDetails.getFullname());
|
||||
}
|
||||
@ -458,51 +648,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
tinyDb.putString("userEmail", userDetails.getEmail());
|
||||
tinyDb.putString("userAvatar", userDetails.getAvatar());
|
||||
|
||||
if(userDetails.getLang() != null) {
|
||||
tinyDb.putString("userLang", userDetails.getLang());
|
||||
}
|
||||
else {
|
||||
tinyDb.putString("userLang", "...");
|
||||
tinyDb.putString("userLang", "");
|
||||
}
|
||||
|
||||
userAvatar = hView.findViewById(R.id.userAvatar);
|
||||
if(!Objects.requireNonNull(userDetails).getAvatar().equals("")) {
|
||||
PicassoService.getInstance(ctx).get().load(userDetails.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(160, 160).centerCrop().into(userAvatar);
|
||||
}
|
||||
else {
|
||||
userAvatar.setImageResource(R.mipmap.app_logo_round);
|
||||
}
|
||||
|
||||
userFullName = hView.findViewById(R.id.userFullname);
|
||||
if(!userDetails.getFullname().equals("")) {
|
||||
userFullName.setText(userDetails.getFullname());
|
||||
}
|
||||
else if(!userDetails.getLogin().equals("")) {
|
||||
userFullName.setText(userDetails.getLogin());
|
||||
}
|
||||
else {
|
||||
userFullName.setText("...");
|
||||
}
|
||||
|
||||
userEmail = hView.findViewById(R.id.userEmail);
|
||||
if(!userDetails.getEmail().equals("")) {
|
||||
userEmail.setText(userDetails.getEmail());
|
||||
}
|
||||
else {
|
||||
userEmail.setText("...");
|
||||
}
|
||||
|
||||
userAvatar.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
public void onClick(View v) {
|
||||
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
||||
drawer.closeDrawers();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
@ -511,7 +664,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
else {
|
||||
|
||||
String toastError = getResources().getString(R.string.genericApiStatusError) + String.valueOf(response.code());
|
||||
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
||||
Toasty.info(ctx, toastError);
|
||||
|
||||
}
|
||||
|
@ -16,14 +16,14 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityMergePullRequestBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.MergePullRequest;
|
||||
import org.mian.gitnex.models.MergePullRequestSpinner;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import okhttp3.ResponseBody;
|
||||
@ -62,7 +62,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
View view = viewBinding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
@ -217,7 +217,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
String mergePRTitle = viewBinding.mergeTitle.getText().toString();
|
||||
boolean deleteBranch = viewBinding.deleteBranch.isChecked();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
|
@ -5,7 +5,13 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -18,20 +24,28 @@ public class OpenRepoInBrowserActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String instanceUrlWithProtocol = "https://" + tinyDb.getString("instanceUrlRaw");
|
||||
if (!tinyDb.getString("instanceUrlWithProtocol").isEmpty()) {
|
||||
instanceUrlWithProtocol = tinyDb.getString("instanceUrlWithProtocol");
|
||||
}
|
||||
try {
|
||||
|
||||
String repoFullNameBrowser = getIntent().getStringExtra("repoFullNameBrowser");
|
||||
Uri url = Uri.parse(instanceUrlWithProtocol + "/" + repoFullNameBrowser);
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, url);
|
||||
startActivity(i);
|
||||
finish();
|
||||
URI instanceUrl = new URI(tinyDb.getString("instanceUrlWithProtocol"));
|
||||
|
||||
String browserPath = PathsHelper.join(instanceUrl.getPath(), getIntent().getStringExtra("repoFullNameBrowser"));
|
||||
|
||||
String browserUrl = UrlBuilder.fromUri(instanceUrl)
|
||||
.withPath(browserPath)
|
||||
.toString();
|
||||
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(browserUrl));
|
||||
startActivity(i);
|
||||
finish();
|
||||
|
||||
}
|
||||
catch(URISyntaxException e) {
|
||||
Toasty.error(appCtx, getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -17,13 +10,20 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.fragments.MembersByOrgFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetOrganizationFragment;
|
||||
import org.mian.gitnex.fragments.MembersByOrgFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.TeamMembersByOrgAdapter;
|
||||
import org.mian.gitnex.fragments.BottomSheetOrganizationTeamsFragment;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.TeamMembersByOrgViewModel;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
@ -13,18 +10,21 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.AddEmail;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -49,7 +49,7 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -84,7 +84,7 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
|
||||
private void processAddNewEmail() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
|
@ -1,33 +1,42 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import com.hendraanggrian.appcompat.socialview.Mention;
|
||||
import com.hendraanggrian.appcompat.widget.MentionArrayAdapter;
|
||||
import com.hendraanggrian.appcompat.widget.SocialAutoCompleteTextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.IssueActions;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -35,264 +44,374 @@ import java.util.List;
|
||||
|
||||
public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
public ImageView closeActivity;
|
||||
private View.OnClickListener onClickListener;
|
||||
public ImageView closeActivity;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
private SocialAutoCompleteTextView addComment;
|
||||
private ArrayAdapter<Mention> defaultMentionAdapter;
|
||||
private Button replyButton;
|
||||
private TextView draftSaved;
|
||||
private SocialAutoCompleteTextView addComment;
|
||||
private ArrayAdapter<Mention> defaultMentionAdapter;
|
||||
private Button replyButton;
|
||||
private String TAG = StaticGlobalVariables.replyToIssueActivity;
|
||||
private long draftId;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_reply_to_issue;
|
||||
}
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_reply_to_issue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
addComment = findViewById(R.id.addComment);
|
||||
addComment.setShowSoftInputOnFocus(true);
|
||||
draftSaved = findViewById(R.id.draftSaved);
|
||||
addComment = findViewById(R.id.addComment);
|
||||
addComment.setShowSoftInputOnFocus(true);
|
||||
|
||||
defaultMentionAdapter = new MentionArrayAdapter<>(this);
|
||||
loadCollaboratorsList();
|
||||
defaultMentionAdapter = new MentionArrayAdapter<>(ctx);
|
||||
loadCollaboratorsList();
|
||||
|
||||
addComment.setMentionAdapter(defaultMentionAdapter);
|
||||
addComment.setMentionAdapter(defaultMentionAdapter);
|
||||
|
||||
closeActivity = findViewById(R.id.close);
|
||||
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
||||
closeActivity = findViewById(R.id.close);
|
||||
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
||||
|
||||
addComment.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(addComment, InputMethodManager.SHOW_IMPLICIT);
|
||||
addComment.requestFocus();
|
||||
assert imm != null;
|
||||
imm.showSoftInput(addComment, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
if(!tinyDb.getString("issueTitle").isEmpty()) {
|
||||
toolbar_title.setText(tinyDb.getString("issueTitle"));
|
||||
}
|
||||
if(!tinyDb.getString("issueTitle").isEmpty()) {
|
||||
toolbar_title.setText(tinyDb.getString("issueTitle"));
|
||||
}
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
replyButton = findViewById(R.id.replyButton);
|
||||
replyButton = findViewById(R.id.replyButton);
|
||||
|
||||
if(getIntent().getStringExtra("commentBody") != null) {
|
||||
if(getIntent().getStringExtra("commentBody") != null) {
|
||||
|
||||
addComment.setText(getIntent().getStringExtra("commentBody"));
|
||||
addComment.setText(getIntent().getStringExtra("commentBody"));
|
||||
|
||||
if(getIntent().getBooleanExtra("cursorToEnd", false)) {
|
||||
addComment.setSelection(addComment.length());
|
||||
}
|
||||
if(getIntent().getBooleanExtra("cursorToEnd", false)) {
|
||||
addComment.setSelection(addComment.length());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(getIntent().getStringExtra("commentAction") != null && getIntent().getStringExtra("commentAction").equals("edit")) {
|
||||
if(getIntent().getStringExtra("draftTitle") != null) {
|
||||
|
||||
final String commentId = getIntent().getStringExtra("commentId");
|
||||
toolbar_title.setText(getIntent().getStringExtra("draftTitle"));
|
||||
|
||||
toolbar_title.setText(getResources().getString(R.string.editCommentTitle));
|
||||
replyButton.setText(getResources().getString(R.string.editCommentButtonText));
|
||||
}
|
||||
|
||||
replyButton.setOnClickListener(v -> {
|
||||
disableProcessButton();
|
||||
IssueActions.editIssueComment(ctx, Integer.parseInt(commentId), addComment.getText().toString());
|
||||
});
|
||||
if(getIntent().getStringExtra("commentAction") != null && getIntent().getStringExtra("commentAction").equals("edit")) {
|
||||
|
||||
return;
|
||||
final String commentId = getIntent().getStringExtra("commentId");
|
||||
|
||||
}
|
||||
toolbar_title.setText(getResources().getString(R.string.editCommentTitle));
|
||||
replyButton.setText(getResources().getString(R.string.editCommentButtonText));
|
||||
|
||||
if(!connToInternet) {
|
||||
addComment.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
disableProcessButton();
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
} else {
|
||||
}
|
||||
|
||||
replyButton.setOnClickListener(replyToIssue);
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
public void loadCollaboratorsList() {
|
||||
saveDraft(addComment.getText().toString());
|
||||
draftSaved.setVisibility(View.VISIBLE);
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
}
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
});
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||
replyButton.setOnClickListener(v -> {
|
||||
|
||||
call.enqueue(new Callback<List<Collaborators>>() {
|
||||
disableProcessButton();
|
||||
assert commentId != null;
|
||||
IssueActions.editIssueComment(ctx, Integer.parseInt(commentId), addComment.getText().toString());
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull Response<List<Collaborators>> response) {
|
||||
});
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
return;
|
||||
|
||||
assert response.body() != null;
|
||||
String fullName = "";
|
||||
for (int i = 0; i < response.body().size(); i++) {
|
||||
if(!response.body().get(i).getFull_name().equals("")) {
|
||||
fullName = response.body().get(i).getFull_name();
|
||||
}
|
||||
defaultMentionAdapter.add(
|
||||
new Mention(response.body().get(i).getUsername(), fullName, response.body().get(i).getAvatar_url()));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
addComment.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
saveDraft(addComment.getText().toString());
|
||||
draftSaved.setVisibility(View.VISIBLE);
|
||||
|
||||
private View.OnClickListener replyToIssue = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
processNewCommentReply();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void processNewCommentReply() {
|
||||
});
|
||||
|
||||
String newReplyDT = addComment.getText().toString();
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
if(!connToInternet) {
|
||||
|
||||
if(!connToInternet) {
|
||||
disableProcessButton();
|
||||
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
replyButton.setOnClickListener(replyToIssue);
|
||||
|
||||
if(newReplyDT.equals("")) {
|
||||
}
|
||||
|
||||
Toasty.info(ctx, getString(R.string.commentEmptyError));
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
private void saveDraft(String draftText) {
|
||||
|
||||
disableProcessButton();
|
||||
replyComment(newReplyDT);
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
}
|
||||
int repositoryId = (int) tinyDb.getLong("repositoryId", 0);
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
int issueNumber = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
|
||||
}
|
||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
||||
|
||||
private void replyComment(String newReplyDT) {
|
||||
int countDraft = draftsApi.checkDraft(issueNumber, repositoryId);
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
if(countDraft == 0) {
|
||||
draftId = draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, draftText, StaticGlobalVariables.draftTypeComment);
|
||||
}
|
||||
else {
|
||||
DraftsApi.updateDraftByIssueIdAsyncTask(draftText, issueNumber, repositoryId);
|
||||
}
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
}
|
||||
|
||||
Issues issueComment = new Issues(newReplyDT);
|
||||
public void loadCollaboratorsList() {
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.replyCommentToIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull retrofit2.Response<Issues> response) {
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
if(response.code() == 201) {
|
||||
call.enqueue(new Callback<List<Collaborators>>() {
|
||||
|
||||
Toasty.info(ctx, getString(R.string.commentSuccess));
|
||||
tinyDb.putBoolean("commentPosted", true);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull Response<List<Collaborators>> response) {
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
assert response.body() != null;
|
||||
String fullName = "";
|
||||
for(int i = 0; i < response.body().size(); i++) {
|
||||
if(!response.body().get(i).getFull_name().equals("")) {
|
||||
fullName = response.body().get(i).getFull_name();
|
||||
}
|
||||
defaultMentionAdapter.add(new Mention(response.body().get(i).getUsername(), fullName, response.body().get(i).getAvatar_url()));
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.commentError));
|
||||
Log.i(TAG, String.valueOf(response.code()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
});
|
||||
}
|
||||
|
||||
replyButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
replyButton.setBackground(shape);
|
||||
private void initCloseListener() {
|
||||
|
||||
}
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
private View.OnClickListener replyToIssue = v -> processNewCommentReply();
|
||||
|
||||
replyButton.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
replyButton.setBackground(shape);
|
||||
private void processNewCommentReply() {
|
||||
|
||||
}
|
||||
String newReplyDT = addComment.getText().toString();
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(newReplyDT.equals("")) {
|
||||
|
||||
Toasty.info(ctx, getString(R.string.commentEmptyError));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
replyComment(newReplyDT);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void replyComment(String newReplyDT) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
|
||||
Issues issueComment = new Issues(newReplyDT);
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.replyCommentToIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull retrofit2.Response<Issues> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.info(ctx, getString(R.string.commentSuccess));
|
||||
tinyDb.putBoolean("commentPosted", true);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
|
||||
// delete draft comment
|
||||
if(tinyDb.getBoolean("draftsCommentsDeletionEnabled")) {
|
||||
|
||||
int repositoryId = (int) tinyDb.getLong("repositoryId", 0);
|
||||
int issueNumber = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
|
||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
||||
draftId = draftsApi.getDraftIdAsync(issueNumber, repositoryId);
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
}
|
||||
|
||||
finish();
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.commentError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.reply_to_issue, menu);
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch(item.getItemId()) {
|
||||
|
||||
case R.id.replyToIssueMenu:
|
||||
Intent fragmentIntent = new Intent(ReplyToIssueActivity.this, MainActivity.class);
|
||||
fragmentIntent.putExtra("launchFragment", "drafts");
|
||||
ReplyToIssueActivity.this.startActivity(fragmentIntent);
|
||||
break;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
||||
replyButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius(8);
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
replyButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
replyButton.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius(8);
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
replyButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
@ -16,6 +17,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@ -39,14 +41,17 @@ import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.fragments.ReleasesFragment;
|
||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -62,60 +67,21 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
private FragmentRefreshListener fragmentRefreshListener;
|
||||
private FragmentRefreshListenerPr fragmentRefreshListenerPr;
|
||||
private FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone;
|
||||
private FragmentRefreshListenerFiles fragmentRefreshListenerFiles;
|
||||
|
||||
final Context ctx = this;
|
||||
private final Context ctx = this;
|
||||
private Context appCtx;
|
||||
|
||||
// issues interface
|
||||
public FragmentRefreshListener getFragmentRefreshListener() {
|
||||
private TinyDB tinyDB;
|
||||
|
||||
return fragmentRefreshListener;
|
||||
}
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
|
||||
public void setFragmentRefreshListener(FragmentRefreshListener fragmentRefreshListener) {
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
|
||||
this.fragmentRefreshListener = fragmentRefreshListener;
|
||||
}
|
||||
|
||||
public interface FragmentRefreshListener {
|
||||
|
||||
void onRefresh(String text);
|
||||
|
||||
}
|
||||
|
||||
// pr interface
|
||||
public FragmentRefreshListenerPr getFragmentRefreshListenerPr() {
|
||||
|
||||
return fragmentRefreshListenerPr;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerPr(FragmentRefreshListenerPr fragmentRefreshListenerPr) {
|
||||
|
||||
this.fragmentRefreshListenerPr = fragmentRefreshListenerPr;
|
||||
}
|
||||
|
||||
public interface FragmentRefreshListenerPr {
|
||||
|
||||
void onRefresh(String text);
|
||||
|
||||
}
|
||||
|
||||
// milestones interface
|
||||
public FragmentRefreshListenerMilestone getFragmentRefreshListenerMilestone() {
|
||||
|
||||
return fragmentRefreshListenerMilestone;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerMilestone(FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone) {
|
||||
|
||||
this.fragmentRefreshListenerMilestone = fragmentRefreshListenerMilestone;
|
||||
}
|
||||
|
||||
public interface FragmentRefreshListenerMilestone {
|
||||
|
||||
void onRefresh(String text);
|
||||
|
||||
}
|
||||
private int tabsCount;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
@ -129,40 +95,32 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
String repoName1 = parts[1];
|
||||
tinyDB = new TinyDB(appCtx);
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String repoOwner = parts[0];
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
tinyDb.putString("repoIssuesState", "open");
|
||||
tinyDb.putString("repoPrState", "open");
|
||||
tinyDb.putString("milestoneState", "open");
|
||||
|
||||
String appLocale = tinyDb.getString("locale");
|
||||
AppUtil.setAppLocale(getResources(), appLocale);
|
||||
String[] repoNameParts = tinyDB.getString("repoFullName").split("/");
|
||||
repositoryOwner = repoNameParts[0];
|
||||
repositoryName = repoNameParts[1];
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
|
||||
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
toolbarTitle.setText(repositoryName);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repoName1);
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repositoryName);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
instanceUrl = tinyDB.getString("instanceUrl");
|
||||
loginUid = tinyDB.getString("loginUid");
|
||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||
|
||||
ViewPager mViewPager = findViewById(R.id.container);
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
|
||||
TabLayout tabLayout = findViewById(R.id.tabs);
|
||||
tinyDB.putString("repoIssuesState", "open");
|
||||
tinyDB.putString("repoPrState", "open");
|
||||
tinyDB.putString("milestoneState", "open");
|
||||
|
||||
Typeface myTypeface;
|
||||
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
switch(tinyDB.getInt("customFontId", -1)) {
|
||||
|
||||
case 0:
|
||||
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/roboto.ttf");
|
||||
@ -179,34 +137,50 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
}
|
||||
|
||||
toolbarTitle.setTypeface(myTypeface);
|
||||
toolbarTitle.setText(repoName1);
|
||||
|
||||
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
||||
int tabsCount = vg.getChildCount();
|
||||
TabLayout tabLayout = findViewById(R.id.tabs);
|
||||
|
||||
ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);
|
||||
tabsCount = viewGroup.getChildCount();
|
||||
|
||||
for(int j = 0; j < tabsCount; j++) {
|
||||
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
|
||||
|
||||
ViewGroup vgTab = (ViewGroup) viewGroup.getChildAt(j);
|
||||
int tabChildCount = vgTab.getChildCount();
|
||||
|
||||
for(int i = 0; i < tabChildCount; i++) {
|
||||
|
||||
View tabViewChild = vgTab.getChildAt(i);
|
||||
|
||||
if(tabViewChild instanceof TextView) {
|
||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only show Collaborators if you have permission to
|
||||
final View collaboratorTab = vg.getChildAt(8);
|
||||
if(tinyDb.getBoolean("isRepoAdmin")) {
|
||||
// Only show collaborators tab, if you have permission to
|
||||
View collaboratorTab = viewGroup.getChildAt(8);
|
||||
|
||||
if(tinyDB.getBoolean("isRepoAdmin") || new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
collaboratorTab.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
||||
tabsCount--;
|
||||
collaboratorTab.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
|
||||
ViewPager mViewPager = findViewById(R.id.container);
|
||||
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
|
||||
if(tinyDb.getBoolean("enableCounterBadges")) {
|
||||
SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
|
||||
if(tinyDB.getBoolean("enableCounterBadges")) {
|
||||
|
||||
@SuppressLint("InflateParams") View tabHeader2 = LayoutInflater.from(this).inflate(R.layout.badge_issue, null);
|
||||
textViewBadgeIssue = tabHeader2.findViewById(R.id.counterBadgeIssue);
|
||||
@ -221,41 +195,48 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
textViewBadgePull.setVisibility(View.GONE);
|
||||
textViewBadgeRelease.setVisibility(View.GONE);
|
||||
|
||||
getRepoInfo(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName1);
|
||||
getRepoInfo(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
||||
ColorStateList textColor = tabLayout.getTabTextColors();
|
||||
|
||||
// issue count
|
||||
// Issue count
|
||||
if(textViewBadgeIssue.getText() != "") {
|
||||
|
||||
TabLayout.Tab tabOpenIssues = tabLayout.getTabAt(2);
|
||||
Objects.requireNonNull(tabLayout.getTabAt(2)).setCustomView(tabHeader2);
|
||||
assert tabOpenIssues != null;
|
||||
assert tabOpenIssues != null; // FIXME This should be cleaned up
|
||||
TextView openIssueTabView = Objects.requireNonNull(tabOpenIssues.getCustomView()).findViewById(R.id.counterBadgeIssueText);
|
||||
openIssueTabView.setTextColor(textColor);
|
||||
|
||||
}
|
||||
|
||||
// pull count
|
||||
// Pull request count
|
||||
if(textViewBadgePull.getText() != "") { // only show if API returned a number
|
||||
|
||||
Objects.requireNonNull(tabLayout.getTabAt(3)).setCustomView(tabHeader4);
|
||||
TabLayout.Tab tabOpenPulls = tabLayout.getTabAt(3);
|
||||
assert tabOpenPulls != null;
|
||||
assert tabOpenPulls != null; // FIXME This should be cleaned up
|
||||
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
|
||||
openPullTabView.setTextColor(textColor);
|
||||
|
||||
}
|
||||
|
||||
// release count
|
||||
if(new Version("1.11.4").less(tinyDb.getString("giteaVersion"))) {
|
||||
// Release count
|
||||
if(new Version("1.11.4").less(tinyDB.getString("giteaVersion"))) {
|
||||
|
||||
if(textViewBadgeRelease.getText() != "") { // only show if API returned a number
|
||||
|
||||
Objects.requireNonNull(tabLayout.getTabAt(5)).setCustomView(tabHeader6);
|
||||
TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(5);
|
||||
assert tabOpenRelease != null;
|
||||
assert tabOpenRelease != null; // FIXME This should be cleaned up
|
||||
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
|
||||
openReleaseTabView.setTextColor(textColor);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkRepositoryStarStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName1);
|
||||
checkRepositoryWatchStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName1);
|
||||
checkRepositoryStarStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
||||
checkRepositoryWatchStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
||||
|
||||
}
|
||||
|
||||
@ -263,17 +244,10 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("enableCounterIssueBadge")) {
|
||||
getRepoInfo(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||
if(tinyDB.getBoolean("enableCounterIssueBadge")) {
|
||||
|
||||
getRepoInfo(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
||||
}
|
||||
|
||||
}
|
||||
@ -293,27 +267,38 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
int id = item.getItemId();
|
||||
|
||||
switch(id) {
|
||||
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
|
||||
case R.id.repoMenu:
|
||||
BottomSheetRepoFragment bottomSheet = new BottomSheetRepoFragment();
|
||||
bottomSheet.show(getSupportFragmentManager(), "repoBottomSheet");
|
||||
return true;
|
||||
|
||||
case R.id.filter:
|
||||
BottomSheetIssuesFilterFragment filterBottomSheet = new BottomSheetIssuesFilterFragment();
|
||||
filterBottomSheet.show(getSupportFragmentManager(), "repoFilterMenuBottomSheet");
|
||||
return true;
|
||||
|
||||
case R.id.filterPr:
|
||||
BottomSheetPullRequestFilterFragment filterPrBottomSheet = new BottomSheetPullRequestFilterFragment();
|
||||
filterPrBottomSheet.show(getSupportFragmentManager(), "repoFilterMenuPrBottomSheet");
|
||||
return true;
|
||||
|
||||
case R.id.filterMilestone:
|
||||
BottomSheetMilestonesFilterFragment filterMilestoneBottomSheet = new BottomSheetMilestonesFilterFragment();
|
||||
filterMilestoneBottomSheet.show(getSupportFragmentManager(), "repoFilterMenuMilestoneBottomSheet");
|
||||
return true;
|
||||
|
||||
case R.id.switchBranches:
|
||||
chooseBranch();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -321,72 +306,148 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
switch(text) {
|
||||
|
||||
case "label":
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateLabelActivity.class));
|
||||
break;
|
||||
|
||||
case "newIssue":
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateIssueActivity.class));
|
||||
break;
|
||||
|
||||
case "newMilestone":
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateMilestoneActivity.class));
|
||||
break;
|
||||
|
||||
case "addCollaborator":
|
||||
startActivity(new Intent(RepoDetailActivity.this, AddCollaboratorToRepositoryActivity.class));
|
||||
break;
|
||||
|
||||
case "chooseBranch":
|
||||
chooseBranch();
|
||||
break;
|
||||
|
||||
case "createRelease":
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateReleaseActivity.class));
|
||||
break;
|
||||
|
||||
case "openWebRepo":
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(tinyDb.getString("repoHtmlUrl")));
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(tinyDB.getString("repoHtmlUrl")));
|
||||
startActivity(i);
|
||||
break;
|
||||
|
||||
case "shareRepo":
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, tinyDb.getString("repoHtmlUrl"));
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, tinyDb.getString("repoHtmlUrl"));
|
||||
startActivity(Intent.createChooser(sharingIntent, tinyDb.getString("repoHtmlUrl")));
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, tinyDB.getString("repoHtmlUrl"));
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, tinyDB.getString("repoHtmlUrl"));
|
||||
startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl")));
|
||||
break;
|
||||
|
||||
case "newFile":
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
|
||||
break;
|
||||
|
||||
case "openIssues":
|
||||
if(getFragmentRefreshListener() != null) {
|
||||
getFragmentRefreshListener().onRefresh("open");
|
||||
}
|
||||
break;
|
||||
|
||||
case "closedIssues":
|
||||
if(getFragmentRefreshListener() != null) {
|
||||
getFragmentRefreshListener().onRefresh("closed");
|
||||
}
|
||||
break;
|
||||
|
||||
case "openPr":
|
||||
if(getFragmentRefreshListenerPr() != null) {
|
||||
getFragmentRefreshListenerPr().onRefresh("open");
|
||||
}
|
||||
break;
|
||||
|
||||
case "closedPr":
|
||||
if(getFragmentRefreshListenerPr() != null) {
|
||||
getFragmentRefreshListenerPr().onRefresh("closed");
|
||||
}
|
||||
break;
|
||||
|
||||
case "openMilestone":
|
||||
if(getFragmentRefreshListenerMilestone() != null) {
|
||||
getFragmentRefreshListenerMilestone().onRefresh("open");
|
||||
}
|
||||
break;
|
||||
|
||||
case "closedMilestone":
|
||||
if(getFragmentRefreshListenerMilestone() != null) {
|
||||
getFragmentRefreshListenerMilestone().onRefresh("closed");
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void chooseBranch() {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getBranches(instanceToken, repositoryOwner, repositoryName);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull Response<List<Branches>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
int selectedBranch = 0;
|
||||
assert response.body() != null;
|
||||
|
||||
for(int i = 0; i < response.body().size(); i++) {
|
||||
|
||||
Branches branches = response.body().get(i);
|
||||
branchesList.add(branches.getName());
|
||||
|
||||
if(tinyDB.getString("repoBranch").equals(branches.getName())) {
|
||||
|
||||
selectedBranch = i;
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder pBuilder = new AlertDialog.Builder(ctx);
|
||||
pBuilder.setTitle(R.string.pageTitleChooseBranch);
|
||||
|
||||
pBuilder.setSingleChoiceItems(branchesList.toArray(new String[0]), selectedBranch, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
|
||||
tinyDB.putString("repoBranch", branchesList.get(i));
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branchesList.get(i));
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
pBuilder.create().show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
SectionsPagerAdapter(FragmentManager fm) {
|
||||
@ -398,54 +459,58 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
String repoOwner = parts[0];
|
||||
String repoName = parts[1];
|
||||
|
||||
Fragment fragment = null;
|
||||
|
||||
switch(position) {
|
||||
case 0: // information
|
||||
return RepoInfoFragment.newInstance(repoOwner, repoName);
|
||||
case 1: // files
|
||||
return FilesFragment.newInstance(repoOwner, repoName);
|
||||
case 2: // issues
|
||||
|
||||
case 0: // Repository details
|
||||
return RepoInfoFragment.newInstance(repositoryOwner, repositoryName);
|
||||
|
||||
case 1: // Files
|
||||
return FilesFragment.newInstance(repositoryOwner, repositoryName, tinyDB.getString("repoBranch"));
|
||||
|
||||
case 2: // Issues
|
||||
fragment = new IssuesFragment();
|
||||
break;
|
||||
case 3: // pull requests
|
||||
|
||||
case 3: // Pull requests
|
||||
fragment = new PullRequestsFragment();
|
||||
break;
|
||||
case 4: // branches
|
||||
return BranchesFragment.newInstance(repoOwner, repoName);
|
||||
case 5: // releases
|
||||
return ReleasesFragment.newInstance(repoOwner, repoName);
|
||||
case 6: // milestones
|
||||
|
||||
case 4: // Branches
|
||||
return BranchesFragment.newInstance(repositoryOwner, repositoryName);
|
||||
|
||||
case 5: // Releases
|
||||
return ReleasesFragment.newInstance(repositoryOwner, repositoryName);
|
||||
|
||||
case 6: // Milestones
|
||||
fragment = new MilestonesFragment();
|
||||
break;
|
||||
case 7: // labels
|
||||
return LabelsFragment.newInstance(repoOwner, repoName);
|
||||
case 8: // collaborators
|
||||
return CollaboratorsFragment.newInstance(repoOwner, repoName);
|
||||
|
||||
case 7: // Labels
|
||||
return LabelsFragment.newInstance(repositoryOwner, repositoryName);
|
||||
|
||||
case 8: // Collaborators
|
||||
return CollaboratorsFragment.newInstance(repositoryOwner, repositoryName);
|
||||
|
||||
}
|
||||
|
||||
assert fragment != null;
|
||||
return fragment;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
|
||||
return 9;
|
||||
return tabsCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserRepository(token, owner, repo);
|
||||
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
|
||||
@Override
|
||||
@ -453,33 +518,33 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
UserRepositories repoInfo = response.body();
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if(tinyDB.getBoolean("enableCounterBadges")) {
|
||||
assert repoInfo != null;
|
||||
|
||||
if(tinyDb.getBoolean("enableCounterBadges")) {
|
||||
assert repoInfo != null;
|
||||
if(repoInfo.getOpen_issues_count() != null) {
|
||||
|
||||
if(repoInfo.getOpen_issues_count() != null) {
|
||||
textViewBadgeIssue.setVisibility(View.VISIBLE);
|
||||
textViewBadgeIssue.setText(repoInfo.getOpen_issues_count());
|
||||
}
|
||||
|
||||
if(repoInfo.getOpen_pull_count() != null) {
|
||||
textViewBadgePull.setVisibility(View.VISIBLE);
|
||||
textViewBadgePull.setText(repoInfo.getOpen_pull_count());
|
||||
}
|
||||
|
||||
if(repoInfo.getRelease_count() != null) {
|
||||
textViewBadgeRelease.setVisibility(View.VISIBLE);
|
||||
textViewBadgeRelease.setText(repoInfo.getRelease_count());
|
||||
}
|
||||
textViewBadgeIssue.setVisibility(View.VISIBLE);
|
||||
textViewBadgeIssue.setText(repoInfo.getOpen_issues_count());
|
||||
}
|
||||
|
||||
if(repoInfo.getOpen_pull_count() != null) {
|
||||
|
||||
textViewBadgePull.setVisibility(View.VISIBLE);
|
||||
textViewBadgePull.setText(repoInfo.getOpen_pull_count());
|
||||
}
|
||||
|
||||
if(repoInfo.getRelease_count() != null) {
|
||||
|
||||
textViewBadgeRelease.setVisibility(View.VISIBLE);
|
||||
textViewBadgeRelease.setText(repoInfo.getRelease_count());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Log.e("onFailure", String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
@ -497,17 +562,13 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
private void checkRepositoryStarStatus(String instanceUrl, String instanceToken, final String owner, String repo) {
|
||||
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkRepoStarStatus(instanceToken, owner, repo);
|
||||
|
||||
Call<JsonElement> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkRepoStarStatus(instanceToken, owner, repo);
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
tinyDb.putInt("repositoryStarStatus", response.code());
|
||||
tinyDB.putInt("repositoryStarStatus", response.code());
|
||||
|
||||
}
|
||||
|
||||
@ -525,22 +586,23 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkRepoWatchStatus(instanceToken, owner, repo);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
assert response.body() != null;
|
||||
|
||||
if(response.body().getSubscribed()) {
|
||||
tinyDb.putBoolean("repositoryWatchStatus", true);
|
||||
tinyDB.putBoolean("repositoryWatchStatus", true);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
tinyDb.putBoolean("repositoryWatchStatus", false);
|
||||
|
||||
tinyDB.putBoolean("repositoryWatchStatus", false);
|
||||
}
|
||||
|
||||
}
|
||||
@ -554,4 +616,32 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
}
|
||||
|
||||
// Issues interface
|
||||
public FragmentRefreshListener getFragmentRefreshListener() { return fragmentRefreshListener; }
|
||||
|
||||
public void setFragmentRefreshListener(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListener = fragmentRefreshListener; }
|
||||
|
||||
public interface FragmentRefreshListener { void onRefresh(String text); }
|
||||
|
||||
// Pull request interface
|
||||
public FragmentRefreshListenerPr getFragmentRefreshListenerPr() { return fragmentRefreshListenerPr; }
|
||||
|
||||
public void setFragmentRefreshListenerPr(FragmentRefreshListenerPr fragmentRefreshListenerPr) { this.fragmentRefreshListenerPr = fragmentRefreshListenerPr; }
|
||||
|
||||
public interface FragmentRefreshListenerPr { void onRefresh(String text); }
|
||||
|
||||
// Milestones interface
|
||||
public FragmentRefreshListenerMilestone getFragmentRefreshListenerMilestone() { return fragmentRefreshListenerMilestone; }
|
||||
|
||||
public void setFragmentRefreshListenerMilestone(FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone) { this.fragmentRefreshListenerMilestone = fragmentRefreshListenerMilestone; }
|
||||
|
||||
public interface FragmentRefreshListenerMilestone { void onRefresh(String text); }
|
||||
|
||||
// Files interface
|
||||
public FragmentRefreshListenerFiles getFragmentRefreshListenerFiles() { return fragmentRefreshListenerFiles; }
|
||||
|
||||
public void setFragmentRefreshListenerFiles(FragmentRefreshListenerFiles fragmentRefreshListenerFiles) { this.fragmentRefreshListenerFiles = fragmentRefreshListenerFiles; }
|
||||
|
||||
public interface FragmentRefreshListenerFiles { void onRefresh(String text); }
|
||||
|
||||
}
|
||||
|
@ -2,19 +2,19 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import android.view.View;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.RepoStargazersAdapter;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.RepoStargazersViewModel;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -2,19 +2,19 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import android.view.View;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.RepoWatchersAdapter;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.RepoWatchersViewModel;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -9,8 +9,8 @@ import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -27,7 +27,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
private static String[] codeBlockList = {"Green - Black", "White - Black", "Grey - Black", "White - Grey", "Dark - White"};
|
||||
private static int codeBlockSelectedChoice = 0;
|
||||
|
||||
private static String[] homeScreenList = {"My Repositories", "Starred Repositories", "Organizations", "Repositories", "Profile"};
|
||||
private static String[] homeScreenList = {"My Repositories", "Starred Repositories", "Organizations", "Repositories", "Profile", "Explore", "Drafts"};
|
||||
private static int homeScreenSelectedChoice = 0;
|
||||
|
||||
private static String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
|
||||
@ -201,7 +201,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
|
||||
AlertDialog.Builder hsBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
||||
|
||||
hsBuilder.setTitle(R.string.settingshomeScreenSelectorDialogTitle);
|
||||
hsBuilder.setTitle(R.string.settingsHomeScreenSelectorDialogTitle);
|
||||
if(homeScreenSelectedChoice != -1) {
|
||||
hsBuilder.setCancelable(true);
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Switch;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class SettingsDraftsActivity extends BaseActivity {
|
||||
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
|
||||
return R.layout.activity_settings_drafts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
Switch commentsDeletionSwitch = findViewById(R.id.commentsDeletionSwitch);
|
||||
|
||||
if(tinyDb.getBoolean("draftsCommentsDeletionEnabled")) {
|
||||
commentsDeletionSwitch.setChecked(true);
|
||||
}
|
||||
else {
|
||||
commentsDeletionSwitch.setChecked(false);
|
||||
}
|
||||
|
||||
// delete comments on submit switcher
|
||||
commentsDeletionSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
if(isChecked) {
|
||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
}
|
||||
else {
|
||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", false);
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() { onClickListener = view -> finish(); }
|
||||
|
||||
}
|
@ -9,8 +9,8 @@ import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
|
@ -6,8 +6,8 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Switch;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
|
@ -7,15 +7,18 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.NumberPicker;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FilesData;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.notifications.NotificationsMaster;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
@ -27,6 +30,8 @@ import java.util.HashSet;
|
||||
public class SettingsSecurityActivity extends BaseActivity {
|
||||
|
||||
private Context appCtx;
|
||||
private Context ctx = this;
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static String[] cacheSizeDataList = {"50 MB", "100 MB", "250 MB", "500 MB", "1 GB"};
|
||||
@ -35,6 +40,10 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
private static String[] cacheSizeImagesList = {"50 MB", "100 MB", "250 MB", "500 MB", "1 GB"};
|
||||
private static int cacheSizeImagesSelectedChoice = 0;
|
||||
|
||||
private static int MINIMUM_POLLING_DELAY = 1;
|
||||
private static int DEFAULT_POLLING_DELAY = 20;
|
||||
private static int MAXIMUM_POLLING_DELAY = 720;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
|
||||
@ -48,6 +57,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String currentVersion = tinyDb.getString("giteaVersion");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
@ -57,8 +67,10 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
TextView cacheSizeDataSelected = findViewById(R.id.cacheSizeDataSelected); // setter for data cache size
|
||||
TextView cacheSizeImagesSelected = findViewById(R.id.cacheSizeImagesSelected); // setter for images cache size
|
||||
TextView clearCacheSelected = findViewById(R.id.clearCacheSelected); // setter for clear cache
|
||||
TextView pollingDelaySelected = findViewById(R.id.pollingDelaySelected);
|
||||
|
||||
LinearLayout certsFrame = findViewById(R.id.certsFrame);
|
||||
LinearLayout pollingDelayFrame = findViewById(R.id.pollingDelayFrame);
|
||||
LinearLayout cacheSizeDataFrame = findViewById(R.id.cacheSizeDataSelectionFrame);
|
||||
LinearLayout cacheSizeImagesFrame = findViewById(R.id.cacheSizeImagesSelectionFrame);
|
||||
LinearLayout clearCacheFrame = findViewById(R.id.clearCacheSelectionFrame);
|
||||
@ -79,6 +91,12 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
cacheSizeImagesSelectedChoice = tinyDb.getInt("cacheSizeImagesId");
|
||||
}
|
||||
|
||||
if(new Version(currentVersion).less("1.12.3")) {
|
||||
pollingDelayFrame.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), tinyDb.getInt("pollingDelayMinutes", DEFAULT_POLLING_DELAY)));
|
||||
|
||||
// clear cache setter
|
||||
File cacheDir = appCtx.getCacheDir();
|
||||
long size__ = FilesData.getFileSizeRecursively(new HashSet<>(), cacheDir);
|
||||
@ -190,7 +208,6 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
tinyDb.putBoolean("loggedInMode", false);
|
||||
tinyDb.remove("basicAuthPassword");
|
||||
tinyDb.putBoolean("basicAuthFlag", false);
|
||||
//tinyDb.clear();
|
||||
|
||||
Intent loginActivityIntent = new Intent().setClass(appCtx, LoginActivity.class);
|
||||
loginActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@ -203,12 +220,42 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
|
||||
});
|
||||
|
||||
// polling delay
|
||||
pollingDelayFrame.setOnClickListener(v -> {
|
||||
|
||||
NumberPicker numberPicker = new NumberPicker(ctx);
|
||||
numberPicker.setMinValue(MINIMUM_POLLING_DELAY);
|
||||
numberPicker.setMaxValue(MAXIMUM_POLLING_DELAY);
|
||||
numberPicker.setValue(tinyDb.getInt("pollingDelayMinutes", DEFAULT_POLLING_DELAY));
|
||||
numberPicker.setWrapSelectorWheel(true);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||
builder.setTitle(getString(R.string.pollingDelayDialogHeaderText));
|
||||
builder.setMessage(getString(R.string.pollingDelayDialogDescriptionText));
|
||||
|
||||
builder.setCancelable(true);
|
||||
builder.setPositiveButton(getString(R.string.okButton), (dialog, which) -> {
|
||||
|
||||
tinyDb.putInt("pollingDelayMinutes", numberPicker.getValue());
|
||||
|
||||
NotificationsMaster.fireWorker(ctx);
|
||||
NotificationsMaster.hireWorker(ctx);
|
||||
|
||||
pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), numberPicker.getValue()));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
builder.setNegativeButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
|
||||
builder.setView(numberPicker);
|
||||
builder.create().show();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> {
|
||||
finish();
|
||||
};
|
||||
}
|
||||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
|
@ -7,14 +7,14 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CommitsActivity;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CommitsActivity;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
|
@ -14,8 +14,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Commits;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
138
app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java
Normal file
138
app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java
Normal file
@ -0,0 +1,138 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.ReplyToIssueActivity;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
||||
|
||||
private List<DraftWithRepository> draftsList;
|
||||
private Context mCtx;
|
||||
|
||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView draftText;
|
||||
private TextView repoInfo;
|
||||
private TextView repoId;
|
||||
private TextView draftId;
|
||||
private TextView issueNumber;
|
||||
private TextView issueType;
|
||||
private TextView repoOwner;
|
||||
private TextView repoName;
|
||||
|
||||
private DraftsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
draftText = itemView.findViewById(R.id.draftText);
|
||||
repoInfo = itemView.findViewById(R.id.repoInfo);
|
||||
repoId = itemView.findViewById(R.id.repoId);
|
||||
draftId = itemView.findViewById(R.id.draftId);
|
||||
issueNumber = itemView.findViewById(R.id.issueNumber);
|
||||
issueType = itemView.findViewById(R.id.issueType);
|
||||
repoOwner = itemView.findViewById(R.id.repoOwner);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||
|
||||
deleteDraft.setOnClickListener(itemDelete -> {
|
||||
|
||||
int getDraftId = Integer.parseInt(draftId.getText().toString());
|
||||
deleteDraft(getAdapterPosition());
|
||||
DraftsApi draftsApi = new DraftsApi(mCtx);
|
||||
draftsApi.deleteSingleDraft(getDraftId);
|
||||
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(itemEdit -> {
|
||||
|
||||
Intent intent = new Intent(mCtx, ReplyToIssueActivity.class);
|
||||
intent.putExtra("commentBody", draftText.getText().toString());
|
||||
intent.putExtra("issueNumber", issueNumber.getText().toString());
|
||||
intent.putExtra("repositoryId", repoId.getText().toString());
|
||||
intent.putExtra("draftTitle", repoInfo.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(mCtx);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putLong("repositoryId", Long.parseLong(repoId.getText().toString()));
|
||||
//tinyDb.putString("issueType", issueType.getText().toString());
|
||||
|
||||
mCtx.startActivity(intent);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DraftsAdapter(Context mCtx, List<DraftWithRepository> draftsListMain) {
|
||||
this.mCtx = mCtx;
|
||||
this.draftsList = draftsListMain;
|
||||
}
|
||||
|
||||
private void deleteDraft(int position) {
|
||||
|
||||
draftsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, draftsList.size());
|
||||
Toasty.info(mCtx, mCtx.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DraftsAdapter.DraftsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_drafts, parent, false);
|
||||
return new DraftsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DraftsAdapter.DraftsViewHolder holder, int position) {
|
||||
|
||||
DraftWithRepository currentItem = draftsList.get(position);
|
||||
|
||||
holder.repoId.setText(String.valueOf(currentItem.getRepositoryId()));
|
||||
holder.draftId.setText(String.valueOf(currentItem.getDraftId()));
|
||||
holder.issueNumber.setText(String.valueOf(currentItem.getIssueId()));
|
||||
holder.issueType.setText(currentItem.getDraftType());
|
||||
holder.repoOwner.setText(currentItem.getRepositoryOwner());
|
||||
holder.repoName.setText(currentItem.getRepositoryName());
|
||||
holder.draftText.setText(currentItem.getDraftText());
|
||||
|
||||
String issueNumber = "<font color='" + mCtx.getResources().getColor(R.color.lightGray) + "'>" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||
holder.repoInfo.setText(Html.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return draftsList.size();
|
||||
}
|
||||
|
||||
public void updateList(List<DraftWithRepository> list) {
|
||||
|
||||
draftsList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -9,6 +9,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@ -22,11 +23,13 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -58,6 +61,9 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
|
||||
private ReposSearchViewHolder(View itemView) {
|
||||
|
||||
@ -73,6 +79,9 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
repoForks = itemView.findViewById(R.id.repoForks);
|
||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -86,13 +95,35 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
||||
|
||||
String[] parts = fullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String[] parts = repoFullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
@ -133,6 +164,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
@ -150,7 +182,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(fullName.getText());
|
||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
@ -199,10 +231,9 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ExploreRepositoriesAdapter.ReposSearchViewHolder holder, int position) {
|
||||
|
||||
final UserRepositories currentItem = searchedReposList.get(position);
|
||||
|
||||
|
||||
UserRepositories currentItem = searchedReposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -229,10 +260,12 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
holder.repoForks.setText(currentItem.getForks_count());
|
||||
@ -242,6 +275,13 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
}
|
||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||
|
||||
if(currentItem.isArchived()) {
|
||||
holder.archiveRepo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.archiveRepo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,9 +11,9 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Files;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -51,23 +51,20 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
|
||||
//ImageView filesDropdownMenu = itemView.findViewById(R.id.filesDropdownMenu);
|
||||
|
||||
fileName.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
fileName.setOnClickListener(v -> {
|
||||
|
||||
Context context = v.getContext();
|
||||
|
||||
if(fileType.getText().toString().equals("file")) {
|
||||
filesListener.onClickFile(fileName.getText().toString());
|
||||
}
|
||||
else if(fileType.getText().toString().equals("dir")) {
|
||||
filesListener.onClickDir(fileName.getText().toString());
|
||||
}
|
||||
else {
|
||||
Toasty.info(context, context.getString(R.string.filesGenericError));
|
||||
}
|
||||
Context context = v.getContext();
|
||||
|
||||
if(fileType.getText().toString().equals("file")) {
|
||||
filesListener.onClickFile(fileName.getText().toString());
|
||||
}
|
||||
else if(fileType.getText().toString().equals("dir")) {
|
||||
filesListener.onClickDir(fileName.getText().toString());
|
||||
}
|
||||
else {
|
||||
Toasty.info(context, context.getString(R.string.filesGenericError));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -160,15 +157,16 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
holder.fileName.setText(currentItem.getName());
|
||||
|
||||
if(currentItem.getType().equals("file")) {
|
||||
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_file_new));
|
||||
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_file));
|
||||
holder.fileInfo.setVisibility(View.VISIBLE);
|
||||
holder.fileInfo.setText(AppUtil.formatFileSizeInDetail(currentItem.getSize()));
|
||||
}
|
||||
else if(currentItem.getType().equals("dir")) {
|
||||
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_folder_24));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_directory));
|
||||
}
|
||||
else {
|
||||
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_question_mark_24));
|
||||
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_question));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class FilesDiffAdapter extends BaseAdapter {
|
||||
FileDiffView data = (FileDiffView) getItem(position);
|
||||
headerFileName.setText(data.getFileName());
|
||||
|
||||
if(data.isFileType()) {
|
||||
if(data.isFileBinary()) {
|
||||
|
||||
diffStats.setVisibility(View.GONE);
|
||||
diffLines.addView(getMessageView(context.getResources().getString(R.string.binaryFileError)));
|
||||
@ -97,7 +97,7 @@ public class FilesDiffAdapter extends BaseAdapter {
|
||||
diffStats.setVisibility(View.VISIBLE);
|
||||
headerFileInfo.setText(data.getFileInfo());
|
||||
|
||||
String[] codeLines = getLines(data.getFileContents());
|
||||
String[] codeLines = getLines(data.toString());
|
||||
|
||||
if(MAXIMUM_LINES > codeLines.length) {
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@ -24,10 +26,10 @@ import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UserMentions;
|
||||
import org.mian.gitnex.models.IssueComments;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -104,6 +106,8 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
TextView commentMenuEdit = view.findViewById(R.id.commentMenuEdit);
|
||||
TextView commentShare = view.findViewById(R.id.issueCommentShare);
|
||||
TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote);
|
||||
TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy);
|
||||
TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete);
|
||||
|
||||
if(!loginUid.contentEquals(commenterUsername.getText())) {
|
||||
@ -111,6 +115,10 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
commentMenuDelete.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(issueComment.getText().toString().isEmpty()) {
|
||||
commentMenuCopy.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(ctx);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
@ -143,6 +151,48 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
});
|
||||
|
||||
commentMenuQuote.setOnClickListener(v1 -> {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
String commenterName = commenterUsername.getText().toString();
|
||||
|
||||
if(!commenterName.equals(tinyDb.getString("userLogin"))) {
|
||||
|
||||
stringBuilder.append("@").append(commenterName).append("\n\n");
|
||||
}
|
||||
|
||||
String[] lines = commendBodyRaw.getText().toString().split("\\R");
|
||||
|
||||
for(String line : lines) {
|
||||
|
||||
stringBuilder.append(">").append(line).append("\n");
|
||||
}
|
||||
|
||||
stringBuilder.append("\n");
|
||||
|
||||
Intent intent = new Intent(ctx, ReplyToIssueActivity.class);
|
||||
intent.putExtra("commentBody", stringBuilder.toString());
|
||||
intent.putExtra("cursorToEnd", true);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
dialog.dismiss();
|
||||
ctx.startActivity(intent);
|
||||
|
||||
});
|
||||
|
||||
commentMenuCopy.setOnClickListener(view1 -> {
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
assert clipboard != null;
|
||||
|
||||
ClipData clip = ClipData.newPlainText("Comment on issue #" + issueNumber.getText().toString(), issueComment.getText().toString());
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
dialog.dismiss();
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueCommentToastMsg));
|
||||
|
||||
});
|
||||
|
||||
commentMenuDelete.setOnClickListener(deleteComment -> {
|
||||
|
||||
deleteIssueComment(ctx, Integer.parseInt(commendId.getText().toString()), getAdapterPosition());
|
||||
|
@ -18,8 +18,8 @@ import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -125,7 +125,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putString("issueType", "issue");
|
||||
tinyDb.putString("issueType", "Issue");
|
||||
context.startActivity(intent);
|
||||
|
||||
});
|
||||
@ -138,7 +138,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putString("issueType", "issue");
|
||||
tinyDb.putString("issueType", "Issue");
|
||||
context.startActivity(intent);
|
||||
|
||||
});
|
||||
|
@ -3,26 +3,25 @@ package org.mian.gitnex.adapters;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.core.widget.ImageViewCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateLabelActivity;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.models.Labels;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -39,12 +38,17 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
private TextView labelTitle;
|
||||
private TextView labelId;
|
||||
private TextView labelColor;
|
||||
private ImageView labelsView;
|
||||
|
||||
private CardView labelView;
|
||||
private ImageView labelIcon;
|
||||
private TextView labelName;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
labelsView = itemView.findViewById(R.id.labelsView);
|
||||
labelView = itemView.findViewById(R.id.labelView);
|
||||
labelIcon = itemView.findViewById(R.id.labelIcon);
|
||||
labelName = itemView.findViewById(R.id.labelName);
|
||||
ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu);
|
||||
labelTitle = itemView.findViewById(R.id.labelTitle);
|
||||
labelId = itemView.findViewById(R.id.labelId);
|
||||
@ -119,19 +123,13 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
String labelName = currentItem.getName();
|
||||
|
||||
int color = Color.parseColor("#" + labelColor);
|
||||
int contrastColor = new ColorInverter().getContrastColor(color);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.bold()
|
||||
.textColor(new ColorInverter().getContrastColor(color))
|
||||
.fontSize(35)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, 40, 20))
|
||||
.height(55)
|
||||
.endConfig()
|
||||
.buildRoundRect(labelName, color, 10);
|
||||
ImageViewCompat.setImageTintList(holder.labelIcon, ColorStateList.valueOf(contrastColor));
|
||||
|
||||
holder.labelsView.setImageDrawable(drawable);
|
||||
holder.labelName.setTextColor(contrastColor);
|
||||
holder.labelName.setText(labelName);
|
||||
holder.labelView.setCardBackgroundColor(color);
|
||||
|
||||
}
|
||||
|
||||
@ -140,4 +138,4 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
return labelsList.size();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.text.Spanned;
|
||||
@ -15,7 +14,6 @@ import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.mian.gitnex.R;
|
||||
@ -23,8 +21,8 @@ import org.mian.gitnex.actions.MilestoneActions;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Milestones;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -56,369 +54,346 @@ import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
|
||||
public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private Context context;
|
||||
private final int TYPE_LOAD = 0;
|
||||
private List<Milestones> dataList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false;
|
||||
private boolean isMoreDataAvailable = true;
|
||||
private String TAG = StaticGlobalVariables.tagMilestonesAdapter;
|
||||
private Context context;
|
||||
private final int TYPE_LOAD = 0;
|
||||
private List<Milestones> dataList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false;
|
||||
private boolean isMoreDataAvailable = true;
|
||||
private String TAG = StaticGlobalVariables.tagMilestonesAdapter;
|
||||
|
||||
public MilestonesAdapter(Context context, List<Milestones> dataListMain) {
|
||||
public MilestonesAdapter(Context context, List<Milestones> dataListMain) {
|
||||
|
||||
this.context = context;
|
||||
this.dataList = dataListMain;
|
||||
this.context = context;
|
||||
this.dataList = dataListMain;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
|
||||
if(viewType == TYPE_LOAD) {
|
||||
return new MilestonesAdapter.DataHolder(inflater.inflate(R.layout.list_milestones, parent, false));
|
||||
}
|
||||
else {
|
||||
return new MilestonesAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
||||
}
|
||||
if(viewType == TYPE_LOAD) {
|
||||
return new MilestonesAdapter.DataHolder(inflater.inflate(R.layout.list_milestones, parent, false));
|
||||
}
|
||||
else {
|
||||
return new MilestonesAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(getItemViewType(position) == TYPE_LOAD) {
|
||||
if(getItemViewType(position) == TYPE_LOAD) {
|
||||
|
||||
((MilestonesAdapter.DataHolder) holder).bindData(dataList.get(position));
|
||||
((MilestonesAdapter.DataHolder) holder).bindData(dataList.get(position));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class DataHolder extends RecyclerView.ViewHolder {
|
||||
class DataHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView milestoneId;
|
||||
private TextView msTitle;
|
||||
private TextView msDescription;
|
||||
private TextView msOpenIssues;
|
||||
private TextView msClosedIssues;
|
||||
private TextView msDueDate;
|
||||
private ImageView msStatus;
|
||||
private ProgressBar msProgress;
|
||||
private TextView milestoneStatus;
|
||||
private TextView milestoneId;
|
||||
private TextView msTitle;
|
||||
private TextView msDescription;
|
||||
private TextView msOpenIssues;
|
||||
private TextView msClosedIssues;
|
||||
private TextView msDueDate;
|
||||
private ProgressBar msProgress;
|
||||
private TextView milestoneStatus;
|
||||
|
||||
DataHolder(View itemView) {
|
||||
DataHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
super(itemView);
|
||||
|
||||
milestoneId = itemView.findViewById(R.id.milestoneId);
|
||||
msTitle = itemView.findViewById(R.id.milestoneTitle);
|
||||
msStatus = itemView.findViewById(R.id.milestoneState);
|
||||
msDescription = itemView.findViewById(R.id.milestoneDescription);
|
||||
msOpenIssues = itemView.findViewById(R.id.milestoneIssuesOpen);
|
||||
msClosedIssues = itemView.findViewById(R.id.milestoneIssuesClosed);
|
||||
msDueDate = itemView.findViewById(R.id.milestoneDueDate);
|
||||
msProgress = itemView.findViewById(R.id.milestoneProgress);
|
||||
ImageView milestonesMenu = itemView.findViewById(R.id.milestonesMenu);
|
||||
milestoneStatus = itemView.findViewById(R.id.milestoneStatus);
|
||||
milestoneId = itemView.findViewById(R.id.milestoneId);
|
||||
msTitle = itemView.findViewById(R.id.milestoneTitle);
|
||||
msDescription = itemView.findViewById(R.id.milestoneDescription);
|
||||
msOpenIssues = itemView.findViewById(R.id.milestoneIssuesOpen);
|
||||
msClosedIssues = itemView.findViewById(R.id.milestoneIssuesClosed);
|
||||
msDueDate = itemView.findViewById(R.id.milestoneDueDate);
|
||||
msProgress = itemView.findViewById(R.id.milestoneProgress);
|
||||
ImageView milestonesMenu = itemView.findViewById(R.id.milestonesMenu);
|
||||
milestoneStatus = itemView.findViewById(R.id.milestoneStatus);
|
||||
|
||||
milestonesMenu.setOnClickListener(v -> {
|
||||
milestonesMenu.setOnClickListener(v -> {
|
||||
|
||||
Context ctx = v.getContext();
|
||||
int milestoneId_ = Integer.parseInt(milestoneId.getText().toString());
|
||||
Context ctx = v.getContext();
|
||||
int milestoneId_ = Integer.parseInt(milestoneId.getText().toString());
|
||||
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_milestones_in_list, null);
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_milestones_in_list, null);
|
||||
|
||||
TextView closeMilestone = view.findViewById(R.id.closeMilestone);
|
||||
TextView openMilestone = view.findViewById(R.id.openMilestone);
|
||||
TextView closeMilestone = view.findViewById(R.id.closeMilestone);
|
||||
TextView openMilestone = view.findViewById(R.id.openMilestone);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(ctx);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(ctx);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
if(milestoneStatus.getText().toString().equals("open")) {
|
||||
if(milestoneStatus.getText().toString().equals("open")) {
|
||||
|
||||
closeMilestone.setVisibility(View.VISIBLE);
|
||||
openMilestone.setVisibility(View.GONE);
|
||||
closeMilestone.setVisibility(View.VISIBLE);
|
||||
openMilestone.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
|
||||
closeMilestone.setVisibility(View.GONE);
|
||||
openMilestone.setVisibility(View.VISIBLE);
|
||||
closeMilestone.setVisibility(View.GONE);
|
||||
openMilestone.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
closeMilestone.setOnClickListener(v12 -> {
|
||||
closeMilestone.setOnClickListener(v12 -> {
|
||||
|
||||
MilestoneActions.closeMilestone(ctx, milestoneId_);
|
||||
dialog.dismiss();
|
||||
updateAdapter(getAdapterPosition());
|
||||
MilestoneActions.closeMilestone(ctx, milestoneId_);
|
||||
dialog.dismiss();
|
||||
updateAdapter(getAdapterPosition());
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
openMilestone.setOnClickListener(v12 -> {
|
||||
openMilestone.setOnClickListener(v12 -> {
|
||||
|
||||
MilestoneActions.openMilestone(ctx, milestoneId_);
|
||||
dialog.dismiss();
|
||||
updateAdapter(getAdapterPosition());
|
||||
MilestoneActions.openMilestone(ctx, milestoneId_);
|
||||
dialog.dismiss();
|
||||
updateAdapter(getAdapterPosition());
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(Milestones dataModel) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
}
|
||||
|
||||
milestoneId.setText(String.valueOf(dataModel.getId()));
|
||||
milestoneStatus.setText(dataModel.getState());
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(Milestones dataModel) {
|
||||
|
||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(context))
|
||||
.usePlugin(CorePlugin.create())
|
||||
.usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
|
||||
final int resourceId = context.getResources().getIdentifier(
|
||||
raw.substring("drawable://".length()),
|
||||
"drawable",
|
||||
context.getPackageName());
|
||||
|
||||
final Drawable drawable = context.getDrawable(resourceId);
|
||||
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(context.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(context.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
}))
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
builder
|
||||
.codeTextColor(tinyDb.getInt("codeBlockColor"))
|
||||
.codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
|
||||
.linkColor(context.getResources().getColor(R.color.lightBlue));
|
||||
}
|
||||
})
|
||||
.usePlugin(TablePlugin.create(context))
|
||||
.usePlugin(TaskListPlugin.create(context))
|
||||
.usePlugin(HtmlPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(LinkifyPlugin.create())
|
||||
.build();
|
||||
|
||||
Spanned msTitle_ = markwon.toMarkdown(dataModel.getTitle());
|
||||
markwon.setParsedMarkdown(msTitle, msTitle_);
|
||||
|
||||
if(dataModel.getState().equals("open")) {
|
||||
|
||||
@SuppressLint("ResourceType") int color = Color.parseColor(context.getResources().getString(R.color.releaseStable));
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
//.useFont(Typeface.DEFAULT)
|
||||
.textColor(context.getResources().getColor(R.color.white))
|
||||
.fontSize(30)
|
||||
.toUpperCase()
|
||||
.width(120)
|
||||
.height(60)
|
||||
.endConfig()
|
||||
.buildRoundRect("open", color, 8);
|
||||
|
||||
msStatus.setImageDrawable(drawable);
|
||||
|
||||
}
|
||||
else if(dataModel.getState().equals("closed")) {
|
||||
|
||||
@SuppressLint("ResourceType") int color = Color.parseColor(context.getResources().getString(R.color.colorRed));
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
//.useFont(Typeface.DEFAULT)
|
||||
.textColor(context.getResources().getColor(R.color.white))
|
||||
.fontSize(30)
|
||||
.toUpperCase()
|
||||
.width(140)
|
||||
.height(60)
|
||||
.endConfig()
|
||||
.buildRoundRect("closed", color, 8);
|
||||
|
||||
msStatus.setImageDrawable(drawable);
|
||||
|
||||
}
|
||||
|
||||
if (!dataModel.getDescription().equals("")) {
|
||||
final CharSequence bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(dataModel.getDescription()));
|
||||
msDescription.setText(bodyWithMD);
|
||||
}
|
||||
else {
|
||||
msDescription.setText("");
|
||||
}
|
||||
|
||||
msOpenIssues.setText(String.valueOf(dataModel.getOpen_issues()));
|
||||
msOpenIssues.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneOpenIssues, dataModel.getOpen_issues()), context));
|
||||
|
||||
msClosedIssues.setText(String.valueOf(dataModel.getClosed_issues()));
|
||||
msClosedIssues.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneClosedIssues, dataModel.getClosed_issues()), context));
|
||||
|
||||
if ((dataModel.getOpen_issues() + dataModel.getClosed_issues()) > 0) {
|
||||
|
||||
if (dataModel.getOpen_issues() == 0) {
|
||||
msProgress.setProgress(100);
|
||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 100), context));
|
||||
}
|
||||
else {
|
||||
int msCompletion = 100 * dataModel.getClosed_issues() / (dataModel.getOpen_issues() + dataModel.getClosed_issues());
|
||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, msCompletion), context));
|
||||
msProgress.setProgress(msCompletion);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
msProgress.setProgress(0);
|
||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 0), context));
|
||||
}
|
||||
|
||||
if(dataModel.getDue_on() != null) {
|
||||
|
||||
if (timeFormat.equals("normal") || timeFormat.equals("pretty")) {
|
||||
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
|
||||
Date date = null;
|
||||
try {
|
||||
date = formatter.parse(dataModel.getDue_on());
|
||||
}
|
||||
catch (ParseException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
assert date != null;
|
||||
String dueDate = formatter.format(date);
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
|
||||
if(date.before(new Date())) {
|
||||
msDueDate.setTextColor(context.getResources().getColor(R.color.darkRed));
|
||||
}
|
||||
milestoneId.setText(String.valueOf(dataModel.getId()));
|
||||
milestoneStatus.setText(dataModel.getState());
|
||||
|
||||
msDueDate.setText(dueDate);
|
||||
msDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToast(dataModel.getDue_on()), context));
|
||||
Markwon markwon = Markwon.builder(Objects.requireNonNull(context)).usePlugin(CorePlugin.create()).usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
|
||||
}
|
||||
else if (timeFormat.equals("normal1")) {
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale));
|
||||
Date date1 = null;
|
||||
try {
|
||||
date1 = formatter.parse(dataModel.getDue_on());
|
||||
}
|
||||
catch (ParseException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
assert date1 != null;
|
||||
String dueDate = formatter.format(date1);
|
||||
msDueDate.setText(dueDate);
|
||||
final int resourceId = context.getResources().getIdentifier(
|
||||
raw.substring("drawable://".length()),
|
||||
"drawable",
|
||||
context.getPackageName());
|
||||
|
||||
}
|
||||
final Drawable drawable = context.getDrawable(resourceId);
|
||||
|
||||
}
|
||||
else {
|
||||
msDueDate.setText("");
|
||||
}
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
}
|
||||
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(context.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(context.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
}))
|
||||
|
||||
dataList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, dataList.size());
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
builder
|
||||
.codeTextColor(tinyDb.getInt("codeBlockColor"))
|
||||
.codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
|
||||
.linkColor(context.getResources().getColor(R.color.lightBlue));
|
||||
}
|
||||
})
|
||||
.usePlugin(TablePlugin.create(context))
|
||||
.usePlugin(TaskListPlugin.create(context))
|
||||
.usePlugin(HtmlPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(LinkifyPlugin.create())
|
||||
.build();
|
||||
|
||||
}
|
||||
Spanned msTitle_ = markwon.toMarkdown(dataModel.getTitle());
|
||||
markwon.setParsedMarkdown(msTitle, msTitle_);
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if(!dataModel.getDescription().equals("")) {
|
||||
|
||||
if(dataList.get(position).getTitle() != null) {
|
||||
return TYPE_LOAD;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
CharSequence bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(dataModel.getDescription()));
|
||||
msDescription.setText(bodyWithMD);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
msDescription.setText(context.getString(R.string.milestoneNoDescription));
|
||||
}
|
||||
|
||||
return dataList.size();
|
||||
msOpenIssues.setText(context.getString(R.string.milestoneIssueStatusOpen, dataModel.getOpen_issues()));
|
||||
msClosedIssues.setText(context.getString(R.string.milestoneIssueStatusClosed, dataModel.getClosed_issues()));
|
||||
|
||||
}
|
||||
if((dataModel.getOpen_issues() + dataModel.getClosed_issues()) > 0) {
|
||||
|
||||
static class LoadHolder extends RecyclerView.ViewHolder {
|
||||
if(dataModel.getOpen_issues() == 0) {
|
||||
|
||||
LoadHolder(View itemView) {
|
||||
msProgress.setProgress(100);
|
||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 100), context));
|
||||
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
int msCompletion = 100 * dataModel.getClosed_issues() / (dataModel.getOpen_issues() + dataModel.getClosed_issues());
|
||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, msCompletion), context));
|
||||
msProgress.setProgress(msCompletion);
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
}
|
||||
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
msProgress.setProgress(0);
|
||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 0), context));
|
||||
|
||||
public void notifyDataChanged() {
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
if(dataModel.getDue_on() != null) {
|
||||
|
||||
}
|
||||
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
|
||||
Date date = null;
|
||||
|
||||
void onLoadMore();
|
||||
try {
|
||||
date = formatter.parse(dataModel.getDue_on());
|
||||
}
|
||||
catch(ParseException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
assert date != null;
|
||||
String dueDate = formatter.format(date);
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
if(date.before(new Date())) {
|
||||
msDueDate.setTextColor(context.getResources().getColor(R.color.darkRed));
|
||||
}
|
||||
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
msDueDate.setText(dueDate);
|
||||
msDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToast(dataModel.getDue_on()), context));
|
||||
|
||||
}
|
||||
}
|
||||
else if(timeFormat.equals("normal1")) {
|
||||
|
||||
public void updateList(List<Milestones> list) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale));
|
||||
|
||||
dataList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
Date date1 = null;
|
||||
|
||||
try {
|
||||
date1 = formatter.parse(dataModel.getDue_on());
|
||||
}
|
||||
catch(ParseException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
|
||||
assert date1 != null;
|
||||
String dueDate = formatter.format(date1);
|
||||
msDueDate.setText(dueDate);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
msDueDate.setText(context.getString(R.string.milestoneNoDueDate));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
|
||||
dataList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, dataList.size());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
|
||||
if(dataList.get(position).getTitle() != null) {
|
||||
return TYPE_LOAD;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return dataList.size();
|
||||
|
||||
}
|
||||
|
||||
static class LoadHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
LoadHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
|
||||
}
|
||||
|
||||
public void notifyDataChanged() {
|
||||
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
|
||||
}
|
||||
|
||||
public void updateList(List<Milestones> list) {
|
||||
|
||||
dataList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.MultiSelectDialog;
|
||||
import org.mian.gitnex.models.MultiSelectModel;
|
||||
import java.util.ArrayList;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatCheckBox;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.MultiSelectDialog;
|
||||
import org.mian.gitnex.models.MultiSelectModel;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author com.github.abumoallim, modified by M M Arif
|
||||
@ -26,11 +26,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class MutliSelectAdapter extends RecyclerView.Adapter<MutliSelectAdapter.MultiSelectDialogViewHolder> {
|
||||
|
||||
private ArrayList<MultiSelectModel> mDataSet;
|
||||
private List<MultiSelectModel> mDataSet;
|
||||
private String mSearchQuery = "";
|
||||
private Context mContext;
|
||||
|
||||
public MutliSelectAdapter(ArrayList<MultiSelectModel> dataSet, Context context) {
|
||||
public MutliSelectAdapter(List<MultiSelectModel> dataSet, Context context) {
|
||||
this.mDataSet = dataSet;
|
||||
this.mContext = context;
|
||||
}
|
||||
@ -163,7 +163,7 @@ public class MutliSelectAdapter extends RecyclerView.Adapter<MutliSelectAdapter.
|
||||
return mDataSet.size();
|
||||
}
|
||||
|
||||
public void setData(ArrayList<MultiSelectModel> data, String query, MutliSelectAdapter mutliSelectAdapter) {
|
||||
public void setData(List<MultiSelectModel> data, String query, MutliSelectAdapter mutliSelectAdapter) {
|
||||
|
||||
this.mDataSet = data;
|
||||
this.mSearchQuery = query;
|
||||
@ -187,4 +187,4 @@ public class MutliSelectAdapter extends RecyclerView.Adapter<MutliSelectAdapter.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,10 @@ import android.widget.CheckBox;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
@ -22,15 +25,15 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -40,258 +43,297 @@ import retrofit2.Callback;
|
||||
|
||||
public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.MyReposViewHolder> implements Filterable {
|
||||
|
||||
private List<UserRepositories> reposList;
|
||||
private Context mCtx;
|
||||
private List<UserRepositories> reposListFull;
|
||||
private List<UserRepositories> reposList;
|
||||
private Context mCtx;
|
||||
private List<UserRepositories> reposListFull;
|
||||
|
||||
static class MyReposViewHolder extends RecyclerView.ViewHolder {
|
||||
static class MyReposViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView imageAvatar;
|
||||
private TextView repoName;
|
||||
private TextView repoDescription;
|
||||
private TextView repoFullName;
|
||||
private ImageView repoPrivatePublic;
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
private TextView repoType;
|
||||
private CheckBox isRepoAdmin;
|
||||
private ImageView imageAvatar;
|
||||
private TextView repoName;
|
||||
private TextView repoDescription;
|
||||
private TextView repoFullName;
|
||||
private ImageView repoPrivatePublic;
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
private TextView repoType;
|
||||
private CheckBox isRepoAdmin;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
|
||||
private MyReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||
imageAvatar = itemView.findViewById(R.id.imageAvatar);
|
||||
repoFullName = itemView.findViewById(R.id.repoFullName);
|
||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
||||
repoStars = itemView.findViewById(R.id.repoStars);
|
||||
repoForks = itemView.findViewById(R.id.repoForks);
|
||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||
private MyReposViewHolder(View itemView) {
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
super(itemView);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||
imageAvatar = itemView.findViewById(R.id.imageAvatar);
|
||||
repoFullName = itemView.findViewById(R.id.repoFullName);
|
||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
||||
repoStars = itemView.findViewById(R.id.repoStars);
|
||||
repoForks = itemView.findViewById(R.id.repoForks);
|
||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
|
||||
Context context = v.getContext();
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||
Context context = v.getContext();
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String[] parts = repoFullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
String[] parts = repoFullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
Call<WatchInfo> call;
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
if(count == 0) {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
}
|
||||
else {
|
||||
|
||||
assert response.body() != null;
|
||||
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
} else {
|
||||
}
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
if(response.code() != 404) {
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
WatchInfo watch = new WatchInfo();
|
||||
|
||||
}
|
||||
Call<WatchInfo> call;
|
||||
|
||||
}
|
||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
}
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
assert response.body() != null;
|
||||
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||
|
||||
context.startActivity(intent);
|
||||
}
|
||||
else {
|
||||
|
||||
});
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
|
||||
reposDropdownMenu.setOnClickListener(v -> {
|
||||
if(response.code() != 404) {
|
||||
|
||||
final Context context = v.getContext();
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||
}
|
||||
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
}
|
||||
|
||||
bottomSheetHeader.setText(repoFullName.getText());
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", repoFullName.getText());
|
||||
context.startActivity(intentOpenInBrowser);
|
||||
dialog.dismiss();
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
repoStargazers.setOnClickListener(stargazers -> {
|
||||
}
|
||||
|
||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
||||
intent.putExtra("repoFullNameForStars", repoFullName.getText());
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
context.startActivity(intent);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
repoWatchers.setOnClickListener(watchers -> {
|
||||
reposDropdownMenu.setOnClickListener(v -> {
|
||||
|
||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
||||
intentW.putExtra("repoFullNameForWatchers", repoFullName.getText());
|
||||
context.startActivity(intentW);
|
||||
dialog.dismiss();
|
||||
final Context context = v.getContext();
|
||||
|
||||
});
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||
|
||||
});
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
}
|
||||
}
|
||||
bottomSheetHeader.setText(String.format("%s / %s", repoFullName.getText().toString().split("/")[0], repoFullName.getText().toString().split("/")[1]));
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
public MyReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
||||
this.mCtx = mCtx;
|
||||
this.reposList = reposListMain;
|
||||
reposListFull = new ArrayList<>(reposList);
|
||||
}
|
||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyReposListAdapter.MyReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repositories, parent, false);
|
||||
return new MyReposListAdapter.MyReposViewHolder(v);
|
||||
}
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", repoFullName.getText());
|
||||
context.startActivity(intentOpenInBrowser);
|
||||
dialog.dismiss();
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyReposListAdapter.MyReposViewHolder holder, int position) {
|
||||
});
|
||||
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
repoStargazers.setOnClickListener(stargazers -> {
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
||||
intent.putExtra("repoFullNameForStars", repoFullName.getText());
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.fontSize(18)
|
||||
.toUpperCase()
|
||||
.width(28)
|
||||
.height(28)
|
||||
.endConfig()
|
||||
.buildRoundRect(firstCharacter, color, 3);
|
||||
});
|
||||
|
||||
if (currentItem.getAvatar_url() != null) {
|
||||
if (!currentItem.getAvatar_url().equals("")) {
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.imageAvatar);
|
||||
} else {
|
||||
holder.imageAvatar.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
holder.imageAvatar.setImageDrawable(drawable);
|
||||
}
|
||||
repoWatchers.setOnClickListener(watchers -> {
|
||||
|
||||
holder.repoName.setText(currentItem.getName());
|
||||
if (!currentItem.getDescription().equals("")) {
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.repoFullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
holder.repoForks.setText(currentItem.getForks_count());
|
||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
||||
intentW.putExtra("repoFullNameForWatchers", repoFullName.getText());
|
||||
context.startActivity(intentW);
|
||||
dialog.dismiss();
|
||||
|
||||
if(holder.isRepoAdmin == null) {
|
||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
||||
}
|
||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return reposList.size();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return myReposFilter;
|
||||
}
|
||||
}
|
||||
|
||||
private Filter myReposFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<UserRepositories> filteredList = new ArrayList<>();
|
||||
public MyReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(reposListFull);
|
||||
} else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
this.mCtx = mCtx;
|
||||
this.reposList = reposListMain;
|
||||
reposListFull = new ArrayList<>(reposList);
|
||||
}
|
||||
|
||||
for (UserRepositories item : reposListFull) {
|
||||
if (item.getFullname().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public MyReposListAdapter.MyReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repositories, parent, false);
|
||||
return new MyReposListAdapter.MyReposViewHolder(v);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyReposListAdapter.MyReposViewHolder holder, int position) {
|
||||
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(currentItem.getAvatar_url() != null) {
|
||||
if(!currentItem.getAvatar_url().equals("")) {
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.imageAvatar);
|
||||
}
|
||||
else {
|
||||
holder.imageAvatar.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
holder.imageAvatar.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
holder.repoName.setText(currentItem.getName());
|
||||
if(!currentItem.getDescription().equals("")) {
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.repoFullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
holder.repoForks.setText(currentItem.getForks_count());
|
||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
||||
|
||||
if(holder.isRepoAdmin == null) {
|
||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
||||
}
|
||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||
|
||||
if(currentItem.isArchived()) {
|
||||
holder.archiveRepo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.archiveRepo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return reposList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
|
||||
return myReposFilter;
|
||||
}
|
||||
|
||||
private Filter myReposFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<UserRepositories> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(reposListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(UserRepositories item : reposListFull) {
|
||||
if(item.getFullname().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
reposList.clear();
|
||||
reposList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
reposList.clear();
|
||||
reposList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,156 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.NotificationThread;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author opyale
|
||||
*/
|
||||
|
||||
public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdapter.NotificationsViewHolder> {
|
||||
|
||||
private Context context;
|
||||
private List<NotificationThread> notificationThreads;
|
||||
private OnMoreClickedListener onMoreClickedListener;
|
||||
private OnNotificationClickedListener onNotificationClickedListener;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
|
||||
|
||||
this.tinyDb = new TinyDB(context);
|
||||
this.context = context;
|
||||
this.notificationThreads = notificationThreads;
|
||||
this.onMoreClickedListener = onMoreClickedListener;
|
||||
this.onNotificationClickedListener = onNotificationClickedListener;
|
||||
|
||||
}
|
||||
|
||||
static class NotificationsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private LinearLayout frame;
|
||||
private TextView subject;
|
||||
private TextView repository;
|
||||
private ImageView type;
|
||||
private ImageView pinned;
|
||||
private ImageView more;
|
||||
|
||||
public NotificationsViewHolder(@NonNull View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
frame = itemView.findViewById(R.id.frame);
|
||||
subject = itemView.findViewById(R.id.subject);
|
||||
repository = itemView.findViewById(R.id.repository);
|
||||
type = itemView.findViewById(R.id.type);
|
||||
pinned = itemView.findViewById(R.id.pinned);
|
||||
more = itemView.findViewById(R.id.more);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public NotificationsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.list_notifications, parent, false);
|
||||
return new NotificationsAdapter.NotificationsViewHolder(v);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull NotificationsViewHolder holder, int position) {
|
||||
|
||||
NotificationThread notificationThread = notificationThreads.get(position);
|
||||
|
||||
String url = notificationThread.getSubject().getUrl();
|
||||
String subjectId = "<font color='" + context.getResources().getColor(R.color.lightGray) + "'>" + context.getResources()
|
||||
.getString(R.string.hash) + url.substring(url.lastIndexOf("/") + 1) + "</font>";
|
||||
|
||||
holder.subject.setText(Html.fromHtml(subjectId + " " + notificationThread.getSubject().getTitle()));
|
||||
holder.repository.setText(notificationThread.getRepository().getFullname());
|
||||
|
||||
if(notificationThread.isPinned()) {
|
||||
holder.pinned.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.pinned.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
switch(notificationThread.getSubject().getType()) {
|
||||
|
||||
case "Pull":
|
||||
holder.type.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_pull_request, null));
|
||||
break;
|
||||
|
||||
case "Issue":
|
||||
holder.type.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_issue, null));
|
||||
break;
|
||||
|
||||
default:
|
||||
holder.type.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_question, null));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
holder.frame.setOnClickListener(v -> {
|
||||
|
||||
onNotificationClickedListener.onNotificationClicked(notificationThread);
|
||||
|
||||
String[] parts = notificationThread.getRepository().getFullname().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
holder.more.setOnClickListener(v -> onMoreClickedListener.onMoreClicked(notificationThread));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return notificationThreads.size();
|
||||
}
|
||||
|
||||
public interface OnNotificationClickedListener {
|
||||
|
||||
void onNotificationClicked(NotificationThread notificationThread);
|
||||
}
|
||||
|
||||
public interface OnMoreClickedListener {
|
||||
|
||||
void onMoreClicked(NotificationThread notificationThread);
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -12,12 +10,14 @@ import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.models.UserOrganizations;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.UserOrganizations;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -18,8 +18,8 @@ import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.PullRequests;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -136,7 +136,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
tinyDb.putString("prHeadBranch", prHeadBranch.getText().toString());
|
||||
tinyDb.putString("prIsFork", prIsFork.getText().toString());
|
||||
tinyDb.putString("prForkFullName", prForkFullName.getText().toString());
|
||||
tinyDb.putString("issueType", "pr");
|
||||
tinyDb.putString("issueType", "Pull");
|
||||
context.startActivity(intent);
|
||||
|
||||
});
|
||||
@ -155,7 +155,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
tinyDb.putString("prHeadBranch", prHeadBranch.getText().toString());
|
||||
tinyDb.putString("prIsFork", prIsFork.getText().toString());
|
||||
tinyDb.putString("prForkFullName", prForkFullName.getText().toString());
|
||||
tinyDb.putString("issueType", "pr");
|
||||
tinyDb.putString("issueType", "Pull");
|
||||
context.startActivity(intent);
|
||||
|
||||
});
|
||||
@ -188,9 +188,18 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
prNumber.setText(String.valueOf(prModel.getNumber()));
|
||||
prMergeable.setText(String.valueOf(prModel.isMergeable()));
|
||||
prHeadBranch.setText(prModel.getHead().getRef());
|
||||
prIsFork.setText(String.valueOf(prModel.getHead().getRepo().isFork()));
|
||||
prForkFullName.setText(prModel.getHead().getRepo().getFull_name());
|
||||
if(prModel.getHead() != null) {
|
||||
prHeadBranch.setText(prModel.getHead().getRef());
|
||||
if(prModel.getHead().getRepo() != null) {
|
||||
prIsFork.setText(String.valueOf(prModel.getHead().getRepo().isFork()));
|
||||
prForkFullName.setText(prModel.getHead().getRepo().getFull_name());
|
||||
}
|
||||
else {
|
||||
// pull was done from a deleted fork
|
||||
prIsFork.setText("true");
|
||||
prForkFullName.setText(context.getString(R.string.prDeletedFrok));
|
||||
}
|
||||
}
|
||||
prCommentsCount.setText(String.valueOf(prModel.getComments()));
|
||||
|
||||
prCreatedTime.setText(TimeHelper.formatTime(prModel.getCreated_at(), new Locale(locale), timeFormat, context));
|
||||
|
@ -10,19 +10,25 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Releases;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.core.CorePlugin;
|
||||
@ -31,7 +37,6 @@ import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.ext.tables.TablePlugin;
|
||||
import io.noties.markwon.ext.tasklist.TaskListPlugin;
|
||||
import io.noties.markwon.html.HtmlPlugin;
|
||||
import io.noties.markwon.image.AsyncDrawable;
|
||||
import io.noties.markwon.image.DefaultMediaDecoder;
|
||||
import io.noties.markwon.image.ImageItem;
|
||||
import io.noties.markwon.image.ImagesPlugin;
|
||||
@ -49,25 +54,44 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
private List<Releases> releasesList;
|
||||
private Context mCtx;
|
||||
|
||||
static class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
||||
static class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView releaseType;
|
||||
private TextView releaseTitle;
|
||||
private TextView releaseDescription;
|
||||
private TextView releaseDownload;
|
||||
private TextView releaseZipDownload;
|
||||
private TextView releaseTarDownload;
|
||||
private TextView releaseType;
|
||||
private TextView releaseName;
|
||||
private ImageView authorAvatar;
|
||||
private TextView authorName;
|
||||
private TextView releaseTag;
|
||||
private TextView releaseCommitSha;
|
||||
private TextView releaseDate;
|
||||
private TextView releaseBodyContent;
|
||||
private LinearLayout downloadFrame;
|
||||
private RelativeLayout downloads;
|
||||
private TextView releaseZipDownload;
|
||||
private TextView releaseTarDownload;
|
||||
private ImageView downloadDropdownIcon;
|
||||
private RecyclerView downloadList;
|
||||
|
||||
private ReleasesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
releaseType = itemView.findViewById(R.id.releaseType);
|
||||
releaseTitle = itemView.findViewById(R.id.releaseTitle);
|
||||
releaseDescription = itemView.findViewById(R.id.releaseDescription);
|
||||
releaseZipDownload = itemView.findViewById(R.id.releaseZipDownload);
|
||||
releaseTarDownload = itemView.findViewById(R.id.releaseTarDownload);
|
||||
releaseTag = itemView.findViewById(R.id.releaseTag);
|
||||
releaseType = itemView.findViewById(R.id.releaseType);
|
||||
releaseName = itemView.findViewById(R.id.releaseName);
|
||||
authorAvatar = itemView.findViewById(R.id.authorAvatar);
|
||||
authorName = itemView.findViewById(R.id.authorName);
|
||||
releaseTag = itemView.findViewById(R.id.releaseTag);
|
||||
releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha);
|
||||
releaseDate = itemView.findViewById(R.id.releaseDate);
|
||||
releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent);
|
||||
downloadFrame = itemView.findViewById(R.id.downloadFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownload = itemView.findViewById(R.id.releaseZipDownload);
|
||||
releaseTarDownload = itemView.findViewById(R.id.releaseTarDownload);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
downloadList = itemView.findViewById(R.id.downloadList);
|
||||
|
||||
downloadList.setHasFixedSize(true);
|
||||
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
|
||||
|
||||
}
|
||||
}
|
||||
@ -88,83 +112,74 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
|
||||
Releases currentItem = releasesList.get(position);
|
||||
|
||||
holder.releaseTitle.setText(currentItem.getName());
|
||||
holder.releaseName.setText(currentItem.getName());
|
||||
|
||||
if(!currentItem.getTag_name().equals("")) {
|
||||
holder.releaseTag.setText(mCtx.getResources().getString(R.string.releaseTag, currentItem.getTag_name()));
|
||||
}
|
||||
else {
|
||||
holder.releaseTag.setVisibility(View.GONE);
|
||||
}
|
||||
if(currentItem.isPrerelease()) {
|
||||
holder.releaseType.setBackgroundResource(R.drawable.shape_pre_release);
|
||||
holder.releaseType.setText(R.string.releaseTypePre);
|
||||
}
|
||||
else if(currentItem.isDraft()) {
|
||||
holder.releaseType.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
holder.releaseType.setBackgroundResource(R.drawable.shape_stable_release);
|
||||
holder.releaseType.setText(R.string.releaseTypeStable);
|
||||
}
|
||||
|
||||
if(currentItem.isPrerelease()) {
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
//.useFont(Typeface.DEFAULT)
|
||||
.textColor(mCtx.getResources().getColor(R.color.white))
|
||||
.fontSize(34)
|
||||
.width(260)
|
||||
.height(60)
|
||||
.endConfig()
|
||||
.buildRoundRect(mCtx.getResources().getString(R.string.releaseTypePre), mCtx.getResources().getColor(R.color.releasePre), 8);
|
||||
holder.releaseType.setImageDrawable(drawable);
|
||||
}
|
||||
else {
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
//.useFont(Typeface.DEFAULT)
|
||||
.textColor(mCtx.getResources().getColor(R.color.white))
|
||||
.fontSize(34)
|
||||
.width(260)
|
||||
.height(60)
|
||||
.endConfig()
|
||||
.buildRoundRect(mCtx.getResources().getString(R.string.releaseTypeStable), mCtx.getResources().getColor(R.color.releaseStable), 8);
|
||||
holder.releaseType.setImageDrawable(drawable);
|
||||
}
|
||||
if(currentItem.getAuthor().getAvatar_url() != null) {
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAuthor().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.authorAvatar);
|
||||
}
|
||||
|
||||
holder.authorName.setText(mCtx.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getUsername()));
|
||||
|
||||
if(currentItem.getTag_name() != null) {
|
||||
holder.releaseTag.setText(currentItem.getTag_name());
|
||||
}
|
||||
|
||||
if(currentItem.getPublished_at() != null) {
|
||||
holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublished_at(), new Locale(locale), timeFormat, mCtx));
|
||||
}
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublished_at()), mCtx));
|
||||
}
|
||||
|
||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(mCtx))
|
||||
.usePlugin(CorePlugin.create())
|
||||
.usePlugin(ImagesPlugin.create(new ImagesPlugin.ImagesConfigure() {
|
||||
@Override
|
||||
public void configureImages(@NonNull ImagesPlugin plugin) {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
.usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
|
||||
final int resourceId = mCtx.getResources().getIdentifier(
|
||||
raw.substring("drawable://".length()),
|
||||
"drawable",
|
||||
mCtx.getPackageName());
|
||||
final int resourceId = mCtx.getResources().getIdentifier(
|
||||
raw.substring("drawable://".length()),
|
||||
"drawable",
|
||||
mCtx.getPackageName());
|
||||
|
||||
final Drawable drawable = mCtx.getDrawable(resourceId);
|
||||
final Drawable drawable = mCtx.getDrawable(resourceId);
|
||||
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
}
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
plugin.placeholderProvider(new ImagesPlugin.PlaceholderProvider() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Drawable providePlaceholder(@NonNull AsyncDrawable drawable) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(mCtx.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(mCtx.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(mCtx.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(mCtx.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
}))
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
@ -185,12 +200,29 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
Spanned bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(currentItem.getBody()));
|
||||
|
||||
if(!currentItem.getBody().equals("")) {
|
||||
markwon.setParsedMarkdown(holder.releaseDescription, bodyWithMD);
|
||||
markwon.setParsedMarkdown(holder.releaseBodyContent, bodyWithMD);
|
||||
}
|
||||
else {
|
||||
holder.releaseDescription.setVisibility(View.GONE);
|
||||
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
|
||||
}
|
||||
|
||||
holder.downloadFrame.setOnClickListener(v -> {
|
||||
|
||||
if(holder.downloads.getVisibility() == View.GONE) {
|
||||
|
||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_down);
|
||||
holder.downloads.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_right);
|
||||
holder.downloads.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
holder.releaseZipDownload.setText(
|
||||
Html.fromHtml("<a href='" + currentItem.getZipball_url() + "'>" + mCtx.getResources().getString(R.string.zipArchiveDownloadReleasesTab) + "</a> "));
|
||||
holder.releaseZipDownload.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
@ -199,6 +231,9 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
||||
Html.fromHtml("<a href='" + currentItem.getTarball_url() + "'>" + mCtx.getResources().getString(R.string.tarArchiveDownloadReleasesTab) + "</a> "));
|
||||
holder.releaseTarDownload.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
ReleasesDownloadsAdapter adapter = new ReleasesDownloadsAdapter(currentItem.getAssets());
|
||||
holder.downloadList.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,68 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.models.Releases;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
**/
|
||||
|
||||
public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownloadsAdapter.ReleasesDownloadsViewHolder> {
|
||||
|
||||
private List<Releases.assetsObject> releasesDownloadsList;
|
||||
|
||||
static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView downloadName;
|
||||
|
||||
private ReleasesDownloadsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
downloadName = itemView.findViewById(R.id.downloadName);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ReleasesDownloadsAdapter(List<Releases.assetsObject> releasesDownloadsMain) {
|
||||
|
||||
this.releasesDownloadsList = releasesDownloadsMain;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ReleasesDownloadsAdapter.ReleasesDownloadsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_releases_downloads, parent, false);
|
||||
return new ReleasesDownloadsAdapter.ReleasesDownloadsViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ReleasesDownloadsAdapter.ReleasesDownloadsViewHolder holder, int position) {
|
||||
|
||||
Releases.assetsObject currentItem = releasesDownloadsList.get(position);
|
||||
|
||||
if(currentItem.getName() != null) {
|
||||
|
||||
holder.downloadName.setText(
|
||||
Html.fromHtml("<a href='" + currentItem.getBrowser_download_url() + "'>" + currentItem.getName() + "</a> "));
|
||||
holder.downloadName.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return releasesDownloadsList.size();
|
||||
}
|
||||
|
||||
}
|
@ -12,8 +12,8 @@ import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -109,13 +109,6 @@ public class RepoStargazersAdapter extends BaseAdapter {
|
||||
viewHolder.memberName.setTypeface(myTypeface);
|
||||
}
|
||||
|
||||
if(tinyDb.getInt("themeId") == 1) { //light
|
||||
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.lightThemeTextColor));
|
||||
}
|
||||
else { // dark
|
||||
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.white));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -109,13 +109,6 @@ public class RepoWatchersAdapter extends BaseAdapter {
|
||||
viewHolder.memberName.setTypeface(myTypeface);
|
||||
}
|
||||
|
||||
if(tinyDb.getInt("themeId") == 1) { //light
|
||||
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.lightThemeTextColor));
|
||||
}
|
||||
else { // dark
|
||||
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.white));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import android.widget.CheckBox;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@ -24,11 +25,13 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -56,6 +59,8 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
|
||||
private ReposViewHolder(View itemView) {
|
||||
|
||||
@ -71,6 +76,8 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -86,13 +93,35 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
||||
|
||||
String[] parts = repoFullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String[] parts = repoFullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
@ -133,6 +162,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
@ -150,7 +180,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(fullName.getText());
|
||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
@ -208,6 +238,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -234,11 +265,11 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
@ -249,6 +280,13 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
}
|
||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||
|
||||
if(currentItem.isArchived()) {
|
||||
holder.archiveRepo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.archiveRepo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,10 @@ import android.widget.CheckBox;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
@ -22,15 +25,15 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -56,6 +59,8 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
|
||||
private OrgReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -70,6 +75,8 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -83,16 +90,36 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
||||
|
||||
String[] parts = fullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String[] parts = fullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
@ -130,6 +157,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
@ -147,7 +175,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(fullName.getText());
|
||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
@ -203,6 +231,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -236,11 +265,11 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
@ -252,6 +281,13 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
}
|
||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||
|
||||
if(currentItem.isArchived()) {
|
||||
holder.archiveRepo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.archiveRepo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,10 @@ import android.widget.CheckBox;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
@ -22,15 +25,15 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -56,6 +59,8 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
|
||||
private StarredReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -70,6 +75,8 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -83,13 +90,35 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
||||
|
||||
String[] parts = fullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String[] parts = fullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
@ -130,6 +159,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
@ -148,7 +178,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(fullName.getText());
|
||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
@ -204,6 +234,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -237,11 +268,11 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
@ -252,6 +283,13 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
}
|
||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||
|
||||
if(currentItem.isArchived()) {
|
||||
holder.archiveRepo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.archiveRepo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,10 +11,9 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.FontsOverride;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -111,12 +110,5 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
|
||||
viewHolder.memberName.setTypeface(myTypeface);
|
||||
}
|
||||
|
||||
if(tinyDb.getInt("themeId") == 1) { //light
|
||||
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.lightThemeTextColor));
|
||||
}
|
||||
else { // dark
|
||||
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.white));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,116 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapter.UserAccountsViewHolder> {
|
||||
|
||||
private List<UserAccount> userAccountsList;
|
||||
private Context mCtx;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
static class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView accountUrl;
|
||||
private TextView userId;
|
||||
private ImageView activeAccount;
|
||||
private ImageView deleteAccount;
|
||||
private ImageView repoAvatar;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
accountUrl = itemView.findViewById(R.id.accountUrl);
|
||||
userId = itemView.findViewById(R.id.userId);
|
||||
activeAccount = itemView.findViewById(R.id.activeAccount);
|
||||
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
||||
repoAvatar = itemView.findViewById(R.id.repoAvatar);
|
||||
|
||||
deleteAccount.setOnClickListener(itemDelete -> {
|
||||
// use later to delete an account
|
||||
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(itemEdit -> {
|
||||
// use later to switch account
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public UserAccountsAdapter(Context mCtx, List<UserAccount> userAccountsListMain) {
|
||||
|
||||
this.mCtx = mCtx;
|
||||
this.userAccountsList = userAccountsListMain;
|
||||
}
|
||||
|
||||
private void deleteAccount(int position) {
|
||||
|
||||
userAccountsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, userAccountsList.size());
|
||||
Toasty.info(mCtx, mCtx.getResources().getString(R.string.accountDeletedMessage));
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public UserAccountsAdapter.UserAccountsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_user_accounts, parent, false);
|
||||
return new UserAccountsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
||||
|
||||
UserAccount currentItem = userAccountsList.get(position);
|
||||
tinyDB = new TinyDB(mCtx);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
|
||||
holder.userId.setText(String.format("@%s", currentItem.getUserName()));
|
||||
holder.accountUrl.setText(url);
|
||||
|
||||
PicassoService.getInstance(mCtx).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.repoAvatar);
|
||||
|
||||
if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) {
|
||||
holder.activeAccount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.deleteAccount.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return userAccountsList.size();
|
||||
}
|
||||
|
||||
}
|
@ -9,6 +9,9 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.CollaboratorActions;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -16,13 +19,10 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -14,9 +14,9 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -104,12 +104,11 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
|
||||
if (!currentItem.getFullname().equals("")) {
|
||||
holder.userFullName.setText(currentItem.getFullname());
|
||||
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
}
|
||||
else {
|
||||
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
}
|
||||
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
|
||||
if (!currentItem.getAvatar().equals("")) {
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||
@ -123,7 +122,6 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
Call<UserInfo> call = RetrofitClient
|
||||
|
@ -2,10 +2,10 @@ package org.mian.gitnex.clients;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FilesData;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.io.File;
|
||||
import java.security.SecureRandom;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
@ -27,7 +27,7 @@ public class AppApiService {
|
||||
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context ctx) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||
final boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||
int cacheSize = FilesData.returnOnlyNumber(tinyDb.getString("cacheSizeStr")) * 1024 * 1024;
|
||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||
|
@ -14,16 +14,18 @@ import javax.net.ssl.X509TrustManager;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
/**
|
||||
* Author anonTree1417
|
||||
* Author opyale
|
||||
*/
|
||||
|
||||
public class PicassoService {
|
||||
|
||||
private static PicassoService picassoService;
|
||||
private static File cachePath;
|
||||
private Picasso picasso;
|
||||
|
||||
private PicassoService(Context context) {
|
||||
|
||||
cachePath = new File(context.getCacheDir() + "/picasso_cache/");
|
||||
Picasso.Builder builder = new Picasso.Builder(context);
|
||||
|
||||
try {
|
||||
@ -45,10 +47,6 @@ public class PicassoService {
|
||||
|
||||
});
|
||||
|
||||
File cachePath = new File(context.getCacheDir() + "/picasso_cache/");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
cachePath.mkdirs();
|
||||
|
||||
picasso = builder.memoryCache(new PicassoCache(cachePath, context)).build();
|
||||
|
||||
}
|
||||
@ -61,7 +59,9 @@ public class PicassoService {
|
||||
|
||||
public Picasso get() {
|
||||
|
||||
cachePath.mkdirs();
|
||||
return picasso;
|
||||
|
||||
}
|
||||
|
||||
public static synchronized PicassoService getInstance(Context context) {
|
||||
|
@ -2,12 +2,12 @@ package org.mian.gitnex.clients;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.FilesData;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
import org.mian.gitnex.interfaces.ApiInterface;
|
||||
import org.mian.gitnex.interfaces.WebInterface;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.io.File;
|
||||
import java.security.SecureRandom;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
@ -32,7 +32,7 @@ public class RetrofitClient {
|
||||
private RetrofitClient(String instanceUrl, Context ctx) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||
final boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
int cacheSize = FilesData.returnOnlyNumber(tinyDb.getString("cacheSizeStr")) * 1024 * 1024;
|
||||
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||
|
125
app/src/main/java/org/mian/gitnex/database/api/DraftsApi.java
Normal file
125
app/src/main/java/org/mian/gitnex/database/api/DraftsApi.java
Normal file
@ -0,0 +1,125 @@
|
||||
package org.mian.gitnex.database.api;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import org.mian.gitnex.database.dao.DraftsDao;
|
||||
import org.mian.gitnex.database.db.GitnexDatabase;
|
||||
import org.mian.gitnex.database.models.Draft;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class DraftsApi {
|
||||
|
||||
private static DraftsDao draftsDao;
|
||||
private static long draftId;
|
||||
private static Integer checkDraftFlag;
|
||||
|
||||
public DraftsApi(Context context) {
|
||||
|
||||
GitnexDatabase db;
|
||||
db = GitnexDatabase.getDatabaseInstance(context);
|
||||
draftsDao = db.draftsDao();
|
||||
}
|
||||
|
||||
public long insertDraft(int repositoryId, int draftAccountId, int issueId, String draftText, String draftType) {
|
||||
|
||||
Draft draft = new Draft();
|
||||
draft.setDraftRepositoryId(repositoryId);
|
||||
draft.setDraftAccountId(draftAccountId);
|
||||
draft.setIssueId(issueId);
|
||||
draft.setDraftText(draftText);
|
||||
draft.setDraftType(draftType);
|
||||
|
||||
return insertDraftAsyncTask(draft);
|
||||
}
|
||||
|
||||
private static long insertDraftAsyncTask(final Draft draft) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> draftId = draftsDao.insertDraft(draft));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.draftsRepository, e.toString());
|
||||
}
|
||||
|
||||
return draftId;
|
||||
}
|
||||
|
||||
public long getDraftIdAsync(int issueId, int draftRepositoryId) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> draftId = draftsDao.getDraftId(issueId, draftRepositoryId));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.draftsRepository, e.toString());
|
||||
}
|
||||
|
||||
return draftId;
|
||||
}
|
||||
|
||||
public Integer checkDraft(int issueId, int draftRepositoryId) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> checkDraftFlag = draftsDao.checkDraftDao(issueId, draftRepositoryId));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.draftsRepository, e.toString());
|
||||
}
|
||||
|
||||
return checkDraftFlag;
|
||||
}
|
||||
|
||||
public LiveData<List<DraftWithRepository>> getDrafts(int accountId) {
|
||||
|
||||
return draftsDao.fetchAllDrafts(accountId);
|
||||
}
|
||||
|
||||
public LiveData<Draft> getDraftByIssueId(int issueId) {
|
||||
|
||||
return draftsDao.fetchDraftByIssueId(issueId);
|
||||
}
|
||||
|
||||
public void deleteSingleDraft(final int draftId) {
|
||||
|
||||
final LiveData<Draft> draft = draftsDao.fetchDraftById(draftId);
|
||||
|
||||
if(draft != null) {
|
||||
|
||||
new Thread(() -> draftsDao.deleteByDraftId(draftId)).start();
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteAllDrafts(final int accountId) {
|
||||
|
||||
new Thread(() -> draftsDao.deleteAllDrafts(accountId)).start();
|
||||
}
|
||||
|
||||
public static void updateDraft(final String draftText, final int draftId) {
|
||||
|
||||
new Thread(() -> draftsDao.updateDraft(draftText, draftId)).start();
|
||||
}
|
||||
|
||||
public static void updateDraftByIssueIdAsyncTask(final String draftText, final int issueId, final int draftRepositoryId) {
|
||||
|
||||
new Thread(() -> draftsDao.updateDraftByIssueId(draftText, issueId, draftRepositoryId)).start();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package org.mian.gitnex.database.api;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import org.mian.gitnex.database.dao.RepositoriesDao;
|
||||
import org.mian.gitnex.database.db.GitnexDatabase;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class RepositoriesApi {
|
||||
|
||||
private static RepositoriesDao repositoriesDao;
|
||||
private static long repositoryId;
|
||||
private static Repository repository;
|
||||
private static Integer checkRepository;
|
||||
|
||||
public RepositoriesApi(Context context) {
|
||||
|
||||
GitnexDatabase db;
|
||||
db = GitnexDatabase.getDatabaseInstance(context);
|
||||
repositoriesDao = db.repositoriesDao();
|
||||
}
|
||||
|
||||
public long insertRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
||||
|
||||
Repository repository = new Repository();
|
||||
repository.setRepoAccountId(repoAccountId);
|
||||
repository.setRepositoryOwner(repositoryOwner);
|
||||
repository.setRepositoryName(repositoryName);
|
||||
|
||||
return insertRepositoryAsyncTask(repository);
|
||||
}
|
||||
|
||||
public long insertRepositoryAsyncTask(Repository repository) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> repositoryId = repositoriesDao.newRepository(repository));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
||||
}
|
||||
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
public Repository getRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> repository = repositoriesDao.getSingleRepositoryDao(repoAccountId, repositoryOwner, repositoryName));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
public LiveData<List<Repository>> getAllRepositories() {
|
||||
|
||||
return repositoriesDao.fetchAllRepositories();
|
||||
}
|
||||
|
||||
public LiveData<List<Repository>> getAllRepositoriesByAccount(int repoAccountId) {
|
||||
|
||||
return repositoriesDao.getAllRepositoriesByAccountDao(repoAccountId);
|
||||
}
|
||||
|
||||
public Integer checkRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> checkRepository = repositoriesDao.checkRepositoryDao(repoAccountId, repositoryOwner, repositoryName));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
||||
}
|
||||
|
||||
return checkRepository;
|
||||
}
|
||||
|
||||
public Repository fetchRepositoryById(int repositoryId) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> repository = repositoriesDao.fetchRepositoryByIdDao(repositoryId));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
public Repository fetchRepositoryByAccountIdByRepositoryId(int repositoryId, int repoAccountId) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> repository = repositoriesDao.fetchRepositoryByAccountIdByRepositoryIdDao(repositoryId, repoAccountId));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
public static void deleteRepositoriesByAccount(final int repoAccountId) {
|
||||
|
||||
new Thread(() -> repositoriesDao.deleteRepositoriesByAccount(repoAccountId)).start();
|
||||
}
|
||||
|
||||
public static void deleteRepository(final int repositoryId) {
|
||||
|
||||
new Thread(() -> repositoriesDao.deleteRepository(repositoryId)).start();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package org.mian.gitnex.database.api;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import org.mian.gitnex.database.dao.UserAccountsDao;
|
||||
import org.mian.gitnex.database.db.GitnexDatabase;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class UserAccountsApi {
|
||||
|
||||
private static UserAccountsDao userAccountsDao;
|
||||
private static UserAccount userAccount;
|
||||
private static Integer checkAccount;
|
||||
|
||||
public UserAccountsApi(Context context) {
|
||||
|
||||
GitnexDatabase db;
|
||||
db = GitnexDatabase.getDatabaseInstance(context);
|
||||
userAccountsDao = db.userAccountsDao();
|
||||
}
|
||||
|
||||
public void insertNewAccount(String accountName, String instanceUrl, String userName, String token, String serverVersion) {
|
||||
|
||||
UserAccount userAccount = new UserAccount();
|
||||
userAccount.setAccountName(accountName);
|
||||
userAccount.setInstanceUrl(instanceUrl);
|
||||
userAccount.setUserName(userName);
|
||||
userAccount.setToken(token);
|
||||
userAccount.setServerVersion(serverVersion);
|
||||
|
||||
insertNewAccountAsync(userAccount);
|
||||
}
|
||||
|
||||
private static void insertNewAccountAsync(final UserAccount userAccount) {
|
||||
|
||||
new Thread(() -> userAccountsDao.newAccount(userAccount)).start();
|
||||
}
|
||||
|
||||
public static void updateServerVersion(final String serverVersion, final int accountId) {
|
||||
|
||||
new Thread(() -> userAccountsDao.updateServerVersion(serverVersion, accountId)).start();
|
||||
}
|
||||
|
||||
public static void updateToken(final int accountId, final String token) {
|
||||
|
||||
new Thread(() -> userAccountsDao.updateAccountToken(accountId, token)).start();
|
||||
}
|
||||
|
||||
public UserAccount getAccountData(String accountName) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> userAccount = userAccountsDao.fetchRowByAccount_(accountName));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.userAccountsRepository, e.toString());
|
||||
}
|
||||
|
||||
return userAccount;
|
||||
}
|
||||
|
||||
public Integer getCount(String accountName) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> checkAccount = userAccountsDao.getCount(accountName));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.userAccountsRepository, e.toString());
|
||||
}
|
||||
|
||||
return checkAccount;
|
||||
}
|
||||
|
||||
public LiveData<List<UserAccount>> getAllAccounts() {
|
||||
|
||||
return userAccountsDao.fetchAllAccounts();
|
||||
}
|
||||
|
||||
public static void deleteAccount(final int accountId) {
|
||||
|
||||
new Thread(() -> userAccountsDao.deleteAccount(accountId)).start();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package org.mian.gitnex.database.dao;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import org.mian.gitnex.database.models.Draft;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Dao
|
||||
public interface DraftsDao {
|
||||
|
||||
@Insert
|
||||
long insertDraft(Draft drafts);
|
||||
|
||||
@Query("SELECT * FROM Drafts JOIN Repositories ON Repositories.repositoryId = Drafts.draftRepositoryId WHERE draftAccountId = :accountId" +
|
||||
" ORDER BY " +
|
||||
"draftId DESC")
|
||||
LiveData<List<DraftWithRepository>> fetchAllDrafts(int accountId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE draftAccountId = :accountId ORDER BY draftId DESC")
|
||||
LiveData<List<Draft>> fetchDrafts(int accountId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE draftAccountId = :accountId and draftRepositoryId = :repositoryId")
|
||||
LiveData<Draft> fetchSingleDraftByAccountIdAndRepositoryId(int accountId, int repositoryId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE draftId = :draftId")
|
||||
LiveData<Draft> fetchDraftById(int draftId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE issueId = :issueId")
|
||||
LiveData<Draft> fetchDraftByIssueId(int issueId);
|
||||
|
||||
@Query("SELECT count(draftId) FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||
Integer checkDraftDao(int issueId, int draftRepositoryId);
|
||||
|
||||
@Query("UPDATE Drafts SET draftText= :draftText WHERE draftId = :draftId")
|
||||
void updateDraft(String draftText, int draftId);
|
||||
|
||||
@Query("UPDATE Drafts SET draftText= :draftText WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||
void updateDraftByIssueId(String draftText, int issueId, int draftRepositoryId);
|
||||
|
||||
@Query("SELECT draftId FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||
Integer getDraftId(int issueId, int draftRepositoryId);
|
||||
|
||||
@Query("DELETE FROM Drafts WHERE draftId = :draftId")
|
||||
void deleteByDraftId(int draftId);
|
||||
|
||||
@Query("DELETE FROM Drafts WHERE draftAccountId = :accountId")
|
||||
void deleteAllDrafts(int accountId);
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.mian.gitnex.database.dao;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Dao
|
||||
public interface RepositoriesDao {
|
||||
|
||||
@Insert
|
||||
long newRepository(Repository repositories);
|
||||
|
||||
@Query("SELECT * FROM Repositories ORDER BY repositoryId ASC")
|
||||
LiveData<List<Repository>> fetchAllRepositories();
|
||||
|
||||
@Query("SELECT * FROM Repositories WHERE repoAccountId = :repoAccountId")
|
||||
LiveData<List<Repository>> getAllRepositoriesByAccountDao(int repoAccountId);
|
||||
|
||||
@Query("SELECT count(repositoryId) FROM Repositories WHERE repoAccountId = :repoAccountId AND repositoryOwner = :repositoryOwner AND repositoryName = :repositoryName")
|
||||
Integer checkRepositoryDao(int repoAccountId, String repositoryOwner, String repositoryName);
|
||||
|
||||
@Query("SELECT * FROM Repositories WHERE repoAccountId = :repoAccountId AND repositoryOwner = :repositoryOwner AND repositoryName = :repositoryName")
|
||||
Repository getSingleRepositoryDao(int repoAccountId, String repositoryOwner, String repositoryName);
|
||||
|
||||
@Query("SELECT * FROM Repositories WHERE repositoryId = :repositoryId")
|
||||
Repository fetchRepositoryByIdDao(int repositoryId);
|
||||
|
||||
@Query("SELECT * FROM Repositories WHERE repositoryId = :repositoryId AND repoAccountId = :repoAccountId")
|
||||
Repository fetchRepositoryByAccountIdByRepositoryIdDao(int repositoryId, int repoAccountId);
|
||||
|
||||
@Query("UPDATE Repositories SET repositoryOwner = :repositoryOwner, repositoryName = :repositoryName WHERE repositoryId = :repositoryId")
|
||||
void updateRepositoryOwnerAndName(String repositoryOwner, String repositoryName, int repositoryId);
|
||||
|
||||
@Query("DELETE FROM Repositories WHERE repositoryId = :repositoryId")
|
||||
void deleteRepository(int repositoryId);
|
||||
|
||||
@Query("DELETE FROM Repositories WHERE repoAccountId = :repoAccountId")
|
||||
void deleteRepositoriesByAccount(int repoAccountId);
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package org.mian.gitnex.database.dao;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Dao
|
||||
public interface UserAccountsDao {
|
||||
|
||||
@Insert
|
||||
void newAccount(UserAccount userAccounts);
|
||||
|
||||
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
||||
LiveData<List<UserAccount>> fetchAllAccounts();
|
||||
|
||||
@Query("SELECT COUNT(accountId) FROM UserAccounts WHERE accountName = :accountName")
|
||||
Integer getCount(String accountName);
|
||||
|
||||
@Query("SELECT * FROM UserAccounts WHERE accountName = :accountName")
|
||||
UserAccount fetchRowByAccount_(String accountName);
|
||||
|
||||
@Query("SELECT * FROM UserAccounts WHERE accountId = :accountId")
|
||||
UserAccount fetchRowByAccountId(int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET serverVersion = :serverVersion WHERE accountId = :accountId")
|
||||
void updateServerVersion(String serverVersion, int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET accountName = :accountName WHERE accountId = :accountId")
|
||||
void updateAccountName(String accountName, int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET token = :token WHERE accountId = :accountId")
|
||||
void updateAccountToken(int accountId, String token);
|
||||
|
||||
@Query("UPDATE UserAccounts SET instanceUrl = :instanceUrl, token = :token WHERE accountId = :accountId")
|
||||
void updateHostInfo(String instanceUrl, String token, int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET userName = :userName WHERE accountId = :accountId")
|
||||
void updateUserName(String userName, int accountId);
|
||||
|
||||
@Query("UPDATE UserAccounts SET instanceUrl = :instanceUrl, token = :token, userName = :userName, serverVersion = :serverVersion WHERE accountId = :accountId")
|
||||
void updateAll(String instanceUrl, String token, String userName, String serverVersion, int accountId);
|
||||
|
||||
@Query("DELETE FROM UserAccounts WHERE accountId = :accountId")
|
||||
void deleteAccount(int accountId);
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package org.mian.gitnex.database.db;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
import androidx.room.migration.Migration;
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
import org.mian.gitnex.database.dao.DraftsDao;
|
||||
import org.mian.gitnex.database.dao.RepositoriesDao;
|
||||
import org.mian.gitnex.database.dao.UserAccountsDao;
|
||||
import org.mian.gitnex.database.models.Draft;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
||||
version = 1, exportSchema = false)
|
||||
public abstract class GitnexDatabase extends RoomDatabase {
|
||||
|
||||
private static GitnexDatabase gitnexDatabase;
|
||||
|
||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||
|
||||
if (gitnexDatabase == null) {
|
||||
String DB_NAME = "gitnex";
|
||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||
//.fallbackToDestructiveMigration()
|
||||
//.addMigrations(MIGRATION_1_2)
|
||||
.build();
|
||||
}
|
||||
|
||||
return gitnexDatabase;
|
||||
}
|
||||
|
||||
public abstract DraftsDao draftsDao();
|
||||
|
||||
public abstract RepositoriesDao repositoriesDao();
|
||||
|
||||
public abstract UserAccountsDao userAccountsDao();
|
||||
|
||||
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
|
||||
//database.execSQL("DROP TABLE Drafts");
|
||||
//database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'draftType' TEXT");
|
||||
|
||||
}
|
||||
};
|
||||
}
|
89
app/src/main/java/org/mian/gitnex/database/models/Draft.java
Normal file
89
app/src/main/java/org/mian/gitnex/database/models/Draft.java
Normal file
@ -0,0 +1,89 @@
|
||||
package org.mian.gitnex.database.models;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.ForeignKey;
|
||||
import androidx.room.Index;
|
||||
import androidx.room.PrimaryKey;
|
||||
import java.io.Serializable;
|
||||
import static androidx.room.ForeignKey.CASCADE;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Entity(tableName = "Drafts", foreignKeys = @ForeignKey(entity = Repository.class, parentColumns = "repositoryId", childColumns = "draftRepositoryId", onDelete = CASCADE), indices = {@Index("draftRepositoryId")})
|
||||
public class Draft implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int draftId;
|
||||
|
||||
private int draftRepositoryId;
|
||||
private int draftAccountId;
|
||||
private int issueId;
|
||||
private String draftText;
|
||||
@Nullable
|
||||
private String draftType;
|
||||
|
||||
public int getDraftId() {
|
||||
|
||||
return draftId;
|
||||
}
|
||||
|
||||
public void setDraftId(int draftId) {
|
||||
|
||||
this.draftId = draftId;
|
||||
}
|
||||
|
||||
public int getDraftRepositoryId() {
|
||||
|
||||
return draftRepositoryId;
|
||||
}
|
||||
|
||||
public void setDraftRepositoryId(int draftRepositoryId) {
|
||||
|
||||
this.draftRepositoryId = draftRepositoryId;
|
||||
}
|
||||
|
||||
public int getDraftAccountId() {
|
||||
|
||||
return draftAccountId;
|
||||
}
|
||||
|
||||
public void setDraftAccountId(int draftAccountId) {
|
||||
|
||||
this.draftAccountId = draftAccountId;
|
||||
}
|
||||
|
||||
public int getIssueId() {
|
||||
|
||||
return issueId;
|
||||
}
|
||||
|
||||
public void setIssueId(int issueId) {
|
||||
|
||||
this.issueId = issueId;
|
||||
}
|
||||
|
||||
public String getDraftText() {
|
||||
|
||||
return draftText;
|
||||
}
|
||||
|
||||
public void setDraftText(String draftText) {
|
||||
|
||||
this.draftText = draftText;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDraftType() {
|
||||
|
||||
return draftType;
|
||||
}
|
||||
|
||||
public void setDraftType(@Nullable String draftType) {
|
||||
|
||||
this.draftType = draftType;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package org.mian.gitnex.database.models;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class DraftWithRepository {
|
||||
|
||||
private int repositoryId;
|
||||
private int draftId;
|
||||
|
||||
private int repoAccountId;
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
|
||||
private int draftRepositoryId;
|
||||
private int draftAccountId;
|
||||
private int issueId;
|
||||
private String draftText;
|
||||
private String draftType;
|
||||
|
||||
public int getRepositoryId() {
|
||||
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
public void setRepositoryId(int repositoryId) {
|
||||
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
public int getDraftId() {
|
||||
|
||||
return draftId;
|
||||
}
|
||||
|
||||
public void setDraftId(int draftId) {
|
||||
|
||||
this.draftId = draftId;
|
||||
}
|
||||
|
||||
public int getRepoAccountId() {
|
||||
|
||||
return repoAccountId;
|
||||
}
|
||||
|
||||
public void setRepoAccountId(int repoAccountId) {
|
||||
|
||||
this.repoAccountId = repoAccountId;
|
||||
}
|
||||
|
||||
public String getRepositoryOwner() {
|
||||
|
||||
return repositoryOwner;
|
||||
}
|
||||
|
||||
public void setRepositoryOwner(String repositoryOwner) {
|
||||
|
||||
this.repositoryOwner = repositoryOwner;
|
||||
}
|
||||
|
||||
public String getRepositoryName() {
|
||||
|
||||
return repositoryName;
|
||||
}
|
||||
|
||||
public void setRepositoryName(String repositoryName) {
|
||||
|
||||
this.repositoryName = repositoryName;
|
||||
}
|
||||
|
||||
public int getDraftRepositoryId() {
|
||||
|
||||
return draftRepositoryId;
|
||||
}
|
||||
|
||||
public void setDraftRepositoryId(int draftRepositoryId) {
|
||||
|
||||
this.draftRepositoryId = draftRepositoryId;
|
||||
}
|
||||
|
||||
public int getDraftAccountId() {
|
||||
|
||||
return draftAccountId;
|
||||
}
|
||||
|
||||
public void setDraftAccountId(int draftAccountId) {
|
||||
|
||||
this.draftAccountId = draftAccountId;
|
||||
}
|
||||
|
||||
public int getIssueId() {
|
||||
|
||||
return issueId;
|
||||
}
|
||||
|
||||
public void setIssueId(int issueId) {
|
||||
|
||||
this.issueId = issueId;
|
||||
}
|
||||
|
||||
public String getDraftText() {
|
||||
|
||||
return draftText;
|
||||
}
|
||||
|
||||
public void setDraftText(String draftText) {
|
||||
|
||||
this.draftText = draftText;
|
||||
}
|
||||
|
||||
public String getDraftType() {
|
||||
|
||||
return draftType;
|
||||
}
|
||||
|
||||
public void setDraftType(String draftType) {
|
||||
|
||||
this.draftType = draftType;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package org.mian.gitnex.database.models;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.ForeignKey;
|
||||
import androidx.room.Index;
|
||||
import androidx.room.PrimaryKey;
|
||||
import java.io.Serializable;
|
||||
import static androidx.room.ForeignKey.CASCADE;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Entity(tableName = "Repositories", foreignKeys = @ForeignKey(entity = UserAccount.class,
|
||||
parentColumns = "accountId",
|
||||
childColumns = "repoAccountId",
|
||||
onDelete = CASCADE),
|
||||
indices = {@Index("repoAccountId")})
|
||||
public class Repository implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int repositoryId;
|
||||
|
||||
private int repoAccountId;
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
|
||||
public int getRepositoryId() {
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
public void setRepositoryId(int repositoryId) {
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
public int getRepoAccountId() {
|
||||
return repoAccountId;
|
||||
}
|
||||
|
||||
public void setRepoAccountId(int repoAccountId) {
|
||||
this.repoAccountId = repoAccountId;
|
||||
}
|
||||
|
||||
public String getRepositoryOwner() {
|
||||
return repositoryOwner;
|
||||
}
|
||||
|
||||
public void setRepositoryOwner(String repositoryOwner) {
|
||||
this.repositoryOwner = repositoryOwner;
|
||||
}
|
||||
|
||||
public String getRepositoryName() {
|
||||
return repositoryName;
|
||||
}
|
||||
|
||||
public void setRepositoryName(String repositoryName) {
|
||||
this.repositoryName = repositoryName;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package org.mian.gitnex.database.models;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
@Entity(tableName = "userAccounts")
|
||||
public class UserAccount implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int accountId;
|
||||
|
||||
@Nullable
|
||||
private String accountName;
|
||||
private String instanceUrl;
|
||||
private String userName;
|
||||
private String token;
|
||||
@Nullable
|
||||
private String serverVersion;
|
||||
|
||||
public int getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(int accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public void setAccountName(@Nullable String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public String getInstanceUrl() {
|
||||
return instanceUrl;
|
||||
}
|
||||
|
||||
public void setInstanceUrl(String instanceUrl) {
|
||||
this.instanceUrl = instanceUrl;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getServerVersion() {
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
public void setServerVersion(@Nullable String serverVersion) {
|
||||
this.serverVersion = serverVersion;
|
||||
}
|
||||
}
|
@ -3,19 +3,18 @@ package org.mian.gitnex.fragments;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreditsActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.activities.SponsorsActivity;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.AdminGetUsersActivity;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
|
@ -0,0 +1,58 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class BottomSheetDraftsFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private String TAG = StaticGlobalVariables.tagDraftsBottomSheet;
|
||||
private BottomSheetDraftsFragment.BottomSheetListener bmListener;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.bottom_sheet_drafts, container, false);
|
||||
|
||||
TextView deleteAllDrafts = v.findViewById(R.id.deleteAllDrafts);
|
||||
|
||||
deleteAllDrafts.setOnClickListener(v1 -> {
|
||||
|
||||
dismiss();
|
||||
bmListener.onButtonClicked("deleteDrafts");
|
||||
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public interface BottomSheetListener {
|
||||
void onButtonClicked(String text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
try {
|
||||
bmListener = (BottomSheetDraftsFragment.BottomSheetListener) context;
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
|
||||
/**
|
||||
* Author opyale
|
||||
*/
|
||||
|
||||
public class BottomSheetNotificationsFilterFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private TinyDB tinyDB;
|
||||
private OnDismissedListener onDismissedListener;
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
|
||||
this.tinyDB = new TinyDB(context);
|
||||
super.onAttach(context);
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
View view = inflater.inflate(R.layout.bottom_sheet_notifications_filter, container, false);
|
||||
|
||||
TextView readNotifications = view.findViewById(R.id.readNotifications);
|
||||
TextView unreadNotifications = view.findViewById(R.id.unreadNotifications);
|
||||
|
||||
readNotifications.setOnClickListener(v1 -> {
|
||||
|
||||
tinyDB.putString("notificationsFilterState", "read");
|
||||
dismiss();
|
||||
|
||||
});
|
||||
|
||||
unreadNotifications.setOnClickListener(v12 -> {
|
||||
|
||||
tinyDB.putString("notificationsFilterState", "unread");
|
||||
dismiss();
|
||||
|
||||
});
|
||||
|
||||
return view;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
|
||||
if(onDismissedListener != null) {
|
||||
|
||||
onDismissedListener.onDismissed();
|
||||
}
|
||||
|
||||
super.dismiss();
|
||||
|
||||
}
|
||||
|
||||
public void setOnDismissedListener(OnDismissedListener onDismissedListener) {
|
||||
|
||||
this.onDismissedListener = onDismissedListener;
|
||||
}
|
||||
|
||||
public interface OnDismissedListener {
|
||||
|
||||
void onDismissed();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.NotificationsActions;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.NotificationThread;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author opyale
|
||||
*/
|
||||
|
||||
public class BottomSheetNotificationsFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private Context context;
|
||||
private NotificationThread notificationThread;
|
||||
private OnOptionSelectedListener onOptionSelectedListener;
|
||||
|
||||
public void onAttach(Context context, NotificationThread notificationThread, OnOptionSelectedListener onOptionSelectedListener) {
|
||||
|
||||
this.context = context;
|
||||
this.notificationThread = notificationThread;
|
||||
this.onOptionSelectedListener = onOptionSelectedListener;
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
View v = inflater.inflate(R.layout.bottom_sheet_notifications, container, false);
|
||||
|
||||
TextView markRead = v.findViewById(R.id.markRead);
|
||||
TextView markUnread = v.findViewById(R.id.markUnread);
|
||||
TextView markPinned = v.findViewById(R.id.markPinned);
|
||||
|
||||
NotificationsActions notificationsActions = new NotificationsActions(context);
|
||||
Activity activity = Objects.requireNonNull(getActivity());
|
||||
|
||||
if(notificationThread.isPinned()) {
|
||||
|
||||
AppUtil.setMultiVisibility(View.GONE, markUnread, markPinned);
|
||||
} else if(notificationThread.isUnread()) {
|
||||
|
||||
markUnread.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
markRead.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
markPinned.setOnClickListener(v12 -> {
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
try {
|
||||
|
||||
notificationsActions.setNotificationStatus(notificationThread, NotificationsActions.NotificationStatus.PINNED);
|
||||
activity.runOnUiThread(() -> onOptionSelectedListener.onSelected());
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
activity.runOnUiThread(() -> Toasty.error(context, getString(R.string.genericError)));
|
||||
Log.e("onError", e.toString());
|
||||
|
||||
} finally {
|
||||
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
thread.start();
|
||||
|
||||
});
|
||||
|
||||
markRead.setOnClickListener(v1 -> {
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
try {
|
||||
|
||||
notificationsActions.setNotificationStatus(notificationThread, NotificationsActions.NotificationStatus.READ);
|
||||
activity.runOnUiThread(() -> onOptionSelectedListener.onSelected());
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
activity.runOnUiThread(() -> Toasty.error(context, getString(R.string.genericError)));
|
||||
Log.e("onError", e.toString());
|
||||
|
||||
} finally {
|
||||
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
thread.start();
|
||||
|
||||
});
|
||||
|
||||
markUnread.setOnClickListener(v13 -> {
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
try {
|
||||
|
||||
notificationsActions.setNotificationStatus(notificationThread, NotificationsActions.NotificationStatus.UNREAD);
|
||||
activity.runOnUiThread(() -> onOptionSelectedListener.onSelected());
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
activity.runOnUiThread(() -> Toasty.error(context, getString(R.string.genericError)));
|
||||
Log.e("onError", e.toString());
|
||||
|
||||
} finally {
|
||||
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
thread.start();
|
||||
|
||||
});
|
||||
|
||||
return v;
|
||||
|
||||
}
|
||||
|
||||
public interface OnOptionSelectedListener {
|
||||
|
||||
void onSelected();
|
||||
}
|
||||
|
||||
}
|
@ -22,43 +22,42 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.bottom_sheet_organization, container, false);
|
||||
|
||||
View v = inflater.inflate(R.layout.bottom_sheet_organization, container, false);
|
||||
|
||||
TextView createTeam = v.findViewById(R.id.createTeam);
|
||||
TextView createRepository = v.findViewById(R.id.createRepository);
|
||||
|
||||
createTeam.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bmListener.onButtonClicked("team");
|
||||
dismiss();
|
||||
}
|
||||
createTeam.setOnClickListener(v1 -> {
|
||||
|
||||
bmListener.onButtonClicked("team");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
createRepository.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bmListener.onButtonClicked("repository");
|
||||
dismiss();
|
||||
}
|
||||
createRepository.setOnClickListener(v12 -> {
|
||||
|
||||
bmListener.onButtonClicked("repository");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public interface BottomSheetListener {
|
||||
|
||||
void onButtonClicked(String text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
|
||||
super.onAttach(context);
|
||||
|
||||
try {
|
||||
bmListener = (BottomSheetOrganizationFragment.BottomSheetListener) context;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(context.toString()
|
||||
+ " must implement BottomSheetListener");
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user