Merge branch 'master' into 7-assign-team-to-repo
This commit is contained in:
commit
5b92be3a28
@ -1,32 +1,37 @@
|
|||||||
## # What do you want to address?
|
## # What do you want to address?
|
||||||
(This step is required; examples are shown below)
|
<!-- This step is required; examples are shown below -->
|
||||||
|
|
||||||
- [ ] Bug
|
- [ ] Bug
|
||||||
- [ ] Feature
|
- [ ] Feature
|
||||||
- [ ] Suggestion
|
- [ ] Suggestion
|
||||||
|
|
||||||
## # Describe your matter briefly
|
## # Describe your matter briefly
|
||||||
(This step is required)
|
<!-- This step is required. -->
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
##### What did you expect? <!-- Useful when addressing bugs -->
|
||||||
##### What did you expect? (Useful when addressing bugs)
|
|
||||||
---
|
---
|
||||||
_(This step is optional)_
|
<!-- This step is optional. -->
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
##### Some additional details <!-- Useful, when we are trying to reproduce a bug -->
|
||||||
##### Some additional details (Useful, when we are trying to reproduce a bug)
|
|
||||||
---
|
---
|
||||||
_(This step is optional; an example is shown below)_
|
<!-- This step is optional; an example is shown below -->
|
||||||
|
|
||||||
* The version of **Gitea** you are using:
|
* The version of **Gitea** you are using:
|
||||||
* The version of **GitNex** you are using:
|
* The version of **GitNex** you are using:
|
||||||
* Phone **OS** version and model:
|
* Source of installation (Play Store, F-Droid, APK):
|
||||||
* The type of certificate you are using (self-signed, signed):
|
* Current android version and phone model/manufacturer:
|
||||||
|
* The type of certificate your instance is using (self-signed, signed):
|
||||||
* How you used to log in (via password or token):
|
* How you used to log in (via password or token):
|
||||||
|
<br>
|
||||||
|
|
||||||
##### We would appreciate some screenshots or stacktrace's, but this is also not required.
|
##### We would appreciate some screenshots or stacktrace's, but this is also not required.
|
||||||
---
|
---
|
||||||
_(Screenshots and stacktrace's can go here)_
|
<!-- Screenshots and stacktrace's can go here. -->
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
- [ ] I carefully read the [contribution guidelines](https://codeberg.org/GitNex/GitNex/src/branch/master/CONTRIBUTING.md).
|
||||||
|
<br>
|
||||||
|
|
||||||
#### Thank you for your time.
|
#### Thank you for your time.
|
@ -1,8 +1,9 @@
|
|||||||
Please check the following:
|
### Describe what your pull request does and which issue you’re targeting
|
||||||
|
<!-- Create a new issue, if it doesn't exist yet -->
|
||||||
|
<br><br>
|
||||||
|
|
||||||
1. Make sure you are targeting the `master` branch, pull requests on release branches are only allowed for bug fixes.
|
<!-- Make sure you are targeting the master branch, pull requests on release branches are only allowed for bug fixes. -->
|
||||||
2. Read contributing guidelines: [CONTRIBUTING.md](https://gitea.com/GitNex/GitNex/src/branch/master/CONTRIBUTING.md)
|
|
||||||
3. Please follow the [Code-Standards](https://gitea.com/gitnex/GitNex/wiki/Code-Standards)
|
|
||||||
4. Describe what your pull request does and which issue you’re targeting (create one if does not exist)
|
|
||||||
|
|
||||||
**You MUST delete the content above including this line before posting, otherwise your pull request will be invalid.**
|
- [ ] I carefully read the [contribution guidelines](https://codeberg.org/GitNex/GitNex/src/branch/master/CONTRIBUTING.md).
|
||||||
|
- [ ] I'm following the code standards as defined [here](https://codeberg.org/gitnex/GitNex/wiki/Code-Standards).
|
||||||
|
- [ ] By submitting this pull request, I permit GitNex to license my work under the [GNU General Public License v3](https://codeberg.org/GitNex/GitNex/src/branch/master/LICENSE).
|
2
.idea/codeStyles/Project.xml
generated
2
.idea/codeStyles/Project.xml
generated
@ -180,4 +180,4 @@
|
|||||||
</arrangement>
|
</arrangement>
|
||||||
</codeStyleSettings>
|
</codeStyleSettings>
|
||||||
</code_scheme>
|
</code_scheme>
|
||||||
</component>
|
</component>
|
@ -2,26 +2,35 @@
|
|||||||
|
|
||||||
Please take a few minutes to read this document to make the process of contribution more easy and healthy for all involved.
|
Please take a few minutes to read this document to make the process of contribution more easy and healthy for all involved.
|
||||||
|
|
||||||
## Pull Requests
|
### General
|
||||||
Patches, enhancements, features are always welcome. The PR should focus on the scope of work and avoid many unnecessary commits. Please provide as much detail and context as possible to explain the work submitted.
|
> **Be polite and gentle while commenting or creating new issues to maintain a healthy environment in which __everyone__ is able to feel comfortable.**
|
||||||
|
<br>
|
||||||
|
|
||||||
Please ask if you are not sure about the scope of work to be submitted to avoid waste of time spent on the work.
|
### Issues and Reports
|
||||||
|
Before creating an issue please take a moment and search the repository issues(open/closed) to avoid duplicate issues either it's a bug or feature.
|
||||||
|
In case you want to submit a bug report, please provide as much details as possible to better debug the problem. The important part is how to reproduce the bug and steps to reproduce are appreciated.<br><br>
|
||||||
|
**Note:** Please contact the project directly via [email](mailto:gitnex@swatian.com) if have to share sensitive and security related details.
|
||||||
|
<br>
|
||||||
|
|
||||||
**Code Standards**
|
### Pull Requests
|
||||||
|
Patches, enhancements and features are always welcome.
|
||||||
|
The PR should focus on the scope of work and avoid many unnecessary commits.
|
||||||
|
Please provide as much detail and context as possible to explain the work submitted.
|
||||||
|
|
||||||
|
**Please ask if you are not sure about the scope of work to be submitted to avoid waste of time spent on the work.** (Submit an issue, __before__ submitting a PR)
|
||||||
|
|
||||||
|
**Code Standards**<br><br>
|
||||||
Please follow the code standards, this will help other developers to understand your code too.
|
Please follow the code standards, this will help other developers to understand your code too.
|
||||||
It also helps maintaining the code afterwards.
|
It also helps maintaining the code afterwards.
|
||||||
It is documented in the Wiki: [Code-Standards](https://codeberg.org/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**
|
**How to submit a PR (Pull Request)**
|
||||||
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.
|
1. Fork this repository.
|
||||||
|
2. Clone the forked repository from your namespace to your local machine.
|
||||||
|
3. Create a new branch and work on your feature, enhancement or patch.
|
||||||
|
4. Push your commits to your forked version.
|
||||||
|
5. You can now create a PR using the web interface against **master** branch.
|
||||||
|
|
||||||
**IMPORTANT:** By submitting PR, you agree to allow GitNex to license your work under the same license as that used by GitNex.
|
For more information, click [here](http://makeapullrequest.com/).
|
||||||
|
|
||||||
## Issues and Reports
|
**IMPORTANT:** By submitting PR, you agree to allow GitNex to license your work under the same license as that used by GitNex.
|
||||||
*1st of please be polite and gentle while commenting or creating new issue to maintain a healthy environment.*
|
|
||||||
|
|
||||||
Before creating an issue please take a moment and search the repository issues(open/closed) to avoid duplicate issues either it's a bug or feature.
|
|
||||||
|
|
||||||
In case you want to submit a bug report, please provide as much details as possible to better debug the problem. The important part is how to reproduce the bug and steps to reproduce are appreciated.
|
|
||||||
|
|
||||||
**Note:** Please contact the project directly via email(gitnex@swatian.com) if have to share sensitive and security related details.
|
|
@ -1,6 +1,6 @@
|
|||||||
[](https://www.gnu.org/licenses/gpl-3.0)  [](https://codeberg.org/gitnex/GitNex/releases) [](https://crowdin.com/project/gitnex) [](https://discord.gg/FbSS4rf)
|
[](https://www.gnu.org/licenses/gpl-3.0) [](https://gitlab.com/opyale/gitnex/-/pipelines) [](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)
|
[<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)
|
||||||
|
|
||||||
# GitNex - Android client for Gitea
|
# GitNex - Android client for Gitea
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ GitNex is licensed under GPLv3 License. See the LICENSE file for the full licens
|
|||||||
## Downloads
|
## 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 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.pro)
|
[<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.pro)
|
||||||
[<img alt='Download builds and releases' src='assets/apk-badge.png' height="82"/>](https://cloud.swatian.com/s/DN7E5xxtaw4fRbE)
|
[<img alt='Download builds and releases' src='https://codeberg.org/gitnex/GitNex/raw/branch/master/assets/apk-badge.png' height="82"/>](https://cloud.swatian.com/s/DN7E5xxtaw4fRbE)
|
||||||
|
|
||||||
## Note about Gitea version
|
## Note about Gitea version
|
||||||
Please make sure that you are on latest stable release or later for better app experience.
|
Please make sure that you are on latest stable release or later for better app experience.
|
||||||
@ -74,11 +74,11 @@ Thanks to all the open source libraries, contributors and donators.
|
|||||||
- Okhttp
|
- Okhttp
|
||||||
- Picasso
|
- Picasso
|
||||||
- Markwon
|
- Markwon
|
||||||
|
- Prism4j
|
||||||
- Prettytime
|
- Prettytime
|
||||||
- Amulyakhare/textdrawable
|
- Amulyakhare/textdrawable
|
||||||
- Vdurmont/emoji-java
|
- Vdurmont/emoji-java
|
||||||
- Pes/materialcolorpicker
|
- Pes/materialcolorpicker
|
||||||
- Hendraanggrian/socialview
|
|
||||||
- HamidrezaAmz/BreadcrumbsView
|
- HamidrezaAmz/BreadcrumbsView
|
||||||
- Chrisbanes/PhotoView
|
- Chrisbanes/PhotoView
|
||||||
- Pddstudio/highlightjs-android
|
- Pddstudio/highlightjs-android
|
||||||
|
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "org.mian.gitnex"
|
applicationId "org.mian.gitnex"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 327
|
versionCode 346
|
||||||
versionName "3.3.0-dev"
|
versionName "3.5.0-dev"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@ -38,8 +38,10 @@ android {
|
|||||||
abortOnError false
|
abortOnError false
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
targetCompatibility = "8"
|
coreLibraryDesugaringEnabled true
|
||||||
sourceCompatibility = "8"
|
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
defaultConfig{
|
defaultConfig{
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
@ -52,18 +54,18 @@ configurations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
def lifecycle_version = '2.3.0-beta01'
|
def lifecycle_version = '2.3.0-rc01'
|
||||||
def markwon_version = '4.6.0'
|
def markwon_version = '4.6.1'
|
||||||
def work_version = "2.4.0"
|
def work_version = "2.4.0"
|
||||||
def acra = "5.5.0"
|
def acra = "5.7.0"
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
|
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
|
||||||
implementation 'com.google.android.material:material:1.3.0-alpha03'
|
implementation 'com.google.android.material:material:1.3.0-alpha03'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||||
testImplementation "junit:junit:4.13"
|
testImplementation 'junit:junit:4.13.1'
|
||||||
androidTestImplementation 'androidx.test:runner:1.3.0'
|
androidTestImplementation 'androidx.test:runner:1.3.0'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
|
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
|
||||||
@ -74,8 +76,7 @@ dependencies {
|
|||||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||||
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
|
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
|
||||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
|
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
|
||||||
implementation 'org.ocpsoft.prettytime:prettytime:4.0.6.Final'
|
implementation 'org.ocpsoft.prettytime:prettytime:5.0.0.Final'
|
||||||
implementation "com.vdurmont:emoji-java:5.1.1"
|
|
||||||
implementation "com.pes.materialcolorpicker:library:1.2.5"
|
implementation "com.pes.materialcolorpicker:library:1.2.5"
|
||||||
implementation "io.noties.markwon:core:$markwon_version"
|
implementation "io.noties.markwon:core:$markwon_version"
|
||||||
implementation "io.noties.markwon:ext-latex:$markwon_version"
|
implementation "io.noties.markwon:ext-latex:$markwon_version"
|
||||||
@ -90,10 +91,11 @@ dependencies {
|
|||||||
implementation "io.noties.markwon:recycler-table:$markwon_version"
|
implementation "io.noties.markwon:recycler-table:$markwon_version"
|
||||||
implementation "io.noties.markwon:simple-ext:$markwon_version"
|
implementation "io.noties.markwon:simple-ext:$markwon_version"
|
||||||
implementation "io.noties.markwon:syntax-highlight:$markwon_version"
|
implementation "io.noties.markwon:syntax-highlight:$markwon_version"
|
||||||
|
implementation "io.noties.markwon:image-picasso:$markwon_version"
|
||||||
|
implementation "io.noties:prism4j:2.0.0"
|
||||||
|
annotationProcessor "io.noties:prism4j-bundler:2.0.0"
|
||||||
implementation "com.caverock:androidsvg:1.4"
|
implementation "com.caverock:androidsvg:1.4"
|
||||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.19"
|
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.21"
|
||||||
implementation "com.hendraanggrian.appcompat:socialview:0.2"
|
|
||||||
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
|
||||||
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
||||||
implementation "commons-io:commons-io:20030203.000550"
|
implementation "commons-io:commons-io:20030203.000550"
|
||||||
implementation 'org.apache.commons:commons-lang3:3.11'
|
implementation 'org.apache.commons:commons-lang3:3.11'
|
||||||
@ -102,10 +104,12 @@ dependencies {
|
|||||||
implementation "ch.acra:acra-mail:$acra"
|
implementation "ch.acra:acra-mail:$acra"
|
||||||
implementation "ch.acra:acra-limiter:$acra"
|
implementation "ch.acra:acra-limiter:$acra"
|
||||||
implementation "ch.acra:acra-notification:$acra"
|
implementation "ch.acra:acra-notification:$acra"
|
||||||
implementation "androidx.room:room-runtime:2.2.5"
|
implementation 'androidx.room:room-runtime:2.2.6'
|
||||||
annotationProcessor "androidx.room:room-compiler:2.2.5"
|
annotationProcessor 'androidx.room:room-compiler:2.2.6'
|
||||||
implementation "androidx.work:work-runtime:$work_version"
|
implementation "androidx.work:work-runtime:$work_version"
|
||||||
implementation "com.eightbitlab:blurview:1.6.3"
|
implementation "com.eightbitlab:blurview:1.6.4"
|
||||||
implementation "io.mikael:urlbuilder:2.0.9"
|
implementation "io.mikael:urlbuilder:2.0.9"
|
||||||
|
implementation "org.codeberg.gitnex-garage:emoji-java:v5.1.2"
|
||||||
|
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.1"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@ -74,9 +75,6 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activities.CreateMilestoneActivity"
|
android:name=".activities.CreateMilestoneActivity"
|
||||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation" />
|
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation" />
|
||||||
<activity
|
|
||||||
android:name=".activities.ReplyToIssueActivity"
|
|
||||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.IssueDetailActivity"
|
android:name=".activities.IssueDetailActivity"
|
||||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation"
|
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation"
|
||||||
@ -153,12 +151,42 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activities.CreatePullRequestActivity"
|
android:name=".activities.CreatePullRequestActivity"
|
||||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation" />
|
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation" />
|
||||||
|
<activity
|
||||||
|
android:name=".activities.SettingsGeneralActivity"
|
||||||
|
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation" />
|
||||||
|
<activity
|
||||||
|
android:name=".activities.SettingsNotificationsActivity"
|
||||||
|
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation" />
|
||||||
|
|
||||||
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
|
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
|
||||||
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
|
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
|
||||||
<!-- Version >= 3.0. DeX Dual Mode support -->
|
<!-- Version >= 3.0. DeX Dual Mode support -->
|
||||||
<meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true"/>
|
<meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true"/>
|
||||||
|
|
||||||
|
<!-- deep links -->
|
||||||
|
<activity
|
||||||
|
android:name=".activities.DeepLinksActivity"
|
||||||
|
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||||
|
android:noHistory="true"
|
||||||
|
android:launchMode="singleTask">
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:scheme="http" />
|
||||||
|
<data android:scheme="https" />
|
||||||
|
<data android:host="codeberg.org" />
|
||||||
|
<data android:host="gitea.com" />
|
||||||
|
<data android:host="try.gitea.io" />
|
||||||
|
<data android:host="code.obermui.de" />
|
||||||
|
<data android:host="git.fsfe.org" />
|
||||||
|
<data android:host="opendev.org" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
<!-- deep links -->
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 3.2 KiB |
@ -24,12 +24,11 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class AssigneesActions {
|
public class AssigneesActions {
|
||||||
|
|
||||||
public static void getCurrentIssueAssignees(Context ctx, String instanceUrl, String loginUid, String instanceToken, String repoOwner, String repoName, int issueIndex, List<String> currentAssignees) {
|
public static void getCurrentIssueAssignees(Context ctx, String repoOwner, String repoName, int issueIndex, List<String> currentAssignees) {
|
||||||
|
|
||||||
Call<Issues> callSingleIssueLabels = RetrofitClient
|
Call<Issues> callSingleIssueLabels = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||||
.getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
|
||||||
|
|
||||||
callSingleIssueLabels.enqueue(new Callback<Issues>() {
|
callSingleIssueLabels.enqueue(new Callback<Issues>() {
|
||||||
|
|
||||||
@ -63,14 +62,13 @@ public class AssigneesActions {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getRepositoryAssignees(Context ctx, String instanceUrl, String instanceToken, String repoOwner, String repoName, List<Collaborators> assigneesList, Dialog dialogAssignees, AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding) {
|
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<Collaborators> assigneesList, Dialog dialogAssignees, AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding) {
|
||||||
|
|
||||||
TinyDB tinyDB = new TinyDB(ctx);
|
TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
Call<List<Collaborators>> call = RetrofitClient
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getCollaborators(Authorization.get(ctx), repoOwner, repoName);
|
||||||
.getCollaborators(instanceToken, repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Collaborators>>() {
|
call.enqueue(new Callback<List<Collaborators>>() {
|
||||||
|
|
||||||
@ -89,8 +87,6 @@ public class AssigneesActions {
|
|||||||
|
|
||||||
if(assigneesList_.size() > 0) {
|
if(assigneesList_.size() > 0) {
|
||||||
|
|
||||||
dialogAssignees.show();
|
|
||||||
|
|
||||||
assigneesList.add(new Collaborators(tinyDB.getString("userFullname"), tinyDB.getString("loginUid"), tinyDB.getString("userAvatar")));
|
assigneesList.add(new Collaborators(tinyDB.getString("userFullname"), tinyDB.getString("loginUid"), tinyDB.getString("userAvatar")));
|
||||||
assigneesList.addAll(assigneesList_);
|
assigneesList.addAll(assigneesList_);
|
||||||
}
|
}
|
||||||
|
@ -25,21 +25,16 @@ public class CollaboratorActions {
|
|||||||
|
|
||||||
public static void deleteCollaborator(final Context context, final String searchKeyword, String userName) {
|
public static void deleteCollaborator(final Context context, final String searchKeyword, String userName) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
Call<Collaborators> call;
|
Call<Collaborators> call = RetrofitClient
|
||||||
|
.getApiInterface(context)
|
||||||
call = RetrofitClient
|
.deleteCollaborator(Authorization.get(context), repoOwner, repoName, userName);
|
||||||
.getInstance(instanceUrl, context)
|
|
||||||
.getApiInterface()
|
|
||||||
.deleteCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Collaborators>() {
|
call.enqueue(new Callback<Collaborators>() {
|
||||||
|
|
||||||
@ -54,7 +49,7 @@ public class CollaboratorActions {
|
|||||||
//Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
|
//Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
|
||||||
//tinyDb.putBoolean("updateDataSet", true);
|
//tinyDb.putBoolean("updateDataSet", true);
|
||||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
||||||
//usersSearchData.loadUserSearchList(instanceUrl, instanceToken, searchKeyword, context);
|
//usersSearchData.loadUserSearchList(instanceToken, searchKeyword, context);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,22 +89,18 @@ public class CollaboratorActions {
|
|||||||
|
|
||||||
public static void addCollaborator(final Context context, String permission, String userName) {
|
public static void addCollaborator(final Context context, String permission, String userName) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
Permission permissionString = new Permission(permission);
|
Permission permissionString = new Permission(permission);
|
||||||
Call<Permission> call;
|
|
||||||
|
|
||||||
call = RetrofitClient
|
Call<Permission> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.addCollaborator(Authorization.get(context), repoOwner, repoName, userName, permissionString);
|
||||||
.addCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName, permissionString);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Permission>() {
|
call.enqueue(new Callback<Permission>() {
|
||||||
|
|
||||||
@ -122,7 +113,7 @@ public class CollaboratorActions {
|
|||||||
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
||||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
||||||
//usersSearchData.loadUserSearchList(instanceUrl, instanceToken, searchKeyword, context);
|
//usersSearchData.loadUserSearchList(instanceToken, searchKeyword, context);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,11 +155,7 @@ public class CollaboratorActions {
|
|||||||
public static ActionResult<List<Collaborators>> getCollaborators(Context context) {
|
public static ActionResult<List<Collaborators>> getCollaborators(Context context) {
|
||||||
|
|
||||||
ActionResult<List<Collaborators>> actionResult = new ActionResult<>();
|
ActionResult<List<Collaborators>> actionResult = new ActionResult<>();
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
|
|
||||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
String loginUid = tinyDb.getString("loginUid");
|
|
||||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
@ -176,9 +163,8 @@ public class CollaboratorActions {
|
|||||||
String repoName = parts[1];
|
String repoName = parts[1];
|
||||||
|
|
||||||
Call<List<Collaborators>> call = RetrofitClient
|
Call<List<Collaborators>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.getCollaborators(Authorization.get(context), repoOwner, repoName);
|
||||||
.getCollaborators(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Collaborators>>() {
|
call.enqueue(new Callback<List<Collaborators>>() {
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import androidx.annotation.NonNull;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.DraftsApi;
|
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
@ -15,6 +14,7 @@ import org.mian.gitnex.models.Issues;
|
|||||||
import org.mian.gitnex.models.UpdateIssueState;
|
import org.mian.gitnex.models.UpdateIssueState;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -22,85 +22,72 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class IssueActions {
|
public class IssueActions {
|
||||||
|
|
||||||
public static void editIssueComment(final Context ctx, final int commentId, final String commentBody, long draftIdOnCreate) {
|
public static ActionResult<Response<?>> edit(Context context, String comment, int commentId) {
|
||||||
|
|
||||||
|
ActionResult<Response<?>> actionResult = new ActionResult<>();
|
||||||
|
|
||||||
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(ctx);
|
|
||||||
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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
|
||||||
final String repoName = parts[1];
|
|
||||||
|
|
||||||
IssueComments commentBodyJson = new IssueComments(commentBody);
|
String repoOwner = parts[0];
|
||||||
Call<IssueComments> call;
|
String repoName = parts[1];
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().patchIssueComment(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, commentId, commentBodyJson);
|
Call<IssueComments> call = RetrofitClient
|
||||||
|
.getApiInterface(context)
|
||||||
|
.patchIssueComment(Authorization.get(context), repoOwner, repoName, commentId, new IssueComments(comment));
|
||||||
|
|
||||||
call.enqueue(new Callback<IssueComments>() {
|
call.enqueue(new Callback<IssueComments>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<IssueComments> call, @NonNull retrofit2.Response<IssueComments> response) {
|
public void onResponse(@NonNull Call<IssueComments> call, @NonNull retrofit2.Response<IssueComments> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
switch(response.code()) {
|
||||||
if(response.code() == 200) {
|
|
||||||
|
|
||||||
tinyDb.putBoolean("commentEdited", true);
|
case 200:
|
||||||
Toasty.info(ctx, ctx.getString(R.string.editCommentUpdatedText));
|
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||||
|
break;
|
||||||
|
|
||||||
DraftsApi draftsApi = new DraftsApi(ctx);
|
case 401:
|
||||||
draftsApi.deleteSingleDraft((int) draftIdOnCreate);
|
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||||
|
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle), context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), context.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
default:
|
||||||
}
|
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||||
else if(response.code() == 401) {
|
break;
|
||||||
|
|
||||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
|
||||||
|
|
||||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(response.code() == 404) {
|
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<IssueComments> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<IssueComments> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
actionResult.finish(ActionResult.Status.FAILED);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return actionResult;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void closeReopenIssue(final Context ctx, final int issueIndex, final String issueState) {
|
public static void closeReopenIssue(final Context ctx, final int issueIndex, final String issueState) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(ctx);
|
final TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||||
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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
|
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
UpdateIssueState issueStatJson = new UpdateIssueState(issueState);
|
UpdateIssueState issueStatJson = new UpdateIssueState(issueState);
|
||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().closeReopenIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueStatJson);
|
call = RetrofitClient
|
||||||
|
.getApiInterface(ctx)
|
||||||
|
.closeReopenIssue(Authorization.get(ctx), repoOwner, repoName, issueIndex, issueStatJson);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -162,20 +149,23 @@ public class IssueActions {
|
|||||||
|
|
||||||
public static void subscribe(final Context ctx) {
|
public static void subscribe(final Context ctx) {
|
||||||
|
|
||||||
final TinyDB tinyDB = new TinyDB(ctx);
|
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
final String instanceUrl = tinyDB.getString("instanceUrl");
|
|
||||||
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
||||||
|
|
||||||
if(repoFullName.length != 2) {
|
if(repoFullName.length != 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String userLogin = tinyDB.getString("userLogin");
|
final String userLogin = tinyDB.getString("userLogin");
|
||||||
final String token = "token " + tinyDB.getString(tinyDB.getString("loginUid") + "-token");
|
final String token = "token " + tinyDB.getString(tinyDB.getString("loginUid") + "-token");
|
||||||
final int issueNr = Integer.parseInt(tinyDB.getString("issueNumber"));
|
final int issueNr = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
Call<Void> call;
|
Call<Void> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().addIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
call = RetrofitClient
|
||||||
|
.getApiInterface(ctx)
|
||||||
|
.addIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
||||||
|
|
||||||
call.enqueue(new Callback<Void>() {
|
call.enqueue(new Callback<Void>() {
|
||||||
|
|
||||||
@ -222,9 +212,8 @@ public class IssueActions {
|
|||||||
|
|
||||||
public static void unsubscribe(final Context ctx) {
|
public static void unsubscribe(final Context ctx) {
|
||||||
|
|
||||||
final TinyDB tinyDB = new TinyDB(ctx);
|
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
final String instanceUrl = tinyDB.getString("instanceUrl");
|
|
||||||
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
||||||
if(repoFullName.length != 2) {
|
if(repoFullName.length != 2) {
|
||||||
return;
|
return;
|
||||||
@ -235,7 +224,7 @@ public class IssueActions {
|
|||||||
|
|
||||||
Call<Void> call;
|
Call<Void> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().delIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
call = RetrofitClient.getApiInterface(ctx).delIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
||||||
|
|
||||||
call.enqueue(new Callback<Void>() {
|
call.enqueue(new Callback<Void>() {
|
||||||
|
|
||||||
@ -282,11 +271,8 @@ public class IssueActions {
|
|||||||
public static ActionResult<ActionResult.None> reply(Context context, String comment, int issueIndex) {
|
public static ActionResult<ActionResult.None> reply(Context context, String comment, int issueIndex) {
|
||||||
|
|
||||||
ActionResult<ActionResult.None> actionResult = new ActionResult<>();
|
ActionResult<ActionResult.None> actionResult = new ActionResult<>();
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
|
||||||
|
|
||||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
String loginUid = tinyDb.getString("loginUid");
|
|
||||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
@ -296,9 +282,8 @@ public class IssueActions {
|
|||||||
Issues issueComment = new Issues(comment);
|
Issues issueComment = new Issues(comment);
|
||||||
|
|
||||||
Call<Issues> call = RetrofitClient
|
Call<Issues> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.replyCommentToIssue(Authorization.get(context), repoOwner, repoName, issueIndex, issueComment);
|
||||||
.replyCommentToIssue(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Issues>() {
|
call.enqueue(new Callback<Issues>() {
|
||||||
|
|
||||||
|
@ -22,12 +22,11 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class LabelsActions {
|
public class LabelsActions {
|
||||||
|
|
||||||
public static void getCurrentIssueLabels(Context ctx, String instanceUrl, String loginUid, String instanceToken, String repoOwner, String repoName, int issueIndex, List<Integer> currentLabelsIds) {
|
public static void getCurrentIssueLabels(Context ctx, String repoOwner, String repoName, int issueIndex, List<Integer> currentLabelsIds) {
|
||||||
|
|
||||||
Call<List<Labels>> callSingleIssueLabels = RetrofitClient
|
Call<List<Labels>> callSingleIssueLabels = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getIssueLabels(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||||
.getIssueLabels(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
|
||||||
|
|
||||||
callSingleIssueLabels.enqueue(new Callback<List<Labels>>() {
|
callSingleIssueLabels.enqueue(new Callback<List<Labels>>() {
|
||||||
|
|
||||||
@ -60,12 +59,11 @@ public class LabelsActions {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getRepositoryLabels(Context ctx, String instanceUrl, String instanceToken, String repoOwner, String repoName, List<Labels> labelsList, Dialog dialogLabels, LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding) {
|
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Labels> labelsList, Dialog dialogLabels, LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding) {
|
||||||
|
|
||||||
Call<List<Labels>> call = RetrofitClient
|
Call<List<Labels>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getLabels(Authorization.get(ctx), repoOwner, repoName);
|
||||||
.getlabels(instanceToken, repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Labels>>() {
|
call.enqueue(new Callback<List<Labels>>() {
|
||||||
|
|
||||||
@ -73,28 +71,45 @@ public class LabelsActions {
|
|||||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> response) {
|
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> response) {
|
||||||
|
|
||||||
labelsList.clear();
|
labelsList.clear();
|
||||||
List<Labels> labelsList_ = response.body();
|
|
||||||
|
|
||||||
labelsBinding.progressBar.setVisibility(View.GONE);
|
|
||||||
labelsBinding.dialogFrame.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (response.code() == 200) {
|
if (response.code() == 200) {
|
||||||
|
|
||||||
assert labelsList_ != null;
|
if(response.body() != null) {
|
||||||
|
|
||||||
if(labelsList_.size() > 0) {
|
labelsList.addAll(response.body());
|
||||||
|
|
||||||
dialogLabels.show();
|
|
||||||
|
|
||||||
labelsList.addAll(labelsList_);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
dialogLabels.dismiss();
|
|
||||||
Toasty.warning(ctx, ctx.getResources().getString(R.string.noLabelsFound));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
labelsBinding.labelsRecyclerView.setAdapter(labelsAdapter);
|
// Load organization labels
|
||||||
|
Call<List<Labels>> callOrgLabels = RetrofitClient
|
||||||
|
.getApiInterface(ctx)
|
||||||
|
.getOrganizationLabels(Authorization.get(ctx), repoOwner);
|
||||||
|
|
||||||
|
callOrgLabels.enqueue(new Callback<List<Labels>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> responseOrg) {
|
||||||
|
|
||||||
|
labelsBinding.progressBar.setVisibility(View.GONE);
|
||||||
|
labelsBinding.dialogFrame.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
if(responseOrg.body() != null) {
|
||||||
|
|
||||||
|
labelsList.addAll(responseOrg.body());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(labelsList.isEmpty()) {
|
||||||
|
|
||||||
|
dialogLabels.dismiss();
|
||||||
|
Toasty.warning(ctx, ctx.getResources().getString(R.string.noLabelsFound));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
labelsBinding.labelsRecyclerView.setAdapter(labelsAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -23,9 +23,8 @@ public class MilestoneActions {
|
|||||||
|
|
||||||
public static void closeMilestone(final Context ctx, int milestoneId_) {
|
public static void closeMilestone(final Context ctx, int milestoneId_) {
|
||||||
|
|
||||||
final TinyDB tinyDB = new TinyDB(ctx);
|
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
final String instanceUrl = tinyDB.getString("instanceUrl");
|
|
||||||
String repoFullName = tinyDB.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -37,8 +36,7 @@ public class MilestoneActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
@ -81,9 +79,8 @@ public class MilestoneActions {
|
|||||||
|
|
||||||
public static void openMilestone(final Context ctx, int milestoneId_) {
|
public static void openMilestone(final Context ctx, int milestoneId_) {
|
||||||
|
|
||||||
final TinyDB tinyDB = new TinyDB(ctx);
|
final TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
final String instanceUrl = tinyDB.getString("instanceUrl");
|
|
||||||
String repoFullName = tinyDB.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -95,8 +92,7 @@ public class MilestoneActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
.closeReopenMilestone(token, repoOwner, repoName, milestoneId_, milestoneStateJson);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
@ -20,24 +20,22 @@ public class NotificationsActions {
|
|||||||
|
|
||||||
private TinyDB tinyDB;
|
private TinyDB tinyDB;
|
||||||
private Context context;
|
private Context context;
|
||||||
private String instanceUrl;
|
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
|
|
||||||
public NotificationsActions(Context context) {
|
public NotificationsActions(Context context) {
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.tinyDB = new TinyDB(context);
|
this.tinyDB = TinyDB.getInstance(context);
|
||||||
|
|
||||||
String loginUid = tinyDB.getString("loginUid");
|
String loginUid = tinyDB.getString("loginUid");
|
||||||
|
|
||||||
instanceUrl = tinyDB.getString("instanceUrl");
|
|
||||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotificationStatus(NotificationThread notificationThread, NotificationStatus notificationStatus) throws IOException {
|
public void setNotificationStatus(NotificationThread notificationThread, NotificationStatus notificationStatus) throws IOException {
|
||||||
|
|
||||||
Call<ResponseBody> call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface()
|
Call<ResponseBody> call = RetrofitClient.getApiInterface(context)
|
||||||
.markNotificationThreadAsRead(instanceToken, notificationThread.getId(), notificationStatus.name());
|
.markNotificationThreadAsRead(instanceToken, notificationThread.getId(), notificationStatus.name());
|
||||||
|
|
||||||
if(!call.execute().isSuccessful()) {
|
if(!call.execute().isSuccessful()) {
|
||||||
@ -48,7 +46,7 @@ public class NotificationsActions {
|
|||||||
|
|
||||||
public boolean setAllNotificationsRead(Date date) throws IOException {
|
public boolean setAllNotificationsRead(Date date) throws IOException {
|
||||||
|
|
||||||
Call<ResponseBody> call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface()
|
Call<ResponseBody> call = RetrofitClient.getApiInterface(context)
|
||||||
.markNotificationThreadsAsRead(instanceToken, AppUtil.getTimestampFromDate(context, date), true,
|
.markNotificationThreadsAsRead(instanceToken, AppUtil.getTimestampFromDate(context, date), true,
|
||||||
new String[]{"unread", "pinned"}, "read");
|
new String[]{"unread", "pinned"}, "read");
|
||||||
|
|
||||||
|
@ -21,10 +21,8 @@ public class RepositoryActions {
|
|||||||
|
|
||||||
public static void starRepository(final Context context) {
|
public static void starRepository(final Context context) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -33,9 +31,8 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.starRepository(Authorization.get(context), repoOwner, repoName);
|
||||||
.starRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -86,10 +83,8 @@ public class RepositoryActions {
|
|||||||
|
|
||||||
public static void unStarRepository(final Context context) {
|
public static void unStarRepository(final Context context) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -98,9 +93,8 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.unStarRepository(Authorization.get(context), repoOwner, repoName);
|
||||||
.unStarRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -151,10 +145,8 @@ public class RepositoryActions {
|
|||||||
|
|
||||||
public static void watchRepository(final Context context) {
|
public static void watchRepository(final Context context) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -163,9 +155,8 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.watchRepository(Authorization.get(context), repoOwner, repoName);
|
||||||
.watchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -216,10 +207,8 @@ public class RepositoryActions {
|
|||||||
|
|
||||||
public static void unWatchRepository(final Context context) {
|
public static void unWatchRepository(final Context context) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
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 repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -228,9 +217,8 @@ public class RepositoryActions {
|
|||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.unWatchRepository(Authorization.get(context), repoOwner, repoName);
|
||||||
.unWatchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
|
@ -21,17 +21,13 @@ public class TeamActions {
|
|||||||
|
|
||||||
public static void removeTeamMember(final Context context, String userName, int teamId) {
|
public static void removeTeamMember(final Context context, String userName, int teamId) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, context)
|
.getApiInterface(context)
|
||||||
.getApiInterface()
|
.removeTeamMember(Authorization.get(context), teamId, userName);
|
||||||
.removeTeamMember(Authorization.returnAuthentication(context, loginUid, instanceToken), teamId, userName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -87,17 +83,11 @@ public class TeamActions {
|
|||||||
|
|
||||||
public static void addTeamMember(final Context context, String userName, int teamId) {
|
public static void addTeamMember(final Context context, String userName, int teamId) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
Call<JsonElement> call;
|
Call<JsonElement> call = RetrofitClient
|
||||||
|
.getApiInterface(context)
|
||||||
call = RetrofitClient
|
.addTeamMember(Authorization.get(context), teamId, userName);
|
||||||
.getInstance(instanceUrl, context)
|
|
||||||
.getApiInterface()
|
|
||||||
.addTeamMember(Authorization.returnAuthentication(context, loginUid, instanceToken), teamId, userName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.adapters.UserSearchAdapter;
|
import org.mian.gitnex.adapters.UserSearchAdapter;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.models.UserInfo;
|
import org.mian.gitnex.models.UserInfo;
|
||||||
import org.mian.gitnex.models.UserSearch;
|
import org.mian.gitnex.models.UserSearch;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -32,8 +31,6 @@ import retrofit2.Response;
|
|||||||
public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TextView addCollaboratorSearch;
|
private TextView addCollaboratorSearch;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
@ -49,21 +46,13 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
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 instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
addCollaboratorSearch = findViewById(R.id.addCollaboratorSearch);
|
addCollaboratorSearch = findViewById(R.id.addCollaboratorSearch);
|
||||||
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
||||||
mProgressBar = findViewById(R.id.progress_bar);
|
mProgressBar = findViewById(R.id.progressBar);
|
||||||
noData = findViewById(R.id.noData);
|
noData = findViewById(R.id.noData);
|
||||||
|
|
||||||
addCollaboratorSearch.requestFocus();
|
addCollaboratorSearch.requestFocus();
|
||||||
@ -76,8 +65,11 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||||||
addCollaboratorSearch.setOnEditorActionListener((v, actionId, event) -> {
|
addCollaboratorSearch.setOnEditorActionListener((v, actionId, event) -> {
|
||||||
|
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||||
|
|
||||||
if(!addCollaboratorSearch.getText().toString().equals("")) {
|
if(!addCollaboratorSearch.getText().toString().equals("")) {
|
||||||
loadUserSearchList(instanceUrl, instanceToken, addCollaboratorSearch.getText().toString(), loginUid);
|
|
||||||
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
loadUserSearchList(addCollaboratorSearch.getText().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,22 +79,26 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadUserSearchList(String instanceUrl, String token, String searchKeyword, String loginUid) {
|
public void loadUserSearchList(String searchKeyword) {
|
||||||
|
|
||||||
Call<UserSearch> call = RetrofitClient
|
Call<UserSearch> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
.getUserBySearch(Authorization.get(ctx), searchKeyword, 10);
|
||||||
.getUserBySearch(Authorization.returnAuthentication(ctx, loginUid, token), searchKeyword, 10);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<UserSearch>() {
|
call.enqueue(new Callback<UserSearch>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<UserSearch> call, @NonNull Response<UserSearch> response) {
|
public void onResponse(@NonNull Call<UserSearch> call, @NonNull Response<UserSearch> response) {
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
mProgressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if (response.code() == 200) {
|
||||||
|
|
||||||
assert response.body() != null;
|
assert response.body() != null;
|
||||||
getUsersList(response.body().getData(), ctx);
|
getUsersList(response.body().getData(), ctx);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
Log.i("onResponse", String.valueOf(response.code()));
|
Log.i("onResponse", String.valueOf(response.code()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,15 +125,16 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if(adapter.getItemCount() > 0) {
|
if(adapter.getItemCount() > 0) {
|
||||||
|
|
||||||
mRecyclerView.setAdapter(adapter);
|
mRecyclerView.setAdapter(adapter);
|
||||||
noData.setVisibility(View.GONE);
|
noData.setVisibility(View.GONE);
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
noData.setVisibility(View.VISIBLE);
|
noData.setVisibility(View.VISIBLE);
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mProgressBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -15,7 +14,6 @@ import org.mian.gitnex.database.api.UserAccountsApi;
|
|||||||
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
|
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.PathsHelper;
|
import org.mian.gitnex.helpers.PathsHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.UrlHelper;
|
import org.mian.gitnex.helpers.UrlHelper;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
@ -32,10 +30,6 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class AddNewAccountActivity extends BaseActivity {
|
public class AddNewAccountActivity extends BaseActivity {
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDB;
|
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private ActivityAddNewAccountBinding viewBinding;
|
private ActivityAddNewAccountBinding viewBinding;
|
||||||
|
|
||||||
@ -52,8 +46,6 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDB = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityAddNewAccountBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityAddNewAccountBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
@ -76,7 +68,6 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -132,7 +123,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
|
|
||||||
Call<GiteaVersion> callVersion;
|
Call<GiteaVersion> callVersion;
|
||||||
|
|
||||||
callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken("token " + loginToken);
|
callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken("token " + loginToken);
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
|
|
||||||
@ -144,7 +135,9 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
GiteaVersion version = responseVersion.body();
|
GiteaVersion version = responseVersion.body();
|
||||||
|
|
||||||
assert version != null;
|
assert version != null;
|
||||||
|
|
||||||
if(!Version.valid(version.getVersion())) {
|
if(!Version.valid(version.getVersion())) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
|
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -170,7 +163,6 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
alertDialogBuilder.create().show();
|
alertDialogBuilder.create().show();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(giteaVersion.lessOrEqual(getString(R.string.versionHigh))) {
|
else if(giteaVersion.lessOrEqual(getString(R.string.versionHigh))) {
|
||||||
|
|
||||||
@ -180,7 +172,6 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
|
|
||||||
Toasty.warning(ctx, getResources().getString(R.string.versionUnsupportedNew));
|
Toasty.warning(ctx, getResources().getString(R.string.versionUnsupportedNew));
|
||||||
login(instanceUrl, loginToken);
|
login(instanceUrl, loginToken);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -193,7 +184,6 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
private void login(String instanceUrl, String loginToken) {
|
private void login(String instanceUrl, String loginToken) {
|
||||||
|
|
||||||
setupNewAccountWithToken(instanceUrl, loginToken);
|
setupNewAccountWithToken(instanceUrl, loginToken);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -207,7 +197,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void setupNewAccountWithToken(String instanceUrl, final String loginToken) {
|
private void setupNewAccountWithToken(String instanceUrl, final String loginToken) {
|
||||||
|
|
||||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserInfo("token " + loginToken);
|
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx, instanceUrl).getUserInfo("token " + loginToken);
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.adapters.UserSearchForTeamMemberAdapter;
|
import org.mian.gitnex.adapters.UserSearchForTeamMemberAdapter;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.models.UserInfo;
|
import org.mian.gitnex.models.UserInfo;
|
||||||
import org.mian.gitnex.models.UserSearch;
|
import org.mian.gitnex.models.UserSearch;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -35,8 +34,6 @@ import retrofit2.Response;
|
|||||||
public class AddNewTeamMemberActivity extends BaseActivity {
|
public class AddNewTeamMemberActivity extends BaseActivity {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TextView addNewTeamMember;
|
private TextView addNewTeamMember;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
@ -56,17 +53,9 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
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 instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
addNewTeamMember = findViewById(R.id.addNewTeamMember);
|
addNewTeamMember = findViewById(R.id.addNewTeamMember);
|
||||||
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
||||||
@ -81,9 +70,11 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
if(getIntent().getStringExtra("teamId") != null && !Objects.requireNonNull(getIntent().getStringExtra("teamId")).equals("")) {
|
if(getIntent().getStringExtra("teamId") != null && !Objects.requireNonNull(getIntent().getStringExtra("teamId")).equals("")) {
|
||||||
|
|
||||||
teamId = getIntent().getStringExtra("teamId");
|
teamId = getIntent().getStringExtra("teamId");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
teamId = "0";
|
teamId = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,10 +94,8 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
|||||||
if(!addNewTeamMember.getText().toString().equals("") && addNewTeamMember.getText().toString().length() > 1) {
|
if(!addNewTeamMember.getText().toString().equals("") && addNewTeamMember.getText().toString().length() > 1) {
|
||||||
|
|
||||||
adapter = new UserSearchForTeamMemberAdapter(dataList, ctx, Integer.parseInt(teamId));
|
adapter = new UserSearchForTeamMemberAdapter(dataList, ctx, Integer.parseInt(teamId));
|
||||||
loadUserSearchList(instanceUrl, instanceToken, addNewTeamMember.getText().toString(), loginUid, teamId);
|
loadUserSearchList(addNewTeamMember.getText().toString(), teamId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -121,9 +110,9 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadUserSearchList(String instanceUrl, String token, String searchKeyword, String loginUid, String teamId) {
|
public void loadUserSearchList(String searchKeyword, String teamId) {
|
||||||
|
|
||||||
Call<UserSearch> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserBySearch(Authorization.returnAuthentication(ctx, loginUid, token), searchKeyword, 10);
|
Call<UserSearch> call = RetrofitClient.getApiInterface(ctx).getUserBySearch(Authorization.get(ctx), searchKeyword, 10);
|
||||||
|
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
@ -141,16 +130,13 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
|||||||
dataList.addAll(response.body().getData());
|
dataList.addAll(response.body().getData());
|
||||||
mRecyclerView.setAdapter(adapter);
|
mRecyclerView.setAdapter(adapter);
|
||||||
noData.setVisibility(View.GONE);
|
noData.setVisibility(View.GONE);
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
noData.setVisibility(View.VISIBLE);
|
noData.setVisibility(View.VISIBLE);
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mProgressBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import org.mian.gitnex.adapters.AdminGetUsersAdapter;
|
|||||||
import org.mian.gitnex.fragments.BottomSheetAdminUsersFragment;
|
import org.mian.gitnex.fragments.BottomSheetAdminUsersFragment;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,8 +33,6 @@ import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
|||||||
public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAdminUsersFragment.BottomSheetListener {
|
public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAdminUsersFragment.BottomSheetListener {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private AdminGetUsersAdapter adapter;
|
private AdminGetUsersAdapter adapter;
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private TextView noDataUsers;
|
private TextView noDataUsers;
|
||||||
@ -50,12 +47,6 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
noDataUsers = findViewById(R.id.noDataUsers);
|
noDataUsers = findViewById(R.id.noDataUsers);
|
||||||
@ -79,30 +70,30 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
|||||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
AdminGetUsersViewModel.loadUsersList(ctx, instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken));
|
AdminGetUsersViewModel.loadUsersList(ctx, Authorization.get(ctx));
|
||||||
|
|
||||||
}, 500));
|
}, 500));
|
||||||
|
|
||||||
fetchDataAsync(ctx, instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken));
|
fetchDataAsync(ctx, Authorization.get(ctx));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchDataAsync(Context ctx, String instanceUrl, String instanceToken) {
|
private void fetchDataAsync(Context ctx, String instanceToken) {
|
||||||
|
|
||||||
AdminGetUsersViewModel usersModel = new ViewModelProvider(this).get(AdminGetUsersViewModel.class);
|
AdminGetUsersViewModel usersModel = new ViewModelProvider(this).get(AdminGetUsersViewModel.class);
|
||||||
|
|
||||||
usersModel.getUsersList(ctx, instanceUrl, instanceToken).observe(this, usersListMain -> {
|
usersModel.getUsersList(ctx, instanceToken).observe(this, usersListMain -> {
|
||||||
|
|
||||||
adapter = new AdminGetUsersAdapter(ctx, usersListMain);
|
adapter = new AdminGetUsersAdapter(ctx, usersListMain);
|
||||||
if(adapter.getItemCount() > 0) {
|
if(adapter.getItemCount() > 0) {
|
||||||
|
|
||||||
mRecyclerView.setVisibility(View.VISIBLE);
|
mRecyclerView.setVisibility(View.VISIBLE);
|
||||||
mRecyclerView.setAdapter(adapter);
|
mRecyclerView.setAdapter(adapter);
|
||||||
noDataUsers.setVisibility(View.GONE);
|
noDataUsers.setVisibility(View.GONE);
|
||||||
searchFilter = true;
|
searchFilter = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//adapter.notifyDataSetChanged();
|
|
||||||
//mRecyclerView.setAdapter(adapter);
|
|
||||||
mRecyclerView.setVisibility(View.GONE);
|
mRecyclerView.setVisibility(View.GONE);
|
||||||
noDataUsers.setVisibility(View.VISIBLE);
|
noDataUsers.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
@ -140,6 +131,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextChange(String newText) {
|
public boolean onQueryTextChange(String newText) {
|
||||||
|
|
||||||
adapter.getFilter().filter(newText);
|
adapter.getFilter().filter(newText);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -157,18 +149,21 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
|||||||
|
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
switch (id) {
|
if(id == android.R.id.home) {
|
||||||
case android.R.id.home:
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
case R.id.genericMenu:
|
|
||||||
BottomSheetAdminUsersFragment bottomSheet = new BottomSheetAdminUsersFragment();
|
|
||||||
bottomSheet.show(getSupportFragmentManager(), "usersBottomSheet");
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(id == R.id.genericMenu) {
|
||||||
|
|
||||||
|
BottomSheetAdminUsersFragment bottomSheet = new BottomSheetAdminUsersFragment();
|
||||||
|
bottomSheet.show(getSupportFragmentManager(), "usersBottomSheet");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -14,6 +15,7 @@ import org.acra.data.StringFormat;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.FontsOverride;
|
import org.mian.gitnex.helpers.FontsOverride;
|
||||||
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.notifications.NotificationsMaster;
|
import org.mian.gitnex.notifications.NotificationsMaster;
|
||||||
@ -25,6 +27,7 @@ import static org.acra.ReportField.STACK_TRACE;
|
|||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@SuppressLint("NonConstantResourceId")
|
||||||
@AcraNotification(resIcon = R.drawable.gitnex_transparent,
|
@AcraNotification(resIcon = R.drawable.gitnex_transparent,
|
||||||
resTitle = R.string.crashTitle,
|
resTitle = R.string.crashTitle,
|
||||||
resChannelName = R.string.setCrashReports,
|
resChannelName = R.string.setCrashReports,
|
||||||
@ -33,119 +36,144 @@ import static org.acra.ReportField.STACK_TRACE;
|
|||||||
|
|
||||||
public abstract class BaseActivity extends AppCompatActivity {
|
public abstract class BaseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
protected TinyDB tinyDB;
|
||||||
|
|
||||||
|
protected Context ctx = this;
|
||||||
|
protected Context appCtx;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
appCtx = getApplicationContext();
|
this.appCtx = getApplicationContext();
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
this.tinyDB = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
switch(tinyDb.getInt("themeId")) {
|
switch(tinyDB.getInt("themeId")) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
|
tinyDB.putString("currentTheme", "light");
|
||||||
setTheme(R.style.AppThemeLight);
|
setTheme(R.style.AppThemeLight);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
||||||
|
|
||||||
|
tinyDB.putString("currentTheme", "dark");
|
||||||
setTheme(R.style.AppTheme);
|
setTheme(R.style.AppTheme);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
tinyDB.putString("currentTheme", "light");
|
||||||
setTheme(R.style.AppThemeLight);
|
setTheme(R.style.AppThemeLight);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
|
||||||
|
tinyDB.putString("currentTheme", "light");
|
||||||
setTheme(R.style.AppThemeRetro);
|
setTheme(R.style.AppThemeRetro);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
||||||
|
|
||||||
|
tinyDB.putString("currentTheme", "dark");
|
||||||
setTheme(R.style.AppTheme);
|
setTheme(R.style.AppTheme);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
tinyDB.putString("currentTheme", "light");
|
||||||
setTheme(R.style.AppThemeRetro);
|
setTheme(R.style.AppThemeRetro);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
|
||||||
default:
|
tinyDB.putString("currentTheme", "dark");
|
||||||
setTheme(R.style.AppTheme);
|
setTheme(R.style.AppThemePitchBlack);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
tinyDB.putString("currentTheme", "dark");
|
||||||
|
setTheme(R.style.AppTheme);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String appLocale = tinyDb.getString("locale");
|
String appLocale = tinyDB.getString("locale");
|
||||||
AppUtil.setAppLocale(getResources(), appLocale);
|
AppUtil.setAppLocale(getResources(), appLocale);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(getLayoutResourceId());
|
setContentView(getLayoutResourceId());
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
// FIXME Performance nightmare
|
||||||
|
switch(tinyDB.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/roboto.ttf");
|
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/roboto.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/roboto.ttf");
|
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/roboto.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/roboto.ttf");
|
FontsOverride.setDefaultFont(this, "SERIF", "fonts/roboto.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/roboto.ttf");
|
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/roboto.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/sourcecodeproregular.ttf");
|
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/sourcecodeproregular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/sourcecodeproregular.ttf");
|
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/sourcecodeproregular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/sourcecodeproregular.ttf");
|
FontsOverride.setDefaultFont(this, "SERIF", "fonts/sourcecodeproregular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/sourcecodeproregular.ttf");
|
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/sourcecodeproregular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/manroperegular.ttf");
|
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/manroperegular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/manroperegular.ttf");
|
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/manroperegular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/manroperegular.ttf");
|
FontsOverride.setDefaultFont(this, "SERIF", "fonts/manroperegular.ttf");
|
||||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/manroperegular.ttf");
|
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/manroperegular.ttf");
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getInt("pollingDelayMinutes") == 0) {
|
if(tinyDB.getInt("pollingDelayMinutes", 0) <= 0) {
|
||||||
tinyDb.putInt("pollingDelayMinutes", 15);
|
|
||||||
|
tinyDB.putInt("pollingDelayMinutes", StaticGlobalVariables.defaultPollingDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME Performance nightmare
|
||||||
NotificationsMaster.hireWorker(appCtx);
|
NotificationsMaster.hireWorker(appCtx);
|
||||||
|
|
||||||
// enabling counter badges by default
|
// enabling counter badges by default
|
||||||
if(tinyDb.getString("enableCounterBadgesInit").isEmpty()) {
|
if(tinyDB.getString("enableCounterBadgesInit").isEmpty()) {
|
||||||
tinyDb.putBoolean("enableCounterBadges", true);
|
|
||||||
tinyDb.putString("enableCounterBadgesInit", "yes");
|
tinyDB.putBoolean("enableCounterBadges", true);
|
||||||
|
tinyDB.putString("enableCounterBadgesInit", "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable crash reports by default
|
// enable crash reports by default
|
||||||
if(tinyDb.getString("crashReportingEnabledInit").isEmpty()) {
|
if(tinyDB.getString("crashReportingEnabledInit").isEmpty()) {
|
||||||
tinyDb.putBoolean("crashReportingEnabled", true);
|
|
||||||
tinyDb.putString("crashReportingEnabledInit", "yes");
|
tinyDB.putBoolean("crashReportingEnabled", true);
|
||||||
|
tinyDB.putString("crashReportingEnabledInit", "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
// default cache setter
|
// default cache setter
|
||||||
if(tinyDb.getString("cacheSizeStr").isEmpty()) {
|
if(tinyDB.getString("cacheSizeStr").isEmpty()) {
|
||||||
tinyDb.putString("cacheSizeStr", getResources().getString(R.string.cacheSizeDataSelectionSelectedText));
|
|
||||||
|
tinyDB.putString("cacheSizeStr", getResources().getString(R.string.cacheSizeDataSelectionSelectedText));
|
||||||
}
|
}
|
||||||
if(tinyDb.getString("cacheSizeImagesStr").isEmpty()) {
|
if(tinyDB.getString("cacheSizeImagesStr").isEmpty()) {
|
||||||
tinyDb.putString("cacheSizeImagesStr", getResources().getString(R.string.cacheSizeImagesSelectionSelectedText));
|
|
||||||
|
tinyDB.putString("cacheSizeImagesStr", getResources().getString(R.string.cacheSizeImagesSelectionSelectedText));
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable comment drafts by default
|
// enable comment drafts by default
|
||||||
if(tinyDb.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
|
if(tinyDB.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
|
||||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
|
|
||||||
tinyDb.putString("draftsCommentsDeletionEnabledInit", "yes");
|
tinyDB.putBoolean("draftsCommentsDeletionEnabled", true);
|
||||||
|
tinyDB.putString("draftsCommentsDeletionEnabledInit", "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tinyDb.getBoolean("crashReportingEnabled")) {
|
// FIXME Performance nightmare
|
||||||
|
if (tinyDB.getBoolean("crashReportingEnabled")) {
|
||||||
|
|
||||||
CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
|
CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
|
||||||
ACRABuilder.setBuildConfigClass(BuildConfig.class).setReportFormat(StringFormat.KEY_VALUE_LIST);
|
ACRABuilder.setBuildConfigClass(BuildConfig.class).setReportFormat(StringFormat.KEY_VALUE_LIST);
|
||||||
ACRABuilder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder.class).setReportAsFile(true).setMailTo(getResources().getString(R.string.appEmail)).setSubject(getResources().getString(R.string.crashReportEmailSubject, AppUtil.getAppBuildNo(getApplicationContext()))).setEnabled(true);
|
ACRABuilder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder.class).setReportAsFile(true).setMailTo(getResources().getString(R.string.appEmail)).setSubject(getResources().getString(R.string.crashReportEmailSubject, AppUtil.getAppBuildNo(getApplicationContext()))).setEnabled(true);
|
||||||
ACRABuilder.getPluginConfigurationBuilder(LimiterConfigurationBuilder.class).setEnabled(true);
|
ACRABuilder.getPluginConfigurationBuilder(LimiterConfigurationBuilder.class).setEnabled(true);
|
||||||
ACRA.init(getApplication(), ACRABuilder);
|
ACRA.init(getApplication(), ACRABuilder);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@ -21,13 +20,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.CommitsAdapter;
|
import org.mian.gitnex.adapters.CommitsAdapter;
|
||||||
import org.mian.gitnex.clients.AppApiService;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.interfaces.ApiInterface;
|
|
||||||
import org.mian.gitnex.models.Commits;
|
import org.mian.gitnex.models.Commits;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,8 +38,6 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class CommitsActivity extends BaseActivity {
|
public class CommitsActivity extends BaseActivity {
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
@ -53,7 +48,6 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private List<Commits> commitsList;
|
private List<Commits> commitsList;
|
||||||
private CommitsAdapter adapter;
|
private CommitsAdapter adapter;
|
||||||
private ApiInterface api;
|
|
||||||
private ProgressBar progressLoadMore;
|
private ProgressBar progressLoadMore;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,15 +60,10 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
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("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
@ -95,7 +84,8 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
|
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12")) {
|
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12")) {
|
||||||
|
|
||||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,9 +95,8 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName, resultLimit);
|
loadInitial(Authorization.get(ctx), repoOwner, repoName, branchName, resultLimit);
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
|
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
adapter = new CommitsAdapter(ctx, commitsList);
|
adapter = new CommitsAdapter(ctx, commitsList);
|
||||||
@ -116,23 +105,20 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
if(commitsList.size() == resultLimit || pageSize == resultLimit) {
|
if(commitsList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
|
||||||
int page = (commitsList.size() + resultLimit) / resultLimit;
|
int page = (commitsList.size() + resultLimit) / resultLimit;
|
||||||
loadMore(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, branchName, resultLimit);
|
loadMore(Authorization.get(ctx), repoOwner, repoName, page, branchName, resultLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
api = AppApiService.createService(ApiInterface.class, instanceUrl, ctx);
|
loadInitial(Authorization.get(ctx), repoOwner, repoName, branchName, resultLimit);
|
||||||
loadInitial(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName, resultLimit);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadInitial(String token, String repoOwner, String repoName, String branchName, int resultLimit) {
|
private void loadInitial(String token, String repoOwner, String repoName, String branchName, int resultLimit) {
|
||||||
|
|
||||||
Call<List<Commits>> call = api.getRepositoryCommits(token, repoOwner, repoName, 1, branchName, resultLimit);
|
Call<List<Commits>> call = RetrofitClient.getApiInterface(ctx).getRepositoryCommits(token, repoOwner, repoName, 1, branchName, resultLimit);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Commits>>() {
|
call.enqueue(new Callback<List<Commits>>() {
|
||||||
|
|
||||||
@ -148,7 +134,6 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
commitsList.addAll(response.body());
|
commitsList.addAll(response.body());
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
noData.setVisibility(View.GONE);
|
noData.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -164,7 +149,6 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
Log.e(TAG, String.valueOf(response.code()));
|
Log.e(TAG, String.valueOf(response.code()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
@ -184,7 +168,7 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
|
|
||||||
progressLoadMore.setVisibility(View.VISIBLE);
|
progressLoadMore.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
Call<List<Commits>> call = api.getRepositoryCommits(token, repoOwner, repoName, page, branchName, resultLimit);
|
Call<List<Commits>> call = RetrofitClient.getApiInterface(ctx).getRepositoryCommits(token, repoOwner, repoName, page, branchName, resultLimit);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Commits>>() {
|
call.enqueue(new Callback<List<Commits>>() {
|
||||||
|
|
||||||
@ -211,7 +195,6 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
Log.e(TAG, String.valueOf(response.code()));
|
Log.e(TAG, String.valueOf(response.code()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
progressLoadMore.setVisibility(View.GONE);
|
progressLoadMore.setVisibility(View.GONE);
|
||||||
@ -255,7 +238,6 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filter(String text) {
|
private void filter(String text) {
|
||||||
@ -263,7 +245,9 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
List<Commits> arr = new ArrayList<>();
|
List<Commits> arr = new ArrayList<>();
|
||||||
|
|
||||||
for(Commits d : commitsList) {
|
for(Commits d : commitsList) {
|
||||||
|
|
||||||
if(d.getCommit().getMessage().toLowerCase().contains(text) || d.getSha().toLowerCase().contains(text)) {
|
if(d.getCommit().getMessage().toLowerCase().contains(text) || d.getSha().toLowerCase().contains(text)) {
|
||||||
|
|
||||||
arr.add(d);
|
arr.add(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,6 +258,7 @@ public class CommitsActivity extends BaseActivity {
|
|||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
|
||||||
onClickListener = view -> {
|
onClickListener = view -> {
|
||||||
|
|
||||||
getIntent().removeExtra("branchName");
|
getIntent().removeExtra("branchName");
|
||||||
finish();
|
finish();
|
||||||
};
|
};
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -19,7 +20,6 @@ import org.mian.gitnex.clients.RetrofitClient;
|
|||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
import org.mian.gitnex.models.DeleteFile;
|
import org.mian.gitnex.models.DeleteFile;
|
||||||
@ -44,49 +44,48 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
private EditText newFileContent;
|
private EditText newFileContent;
|
||||||
private EditText newFileBranchName;
|
private EditText newFileBranchName;
|
||||||
private EditText newFileCommitMessage;
|
private EditText newFileCommitMessage;
|
||||||
private Spinner newFileBranchesSpinner;
|
private AutoCompleteTextView newFileBranchesSpinner;
|
||||||
private String filePath;
|
private String filePath;
|
||||||
private String fileSha;
|
private String fileSha;
|
||||||
private int fileAction = 0; // 0 = create, 1 = delete, 2 = edit
|
private int fileAction = 0; // 0 = create, 1 = delete, 2 = edit
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
List<Branches> branchesList = new ArrayList<>();
|
List<Branches> branchesList = new ArrayList<>();
|
||||||
|
|
||||||
|
private String loginUid;
|
||||||
|
private String repoOwner;
|
||||||
|
private String repoName;
|
||||||
|
private String instanceToken;
|
||||||
|
|
||||||
|
private String selectedBranch;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
return R.layout.activity_new_file;
|
return R.layout.activity_new_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
repoName = parts[1];
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
closeActivity = findViewById(R.id.close);
|
closeActivity = findViewById(R.id.close);
|
||||||
newFileName = findViewById(R.id.newFileName);
|
newFileName = findViewById(R.id.newFileName);
|
||||||
newFileContent = findViewById(R.id.newFileContent);
|
newFileContent = findViewById(R.id.newFileContent);
|
||||||
newFileBranchName = findViewById(R.id.newFileBranchName);
|
newFileBranchName = findViewById(R.id.newFileBranchName);
|
||||||
newFileCommitMessage = findViewById(R.id.newFileCommitMessage);
|
newFileCommitMessage = findViewById(R.id.newFileCommitMessage);
|
||||||
TextView branchNameId = findViewById(R.id.branchNameId);
|
|
||||||
TextView branchNameHintText = findViewById(R.id.branchNameHintText);
|
|
||||||
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
|
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
|
||||||
TextView fileNameHint = findViewById(R.id.fileNameHint);
|
|
||||||
|
|
||||||
newFileName.requestFocus();
|
newFileName.requestFocus();
|
||||||
assert imm != null;
|
assert imm != null;
|
||||||
@ -97,9 +96,19 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
newFileCreate = findViewById(R.id.newFileCreate);
|
newFileCreate = findViewById(R.id.newFileCreate);
|
||||||
|
|
||||||
|
newFileContent.setOnTouchListener((touchView, motionEvent) -> {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||||
|
|
||||||
|
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", 1) == 1) {
|
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", 1) == 1) {
|
||||||
|
|
||||||
fileNameHint.setVisibility(View.GONE);
|
|
||||||
fileAction = getIntent().getIntExtra("fileAction", 1);
|
fileAction = getIntent().getIntExtra("fileAction", 1);
|
||||||
|
|
||||||
filePath = getIntent().getStringExtra("filePath");
|
filePath = getIntent().getStringExtra("filePath");
|
||||||
@ -120,7 +129,6 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", 2) == 2) {
|
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", 2) == 2) {
|
||||||
|
|
||||||
fileNameHint.setVisibility(View.GONE);
|
|
||||||
fileAction = getIntent().getIntExtra("fileAction", 2);
|
fileAction = getIntent().getIntExtra("fileAction", 2);
|
||||||
|
|
||||||
filePath = getIntent().getStringExtra("filePath");
|
filePath = getIntent().getStringExtra("filePath");
|
||||||
@ -141,33 +149,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
newFileBranchesSpinner = findViewById(R.id.newFileBranchesSpinner);
|
newFileBranchesSpinner = findViewById(R.id.newFileBranchesSpinner);
|
||||||
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
getBranches(instanceToken, repoOwner, repoName, loginUid);
|
||||||
|
|
||||||
newFileBranchesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
|
||||||
{
|
|
||||||
public void onItemSelected(AdapterView<?> arg0,
|
|
||||||
View arg1, int arg2, long arg3)
|
|
||||||
{
|
|
||||||
Branches bModelValue = (Branches) newFileBranchesSpinner.getSelectedItem();
|
|
||||||
|
|
||||||
if(bModelValue.toString().equals("No branch")) {
|
|
||||||
newFileBranchName.setEnabled(true);
|
|
||||||
newFileBranchName.setVisibility(View.VISIBLE);
|
|
||||||
branchNameId.setVisibility(View.VISIBLE);
|
|
||||||
branchNameHintText.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
newFileBranchName.setEnabled(false);
|
|
||||||
newFileBranchName.setVisibility(View.GONE);
|
|
||||||
branchNameId.setVisibility(View.GONE);
|
|
||||||
branchNameHintText.setVisibility(View.GONE);
|
|
||||||
newFileBranchName.setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onNothingSelected(AdapterView<?> arg0) {}
|
|
||||||
});
|
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
|
|
||||||
@ -182,54 +164,43 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener createFileListener = v -> processNewFile();
|
private final View.OnClickListener createFileListener = v -> processNewFile();
|
||||||
|
|
||||||
private void processNewFile() {
|
private void processNewFile() {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
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];
|
|
||||||
|
|
||||||
String newFileName_ = newFileName.getText().toString();
|
String newFileName_ = newFileName.getText().toString();
|
||||||
String newFileContent_ = newFileContent.getText().toString();
|
String newFileContent_ = newFileContent.getText().toString();
|
||||||
String newFileBranchName_ = newFileBranchName.getText().toString();
|
String newFileBranchName_ = newFileBranchName.getText().toString();
|
||||||
String newFileCommitMessage_ = newFileCommitMessage.getText().toString();
|
String newFileCommitMessage_ = newFileCommitMessage.getText().toString();
|
||||||
|
|
||||||
Branches currentBranch = (Branches) newFileBranchesSpinner.getSelectedItem();
|
|
||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newFileName_.equals("") || newFileContent_.equals("") || newFileCommitMessage_.equals("")) {
|
if(newFileName_.equals("") || newFileContent_.equals("") || newFileCommitMessage_.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.newFileRequiredFields));
|
Toasty.error(ctx, getString(R.string.newFileRequiredFields));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentBranch.toString().equals("No branch")) {
|
if(selectedBranch.equals("No branch")) {
|
||||||
|
|
||||||
if(newFileBranchName_.equals("")) {
|
if(newFileBranchName_.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.newFileRequiredFieldNewBranchName));
|
Toasty.error(ctx, getString(R.string.newFileRequiredFieldNewBranchName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if(!appUtil.checkStringsWithDash(newFileBranchName_)) {
|
if(!appUtil.checkStringsWithDash(newFileBranchName_)) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
|
Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +209,6 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
if(appUtil.charactersLength(newFileCommitMessage_) > 255) {
|
if(appUtil.charactersLength(newFileCommitMessage_) > 255) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.newFileCommitMessageError));
|
Toasty.warning(ctx, getString(R.string.newFileCommitMessageError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -246,37 +216,38 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(fileAction == 1) {
|
if(fileAction == 1) {
|
||||||
|
|
||||||
deleteFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, filePath,
|
deleteFile(Authorization.get(ctx), repoOwner, repoName, filePath,
|
||||||
newFileBranchName_, newFileCommitMessage_, currentBranch.toString(), fileSha);
|
newFileBranchName_, newFileCommitMessage_, selectedBranch, fileSha);
|
||||||
}
|
}
|
||||||
else if(fileAction == 2) {
|
else if(fileAction == 2) {
|
||||||
|
|
||||||
editFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, filePath,
|
editFile(Authorization.get(ctx), repoOwner, repoName, filePath,
|
||||||
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, currentBranch.toString(), fileSha);
|
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, selectedBranch, fileSha);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
createNewFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newFileName_,
|
createNewFile(Authorization.get(ctx), repoOwner, repoName, newFileName_,
|
||||||
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, currentBranch.toString());
|
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, selectedBranch);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewFile(final String instanceUrl, final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch) {
|
private void createNewFile(final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch) {
|
||||||
|
|
||||||
NewFile createNewFileJsonStr;
|
NewFile createNewFileJsonStr;
|
||||||
if(currentBranch.equals("No branch")) {
|
if(currentBranch.equals("No branch")) {
|
||||||
|
|
||||||
createNewFileJsonStr = new NewFile("", fileContent, fileCommitMessage, fileBranchName);
|
createNewFileJsonStr = new NewFile("", fileContent, fileCommitMessage, fileBranchName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
createNewFileJsonStr = new NewFile(currentBranch, fileContent, fileCommitMessage, "");
|
createNewFileJsonStr = new NewFile(currentBranch, fileContent, fileCommitMessage, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewFile(token, repoOwner, repoName, fileName, createNewFileJsonStr);
|
.createNewFile(token, repoOwner, repoName, fileName, createNewFileJsonStr);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
@ -289,7 +260,6 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
|
Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -298,21 +268,20 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if(response.code() == 404) {
|
if(response.code() == 404) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.orgCreatedError));
|
Toasty.error(ctx, getString(R.string.orgCreatedError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -325,10 +294,11 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteFile(final String instanceUrl, final String token, String repoOwner, String repoName, String fileName, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
private void deleteFile(final String token, String repoOwner, String repoName, String fileName, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
||||||
|
|
||||||
String branchName;
|
String branchName;
|
||||||
DeleteFile deleteFileJsonStr;
|
DeleteFile deleteFileJsonStr;
|
||||||
|
|
||||||
if(currentBranch.equals("No branch")) {
|
if(currentBranch.equals("No branch")) {
|
||||||
|
|
||||||
branchName = fileBranchName;
|
branchName = fileBranchName;
|
||||||
@ -341,8 +311,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.deleteFile(token, repoOwner, repoName, fileName, deleteFileJsonStr);
|
.deleteFile(token, repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
@ -358,7 +327,6 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
getIntent().removeExtra("fileSha");
|
getIntent().removeExtra("fileSha");
|
||||||
getIntent().removeExtra("fileContents");
|
getIntent().removeExtra("fileContents");
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -367,7 +335,6 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -381,9 +348,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.info(ctx, getString(R.string.genericError));
|
Toasty.info(ctx, getString(R.string.genericError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -396,10 +361,11 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editFile(final String instanceUrl, final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
private void editFile(final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
||||||
|
|
||||||
String branchName;
|
String branchName;
|
||||||
EditFile editFileJsonStr;
|
EditFile editFileJsonStr;
|
||||||
|
|
||||||
if(currentBranch.equals("No branch")) {
|
if(currentBranch.equals("No branch")) {
|
||||||
|
|
||||||
branchName = fileBranchName;
|
branchName = fileBranchName;
|
||||||
@ -412,8 +378,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.editFile(token, repoOwner, repoName, fileName, editFileJsonStr);
|
.editFile(token, repoOwner, repoName, fileName, editFileJsonStr);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
@ -428,9 +393,8 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
getIntent().removeExtra("filePath");
|
getIntent().removeExtra("filePath");
|
||||||
getIntent().removeExtra("fileSha");
|
getIntent().removeExtra("fileSha");
|
||||||
getIntent().removeExtra("fileContents");
|
getIntent().removeExtra("fileContents");
|
||||||
tinyDb.putBoolean("fileModified", true);
|
tinyDB.putBoolean("fileModified", true);
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -439,7 +403,6 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -453,9 +416,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.info(ctx, getString(R.string.genericError));
|
Toasty.info(ctx, getString(R.string.genericError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -468,12 +429,11 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getBranches(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
private void getBranches(String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||||
|
|
||||||
Call<List<Branches>> call = RetrofitClient
|
Call<List<Branches>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||||
.getBranches(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Branches>>() {
|
call.enqueue(new Callback<List<Branches>>() {
|
||||||
|
|
||||||
@ -481,37 +441,53 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
|
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
if(response.code() == 200) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
List<Branches> branchesList_ = response.body();
|
List<Branches> branchesList_ = response.body();
|
||||||
|
|
||||||
branchesList.add(new Branches("No branch"));
|
branchesList.add(new Branches("No branch"));
|
||||||
assert branchesList_ != null;
|
assert branchesList_ != null;
|
||||||
|
|
||||||
if(branchesList_.size() > 0) {
|
if(branchesList_.size() > 0) {
|
||||||
|
|
||||||
for (int i = 0; i < branchesList_.size(); i++) {
|
for (int i = 0; i < branchesList_.size(); i++) {
|
||||||
|
|
||||||
Branches data = new Branches(
|
Branches data = new Branches(branchesList_.get(i).getName());
|
||||||
branchesList_.get(i).getName()
|
|
||||||
);
|
|
||||||
branchesList.add(data);
|
branchesList.add(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayAdapter<Branches> adapter = new ArrayAdapter<>(CreateFileActivity.this,
|
ArrayAdapter<Branches> adapter = new ArrayAdapter<>(CreateFileActivity.this,
|
||||||
R.layout.spinner_item, branchesList);
|
R.layout.list_spinner_items, branchesList);
|
||||||
|
|
||||||
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
|
||||||
newFileBranchesSpinner.setAdapter(adapter);
|
newFileBranchesSpinner.setAdapter(adapter);
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
|
newFileBranchesSpinner.setOnItemClickListener ((parent, view, position, id) -> {
|
||||||
|
|
||||||
|
selectedBranch = branchesList.get(position).getName();
|
||||||
|
|
||||||
|
if(selectedBranch.equals("No branch")) {
|
||||||
|
|
||||||
|
newFileBranchName.setEnabled(true);
|
||||||
|
newFileBranchName.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
newFileBranchName.setEnabled(false);
|
||||||
|
newFileBranchName.setVisibility(View.GONE);
|
||||||
|
newFileBranchName.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -519,6 +495,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
|
||||||
onClickListener = view -> finish();
|
onClickListener = view -> finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.DatePickerDialog;
|
import android.app.DatePickerDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -7,6 +8,7 @@ import android.graphics.Color;
|
|||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
@ -49,9 +51,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
private CustomLabelsSelectionDialogBinding labelsBinding;
|
private CustomLabelsSelectionDialogBinding labelsBinding;
|
||||||
private CustomAssigneesSelectionDialogBinding assigneesBinding;
|
private CustomAssigneesSelectionDialogBinding assigneesBinding;
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||||
private Dialog dialogLabels;
|
private Dialog dialogLabels;
|
||||||
private Dialog dialogAssignees;
|
private Dialog dialogAssignees;
|
||||||
@ -59,9 +58,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
private String assigneesSetter;
|
private String assigneesSetter;
|
||||||
private int milestoneId;
|
private int milestoneId;
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
|
||||||
private String repoOwner;
|
private String repoOwner;
|
||||||
private String repoName;
|
private String repoName;
|
||||||
|
|
||||||
@ -79,12 +76,11 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
return R.layout.activity_create_issue;
|
return R.layout.activity_create_issue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityCreateIssueBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityCreateIssueBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
@ -94,17 +90,14 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
final String loginFullName = tinyDb.getString("userFullname");
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
repoName = parts[1];
|
repoName = parts[1];
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
// require gitea 1.12 or higher
|
// require gitea 1.12 or higher
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||||
|
|
||||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||||
}
|
}
|
||||||
@ -113,6 +106,17 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
assert imm != null;
|
assert imm != null;
|
||||||
imm.showSoftInput(viewBinding.newIssueTitle, InputMethodManager.SHOW_IMPLICIT);
|
imm.showSoftInput(viewBinding.newIssueTitle, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
|
||||||
|
viewBinding.newIssueDescription.setOnTouchListener((touchView, motionEvent) -> {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||||
|
|
||||||
|
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
labelsAdapter = new LabelsListAdapter(labelsList, CreateIssueActivity.this, labelsIds);
|
labelsAdapter = new LabelsListAdapter(labelsList, CreateIssueActivity.this, labelsIds);
|
||||||
assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, CreateIssueActivity.this, assigneesListData);
|
assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, CreateIssueActivity.this, assigneesListData);
|
||||||
|
|
||||||
@ -123,17 +127,13 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
viewBinding.newIssueLabels.setOnClickListener(this);
|
viewBinding.newIssueLabels.setOnClickListener(this);
|
||||||
viewBinding.newIssueDueDate.setOnClickListener(this);
|
viewBinding.newIssueDueDate.setOnClickListener(this);
|
||||||
|
|
||||||
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
|
getMilestones(repoOwner, repoName, resultLimit);
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
|
|
||||||
viewBinding.newIssueLabels.setOnClickListener(newIssueLabels ->
|
viewBinding.newIssueLabels.setOnClickListener(newIssueLabels -> showLabels());
|
||||||
showLabels()
|
|
||||||
);
|
|
||||||
|
|
||||||
viewBinding.newIssueAssigneesList.setOnClickListener(newIssueAssigneesList ->
|
viewBinding.newIssueAssigneesList.setOnClickListener(newIssueAssigneesList -> showAssignees());
|
||||||
showAssignees()
|
|
||||||
);
|
|
||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
@ -181,11 +181,10 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
View view = assigneesBinding.getRoot();
|
View view = assigneesBinding.getRoot();
|
||||||
dialogAssignees.setContentView(view);
|
dialogAssignees.setContentView(view);
|
||||||
|
|
||||||
assigneesBinding.cancel.setOnClickListener(assigneesBinding_ ->
|
assigneesBinding.cancel.setOnClickListener(assigneesBinding_ -> dialogAssignees.dismiss());
|
||||||
dialogAssignees.dismiss()
|
|
||||||
);
|
|
||||||
|
|
||||||
AssigneesActions.getRepositoryAssignees(ctx, instanceUrl, instanceToken, repoOwner, repoName, assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
dialogAssignees.show();
|
||||||
|
AssigneesActions.getRepositoryAssignees(ctx, repoOwner, repoName, assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showLabels() {
|
private void showLabels() {
|
||||||
@ -202,11 +201,10 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
View view = labelsBinding.getRoot();
|
View view = labelsBinding.getRoot();
|
||||||
dialogLabels.setContentView(view);
|
dialogLabels.setContentView(view);
|
||||||
|
|
||||||
labelsBinding.cancel.setOnClickListener(labelsBinding_ ->
|
labelsBinding.cancel.setOnClickListener(labelsBinding_ -> dialogLabels.dismiss());
|
||||||
dialogLabels.dismiss()
|
|
||||||
);
|
|
||||||
|
|
||||||
LabelsActions.getRepositoryLabels(ctx, instanceUrl, instanceToken, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
dialogLabels.show();
|
||||||
|
LabelsActions.getRepositoryLabels(ctx, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processNewIssue() {
|
private void processNewIssue() {
|
||||||
@ -221,7 +219,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newIssueTitleForm.equals("")) {
|
if (newIssueTitleForm.equals("")) {
|
||||||
@ -240,20 +237,18 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
createNewIssueFunc(instanceUrl, instanceToken, repoOwner, repoName, loginUid, newIssueDescriptionForm, newIssueDueDateForm, milestoneId, newIssueTitleForm);
|
createNewIssueFunc(repoOwner, repoName, loginUid, newIssueDescriptionForm, newIssueDueDateForm, milestoneId, newIssueTitleForm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewIssueFunc(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String loginUid, String newIssueDescriptionForm, String newIssueDueDateForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
private void createNewIssueFunc(String repoOwner, String repoName, String loginUid, String newIssueDescriptionForm, String newIssueDueDateForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
||||||
|
|
||||||
CreateIssue createNewIssueJson = new CreateIssue(loginUid, newIssueDescriptionForm, false, newIssueDueDateForm, newIssueMilestoneIdForm, newIssueTitleForm, assigneesListData, labelsIds);
|
CreateIssue createNewIssueJson = new CreateIssue(loginUid, newIssueDescriptionForm, false, newIssueDueDateForm, newIssueMilestoneIdForm, newIssueTitleForm, assigneesListData, labelsIds);
|
||||||
|
|
||||||
Call<JsonElement> call3;
|
Call<JsonElement> call3;
|
||||||
|
|
||||||
call3 = RetrofitClient
|
call3 = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.createNewIssue(Authorization.get(ctx), repoOwner, repoName, createNewIssueJson);
|
||||||
.createNewIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, createNewIssueJson);
|
|
||||||
|
|
||||||
call3.enqueue(new Callback<JsonElement>() {
|
call3.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -262,7 +257,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
|
|
||||||
if(response2.code() == 201) {
|
if(response2.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
Toasty.success(ctx, getString(R.string.issueCreated));
|
||||||
@ -300,13 +295,12 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
onClickListener = view -> finish();
|
onClickListener = view -> finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getMilestones(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid, int resultLimit) {
|
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||||
|
|
||||||
String msState = "open";
|
String msState = "open";
|
||||||
Call<List<Milestones>> call = RetrofitClient
|
Call<List<Milestones>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||||
.getMilestones(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, 1, resultLimit, msState);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Milestones>>() {
|
call.enqueue(new Callback<List<Milestones>>() {
|
||||||
|
|
||||||
@ -314,13 +308,16 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull retrofit2.Response<List<Milestones>> response) {
|
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull retrofit2.Response<List<Milestones>> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
if(response.code() == 200) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
List<Milestones> milestonesList_ = response.body();
|
List<Milestones> milestonesList_ = response.body();
|
||||||
|
|
||||||
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
|
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
|
||||||
assert milestonesList_ != null;
|
assert milestonesList_ != null;
|
||||||
|
|
||||||
if(milestonesList_.size() > 0) {
|
if(milestonesList_.size() > 0) {
|
||||||
|
|
||||||
for (int i = 0; i < milestonesList_.size(); i++) {
|
for (int i = 0; i < milestonesList_.size(); i++) {
|
||||||
|
|
||||||
//Don't translate "open" is a enum
|
//Don't translate "open" is a enum
|
||||||
@ -331,7 +328,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
);
|
);
|
||||||
milestonesList.add(data);
|
milestonesList.add(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,9 +371,9 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||||||
datePickerDialog.show();
|
datePickerDialog.show();
|
||||||
}
|
}
|
||||||
else if(v == viewBinding.createNewIssueButton) {
|
else if(v == viewBinding.createNewIssueButton) {
|
||||||
|
|
||||||
processNewIssue();
|
processNewIssue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
@ -10,11 +10,9 @@ import android.widget.Button;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.ColorInt;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
|
import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
|
||||||
import com.pes.androidmaterialcolorpickerdialog.ColorPickerCallback;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
@ -25,6 +23,7 @@ import org.mian.gitnex.helpers.Toasty;
|
|||||||
import org.mian.gitnex.models.CreateLabel;
|
import org.mian.gitnex.models.CreateLabel;
|
||||||
import org.mian.gitnex.models.Labels;
|
import org.mian.gitnex.models.Labels;
|
||||||
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||||
|
import org.mian.gitnex.viewmodels.OrganizationLabelsViewModel;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
@ -39,8 +38,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
private TextView colorPicker;
|
private TextView colorPicker;
|
||||||
private EditText labelName;
|
private EditText labelName;
|
||||||
private Button createLabelButton;
|
private Button createLabelButton;
|
||||||
final Context ctx = this;
|
private TinyDB tinyDB;
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
@ -51,25 +49,20 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
tinyDB = TinyDB.getInstance(appCtx);
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
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");
|
|
||||||
|
|
||||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
||||||
|
|
||||||
deleteLabel(instanceUrl, instanceToken, repoOwner, repoName, Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
deleteLabel(repoOwner, repoName, Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
@ -87,22 +80,14 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
colorPicker.setOnClickListener(new View.OnClickListener() {
|
colorPicker.setOnClickListener(v -> cp.show());
|
||||||
public void onClick(View v) {
|
|
||||||
cp.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
cp.setCallback(new ColorPickerCallback() {
|
cp.setCallback(color -> {
|
||||||
@Override
|
|
||||||
public void onColorChosen(@ColorInt int color) {
|
|
||||||
|
|
||||||
//Log.i("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));
|
//Log.i("#Hex no alpha", String.format("#%06X", (0xFFFFFF & color)));
|
||||||
colorPicker.setBackgroundColor(color);
|
colorPicker.setBackgroundColor(color);
|
||||||
tinyDb.putString("labelColor", String.format("#%06X", (0xFFFFFF & color)));
|
tinyDB.putString("labelColor", String.format("#%06X", (0xFFFFFF & color)));
|
||||||
cp.dismiss();
|
cp.dismiss();
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("edit")) {
|
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("edit")) {
|
||||||
@ -110,7 +95,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
labelName.setText(getIntent().getStringExtra("labelTitle"));
|
labelName.setText(getIntent().getStringExtra("labelTitle"));
|
||||||
int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
|
int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
|
||||||
colorPicker.setBackgroundColor(labelColor_);
|
colorPicker.setBackgroundColor(labelColor_);
|
||||||
tinyDb.putString("labelColorDefault", "#" + getIntent().getStringExtra("labelColor"));
|
tinyDB.putString("labelColorDefault", "#" + getIntent().getStringExtra("labelColor"));
|
||||||
|
|
||||||
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
||||||
toolbar_title.setText(getResources().getString(R.string.pageTitleLabelUpdate));
|
toolbar_title.setText(getResources().getString(R.string.pageTitleLabelUpdate));
|
||||||
@ -131,57 +116,52 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener createLabelListener = v -> processCreateLabel();
|
private final View.OnClickListener createLabelListener = v -> processCreateLabel();
|
||||||
|
|
||||||
private View.OnClickListener updateLabelListener = v -> processUpdateLabel();
|
private final View.OnClickListener updateLabelListener = v -> processUpdateLabel();
|
||||||
|
|
||||||
private void processUpdateLabel() {
|
private void processUpdateLabel() {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
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");
|
|
||||||
|
|
||||||
String updateLabelName = labelName.getText().toString();
|
String updateLabelName = labelName.getText().toString();
|
||||||
|
|
||||||
String updateLabelColor;
|
String updateLabelColor;
|
||||||
if(tinyDb.getString("labelColor").isEmpty()) {
|
if(tinyDB.getString("labelColor").isEmpty()) {
|
||||||
updateLabelColor = tinyDb.getString("labelColorDefault");
|
|
||||||
|
updateLabelColor = tinyDB.getString("labelColorDefault");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
updateLabelColor = tinyDb.getString("labelColor");
|
|
||||||
|
updateLabelColor = tinyDB.getString("labelColor");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(updateLabelName.equals("")) {
|
if(updateLabelName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!appUtil.checkStrings(updateLabelName)) {
|
if(!appUtil.checkStrings(updateLabelName)) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
Toasty.error(ctx, getString(R.string.labelNameError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
patchLabel(instanceUrl, instanceToken, repoOwner, repoName, updateLabelName, updateLabelColor, Integer.parseInt(
|
patchLabel(repoOwner, repoName, updateLabelName, updateLabelColor, Integer.parseInt(
|
||||||
Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,61 +169,60 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
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");
|
|
||||||
|
|
||||||
String newLabelName = labelName.getText().toString();
|
String newLabelName = labelName.getText().toString();
|
||||||
String newLabelColor;
|
String newLabelColor;
|
||||||
if(tinyDb.getString("labelColor").isEmpty()) {
|
|
||||||
|
if(tinyDB.getString("labelColor").isEmpty()) {
|
||||||
|
|
||||||
newLabelColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(ctx, R.color.releasePre)));
|
newLabelColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(ctx, R.color.releasePre)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newLabelColor = tinyDb.getString("labelColor");
|
|
||||||
|
newLabelColor = tinyDB.getString("labelColor");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newLabelName.equals("")) {
|
if(newLabelName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!appUtil.checkStrings(newLabelName)) {
|
if(!appUtil.checkStrings(newLabelName)) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
Toasty.error(ctx, getString(R.string.labelNameError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
createNewLabel(instanceUrl, instanceToken, repoOwner, repoName, newLabelName, newLabelColor, loginUid);
|
createNewLabel(repoOwner, repoName, newLabelName, newLabelColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewLabel(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String newLabelName, String newLabelColor, String loginUid) {
|
private void createNewLabel(String repoOwner, String repoName, String newLabelName, String newLabelColor) {
|
||||||
|
|
||||||
CreateLabel createLabelFunc = new CreateLabel(newLabelName, newLabelColor);
|
CreateLabel createLabelFunc = new CreateLabel(newLabelName, newLabelColor);
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
Call<CreateLabel> call;
|
Call<CreateLabel> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||||
.getInstance(instanceUrl, ctx)
|
|
||||||
.getApiInterface()
|
call = RetrofitClient.getApiInterface(ctx).createOrganizationLabel(Authorization.get(ctx), getIntent().getStringExtra("orgName"), createLabelFunc);
|
||||||
.createLabel(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, createLabelFunc);
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
call = RetrofitClient.getApiInterface(ctx).createLabel(Authorization.get(ctx), repoOwner, repoName, createLabelFunc);
|
||||||
|
}
|
||||||
|
|
||||||
call.enqueue(new Callback<CreateLabel>() {
|
call.enqueue(new Callback<CreateLabel>() {
|
||||||
|
|
||||||
@ -253,10 +232,9 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.labelCreated));
|
Toasty.success(ctx, getString(R.string.labelCreated));
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDB.putString("labelColor", "");
|
||||||
tinyDb.putBoolean("labelsRefresh", true);
|
tinyDB.putBoolean("labelsRefresh", true);
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -265,22 +243,19 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDB.putString("labelColor", "");
|
||||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDB.putString("labelColor", "");
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
@ -288,17 +263,20 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void patchLabel(final String instanceUrl, final String instanceToken, String repoOwner, String repoName, String updateLabelName, String updateLabelColor, int labelId, String loginUid) {
|
private void patchLabel(String repoOwner, String repoName, String updateLabelName, String updateLabelColor, int labelId) {
|
||||||
|
|
||||||
CreateLabel createLabelFunc = new CreateLabel(updateLabelName, updateLabelColor);
|
CreateLabel createLabelFunc = new CreateLabel(updateLabelName, updateLabelColor);
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
Call<CreateLabel> call;
|
Call<CreateLabel> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||||
.getInstance(instanceUrl, ctx)
|
|
||||||
.getApiInterface()
|
call = RetrofitClient.getApiInterface(ctx).patchOrganizationLabel(Authorization.get(ctx), getIntent().getStringExtra("orgName"), labelId, createLabelFunc);
|
||||||
.patchLabel(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, labelId, createLabelFunc);
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
call = RetrofitClient.getApiInterface(appCtx).patchLabel(Authorization.get(ctx), repoOwner, repoName, labelId, createLabelFunc);
|
||||||
|
}
|
||||||
|
|
||||||
call.enqueue(new Callback<CreateLabel>() {
|
call.enqueue(new Callback<CreateLabel>() {
|
||||||
|
|
||||||
@ -306,18 +284,19 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
public void onResponse(@NonNull Call<CreateLabel> call, @NonNull retrofit2.Response<CreateLabel> response) {
|
public void onResponse(@NonNull Call<CreateLabel> call, @NonNull retrofit2.Response<CreateLabel> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
if(response.code() == 200) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.labelUpdated));
|
Toasty.success(ctx, getString(R.string.labelUpdated));
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDB.putString("labelColor", "");
|
||||||
tinyDb.putBoolean("labelsRefresh", true);
|
tinyDB.putBoolean("labelsRefresh", true);
|
||||||
tinyDb.putString("labelColorDefault", "");
|
tinyDB.putString("labelColorDefault", "");
|
||||||
getIntent().removeExtra("labelAction");
|
getIntent().removeExtra("labelAction");
|
||||||
getIntent().removeExtra("labelId");
|
getIntent().removeExtra("labelId");
|
||||||
getIntent().removeExtra("labelTitle");
|
getIntent().removeExtra("labelTitle");
|
||||||
getIntent().removeExtra("labelColor");
|
getIntent().removeExtra("labelColor");
|
||||||
|
getIntent().removeExtra("type");
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
@ -327,24 +306,21 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDB.putString("labelColor", "");
|
||||||
tinyDb.putString("labelColorDefault", "");
|
tinyDB.putString("labelColorDefault", "");
|
||||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
tinyDb.putString("labelColor", "");
|
tinyDB.putString("labelColor", "");
|
||||||
tinyDb.putString("labelColorDefault", "");
|
tinyDB.putString("labelColorDefault", "");
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
@ -353,26 +329,30 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
onClickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
onClickListener = view -> {
|
||||||
public void onClick(View view) {
|
|
||||||
getIntent().removeExtra("labelAction");
|
getIntent().removeExtra("labelAction");
|
||||||
getIntent().removeExtra("labelId");
|
getIntent().removeExtra("labelId");
|
||||||
getIntent().removeExtra("labelTitle");
|
getIntent().removeExtra("labelTitle");
|
||||||
getIntent().removeExtra("labelColor");
|
getIntent().removeExtra("labelColor");
|
||||||
finish();
|
getIntent().removeExtra("type");
|
||||||
}
|
finish();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteLabel(final String instanceUrl, final String instanceToken, final String repoOwner, final String repoName, int labelId, String loginUid) {
|
private void deleteLabel(final String repoOwner, final String repoName, int labelId) {
|
||||||
|
|
||||||
Call<Labels> call;
|
Call<Labels> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||||
.getInstance(instanceUrl, ctx)
|
|
||||||
.getApiInterface()
|
call = RetrofitClient.getApiInterface(appCtx).deleteOrganizationLabel(Authorization.get(ctx), getIntent().getStringExtra("orgName"), labelId);
|
||||||
.deleteLabel(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, labelId);
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
call = RetrofitClient.getApiInterface(appCtx).deleteLabel(Authorization.get(ctx), repoOwner, repoName, labelId);
|
||||||
|
}
|
||||||
|
|
||||||
call.enqueue(new Callback<Labels>() {
|
call.enqueue(new Callback<Labels>() {
|
||||||
|
|
||||||
@ -380,13 +360,21 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
public void onResponse(@NonNull Call<Labels> call, @NonNull retrofit2.Response<Labels> response) {
|
public void onResponse(@NonNull Call<Labels> call, @NonNull retrofit2.Response<Labels> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
if(response.code() == 204) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
||||||
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName, ctx);
|
if(getIntent().getStringExtra("type") != null && Objects.requireNonNull(getIntent().getStringExtra("type")).equals("org")) {
|
||||||
|
|
||||||
|
OrganizationLabelsViewModel.loadOrgLabelsList(Authorization.get(ctx), getIntent().getStringExtra("orgName"), ctx, null, null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
LabelsViewModel.loadLabelsList(Authorization.get(ctx), repoOwner, repoName, ctx);
|
||||||
|
}
|
||||||
getIntent().removeExtra("labelAction");
|
getIntent().removeExtra("labelAction");
|
||||||
getIntent().removeExtra("labelId");
|
getIntent().removeExtra("labelId");
|
||||||
|
getIntent().removeExtra("type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
@ -395,14 +383,11 @@ public class CreateLabelActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelDeleteErrorText));
|
Toasty.error(ctx, getString(R.string.labelDeleteErrorText));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.DatePickerDialog;
|
import android.app.DatePickerDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.DatePicker;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -35,19 +36,17 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
private EditText milestoneTitle;
|
private EditText milestoneTitle;
|
||||||
private EditText milestoneDescription;
|
private EditText milestoneDescription;
|
||||||
private Button createNewMilestoneButton;
|
private Button createNewMilestoneButton;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
return R.layout.activity_new_milestone;
|
return R.layout.activity_new_milestone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -63,6 +62,17 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
assert imm != null;
|
assert imm != null;
|
||||||
imm.showSoftInput(milestoneTitle, InputMethodManager.SHOW_IMPLICIT);
|
imm.showSoftInput(milestoneTitle, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
|
||||||
|
milestoneDescription.setOnTouchListener((touchView, motionEvent) -> {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||||
|
|
||||||
|
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
milestoneDueDate.setOnClickListener(this);
|
milestoneDueDate.setOnClickListener(this);
|
||||||
@ -78,21 +88,17 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener createMilestoneListener = v -> processNewMilestone();
|
private final View.OnClickListener createMilestoneListener = v -> processNewMilestone();
|
||||||
|
|
||||||
private void processNewMilestone() {
|
private void processNewMilestone() {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
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");
|
|
||||||
//String appLocale = tinyDb.getString("locale");
|
|
||||||
|
|
||||||
String newMilestoneTitle = milestoneTitle.getText().toString();
|
String newMilestoneTitle = milestoneTitle.getText().toString();
|
||||||
String newMilestoneDescription = milestoneDescription.getText().toString();
|
String newMilestoneDescription = milestoneDescription.getText().toString();
|
||||||
@ -102,26 +108,25 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newMilestoneTitle.equals("")) {
|
if(newMilestoneTitle.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.milestoneNameErrorEmpty));
|
Toasty.error(ctx, getString(R.string.milestoneNameErrorEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!newMilestoneDescription.equals("")) {
|
if(!newMilestoneDescription.equals("")) {
|
||||||
|
|
||||||
if (appUtil.charactersLength(newMilestoneDescription) > 255) {
|
if (appUtil.charactersLength(newMilestoneDescription) > 255) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.milestoneDescError));
|
Toasty.warning(ctx, getString(R.string.milestoneDescError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String finalMilestoneDueDate = null;
|
String finalMilestoneDueDate = null;
|
||||||
|
|
||||||
if(!newMilestoneDueDate.isEmpty()) {
|
if(!newMilestoneDueDate.isEmpty()) {
|
||||||
|
|
||||||
finalMilestoneDueDate = (AppUtil.customDateCombine(AppUtil.customDateFormat(newMilestoneDueDate)));
|
finalMilestoneDueDate = (AppUtil.customDateCombine(AppUtil.customDateFormat(newMilestoneDueDate)));
|
||||||
@ -134,19 +139,17 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
createNewMilestone(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newMilestoneTitle, newMilestoneDescription, finalMilestoneDueDate);
|
createNewMilestone(Authorization.get(ctx), repoOwner, repoName, newMilestoneTitle, newMilestoneDescription, finalMilestoneDueDate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewMilestone(final String instanceUrl, final String token, String repoOwner, String repoName, String newMilestoneTitle, String newMilestoneDescription, String newMilestoneDueDate) {
|
private void createNewMilestone(final String token, String repoOwner, String repoName, String newMilestoneTitle, String newMilestoneDescription, String newMilestoneDueDate) {
|
||||||
|
|
||||||
Milestones createMilestone = new Milestones(newMilestoneDescription, newMilestoneTitle, newMilestoneDueDate);
|
Milestones createMilestone = new Milestones(newMilestoneDescription, newMilestoneTitle, newMilestoneDueDate);
|
||||||
|
|
||||||
Call<Milestones> call;
|
Call<Milestones> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
|
||||||
.createMilestone(token, repoOwner, repoName, createMilestone);
|
.createMilestone(token, repoOwner, repoName, createMilestone);
|
||||||
|
|
||||||
call.enqueue(new Callback<Milestones>() {
|
call.enqueue(new Callback<Milestones>() {
|
||||||
@ -155,14 +158,14 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
public void onResponse(@NonNull Call<Milestones> call, @NonNull retrofit2.Response<Milestones> response) {
|
public void onResponse(@NonNull Call<Milestones> call, @NonNull retrofit2.Response<Milestones> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
tinyDb.putBoolean("milestoneCreated", true);
|
tinyDb.putBoolean("milestoneCreated", true);
|
||||||
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
@ -172,19 +175,17 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.milestoneCreatedError));
|
Toasty.error(ctx, getString(R.string.milestoneCreatedError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<Milestones> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<Milestones> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
@ -203,16 +204,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||||
|
|
||||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||||
new DatePickerDialog.OnDateSetListener() {
|
(view, year, monthOfYear, dayOfMonth) -> milestoneDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth)), mYear, mMonth, mDay);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDateSet(DatePicker view, int year,
|
|
||||||
int monthOfYear, int dayOfMonth) {
|
|
||||||
|
|
||||||
milestoneDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
|
||||||
|
|
||||||
}
|
|
||||||
}, mYear, mMonth, mDay);
|
|
||||||
datePickerDialog.show();
|
datePickerDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
private EditText userEmail;
|
private EditText userEmail;
|
||||||
private EditText userPassword;
|
private EditText userPassword;
|
||||||
private Button createUserButton;
|
private Button createUserButton;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
@ -45,7 +43,6 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -73,17 +70,13 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
|
|
||||||
createUserButton.setOnClickListener(createNewUserListener);
|
createUserButton.setOnClickListener(createNewUserListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processCreateNewUser() {
|
private void processCreateNewUser() {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
String newFullName = fullName.getText().toString().trim();
|
String newFullName = fullName.getText().toString().trim();
|
||||||
String newUserName = userUserName.getText().toString().trim();
|
String newUserName = userUserName.getText().toString().trim();
|
||||||
@ -94,51 +87,44 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newFullName.equals("") || newUserName.equals("") | newUserEmail.equals("") || newUserPassword.equals("")) {
|
if(newFullName.equals("") || newUserName.equals("") | newUserEmail.equals("") || newUserPassword.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.emptyFields));
|
Toasty.error(ctx, getString(R.string.emptyFields));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!appUtil.checkStrings(newFullName)) {
|
if(!appUtil.checkStrings(newFullName)) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.userInvalidFullName));
|
Toasty.error(ctx, getString(R.string.userInvalidFullName));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!appUtil.checkStringsWithAlphaNumeric(newUserName)) {
|
if(!appUtil.checkStringsWithAlphaNumeric(newUserName)) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.userInvalidUserName));
|
Toasty.error(ctx, getString(R.string.userInvalidUserName));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.userInvalidEmail));
|
Toasty.error(ctx, getString(R.string.userInvalidEmail));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
createNewUser(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), newFullName, newUserName, newUserEmail, newUserPassword);
|
createNewUser(Authorization.get(ctx), newFullName, newUserName, newUserEmail, newUserPassword);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewUser(final String instanceUrl, final String instanceToken, String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
|
private void createNewUser(final String instanceToken, String newFullName, String newUserName, String newUserEmail, String newUserPassword) {
|
||||||
|
|
||||||
UserInfo createUser = new UserInfo(newUserEmail, newFullName, newUserName, newUserPassword, newUserName, 0, true);
|
UserInfo createUser = new UserInfo(newUserEmail, newFullName, newUserName, newUserPassword, newUserName, 0, true);
|
||||||
|
|
||||||
Call<UserInfo> call;
|
Call<UserInfo> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewUser(instanceToken, createUser);
|
.createNewUser(instanceToken, createUser);
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
@ -151,7 +137,6 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
Toasty.success(ctx, getString(R.string.userCreatedText));
|
Toasty.success(ctx, getString(R.string.userCreatedText));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -160,33 +145,27 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
else if(response.code() == 403) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 404) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 422) {
|
else if(response.code() == 422) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.userExistsError));
|
Toasty.warning(ctx, ctx.getString(R.string.userExistsError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.genericError));
|
Toasty.error(ctx, getString(R.string.genericError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -199,7 +178,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener createNewUserListener = v -> processCreateNewUser();
|
private final View.OnClickListener createNewUserListener = v -> processCreateNewUser();
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -32,19 +34,17 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
|
|
||||||
private EditText orgName;
|
private EditText orgName;
|
||||||
private EditText orgDesc;
|
private EditText orgDesc;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
return R.layout.activity_new_organization;
|
return R.layout.activity_new_organization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -58,6 +58,17 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
assert imm != null;
|
assert imm != null;
|
||||||
imm.showSoftInput(orgName, InputMethodManager.SHOW_IMPLICIT);
|
imm.showSoftInput(orgName, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
|
||||||
|
orgDesc.setOnTouchListener((touchView, motionEvent) -> {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||||
|
|
||||||
|
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
@ -75,28 +86,17 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
onClickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
onClickListener = view -> finish();
|
||||||
public void onClick(View view) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener createOrgListener = new View.OnClickListener() {
|
private final View.OnClickListener createOrgListener = v -> processNewOrganization();
|
||||||
public void onClick(View v) {
|
|
||||||
processNewOrganization();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void processNewOrganization() {
|
private void processNewOrganization() {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
String newOrgName = orgName.getText().toString();
|
String newOrgName = orgName.getText().toString();
|
||||||
String newOrgDesc = orgDesc.getText().toString();
|
String newOrgDesc = orgDesc.getText().toString();
|
||||||
@ -105,44 +105,39 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!newOrgDesc.equals("")) {
|
if(!newOrgDesc.equals("")) {
|
||||||
|
|
||||||
if (appUtil.charactersLength(newOrgDesc) > 255) {
|
if (appUtil.charactersLength(newOrgDesc) > 255) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.orgDescError));
|
Toasty.warning(ctx, getString(R.string.orgDescError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newOrgName.equals("")) {
|
if(newOrgName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.orgNameErrorEmpty));
|
Toasty.error(ctx, getString(R.string.orgNameErrorEmpty));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(!appUtil.checkStrings(newOrgName)) {
|
else if(!appUtil.checkStrings(newOrgName)) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.orgNameErrorInvalid));
|
Toasty.warning(ctx, getString(R.string.orgNameErrorInvalid));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
createNewOrganization(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), newOrgName, newOrgDesc);
|
createNewOrganization(Authorization.get(ctx), newOrgName, newOrgDesc);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewOrganization(final String instanceUrl, final String token, String orgName, String orgDesc) {
|
private void createNewOrganization(final String token, String orgName, String orgDesc) {
|
||||||
|
|
||||||
UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
|
UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
|
||||||
|
|
||||||
Call<UserOrganizations> call = RetrofitClient
|
Call<UserOrganizations> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewOrganization(token, createOrganization);
|
.createNewOrganization(token, createOrganization);
|
||||||
|
|
||||||
call.enqueue(new Callback<UserOrganizations>() {
|
call.enqueue(new Callback<UserOrganizations>() {
|
||||||
@ -152,12 +147,11 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
tinyDb.putBoolean("orgCreated", true);
|
tinyDb.putBoolean("orgCreated", true);
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.success(ctx, getString(R.string.orgCreated));
|
Toasty.success(ctx, getString(R.string.orgCreated));
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -166,37 +160,35 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 409) {
|
else if(response.code() == 409) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 422) {
|
else if(response.code() == 422) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if(response.code() == 404) {
|
if(response.code() == 404) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.orgCreatedError));
|
Toasty.error(ctx, getString(R.string.orgCreatedError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<UserOrganizations> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<UserOrganizations> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.DatePickerDialog;
|
import android.app.DatePickerDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -20,7 +21,6 @@ import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
|
|||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
@ -41,9 +41,6 @@ import retrofit2.Callback;
|
|||||||
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
|
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
private ActivityCreatePrBinding viewBinding;
|
private ActivityCreatePrBinding viewBinding;
|
||||||
private CustomLabelsSelectionDialogBinding labelsBinding;
|
private CustomLabelsSelectionDialogBinding labelsBinding;
|
||||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||||
@ -53,7 +50,6 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
private List<String> assignees = new ArrayList<>();
|
private List<String> assignees = new ArrayList<>();
|
||||||
private int milestoneId;
|
private int milestoneId;
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
private String repoOwner;
|
private String repoOwner;
|
||||||
@ -73,30 +69,40 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
return R.layout.activity_create_pr;
|
return R.layout.activity_create_pr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityCreatePrBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityCreatePrBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
repoName = parts[1];
|
repoName = parts[1];
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
// require gitea 1.12 or higher
|
// require gitea 1.12 or higher
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||||
|
|
||||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewBinding.prBody.setOnTouchListener((touchView, motionEvent) -> {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||||
|
|
||||||
|
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
labelsAdapter = new LabelsListAdapter(labelsList, CreatePullRequestActivity.this, labelsIds);
|
labelsAdapter = new LabelsListAdapter(labelsList, CreatePullRequestActivity.this, labelsIds);
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
@ -110,16 +116,12 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
|
|
||||||
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
|
getMilestones(repoOwner, repoName, resultLimit);
|
||||||
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
getBranches(repoOwner, repoName);
|
||||||
|
|
||||||
viewBinding.prLabels.setOnClickListener(prLabels ->
|
viewBinding.prLabels.setOnClickListener(prLabels -> showLabels());
|
||||||
showLabels()
|
|
||||||
);
|
|
||||||
|
|
||||||
viewBinding.createPr.setOnClickListener(createPr ->
|
viewBinding.createPr.setOnClickListener(createPr -> processPullRequest());
|
||||||
processPullRequest()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processPullRequest() {
|
private void processPullRequest() {
|
||||||
@ -133,13 +135,16 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
assignees.add("");
|
assignees.add("");
|
||||||
|
|
||||||
if (labelsIds.size() == 0) {
|
if (labelsIds.size() == 0) {
|
||||||
|
|
||||||
labelsIds.add(0);
|
labelsIds.add(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dueDate.matches("")) {
|
if (dueDate.matches("")) {
|
||||||
|
|
||||||
dueDate = null;
|
dueDate = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
dueDate = AppUtil.customDateCombine(AppUtil.customDateFormat(dueDate));
|
dueDate = AppUtil.customDateCombine(AppUtil.customDateFormat(dueDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,9 +165,9 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
Toasty.error(ctx, getString(R.string.sameBranchesError));
|
Toasty.error(ctx, getString(R.string.sameBranchesError));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
createPullRequest(prTitle, prDescription, mergeInto, pullFrom, milestoneId, dueDate, assignees);
|
createPullRequest(prTitle, prDescription, mergeInto, pullFrom, milestoneId, dueDate, assignees);
|
||||||
}
|
}
|
||||||
//Log.e("processPullRequest", String.valueOf(milestoneId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPullRequest(String prTitle, String prDescription, String mergeInto, String pullFrom, int milestoneId, String dueDate, List<String> assignees) {
|
private void createPullRequest(String prTitle, String prDescription, String mergeInto, String pullFrom, int milestoneId, String dueDate, List<String> assignees) {
|
||||||
@ -170,8 +175,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
CreatePullRequest createPullRequest = new CreatePullRequest(prTitle, prDescription, loginUid, mergeInto, pullFrom, milestoneId, dueDate, assignees, labelsIds);
|
CreatePullRequest createPullRequest = new CreatePullRequest(prTitle, prDescription, loginUid, mergeInto, pullFrom, milestoneId, dueDate, assignees, labelsIds);
|
||||||
|
|
||||||
Call<ResponseBody> transferCall = RetrofitClient
|
Call<ResponseBody> transferCall = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
|
||||||
.createPullRequest(instanceToken, repoOwner, repoName, createPullRequest);
|
.createPullRequest(instanceToken, repoOwner, repoName, createPullRequest);
|
||||||
|
|
||||||
transferCall.enqueue(new Callback<ResponseBody>() {
|
transferCall.enqueue(new Callback<ResponseBody>() {
|
||||||
@ -201,7 +205,6 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.genericError));
|
Toasty.error(ctx, getString(R.string.genericError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -231,6 +234,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
dialogLabels = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
dialogLabels = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||||
|
|
||||||
if (dialogLabels.getWindow() != null) {
|
if (dialogLabels.getWindow() != null) {
|
||||||
|
|
||||||
dialogLabels.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
dialogLabels.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,19 +243,17 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
View view = labelsBinding.getRoot();
|
View view = labelsBinding.getRoot();
|
||||||
dialogLabels.setContentView(view);
|
dialogLabels.setContentView(view);
|
||||||
|
|
||||||
labelsBinding.cancel.setOnClickListener(editProperties ->
|
labelsBinding.cancel.setOnClickListener(editProperties -> dialogLabels.dismiss());
|
||||||
dialogLabels.dismiss()
|
|
||||||
);
|
|
||||||
|
|
||||||
LabelsActions.getRepositoryLabels(ctx, instanceUrl, instanceToken, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
dialogLabels.show();
|
||||||
|
LabelsActions.getRepositoryLabels(ctx, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getBranches(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
private void getBranches(String repoOwner, String repoName) {
|
||||||
|
|
||||||
Call<List<Branches>> call = RetrofitClient
|
Call<List<Branches>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||||
.getBranches(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Branches>>() {
|
call.enqueue(new Callback<List<Branches>>() {
|
||||||
|
|
||||||
@ -259,19 +261,18 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
|
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
if(response.code() == 200) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
List<Branches> branchesList_ = response.body();
|
List<Branches> branchesList_ = response.body();
|
||||||
|
|
||||||
assert branchesList_ != null;
|
assert branchesList_ != null;
|
||||||
|
|
||||||
if(branchesList_.size() > 0) {
|
if(branchesList_.size() > 0) {
|
||||||
|
|
||||||
for (int i = 0; i < branchesList_.size(); i++) {
|
for (int i = 0; i < branchesList_.size(); i++) {
|
||||||
|
|
||||||
Branches data = new Branches(
|
Branches data = new Branches(branchesList_.get(i).getName());
|
||||||
branchesList_.get(i).getName()
|
|
||||||
);
|
|
||||||
branchesList.add(data);
|
branchesList.add(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,13 +297,12 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getMilestones(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid, int resultLimit) {
|
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||||
|
|
||||||
String msState = "open";
|
String msState = "open";
|
||||||
Call<List<Milestones>> call = RetrofitClient
|
Call<List<Milestones>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||||
.getMilestones(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, 1, resultLimit, msState);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Milestones>>() {
|
call.enqueue(new Callback<List<Milestones>>() {
|
||||||
|
|
||||||
@ -315,7 +315,9 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
|
|
||||||
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
|
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
|
||||||
assert milestonesList_ != null;
|
assert milestonesList_ != null;
|
||||||
|
|
||||||
if(milestonesList_.size() > 0) {
|
if(milestonesList_.size() > 0) {
|
||||||
|
|
||||||
for (int i = 0; i < milestonesList_.size(); i++) {
|
for (int i = 0; i < milestonesList_.size(); i++) {
|
||||||
|
|
||||||
//Don't translate "open" is a enum
|
//Don't translate "open" is a enum
|
||||||
@ -326,7 +328,6 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||||||
);
|
);
|
||||||
milestonesList.add(data);
|
milestonesList.add(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Spinner;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
import org.mian.gitnex.models.Releases;
|
import org.mian.gitnex.models.Releases;
|
||||||
@ -36,14 +36,16 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
public ImageView closeActivity;
|
public ImageView closeActivity;
|
||||||
private EditText releaseTagName;
|
private EditText releaseTagName;
|
||||||
private Spinner releaseBranch;
|
private AutoCompleteTextView releaseBranch;
|
||||||
private EditText releaseTitle;
|
private EditText releaseTitle;
|
||||||
private EditText releaseContent;
|
private EditText releaseContent;
|
||||||
private CheckBox releaseType;
|
private CheckBox releaseType;
|
||||||
private CheckBox releaseDraft;
|
private CheckBox releaseDraft;
|
||||||
private Button createNewRelease;
|
private Button createNewRelease;
|
||||||
final Context ctx = this;
|
private String selectedBranch;
|
||||||
private Context appCtx;
|
|
||||||
|
private String repoOwner;
|
||||||
|
private String repoName;
|
||||||
|
|
||||||
List<Branches> branchesList = new ArrayList<>();
|
List<Branches> branchesList = new ArrayList<>();
|
||||||
|
|
||||||
@ -52,24 +54,20 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
return R.layout.activity_create_release;
|
return R.layout.activity_create_release;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
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("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
repoName = parts[1];
|
||||||
|
|
||||||
closeActivity = findViewById(R.id.close);
|
closeActivity = findViewById(R.id.close);
|
||||||
releaseTagName = findViewById(R.id.releaseTagName);
|
releaseTagName = findViewById(R.id.releaseTagName);
|
||||||
@ -78,26 +76,26 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
releaseType = findViewById(R.id.releaseType);
|
releaseType = findViewById(R.id.releaseType);
|
||||||
releaseDraft = findViewById(R.id.releaseDraft);
|
releaseDraft = findViewById(R.id.releaseDraft);
|
||||||
|
|
||||||
releaseTagName.requestFocus();
|
releaseTitle.requestFocus();
|
||||||
assert imm != null;
|
assert imm != null;
|
||||||
imm.showSoftInput(releaseTagName, InputMethodManager.SHOW_IMPLICIT);
|
imm.showSoftInput(releaseTitle, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
|
||||||
|
releaseContent.setOnTouchListener((touchView, motionEvent) -> {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||||
|
|
||||||
|
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
releaseBranch = findViewById(R.id.releaseBranch);
|
releaseBranch = findViewById(R.id.releaseBranch);
|
||||||
getBranches(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
getBranches(Authorization.get(ctx), repoOwner, repoName);
|
||||||
releaseBranch.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
Branches branch = (Branches) parent.getSelectedItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
createNewRelease = findViewById(R.id.createNewRelease);
|
createNewRelease = findViewById(R.id.createNewRelease);
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
@ -113,25 +111,16 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener createReleaseListener = v -> processNewRelease();
|
private final View.OnClickListener createReleaseListener = v -> processNewRelease();
|
||||||
|
|
||||||
private void processNewRelease() {
|
private void processNewRelease() {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
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];
|
|
||||||
|
|
||||||
String newReleaseTagName = releaseTagName.getText().toString();
|
String newReleaseTagName = releaseTagName.getText().toString();
|
||||||
String newReleaseTitle = releaseTitle.getText().toString();
|
String newReleaseTitle = releaseTitle.getText().toString();
|
||||||
String newReleaseContent = releaseContent.getText().toString();
|
String newReleaseContent = releaseContent.getText().toString();
|
||||||
String newReleaseBranch = releaseBranch.getSelectedItem().toString();
|
String checkBranch = selectedBranch;
|
||||||
boolean newReleaseType = releaseType.isChecked();
|
boolean newReleaseType = releaseType.isChecked();
|
||||||
boolean newReleaseDraft = releaseDraft.isChecked();
|
boolean newReleaseDraft = releaseDraft.isChecked();
|
||||||
|
|
||||||
@ -139,37 +128,38 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(newReleaseTitle.equals("")) {
|
||||||
|
|
||||||
|
Toasty.error(ctx, getString(R.string.titleErrorEmpty));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(newReleaseTagName.equals("")) {
|
if(newReleaseTagName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.tagNameErrorEmpty));
|
Toasty.error(ctx, getString(R.string.tagNameErrorEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newReleaseTitle.equals("")) {
|
if(checkBranch == null) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.titleErrorEmpty));
|
Toasty.error(ctx, getString(R.string.selectBranchError));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
createNewReleaseFunc(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newReleaseTagName, newReleaseTitle, newReleaseContent, newReleaseBranch, newReleaseType, newReleaseDraft);
|
createNewReleaseFunc(Authorization.get(ctx), repoOwner, repoName, newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewReleaseFunc(final String instanceUrl, final String token, String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent, String newReleaseBranch, boolean newReleaseType, boolean newReleaseDraft) {
|
private void createNewReleaseFunc(final String token, String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent, String selectedBranch, boolean newReleaseType, boolean newReleaseDraft) {
|
||||||
|
|
||||||
Releases createReleaseJson = new Releases(newReleaseContent, newReleaseDraft, newReleaseTitle, newReleaseType, newReleaseTagName, newReleaseBranch);
|
Releases createReleaseJson = new Releases(newReleaseContent, newReleaseDraft, newReleaseTitle, newReleaseType, newReleaseTagName, selectedBranch);
|
||||||
|
|
||||||
Call<Releases> call;
|
Call<Releases> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewRelease(token, repoOwner, repoName, createReleaseJson);
|
.createNewRelease(token, repoOwner, repoName, createReleaseJson);
|
||||||
|
|
||||||
call.enqueue(new Callback<Releases>() {
|
call.enqueue(new Callback<Releases>() {
|
||||||
@ -179,12 +169,10 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
|
|
||||||
if (response.code() == 201) {
|
if (response.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
tinyDB.putBoolean("updateReleases", true);
|
||||||
tinyDb.putBoolean("updateReleases", true);
|
|
||||||
Toasty.success(ctx, getString(R.string.releaseCreatedText));
|
Toasty.success(ctx, getString(R.string.releaseCreatedText));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -193,31 +181,27 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
else if(response.code() == 403) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 404) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<Releases> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<Releases> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
@ -225,11 +209,10 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getBranches(String instanceUrl, String instanceToken, final String repoOwner, final String repoName) {
|
private void getBranches(String instanceToken, final String repoOwner, final String repoName) {
|
||||||
|
|
||||||
Call<List<Branches>> call = RetrofitClient
|
Call<List<Branches>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.getBranches(instanceToken, repoOwner, repoName);
|
.getBranches(instanceToken, repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Branches>>() {
|
call.enqueue(new Callback<List<Branches>>() {
|
||||||
@ -238,29 +221,27 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
|
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
if(response.code() == 200) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
List<Branches> branchesList_ = response.body();
|
List<Branches> branchesList_ = response.body();
|
||||||
|
|
||||||
assert branchesList_ != null;
|
assert branchesList_ != null;
|
||||||
if(branchesList_.size() > 0) {
|
if(branchesList_.size() > 0) {
|
||||||
for (int i = 0; i < branchesList_.size(); i++) {
|
|
||||||
|
|
||||||
Branches data = new Branches(
|
branchesList.addAll(branchesList_);
|
||||||
branchesList_.get(i).getName()
|
|
||||||
);
|
|
||||||
branchesList.add(data);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayAdapter<Branches> adapter = new ArrayAdapter<>(CreateReleaseActivity.this,
|
ArrayAdapter<Branches> adapter = new ArrayAdapter<>(CreateReleaseActivity.this,
|
||||||
R.layout.spinner_item, branchesList);
|
R.layout.list_spinner_items, branchesList);
|
||||||
|
|
||||||
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
|
||||||
releaseBranch.setAdapter(adapter);
|
releaseBranch.setAdapter(adapter);
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
|
releaseBranch.setOnItemClickListener ((parent, view, position, id) ->
|
||||||
|
|
||||||
|
selectedBranch = branchesList.get(position).getName()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
@ -269,13 +250,13 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -283,12 +264,8 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
onClickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
onClickListener = view -> finish();
|
||||||
public void onClick(View view) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableProcessButton() {
|
private void disableProcessButton() {
|
||||||
|
@ -2,16 +2,17 @@ package org.mian.gitnex.activities;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Spinner;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
@ -37,15 +38,18 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
|
|
||||||
public ImageView closeActivity;
|
public ImageView closeActivity;
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private Spinner spinner;
|
private AutoCompleteTextView spinner;
|
||||||
private Button createRepo;
|
private Button createRepo;
|
||||||
private EditText repoName;
|
private EditText repoName;
|
||||||
private EditText repoDesc;
|
private EditText repoDesc;
|
||||||
private CheckBox repoAccess;
|
private CheckBox repoAccess;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
List<OrgOwner> organizationsList = new ArrayList<>();
|
private String loginUid;
|
||||||
|
private String userLogin;
|
||||||
|
|
||||||
|
private String selectedOwner;
|
||||||
|
|
||||||
|
List<OrgOwner> organizationsList = new ArrayList<>();
|
||||||
|
|
||||||
//https://github.com/go-gitea/gitea/blob/52cfd2743c0e85b36081cf80a850e6a5901f1865/models/repo.go#L964-L967
|
//https://github.com/go-gitea/gitea/blob/52cfd2743c0e85b36081cf80a850e6a5901f1865/models/repo.go#L964-L967
|
||||||
final List<String> reservedRepoNames = Arrays.asList(".", "..");
|
final List<String> reservedRepoNames = Arrays.asList(".", "..");
|
||||||
@ -60,15 +64,11 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
loginUid = tinyDB.getString("loginUid");
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
userLogin = tinyDB.getString("userLogin");
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String userLogin = tinyDb.getString("userLogin");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
@ -85,19 +85,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
spinner = findViewById(R.id.ownerSpinner);
|
spinner = findViewById(R.id.ownerSpinner);
|
||||||
getOrganizations(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), userLogin);
|
getOrganizations(Authorization.get(ctx), userLogin);
|
||||||
|
|
||||||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
OrgOwner user = (OrgOwner) parent.getSelectedItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
createRepo = findViewById(R.id.createNewRepoButton);
|
createRepo = findViewById(R.id.createNewRepoButton);
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
@ -112,24 +100,15 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener createRepoListener = new View.OnClickListener() {
|
private final View.OnClickListener createRepoListener = v -> processNewRepo();
|
||||||
public void onClick(View v) {
|
|
||||||
processNewRepo();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void processNewRepo() {
|
private void processNewRepo() {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
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 newRepoName = repoName.getText().toString();
|
String newRepoName = repoName.getText().toString();
|
||||||
String newRepoDesc = repoDesc.getText().toString();
|
String newRepoDesc = repoDesc.getText().toString();
|
||||||
String repoOwner = spinner.getSelectedItem().toString();
|
|
||||||
boolean newRepoAccess = repoAccess.isChecked();
|
boolean newRepoAccess = repoAccess.isChecked();
|
||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
@ -139,6 +118,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!newRepoDesc.equals("")) {
|
if(!newRepoDesc.equals("")) {
|
||||||
|
|
||||||
if (appUtil.charactersLength(newRepoDesc) > 255) {
|
if (appUtil.charactersLength(newRepoDesc) > 255) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.repoDescError));
|
Toasty.warning(ctx, getString(R.string.repoDescError));
|
||||||
@ -161,32 +141,34 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
else if (reservedRepoPatterns.matcher(newRepoName).find()) {
|
else if (reservedRepoPatterns.matcher(newRepoName).find()) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.repoNameErrorReservedPatterns));
|
Toasty.warning(ctx, getString(R.string.repoNameErrorReservedPatterns));
|
||||||
|
}
|
||||||
|
else if(selectedOwner == null) {
|
||||||
|
|
||||||
|
Toasty.error(ctx, getString(R.string.repoOwnerError));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
createNewRepository(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), loginUid, newRepoName, newRepoDesc, repoOwner, newRepoAccess);
|
createNewRepository(Authorization.get(ctx), loginUid, newRepoName, newRepoDesc, selectedOwner, newRepoAccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewRepository(final String instanceUrl, final String token, String loginUid, String repoName, String repoDesc, String repoOwner, boolean isPrivate) {
|
private void createNewRepository(final String token, String loginUid, String repoName, String repoDesc, String selectedOwner, boolean isPrivate) {
|
||||||
|
|
||||||
OrganizationRepository createRepository = new OrganizationRepository(true, repoDesc, null, null, repoName, isPrivate, "Default");
|
OrganizationRepository createRepository = new OrganizationRepository(true, repoDesc, null, null, repoName, isPrivate, "Default");
|
||||||
|
|
||||||
Call<OrganizationRepository> call;
|
Call<OrganizationRepository> call;
|
||||||
if(repoOwner.equals(loginUid)) {
|
if(selectedOwner.equals(loginUid)) {
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.createNewUserRepository(token, createRepository);
|
.createNewUserRepository(token, createRepository);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.createNewUserOrgRepository(token, selectedOwner, createRepository);
|
||||||
.createNewUserOrgRepository(token, repoOwner, createRepository);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
call.enqueue(new Callback<OrganizationRepository>() {
|
call.enqueue(new Callback<OrganizationRepository>() {
|
||||||
@ -196,7 +178,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
tinyDb.putBoolean("repoCreated", true);
|
tinyDb.putBoolean("repoCreated", true);
|
||||||
Toasty.success(ctx, getString(R.string.repoCreated));
|
Toasty.success(ctx, getString(R.string.repoCreated));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
@ -220,7 +202,6 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.repoCreatedError));
|
Toasty.error(ctx, getString(R.string.repoCreatedError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -232,13 +213,10 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getOrganizations(String instanceUrl, String instanceToken, final String userLogin) {
|
private void getOrganizations(String instanceToken, final String userLogin) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
Call<List<OrgOwner>> call = RetrofitClient
|
Call<List<OrgOwner>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.getOrgOwners(instanceToken);
|
.getOrgOwners(instanceToken);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<OrgOwner>>() {
|
call.enqueue(new Callback<List<OrgOwner>>() {
|
||||||
@ -246,59 +224,58 @@ public class CreateRepoActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<List<OrgOwner>> call, @NonNull retrofit2.Response<List<OrgOwner>> response) {
|
public void onResponse(@NonNull Call<List<OrgOwner>> call, @NonNull retrofit2.Response<List<OrgOwner>> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
if(response.code() == 200) {
|
||||||
if(response.code() == 200) {
|
|
||||||
|
|
||||||
int organizationId = 0;
|
int organizationId = 0;
|
||||||
|
|
||||||
List<OrgOwner> organizationsList_ = response.body();
|
List<OrgOwner> organizationsList_ = response.body();
|
||||||
|
|
||||||
organizationsList.add(new OrgOwner(userLogin));
|
organizationsList.add(new OrgOwner(userLogin));
|
||||||
assert organizationsList_ != null;
|
assert organizationsList_ != null;
|
||||||
if(organizationsList_.size() > 0) {
|
|
||||||
|
|
||||||
for (int i = 0; i < organizationsList_.size(); i++) {
|
if(organizationsList_.size() > 0) {
|
||||||
|
|
||||||
if(!tinyDb.getString("organizationId").isEmpty()) {
|
for(int i = 0; i < organizationsList_.size(); i++) {
|
||||||
|
|
||||||
if (Integer.parseInt(tinyDb.getString("organizationId")) == organizationsList_.get(i).getId()) {
|
if(!tinyDB.getString("organizationId").isEmpty()) {
|
||||||
organizationId = i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OrgOwner data = new OrgOwner(
|
if(Integer.parseInt(tinyDB.getString("organizationId")) == organizationsList_.get(i).getId()) {
|
||||||
organizationsList_.get(i).getUsername()
|
organizationId = i + 1;
|
||||||
);
|
}
|
||||||
organizationsList.add(data);
|
}
|
||||||
|
|
||||||
}
|
OrgOwner data = new OrgOwner(organizationsList_.get(i).getUsername());
|
||||||
}
|
organizationsList.add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ArrayAdapter<OrgOwner> adapter = new ArrayAdapter<>(CreateRepoActivity.this,
|
ArrayAdapter<OrgOwner> adapter = new ArrayAdapter<>(CreateRepoActivity.this, R.layout.list_spinner_items, organizationsList);
|
||||||
R.layout.spinner_item, organizationsList);
|
|
||||||
|
|
||||||
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
spinner.setAdapter(adapter);
|
||||||
spinner.setAdapter(adapter);
|
|
||||||
|
|
||||||
if (tinyDb.getBoolean("organizationAction") & organizationId != 0) {
|
spinner.setOnItemClickListener ((parent, view, position, id) -> selectedOwner = organizationsList.get(position).getUsername());
|
||||||
|
|
||||||
spinner.setSelection(organizationId);
|
if(tinyDB.getBoolean("organizationAction") & organizationId != 0) {
|
||||||
tinyDb.putBoolean("organizationAction", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
enableProcessButton();
|
int selectOwnerById = organizationId;
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
}
|
spinner.setText(organizationsList.get(selectOwnerById).getUsername(), false);
|
||||||
}
|
selectedOwner = organizationsList.get(selectOwnerById).getUsername();
|
||||||
else if(response.code() == 401) {
|
}, 500);
|
||||||
|
|
||||||
enableProcessButton();
|
tinyDB.putBoolean("organizationAction", false);
|
||||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
}
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
enableProcessButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,8 +31,6 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClickListener {
|
public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClickListener {
|
||||||
|
|
||||||
final Context ctx = CreateTeamByOrgActivity.this;
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private TextView teamName;
|
private TextView teamName;
|
||||||
private TextView teamDesc;
|
private TextView teamDesc;
|
||||||
@ -41,7 +39,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
private TextView teamAccessControls;
|
private TextView teamAccessControls;
|
||||||
private TextView teamAccessControlsArray;
|
private TextView teamAccessControlsArray;
|
||||||
private Button createTeamButton;
|
private Button createTeamButton;
|
||||||
private String[] permissionList = {"Read", "Write", "Admin"};
|
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||||
public int permissionSelectedChoice = -1;
|
public int permissionSelectedChoice = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,7 +47,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
return R.layout.activity_create_team_by_org;
|
return R.layout.activity_create_team_by_org;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] accessControlsList = new String[] {
|
private final String[] accessControlsList = new String[] {
|
||||||
"Code",
|
"Code",
|
||||||
"Issues",
|
"Issues",
|
||||||
"Pull Request",
|
"Pull Request",
|
||||||
@ -61,7 +59,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
private List<String> pushAccessList;
|
private List<String> pushAccessList;
|
||||||
|
|
||||||
private boolean[] selectedAccessControlsTrueFalse = new boolean[]{
|
private final boolean[] selectedAccessControlsTrueFalse = new boolean[]{
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
@ -75,7 +73,6 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -102,12 +99,8 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
AlertDialog.Builder pBuilder = new AlertDialog.Builder(ctx);
|
AlertDialog.Builder pBuilder = new AlertDialog.Builder(ctx);
|
||||||
|
|
||||||
pBuilder.setTitle(R.string.newTeamPermission);
|
pBuilder.setTitle(R.string.newTeamPermission);
|
||||||
if(permissionSelectedChoice != -1) {
|
pBuilder.setCancelable(permissionSelectedChoice != -1);
|
||||||
pBuilder.setCancelable(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
||||||
|
|
||||||
permissionSelectedChoice = i;
|
permissionSelectedChoice = i;
|
||||||
@ -136,15 +129,12 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
}
|
}
|
||||||
|
|
||||||
dialogInterface.dismiss();
|
dialogInterface.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AlertDialog pDialog = pBuilder.create();
|
AlertDialog pDialog = pBuilder.create();
|
||||||
pDialog.show();
|
pDialog.show();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
teamAccessControls.setOnClickListener(v -> {
|
teamAccessControls.setOnClickListener(v -> {
|
||||||
|
|
||||||
teamAccessControls.setText("");
|
teamAccessControls.setText("");
|
||||||
@ -189,6 +179,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(value){
|
if(value){
|
||||||
|
|
||||||
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
||||||
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
||||||
}
|
}
|
||||||
@ -198,15 +189,16 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
String data = String.valueOf(teamAccessControls.getText());
|
String data = String.valueOf(teamAccessControls.getText());
|
||||||
if(!data.equals("")) {
|
if(!data.equals("")) {
|
||||||
|
|
||||||
teamAccessControls.setText(data.substring(0, data.length() - 2));
|
teamAccessControls.setText(data.substring(0, data.length() - 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
String dataArray = String.valueOf(teamAccessControlsArray.getText());
|
String dataArray = String.valueOf(teamAccessControlsArray.getText());
|
||||||
|
|
||||||
if(!dataArray.equals("")) {
|
if(!dataArray.equals("")) {
|
||||||
|
|
||||||
teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
|
teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
|
||||||
}
|
}
|
||||||
//Log.i("orgName", String.valueOf(teamAccessControlsArray.getText()));
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AlertDialog aDialog = aDialogBuilder.create();
|
AlertDialog aDialog = aDialogBuilder.create();
|
||||||
@ -222,21 +214,18 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
shape.setCornerRadius( 8 );
|
shape.setCornerRadius( 8 );
|
||||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||||
createTeamButton.setBackground(shape);
|
createTeamButton.setBackground(shape);
|
||||||
|
}
|
||||||
} else {
|
else {
|
||||||
|
|
||||||
createTeamButton.setEnabled(true);
|
createTeamButton.setEnabled(true);
|
||||||
createTeamButton.setOnClickListener(this);
|
createTeamButton.setOnClickListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processCreateTeam() {
|
private void processCreateTeam() {
|
||||||
|
|
||||||
AppUtil appUtil = new AppUtil();
|
AppUtil appUtil = new AppUtil();
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
final String orgName = tinyDb.getString("orgName");;
|
final String orgName = tinyDb.getString("orgName");;
|
||||||
@ -251,64 +240,60 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newTeamName.equals("")) {
|
if (newTeamName.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.teamNameEmpty));
|
Toasty.error(ctx, getString(R.string.teamNameEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!appUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
|
if(!appUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.teamNameError));
|
Toasty.warning(ctx, getString(R.string.teamNameError));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!newTeamDesc.equals("")) {
|
if(!newTeamDesc.equals("")) {
|
||||||
|
|
||||||
if(!appUtil.checkStrings(newTeamDesc)) {
|
if(!appUtil.checkStrings(newTeamDesc)) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.teamDescError));
|
Toasty.warning(ctx, getString(R.string.teamDescError));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newTeamDesc.length() > 100) {
|
if(newTeamDesc.length() > 100) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.teamDescLimit));
|
Toasty.warning(ctx, getString(R.string.teamDescLimit));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newTeamPermission.equals("")) {
|
if (newTeamPermission.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.teamPermissionEmpty));
|
Toasty.error(ctx, getString(R.string.teamPermissionEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> newTeamAccessControls_ = new ArrayList<>(Arrays.asList(newTeamAccessControls.split(",")));
|
List<String> newTeamAccessControls_ = new ArrayList<>(Arrays.asList(newTeamAccessControls.split(",")));
|
||||||
|
|
||||||
for (int i = 0; i < newTeamAccessControls_.size(); i++) {
|
for (int i = 0; i < newTeamAccessControls_.size(); i++) {
|
||||||
|
|
||||||
newTeamAccessControls_.set(i, newTeamAccessControls_.get(i).trim());
|
newTeamAccessControls_.set(i, newTeamAccessControls_.get(i).trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
createNewTeamCall(instanceUrl, instanceToken, orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_, loginUid);
|
createNewTeamCall(instanceToken, orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_, loginUid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewTeamCall(final String instanceUrl, final String instanceToken, String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls, String loginUid) {
|
private void createNewTeamCall(final String instanceToken, String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls, String loginUid) {
|
||||||
|
|
||||||
Teams createNewTeamJson = new Teams(newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls);
|
Teams createNewTeamJson = new Teams(newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls);
|
||||||
|
|
||||||
Call<Teams> call3;
|
Call<Teams> call3;
|
||||||
|
|
||||||
call3 = RetrofitClient
|
call3 = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.createTeamsByOrg(Authorization.get(ctx), orgName, createNewTeamJson);
|
||||||
.createTeamsByOrg(Authorization.returnAuthentication(ctx, loginUid, instanceToken), orgName, createNewTeamJson);
|
|
||||||
|
|
||||||
call3.enqueue(new Callback<Teams>() {
|
call3.enqueue(new Callback<Teams>() {
|
||||||
|
|
||||||
@ -316,15 +301,15 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
public void onResponse(@NonNull Call<Teams> call, @NonNull retrofit2.Response<Teams> response2) {
|
public void onResponse(@NonNull Call<Teams> call, @NonNull retrofit2.Response<Teams> response2) {
|
||||||
|
|
||||||
if(response2.isSuccessful()) {
|
if(response2.isSuccessful()) {
|
||||||
|
|
||||||
if(response2.code() == 201) {
|
if(response2.code() == 201) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
tinyDb.putBoolean("resumeTeams", true);
|
tinyDb.putBoolean("resumeTeams", true);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.teamCreated));
|
Toasty.success(ctx, getString(R.string.teamCreated));
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response2.code() == 404) {
|
else if(response2.code() == 404) {
|
||||||
|
|
||||||
@ -341,7 +326,6 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.teamCreatedError));
|
Toasty.error(ctx, getString(R.string.teamCreatedError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -356,6 +340,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
if(v == createTeamButton) {
|
if(v == createTeamButton) {
|
||||||
|
|
||||||
processCreateTeam();
|
processCreateTeam();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,455 @@
|
|||||||
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
|
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||||
|
import org.mian.gitnex.database.models.Repository;
|
||||||
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
|
import org.mian.gitnex.databinding.ActivityDeeplinksBinding;
|
||||||
|
import org.mian.gitnex.helpers.UrlHelper;
|
||||||
|
import org.mian.gitnex.models.PullRequests;
|
||||||
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import io.mikael.urlbuilder.UrlBuilder;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DeepLinksActivity extends BaseActivity {
|
||||||
|
|
||||||
|
private ActivityDeeplinksBinding viewBinding;
|
||||||
|
private String currentInstance;
|
||||||
|
private String instanceToken;
|
||||||
|
private boolean accountFound = false;
|
||||||
|
|
||||||
|
private Intent mainIntent;
|
||||||
|
private Intent issueIntent;
|
||||||
|
private Intent repoIntent;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutResourceId() {
|
||||||
|
|
||||||
|
return R.layout.activity_deeplinks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
viewBinding = ActivityDeeplinksBinding.inflate(getLayoutInflater());
|
||||||
|
View view = viewBinding.getRoot();
|
||||||
|
setContentView(view);
|
||||||
|
|
||||||
|
mainIntent = new Intent(ctx, MainActivity.class);
|
||||||
|
issueIntent = new Intent(ctx, IssueDetailActivity.class);
|
||||||
|
repoIntent = new Intent(ctx, RepoDetailActivity.class);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
Uri data = intent.getData();
|
||||||
|
assert data != null;
|
||||||
|
|
||||||
|
// check for login
|
||||||
|
if(!tinyDB.getBoolean("loggedInMode")) {
|
||||||
|
|
||||||
|
finish();
|
||||||
|
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for the links(URI) to be in the db
|
||||||
|
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||||
|
List<UserAccount> userAccounts = userAccountsApi.usersAccounts();
|
||||||
|
|
||||||
|
for(UserAccount userAccount : userAccounts) {
|
||||||
|
|
||||||
|
String hostUri = userAccount.getInstanceUrl();
|
||||||
|
|
||||||
|
currentInstance = userAccount.getInstanceUrl();
|
||||||
|
instanceToken = userAccount.getToken();
|
||||||
|
|
||||||
|
if(hostUri.toLowerCase().contains(Objects.requireNonNull(data.getHost().toLowerCase()))) {
|
||||||
|
|
||||||
|
accountFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(accountFound) {
|
||||||
|
|
||||||
|
// redirect to proper fragment/activity, If no action is there, show options where user to want to go like repos, profile, notifications etc
|
||||||
|
if(data.getPathSegments().size() > 0) {
|
||||||
|
|
||||||
|
viewBinding.progressBar.setVisibility(View.GONE);
|
||||||
|
String[] restOfUrl = Objects.requireNonNull(data.getPath()).split("/");
|
||||||
|
|
||||||
|
if(data.getPathSegments().contains("issues")) { // issue
|
||||||
|
|
||||||
|
if(!Objects.requireNonNull(data.getLastPathSegment()).contains("issues") & StringUtils.isNumeric(data.getLastPathSegment())) {
|
||||||
|
|
||||||
|
issueIntent.putExtra("issueNumber", data.getLastPathSegment());
|
||||||
|
|
||||||
|
tinyDB.putString("issueNumber", data.getLastPathSegment());
|
||||||
|
tinyDB.putString("issueType", "Issue");
|
||||||
|
|
||||||
|
tinyDB.putString("repoFullName", restOfUrl[restOfUrl.length - 4] + "/" + restOfUrl[restOfUrl.length - 3]);
|
||||||
|
|
||||||
|
final String repoOwner = restOfUrl[restOfUrl.length - 4];
|
||||||
|
final String repoName = restOfUrl[restOfUrl.length - 3];
|
||||||
|
|
||||||
|
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||||
|
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
||||||
|
|
||||||
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
|
||||||
|
if(count == 0) {
|
||||||
|
|
||||||
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
tinyDB.putLong("repositoryId", id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Repository dataRepo = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
tinyDB.putLong("repositoryId", dataRepo.getRepositoryId());
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.startActivity(issueIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
else if(Objects.requireNonNull(data.getLastPathSegment()).contains("issues")) {
|
||||||
|
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
|
goToRepoSection(currentInstance, instanceToken, restOfUrl[restOfUrl.length - 3], restOfUrl[restOfUrl.length - 2], "issue");
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(data.getPathSegments().contains("pulls")) { // pr
|
||||||
|
|
||||||
|
if(!Objects.requireNonNull(data.getLastPathSegment()).contains("pulls") & StringUtils.isNumeric(data.getLastPathSegment())) {
|
||||||
|
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
|
getPullRequest(currentInstance, instanceToken, restOfUrl[restOfUrl.length - 4], restOfUrl[restOfUrl.length - 3], Integer.parseInt(data.getLastPathSegment()));
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(Objects.requireNonNull(data.getLastPathSegment()).contains("pulls")) {
|
||||||
|
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
|
goToRepoSection(currentInstance, instanceToken, restOfUrl[restOfUrl.length - 3], restOfUrl[restOfUrl.length - 2], "pull");
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(data.getPathSegments().contains("commit")) { // commits (no API yet to properly implement)
|
||||||
|
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
|
goToRepoSection(currentInstance, instanceToken, restOfUrl[restOfUrl.length - 4], restOfUrl[restOfUrl.length - 3], "pull");
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
else if(!restOfUrl[restOfUrl.length - 2].equals("") & !restOfUrl[restOfUrl.length - 1].equals("")) { // go to repo
|
||||||
|
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
|
goToRepoSection(currentInstance, instanceToken, restOfUrl[restOfUrl.length - 2], restOfUrl[restOfUrl.length - 1], "repo");
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
else { // no action, show options
|
||||||
|
|
||||||
|
if(tinyDB.getInt("defaultScreenId") == 1) { // repos
|
||||||
|
|
||||||
|
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
else if(tinyDB.getInt("defaultScreenId") == 2) { // org
|
||||||
|
|
||||||
|
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
else if(tinyDB.getInt("defaultScreenId") == 3) { // notifications
|
||||||
|
|
||||||
|
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
else if(tinyDB.getInt("defaultScreenId") == 4) { // explore
|
||||||
|
|
||||||
|
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
else if(tinyDB.getInt("defaultScreenId") == 0) { // show options
|
||||||
|
|
||||||
|
viewBinding.noActionFrame.setVisibility(View.VISIBLE);
|
||||||
|
viewBinding.addNewAccountFrame.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
viewBinding.repository.setOnClickListener(repository -> {
|
||||||
|
|
||||||
|
tinyDB.putInt("defaultScreenId", 1);
|
||||||
|
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
viewBinding.organization.setOnClickListener(organization -> {
|
||||||
|
|
||||||
|
tinyDB.putInt("defaultScreenId", 2);
|
||||||
|
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
viewBinding.notification.setOnClickListener(notification -> {
|
||||||
|
|
||||||
|
tinyDB.putInt("defaultScreenId", 3);
|
||||||
|
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
viewBinding.explore.setOnClickListener(explore -> {
|
||||||
|
|
||||||
|
tinyDB.putInt("defaultScreenId", 4);
|
||||||
|
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
viewBinding.launchApp2.setOnClickListener(launchApp2 -> {
|
||||||
|
|
||||||
|
tinyDB.putInt("defaultScreenId", 0);
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
viewBinding.progressBar.setVisibility(View.GONE);
|
||||||
|
viewBinding.addNewAccountFrame.setVisibility(View.VISIBLE);
|
||||||
|
viewBinding.noActionFrame.setVisibility(View.GONE);
|
||||||
|
viewBinding.addAccountText.setText(String.format(getResources().getString(R.string.accountDoesNotExist), data.getHost()));
|
||||||
|
|
||||||
|
viewBinding.addNewAccount.setOnClickListener(addNewAccount -> {
|
||||||
|
|
||||||
|
Intent accountIntent = new Intent(ctx, AddNewAccountActivity.class);
|
||||||
|
startActivity(accountIntent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
viewBinding.openInBrowser.setOnClickListener(addNewAccount -> {
|
||||||
|
|
||||||
|
Integer port = data.getPort() >= 0 ? data.getPort() : null;
|
||||||
|
|
||||||
|
URI host = UrlBuilder.fromString(UrlHelper.fixScheme(data.getHost(), "https"))
|
||||||
|
.withPort(port)
|
||||||
|
.toUri();
|
||||||
|
|
||||||
|
Intent intentBrowser = new Intent();
|
||||||
|
|
||||||
|
intentBrowser.setAction(Intent.ACTION_VIEW);
|
||||||
|
intentBrowser.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||||
|
intentBrowser.setData(Uri.parse(String.valueOf(host)));
|
||||||
|
|
||||||
|
startActivity(intentBrowser);
|
||||||
|
finish();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
viewBinding.launchApp.setOnClickListener(launchApp -> {
|
||||||
|
|
||||||
|
startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getPullRequest(String url, String token, String repoOwner, String repoName, int index) {
|
||||||
|
|
||||||
|
Call<PullRequests> call = RetrofitClient
|
||||||
|
.getApiInterface(ctx, url)
|
||||||
|
.getPullRequestByIndex(token, repoOwner, repoName, index);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<PullRequests>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<PullRequests> call, @NonNull retrofit2.Response<PullRequests> response) {
|
||||||
|
|
||||||
|
PullRequests prInfo = response.body();
|
||||||
|
|
||||||
|
if (response.code() == 200) {
|
||||||
|
|
||||||
|
assert prInfo != null;
|
||||||
|
|
||||||
|
issueIntent.putExtra("issueNumber", index);
|
||||||
|
issueIntent.putExtra("prMergeable", prInfo.isMergeable());
|
||||||
|
|
||||||
|
if(prInfo.getHead() != null) {
|
||||||
|
|
||||||
|
issueIntent.putExtra("prHeadBranch", prInfo.getHead().getRef());
|
||||||
|
tinyDB.putString("prHeadBranch", prInfo.getHead().getRef());
|
||||||
|
|
||||||
|
if(prInfo.getHead().getRepo() != null) {
|
||||||
|
|
||||||
|
tinyDB.putString("prIsFork", String.valueOf(prInfo.getHead().getRepo().isFork()));
|
||||||
|
tinyDB.putString("prForkFullName", prInfo.getHead().getRepo().getFull_name());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// pull was done from a deleted fork
|
||||||
|
tinyDB.putString("prIsFork", "true");
|
||||||
|
tinyDB.putString("prForkFullName", ctx.getString(R.string.prDeletedFrok));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tinyDB.putString("issueNumber", String.valueOf(index));
|
||||||
|
tinyDB.putString("prMergeable", String.valueOf(prInfo.isMergeable()));
|
||||||
|
tinyDB.putString("issueType", "Pull");
|
||||||
|
|
||||||
|
tinyDB.putString("repoFullName", repoOwner + "/" + repoName);
|
||||||
|
|
||||||
|
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||||
|
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
||||||
|
|
||||||
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
|
||||||
|
if(count == 0) {
|
||||||
|
|
||||||
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
tinyDB.putLong("repositoryId", id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Repository dataRepo = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
tinyDB.putLong("repositoryId", dataRepo.getRepositoryId());
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.startActivity(issueIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
|
ctx.startActivity(issueIntent);
|
||||||
|
finish();
|
||||||
|
Log.e("onFailure-links-pr", String.valueOf(response.code()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<PullRequests> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
|
ctx.startActivity(issueIntent);
|
||||||
|
finish();
|
||||||
|
Log.e("onFailure-links-pr", t.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void goToRepoSection(String url, String token, String repoOwner, String repoName, String type) {
|
||||||
|
|
||||||
|
Call<UserRepositories> call = RetrofitClient
|
||||||
|
.getApiInterface(ctx, url)
|
||||||
|
.getUserRepository(token, repoOwner, repoName);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<UserRepositories>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||||
|
|
||||||
|
UserRepositories repoInfo = response.body();
|
||||||
|
|
||||||
|
if (response.code() == 200) {
|
||||||
|
|
||||||
|
assert repoInfo != null;
|
||||||
|
|
||||||
|
repoIntent.putExtra("repoFullName", repoInfo.getFullName());
|
||||||
|
repoIntent.putExtra("goToSection", "yes");
|
||||||
|
repoIntent.putExtra("goToSectionType", type);
|
||||||
|
|
||||||
|
tinyDB.putString("repoFullName", repoInfo.getFullName());
|
||||||
|
if(repoInfo.getPrivateFlag()) {
|
||||||
|
|
||||||
|
tinyDB.putString("repoType", getResources().getString(R.string.strPrivate));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
tinyDB.putString("repoType", getResources().getString(R.string.strPublic));
|
||||||
|
}
|
||||||
|
tinyDB.putBoolean("isRepoAdmin", repoInfo.getPermissions().isAdmin());
|
||||||
|
tinyDB.putString("repoBranch", repoInfo.getDefault_branch());
|
||||||
|
|
||||||
|
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||||
|
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.startActivity(repoIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
Log.e("onFailure-goToRepo", String.valueOf(response.code()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
Log.e("onFailure-goToRepo", t.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -4,31 +4,28 @@ import android.annotation.SuppressLint;
|
|||||||
import android.app.DatePickerDialog;
|
import android.app.DatePickerDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.DatePicker;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
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.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.Collaborators;
|
|
||||||
import org.mian.gitnex.models.CreateIssue;
|
import org.mian.gitnex.models.CreateIssue;
|
||||||
import org.mian.gitnex.models.Issues;
|
import org.mian.gitnex.models.Issues;
|
||||||
import org.mian.gitnex.models.Milestones;
|
import org.mian.gitnex.models.Milestones;
|
||||||
@ -39,7 +36,6 @@ import java.util.Calendar;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -47,45 +43,46 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class EditIssueActivity extends BaseActivity implements View.OnClickListener {
|
public class EditIssueActivity extends BaseActivity implements View.OnClickListener {
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||||
|
|
||||||
private EditText editIssueTitle;
|
private EditText editIssueTitle;
|
||||||
private SocialAutoCompleteTextView editIssueDescription;
|
private EditText editIssueDescription;
|
||||||
private TextView editIssueDueDate;
|
private TextView editIssueDueDate;
|
||||||
private Button editIssueButton;
|
private Button editIssueButton;
|
||||||
private Spinner editIssueMilestoneSpinner;
|
private AutoCompleteTextView editIssueMilestoneSpinner;
|
||||||
|
|
||||||
private String msState = "open";
|
private String msState = "open";
|
||||||
|
private int milestoneId;
|
||||||
|
|
||||||
List<Milestones> milestonesList = new ArrayList<>();
|
List<Milestones> milestonesList = new ArrayList<>();
|
||||||
private ArrayAdapter<Mention> defaultMentionAdapter;
|
|
||||||
|
private String loginUid;
|
||||||
|
private String instanceToken;
|
||||||
|
private String repoOwner;
|
||||||
|
private String repoName;
|
||||||
|
private int issueIndex;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
return R.layout.activity_edit_issue;
|
return R.layout.activity_edit_issue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
loginUid = tinyDB.getString("loginUid");
|
||||||
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
repoName = parts[1];
|
||||||
final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
issueIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
editIssueButton = findViewById(R.id.editIssueButton);
|
editIssueButton = findViewById(R.id.editIssueButton);
|
||||||
@ -95,7 +92,8 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
editIssueDueDate = findViewById(R.id.editIssueDueDate);
|
editIssueDueDate = findViewById(R.id.editIssueDueDate);
|
||||||
|
|
||||||
// if gitea is 1.12 or higher use the new limit
|
// if gitea is 1.12 or higher use the new limit
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||||
|
|
||||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,110 +101,49 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
assert imm != null;
|
assert imm != null;
|
||||||
imm.showSoftInput(editIssueTitle, InputMethodManager.SHOW_IMPLICIT);
|
imm.showSoftInput(editIssueTitle, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
|
||||||
defaultMentionAdapter = new MentionArrayAdapter<>(this);
|
editIssueDescription.setOnTouchListener((touchView, motionEvent) -> {
|
||||||
loadCollaboratorsList();
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||||
|
|
||||||
|
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||||
|
|
||||||
|
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
editIssueMilestoneSpinner = findViewById(R.id.editIssueMilestoneSpinner);
|
editIssueMilestoneSpinner = findViewById(R.id.editIssueMilestoneSpinner);
|
||||||
|
|
||||||
editIssueDescription.setMentionAdapter(defaultMentionAdapter);
|
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
editIssueDueDate.setOnClickListener(this);
|
editIssueDueDate.setOnClickListener(this);
|
||||||
editIssueButton.setOnClickListener(this);
|
editIssueButton.setOnClickListener(this);
|
||||||
|
|
||||||
if(!tinyDb.getString("issueNumber").isEmpty()) {
|
if(!tinyDB.getString("issueNumber").isEmpty()) {
|
||||||
|
|
||||||
|
if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||||
|
|
||||||
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
|
|
||||||
toolbar_title.setText(getString(R.string.editPrNavHeader, String.valueOf(issueIndex)));
|
toolbar_title.setText(getString(R.string.editPrNavHeader, String.valueOf(issueIndex)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
toolbar_title.setText(getString(R.string.editIssueNavHeader, String.valueOf(issueIndex)));
|
toolbar_title.setText(getString(R.string.editIssueNavHeader, String.valueOf(issueIndex)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
getIssue(instanceUrl, instanceToken, loginUid, repoOwner, repoName, issueIndex, resultLimit);
|
getIssue(instanceToken, loginUid, repoOwner, repoName, issueIndex, resultLimit);
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadCollaboratorsList() {
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Collaborators>>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull Response<List<Collaborators>> response) {
|
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
|
||||||
|
|
||||||
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 {
|
|
||||||
|
|
||||||
Log.i("onResponse", String.valueOf(response.code()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
|
||||||
Log.i("onFailure", t.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
onClickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
onClickListener = view -> finish();
|
||||||
public void onClick(View view) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processEditIssue() {
|
private void processEditIssue() {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
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");
|
|
||||||
final int issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
|
||||||
|
|
||||||
Milestones mModel = (Milestones) editIssueMilestoneSpinner.getSelectedItem();
|
|
||||||
|
|
||||||
int editIssueMilestoneId = mModel.getId();
|
|
||||||
|
|
||||||
String editIssueTitleForm = editIssueTitle.getText().toString();
|
String editIssueTitleForm = editIssueTitle.getText().toString();
|
||||||
String editIssueDescriptionForm = editIssueDescription.getText().toString();
|
String editIssueDescriptionForm = editIssueDescription.getText().toString();
|
||||||
@ -216,45 +153,34 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editIssueTitleForm.equals("")) {
|
if (editIssueTitleForm.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (editIssueDescriptionForm.equals("")) {
|
|
||||||
|
|
||||||
Toasty.info(ctx, getString(R.string.issueDescriptionEmpty));
|
|
||||||
return;
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (editIssueDueDateForm.equals("")) {
|
if (editIssueDueDateForm.equals("")) {
|
||||||
|
|
||||||
editIssueDueDateForm = null;
|
editIssueDueDateForm = null;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
editIssueDueDateForm = (AppUtil.customDateCombine(AppUtil.customDateFormat(editIssueDueDateForm)));
|
editIssueDueDateForm = (AppUtil.customDateCombine(AppUtil.customDateFormat(editIssueDueDateForm)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log.i("editIssueDueDateForm", String.valueOf(editIssueDueDateForm));
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
editIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid, editIssueTitleForm, editIssueDescriptionForm, editIssueDueDateForm, editIssueMilestoneId);
|
editIssue(instanceToken, repoOwner, repoName, issueIndex, loginUid, editIssueTitleForm, editIssueDescriptionForm, editIssueDueDateForm, milestoneId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editIssue(String instanceUrl, String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid, String title, String description, String dueDate, int editIssueMilestoneId) {
|
private void editIssue(String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid, String title, String description, String dueDate, int milestoneId) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
CreateIssue issueData = new CreateIssue(title, description, dueDate, milestoneId);
|
||||||
|
|
||||||
CreateIssue issueData = new CreateIssue(title, description, dueDate, editIssueMilestoneId);
|
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.patchIssue(Authorization.get(ctx), repoOwner, repoName, issueIndex, issueData);
|
||||||
.patchIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueData);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -263,17 +189,18 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
|
|
||||||
if(response.code() == 201) {
|
if(response.code() == 201) {
|
||||||
|
|
||||||
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
|
if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.editPrSuccessMessage));
|
Toasty.success(ctx, getString(R.string.editPrSuccessMessage));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.editIssueSuccessMessage));
|
Toasty.success(ctx, getString(R.string.editIssueSuccessMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putBoolean("issueEdited", true);
|
tinyDB.putBoolean("issueEdited", true);
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDB.putBoolean("resumeIssues", true);
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -282,19 +209,17 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.genericError));
|
Toasty.error(ctx, getString(R.string.genericError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
@ -302,7 +227,6 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
@ -314,31 +238,21 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||||
|
|
||||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||||
new DatePickerDialog.OnDateSetListener() {
|
(view, year, monthOfYear, dayOfMonth) -> editIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth)), mYear, mMonth, mDay);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDateSet(DatePicker view, int year,
|
|
||||||
int monthOfYear, int dayOfMonth) {
|
|
||||||
|
|
||||||
editIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
|
||||||
|
|
||||||
}
|
|
||||||
}, mYear, mMonth, mDay);
|
|
||||||
datePickerDialog.show();
|
datePickerDialog.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(v == editIssueButton) {
|
else if(v == editIssueButton) {
|
||||||
|
|
||||||
processEditIssue();
|
processEditIssue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getIssue(final String instanceUrl, final String instanceToken, final String loginUid, final String repoOwner, final String repoName, int issueIndex, int resultLimit) {
|
private void getIssue(final String instanceToken, final String loginUid, final String repoOwner, final String repoName, int issueIndex, int resultLimit) {
|
||||||
|
|
||||||
Call<Issues> call = RetrofitClient
|
Call<Issues> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||||
.getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Issues>() {
|
call.enqueue(new Callback<Issues>() {
|
||||||
|
|
||||||
@ -351,27 +265,27 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
editIssueTitle.setText(response.body().getTitle());
|
editIssueTitle.setText(response.body().getTitle());
|
||||||
editIssueDescription.setText(response.body().getBody());
|
editIssueDescription.setText(response.body().getBody());
|
||||||
|
|
||||||
int msId = 0;
|
int currentMilestoneId = 0;
|
||||||
if(response.body().getMilestone() != null) {
|
if(response.body().getMilestone() != null) {
|
||||||
msId = response.body().getMilestone().getId();
|
|
||||||
|
currentMilestoneId = response.body().getMilestone().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
// get milestones list
|
// get milestones list
|
||||||
if(response.body().getId() > 0) {
|
if(response.body().getId() > 0) {
|
||||||
|
|
||||||
Call<List<Milestones>> call_ = RetrofitClient
|
Call<List<Milestones>> call_ = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.getMilestones(Authorization.get(ctx), repoOwner, repoName, 1, resultLimit, msState);
|
||||||
.getMilestones(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, 1, resultLimit, msState);
|
|
||||||
|
|
||||||
final int finalMsId = msId;
|
int checkMilestoneId = currentMilestoneId;
|
||||||
|
|
||||||
call_.enqueue(new Callback<List<Milestones>>() {
|
call_.enqueue(new Callback<List<Milestones>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull retrofit2.Response<List<Milestones>> response_) {
|
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull retrofit2.Response<List<Milestones>> response_) {
|
||||||
|
|
||||||
int finalMsId1 = 0;
|
int getSelectedMilestoneId = 0;
|
||||||
|
|
||||||
if (response_.code() == 200) {
|
if (response_.code() == 200) {
|
||||||
|
|
||||||
@ -379,39 +293,40 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
|
|
||||||
milestonesList.add(new Milestones(0, "No milestone"));
|
milestonesList.add(new Milestones(0, "No milestone"));
|
||||||
assert milestonesList_ != null;
|
assert milestonesList_ != null;
|
||||||
|
|
||||||
if (milestonesList_.size() > 0) {
|
if (milestonesList_.size() > 0) {
|
||||||
|
|
||||||
|
milestonesList.addAll(milestonesList_);
|
||||||
|
|
||||||
for (int i = 0; i < milestonesList_.size(); i++) {
|
for (int i = 0; i < milestonesList_.size(); i++) {
|
||||||
|
|
||||||
Milestones data = new Milestones(
|
if(checkMilestoneId == milestonesList_.get(i).getId()) {
|
||||||
milestonesList_.get(i).getId(),
|
getSelectedMilestoneId = i + 1;
|
||||||
milestonesList_.get(i).getTitle()
|
|
||||||
);
|
|
||||||
milestonesList.add(data);
|
|
||||||
|
|
||||||
if(finalMsId == milestonesList_.get(i).getId()) {
|
|
||||||
finalMsId1 = i + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayAdapter<Milestones> adapter_ = new ArrayAdapter<>(EditIssueActivity.this,
|
ArrayAdapter<Milestones> adapter = new ArrayAdapter<>(EditIssueActivity.this,
|
||||||
R.layout.spinner_item, milestonesList);
|
R.layout.list_spinner_items, milestonesList);
|
||||||
|
|
||||||
adapter_.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
editIssueMilestoneSpinner.setAdapter(adapter);
|
||||||
editIssueMilestoneSpinner.setAdapter(adapter_);
|
|
||||||
|
editIssueMilestoneSpinner.setOnItemClickListener ((parent, view, position, id) -> milestoneId = milestonesList.get(position).getId());
|
||||||
|
|
||||||
|
int finalMsId = getSelectedMilestoneId;
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
|
editIssueMilestoneSpinner.setText(milestonesList.get(finalMsId).getTitle(),false);
|
||||||
|
milestoneId = milestonesList.get(finalMsId).getId();
|
||||||
|
}, 500);
|
||||||
|
|
||||||
if(milestonesList_.size() > 0) {
|
|
||||||
editIssueMilestoneSpinner.setSelection(finalMsId1);
|
|
||||||
}
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -439,11 +354,11 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.genericError));
|
Toasty.error(ctx, getString(R.string.genericError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -14,7 +13,6 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.adapters.FilesDiffAdapter;
|
import org.mian.gitnex.adapters.FilesDiffAdapter;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
|
||||||
import org.mian.gitnex.helpers.ParseDiff;
|
import org.mian.gitnex.helpers.ParseDiff;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
@ -36,8 +34,6 @@ public class FileDiffActivity extends BaseActivity {
|
|||||||
private TextView toolbarTitle;
|
private TextView toolbarTitle;
|
||||||
private ListView mListView;
|
private ListView mListView;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
@ -49,12 +45,11 @@ public class FileDiffActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
@ -77,28 +72,21 @@ public class FileDiffActivity extends BaseActivity {
|
|||||||
|
|
||||||
String pullIndex = tinyDb.getString("issueNumber");
|
String pullIndex = tinyDb.getString("issueNumber");
|
||||||
|
|
||||||
boolean apiCall = true;
|
boolean apiCall = !new Version(tinyDb.getString("giteaVersion")).less("1.13.0");
|
||||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
getPullDiffContent(repoOwner, repoName, pullIndex, instanceToken, apiCall);
|
||||||
|
|
||||||
// fallback for old gitea instances
|
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).less("1.13.0")) {
|
|
||||||
|
|
||||||
apiCall = false;
|
|
||||||
instanceUrl = instanceUrl.substring(0, instanceUrl.lastIndexOf("api/v1/"));
|
|
||||||
}
|
|
||||||
|
|
||||||
getPullDiffContent(instanceUrl, repoOwner, repoName, pullIndex, instanceToken, apiCall);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getPullDiffContent(String instanceUrl, String owner, String repo, String pullIndex, String token, boolean apiCall) {
|
private void getPullDiffContent(String owner, String repo, String pullIndex, String token, boolean apiCall) {
|
||||||
|
|
||||||
Call<ResponseBody> call;
|
Call<ResponseBody> call;
|
||||||
if(apiCall) {
|
if(apiCall) {
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getPullDiffContent(token, owner, repo, pullIndex);
|
|
||||||
|
call = RetrofitClient.getApiInterface(ctx).getPullDiffContent(token, owner, repo, pullIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getWebInterface().getPullDiffContent(owner, repo, pullIndex);
|
|
||||||
|
call = RetrofitClient.getWebInterface(ctx).getPullDiffContent(owner, repo, pullIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
call.enqueue(new Callback<ResponseBody>() {
|
call.enqueue(new Callback<ResponseBody>() {
|
||||||
@ -109,16 +97,18 @@ public class FileDiffActivity extends BaseActivity {
|
|||||||
if(response.code() == 200) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
assert response.body() != null;
|
assert response.body() != null;
|
||||||
|
|
||||||
AppUtil appUtil = new AppUtil();
|
|
||||||
List<FileDiffView> fileContentsArray = ParseDiff.getFileDiffViewArray(response.body().string());
|
List<FileDiffView> fileContentsArray = ParseDiff.getFileDiffViewArray(response.body().string());
|
||||||
|
|
||||||
int filesCount = fileContentsArray.size();
|
int filesCount = fileContentsArray.size();
|
||||||
if(filesCount > 1) {
|
if(filesCount > 1) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.fileDiffViewHeader, Integer.toString(filesCount)));
|
toolbarTitle.setText(getResources().getString(R.string.fileDiffViewHeader, Integer.toString(filesCount)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.fileDiffViewHeaderSingle, Integer.toString(filesCount)));
|
toolbarTitle.setText(getResources().getString(R.string.fileDiffViewHeaderSingle, Integer.toString(filesCount)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,34 +116,28 @@ public class FileDiffActivity extends BaseActivity {
|
|||||||
mListView.setAdapter(adapter);
|
mListView.setAdapter(adapter);
|
||||||
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mProgressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(IOException e) {
|
catch(IOException e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
else if(response.code() == 403) {
|
||||||
|
|
||||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 404) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -174,5 +158,4 @@ public class FileDiffActivity extends BaseActivity {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -8,7 +8,6 @@ import android.graphics.drawable.BitmapDrawable;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spanned;
|
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -21,8 +20,11 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import androidx.activity.result.ActivityResult;
|
||||||
|
import androidx.activity.result.ActivityResultCallback;
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import com.github.barteksc.pdfviewer.PDFView;
|
import com.github.barteksc.pdfviewer.PDFView;
|
||||||
import com.github.barteksc.pdfviewer.util.FitPolicy;
|
import com.github.barteksc.pdfviewer.util.FitPolicy;
|
||||||
@ -33,7 +35,7 @@ import org.mian.gitnex.clients.RetrofitClient;
|
|||||||
import org.mian.gitnex.fragments.BottomSheetFileViewerFragment;
|
import org.mian.gitnex.fragments.BottomSheetFileViewerFragment;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.highlightjs.HighlightJsView;
|
import org.mian.gitnex.helpers.highlightjs.HighlightJsView;
|
||||||
import org.mian.gitnex.helpers.highlightjs.models.Theme;
|
import org.mian.gitnex.helpers.highlightjs.models.Theme;
|
||||||
@ -43,24 +45,7 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
|
||||||
import io.noties.markwon.Markwon;
|
|
||||||
import io.noties.markwon.core.CorePlugin;
|
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
|
||||||
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.DefaultMediaDecoder;
|
|
||||||
import io.noties.markwon.image.ImageItem;
|
|
||||||
import io.noties.markwon.image.ImagesPlugin;
|
|
||||||
import io.noties.markwon.image.SchemeHandler;
|
|
||||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
|
||||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -75,8 +60,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
private LinearLayout singleFileContentsFrame;
|
private LinearLayout singleFileContentsFrame;
|
||||||
private HighlightJsView singleCodeContents;
|
private HighlightJsView singleCodeContents;
|
||||||
private PhotoView imageView;
|
private PhotoView imageView;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private byte[] imageData;
|
private byte[] imageData;
|
||||||
private PDFView pdfView;
|
private PDFView pdfView;
|
||||||
@ -86,7 +69,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
private String singleFileName;
|
private String singleFileName;
|
||||||
private String fileSha;
|
private String fileSha;
|
||||||
private AppUtil appUtil;
|
private AppUtil appUtil;
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
@ -98,23 +80,20 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
appUtil = new AppUtil();
|
appUtil = new AppUtil();
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoBranch = tinyDb.getString("repoBranch");
|
String repoBranch = tinyDB.getString("repoBranch");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
final String loginUid = tinyDB.getString("loginUid");
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
tinyDb.putBoolean("enableMarkdownInFileView", false);
|
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
singleFileContents = findViewById(R.id.singleFileContents);
|
singleFileContents = findViewById(R.id.singleFileContents);
|
||||||
@ -133,25 +112,22 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
tinyDb.putString("downloadFileContents", "");
|
tinyDB.putString("downloadFileContents", "");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
singleFileName = URLDecoder.decode(singleFileName, "UTF-8");
|
singleFileName = URLDecoder.decode(singleFileName, "UTF-8");
|
||||||
singleFileName = singleFileName.replaceAll("//", "/");
|
singleFileName = singleFileName.replaceAll("//", "/");
|
||||||
singleFileName = singleFileName.startsWith("/") ? singleFileName.substring(1) : singleFileName;
|
singleFileName = singleFileName.startsWith("/") ? singleFileName.substring(1) : singleFileName;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(UnsupportedEncodingException e) {
|
catch(UnsupportedEncodingException e) {
|
||||||
|
|
||||||
Log.i("singleFileName", singleFileName);
|
Log.i("singleFileName", singleFileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbar_title.setText(singleFileName);
|
toolbar_title.setText(singleFileName);
|
||||||
|
|
||||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
getSingleFileContents(instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -159,25 +135,25 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoBranch = tinyDb.getString("repoBranch");
|
String repoBranch = tinyDB.getString("repoBranch");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
String repoOwner = parts[0];
|
String repoOwner = parts[0];
|
||||||
String repoName = parts[1];
|
String repoName = parts[1];
|
||||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
String loginUid = tinyDB.getString("loginUid");
|
||||||
String loginUid = tinyDb.getString("loginUid");
|
String instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
if(tinyDb.getBoolean("fileModified")) {
|
if(tinyDB.getBoolean("fileModified")) {
|
||||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
|
||||||
tinyDb.putBoolean("fileModified", false);
|
getSingleFileContents(instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||||
|
tinyDB.putBoolean("fileModified", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename, String ref) {
|
private void getSingleFileContents(String token, final String owner, String repo, final String filename, String ref) {
|
||||||
|
|
||||||
Call<Files> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getSingleFileContents(token, owner, repo, filename, ref);
|
Call<Files> call = RetrofitClient.getApiInterface(ctx).getSingleFileContents(token, owner, repo, filename, ref);
|
||||||
|
|
||||||
call.enqueue(new Callback<Files>() {
|
call.enqueue(new Callback<Files>() {
|
||||||
|
|
||||||
@ -196,8 +172,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
fileSha = response.body().getSha();
|
fileSha = response.body().getSha();
|
||||||
|
|
||||||
// download file meta
|
// download file meta
|
||||||
tinyDb.putString("downloadFileName", filename);
|
tinyDB.putString("downloadFileName", filename);
|
||||||
tinyDb.putString("downloadFileContents", response.body().getContent());
|
tinyDB.putString("downloadFileContents", response.body().getContent());
|
||||||
|
|
||||||
if(appUtil.imageExtension(fileExtension)) { // file is image
|
if(appUtil.imageExtension(fileExtension)) { // file is image
|
||||||
|
|
||||||
@ -209,7 +185,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
imageData = Base64.decode(response.body().getContent(), Base64.DEFAULT);
|
imageData = Base64.decode(response.body().getContent(), Base64.DEFAULT);
|
||||||
Drawable imageDrawable = new BitmapDrawable(getResources(), BitmapFactory.decodeByteArray(imageData, 0, imageData.length));
|
Drawable imageDrawable = new BitmapDrawable(getResources(), BitmapFactory.decodeByteArray(imageData, 0, imageData.length));
|
||||||
imageView.setImageDrawable(imageDrawable);
|
imageView.setImageDrawable(imageDrawable);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(appUtil.sourceCodeExtension(fileExtension)) { // file is sourcecode
|
else if(appUtil.sourceCodeExtension(fileExtension)) { // file is sourcecode
|
||||||
|
|
||||||
@ -218,28 +193,34 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
pdfViewFrame.setVisibility(View.GONE);
|
pdfViewFrame.setVisibility(View.GONE);
|
||||||
singleCodeContents.setVisibility(View.VISIBLE);
|
singleCodeContents.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
switch(tinyDb.getInt("fileviewerSourceCodeThemeId")) {
|
switch(tinyDB.getInt("fileviewerSourceCodeThemeId")) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
singleCodeContents.setTheme(Theme.ARDUINO_LIGHT);
|
singleCodeContents.setTheme(Theme.ARDUINO_LIGHT);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
singleCodeContents.setTheme(Theme.GITHUB);
|
singleCodeContents.setTheme(Theme.GITHUB);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
|
||||||
singleCodeContents.setTheme(Theme.FAR);
|
singleCodeContents.setTheme(Theme.FAR);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
|
||||||
singleCodeContents.setTheme(Theme.IR_BLACK);
|
singleCodeContents.setTheme(Theme.IR_BLACK);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
|
|
||||||
singleCodeContents.setTheme(Theme.ANDROID_STUDIO);
|
singleCodeContents.setTheme(Theme.ANDROID_STUDIO);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
singleCodeContents.setTheme(Theme.MONOKAI_SUBLIME);
|
singleCodeContents.setTheme(Theme.MONOKAI_SUBLIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
singleCodeContents.setSource(appUtil.decodeBase64(response.body().getContent()));
|
singleCodeContents.setSource(appUtil.decodeBase64(response.body().getContent()));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(appUtil.pdfExtension(fileExtension)) { // file is pdf
|
else if(appUtil.pdfExtension(fileExtension)) { // file is pdf
|
||||||
|
|
||||||
@ -248,7 +229,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
singleCodeContents.setVisibility(View.GONE);
|
singleCodeContents.setVisibility(View.GONE);
|
||||||
pdfViewFrame.setVisibility(View.VISIBLE);
|
pdfViewFrame.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
pdfNightMode = tinyDb.getBoolean("enablePdfMode");
|
pdfNightMode = tinyDB.getBoolean("enablePdfMode");
|
||||||
|
|
||||||
decodedPdf = Base64.decode(response.body().getContent(), Base64.DEFAULT);
|
decodedPdf = Base64.decode(response.body().getContent(), Base64.DEFAULT);
|
||||||
pdfView.fromBytes(decodedPdf).enableSwipe(true).swipeHorizontal(false).enableDoubletap(true).defaultPage(0).enableAnnotationRendering(false).password(null).scrollHandle(null).enableAntialiasing(true).spacing(0).autoSpacing(true).pageFitPolicy(FitPolicy.WIDTH).fitEachPage(true).pageSnap(false).pageFling(true).nightMode(pdfNightMode).load();
|
pdfView.fromBytes(decodedPdf).enableSwipe(true).swipeHorizontal(false).enableDoubletap(true).defaultPage(0).enableAnnotationRendering(false).password(null).scrollHandle(null).enableAntialiasing(true).spacing(0).autoSpacing(true).pageFitPolicy(FitPolicy.WIDTH).fitEachPage(true).pageSnap(false).pageFling(true).nightMode(pdfNightMode).load();
|
||||||
@ -264,7 +245,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
singleFileContents.setText(getResources().getString(R.string.excludeFilesInFileviewer));
|
singleFileContents.setText(getResources().getString(R.string.excludeFilesInFileviewer));
|
||||||
singleFileContents.setGravity(Gravity.CENTER);
|
singleFileContents.setGravity(Gravity.CENTER);
|
||||||
singleFileContents.setTypeface(null, Typeface.BOLD);
|
singleFileContents.setTypeface(null, Typeface.BOLD);
|
||||||
|
|
||||||
}
|
}
|
||||||
else { // file type not known - plain text view
|
else { // file type not known - plain text view
|
||||||
|
|
||||||
@ -274,37 +254,30 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
singleFileContentsFrame.setVisibility(View.VISIBLE);
|
singleFileContentsFrame.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
singleFileContents.setText(appUtil.decodeBase64(response.body().getContent()));
|
singleFileContents.setText(appUtil.decodeBase64(response.body().getContent()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
singleFileContents.setText("");
|
singleFileContents.setText("");
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mProgressBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
else if(response.code() == 403) {
|
||||||
|
|
||||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 404) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -324,7 +297,9 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
inflater.inflate(R.menu.files_view_menu, menu);
|
inflater.inflate(R.menu.files_view_menu, menu);
|
||||||
|
|
||||||
String fileExtension = FileUtils.getExtension(singleFileName);
|
String fileExtension = FileUtils.getExtension(singleFileName);
|
||||||
|
|
||||||
if(!fileExtension.equalsIgnoreCase("md")) {
|
if(!fileExtension.equalsIgnoreCase("md")) {
|
||||||
|
|
||||||
menu.getItem(0).setVisible(false);
|
menu.getItem(0).setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,89 +311,42 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
switch(id) {
|
if(id == android.R.id.home) {
|
||||||
case android.R.id.home:
|
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
case R.id.genericMenu:
|
|
||||||
|
|
||||||
BottomSheetFileViewerFragment bottomSheet = new BottomSheetFileViewerFragment();
|
|
||||||
bottomSheet.show(getSupportFragmentManager(), "fileViewerBottomSheet");
|
|
||||||
return true;
|
|
||||||
case R.id.markdown:
|
|
||||||
|
|
||||||
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() {
|
|
||||||
@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();
|
|
||||||
|
|
||||||
if(!tinyDb.getBoolean("enableMarkdownInFileView")) {
|
|
||||||
|
|
||||||
singleCodeContents.setVisibility(View.GONE);
|
|
||||||
singleFileContentsFrame.setVisibility(View.VISIBLE);
|
|
||||||
singleFileContents.setVisibility(View.VISIBLE);
|
|
||||||
Spanned bodyWithMD = markwon.toMarkdown(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
|
|
||||||
markwon.setParsedMarkdown(singleFileContents, bodyWithMD);
|
|
||||||
tinyDb.putBoolean("enableMarkdownInFileView", true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
singleCodeContents.setVisibility(View.VISIBLE);
|
|
||||||
singleFileContentsFrame.setVisibility(View.GONE);
|
|
||||||
singleFileContents.setVisibility(View.GONE);
|
|
||||||
singleCodeContents.setSource(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
|
|
||||||
tinyDb.putBoolean("enableMarkdownInFileView", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
else if(id == R.id.genericMenu) {
|
||||||
|
|
||||||
|
BottomSheetFileViewerFragment bottomSheet = new BottomSheetFileViewerFragment();
|
||||||
|
bottomSheet.show(getSupportFragmentManager(), "fileViewerBottomSheet");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(id == R.id.markdown) {
|
||||||
|
|
||||||
|
new Markdown(ctx, appUtil.decodeBase64(tinyDB.getString("downloadFileContents")), singleFileContents);
|
||||||
|
|
||||||
|
if(!tinyDB.getBoolean("enableMarkdownInFileView")) {
|
||||||
|
|
||||||
|
singleCodeContents.setVisibility(View.GONE);
|
||||||
|
singleFileContentsFrame.setVisibility(View.VISIBLE);
|
||||||
|
singleFileContents.setVisibility(View.VISIBLE);
|
||||||
|
tinyDB.putBoolean("enableMarkdownInFileView", true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
singleCodeContents.setVisibility(View.VISIBLE);
|
||||||
|
singleFileContentsFrame.setVisibility(View.GONE);
|
||||||
|
singleFileContents.setVisibility(View.GONE);
|
||||||
|
singleCodeContents.setSource(appUtil.decodeBase64(tinyDB.getString("downloadFileContents")));
|
||||||
|
tinyDB.putBoolean("enableMarkdownInFileView", false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -432,15 +360,18 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
if("deleteFile".equals(text)) {
|
if("deleteFile".equals(text)) {
|
||||||
|
|
||||||
String fileExtension = FileUtils.getExtension(singleFileName);
|
String fileExtension = FileUtils.getExtension(singleFileName);
|
||||||
String data = appUtil.decodeBase64(tinyDb.getString("downloadFileContents"));
|
String data = appUtil.decodeBase64(tinyDB.getString("downloadFileContents"));
|
||||||
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
||||||
intent.putExtra("fileAction", 1);
|
intent.putExtra("fileAction", 1);
|
||||||
intent.putExtra("filePath", singleFileName);
|
intent.putExtra("filePath", singleFileName);
|
||||||
intent.putExtra("fileSha", fileSha);
|
intent.putExtra("fileSha", fileSha);
|
||||||
|
|
||||||
if(!appUtil.imageExtension(fileExtension)) {
|
if(!appUtil.imageExtension(fileExtension)) {
|
||||||
|
|
||||||
intent.putExtra("fileContents", data);
|
intent.putExtra("fileContents", data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
intent.putExtra("fileContents", "");
|
intent.putExtra("fileContents", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,15 +381,18 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
if("editFile".equals(text)) {
|
if("editFile".equals(text)) {
|
||||||
|
|
||||||
String fileExtension = FileUtils.getExtension(singleFileName);
|
String fileExtension = FileUtils.getExtension(singleFileName);
|
||||||
String data = appUtil.decodeBase64(tinyDb.getString("downloadFileContents"));
|
String data = appUtil.decodeBase64(tinyDB.getString("downloadFileContents"));
|
||||||
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
||||||
intent.putExtra("fileAction", 2);
|
intent.putExtra("fileAction", 2);
|
||||||
intent.putExtra("filePath", singleFileName);
|
intent.putExtra("filePath", singleFileName);
|
||||||
intent.putExtra("fileSha", fileSha);
|
intent.putExtra("fileSha", fileSha);
|
||||||
|
|
||||||
if(!appUtil.imageExtension(fileExtension)) {
|
if(!appUtil.imageExtension(fileExtension)) {
|
||||||
|
|
||||||
intent.putExtra("fileContents", data);
|
intent.putExtra("fileContents", data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
intent.putExtra("fileContents", "");
|
intent.putExtra("fileContents", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,11 +403,9 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
|
|
||||||
private void requestFileDownload() {
|
private void requestFileDownload() {
|
||||||
|
|
||||||
if(!tinyDb.getString("downloadFileContents").isEmpty()) {
|
if(!tinyDB.getString("downloadFileContents").isEmpty()) {
|
||||||
|
|
||||||
int CREATE_REQUEST_CODE = 40;
|
File outputFileName = new File(tinyDB.getString("downloadFileName"));
|
||||||
|
|
||||||
File outputFileName = new File(tinyDb.getString("downloadFileName"));
|
|
||||||
|
|
||||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||||
|
|
||||||
@ -481,48 +413,48 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
|||||||
intent.setType("*/*");
|
intent.setType("*/*");
|
||||||
intent.putExtra(Intent.EXTRA_TITLE, outputFileName.getName());
|
intent.putExtra(Intent.EXTRA_TITLE, outputFileName.getName());
|
||||||
|
|
||||||
startActivityForResult(intent, CREATE_REQUEST_CODE);
|
fileDownloadActivityResultLauncher.launch(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.waitLoadingDownloadFile));
|
Toasty.warning(ctx, getString(R.string.waitLoadingDownloadFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
ActivityResultLauncher<Intent> fileDownloadActivityResultLauncher = registerForActivityResult(
|
||||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
|
||||||
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
@Override
|
||||||
|
public void onActivityResult(ActivityResult result) {
|
||||||
|
|
||||||
if(requestCode == 40 && resultCode == RESULT_OK) {
|
if (result.getResultCode() == Activity.RESULT_OK) {
|
||||||
|
|
||||||
try {
|
Intent data = result.getData();
|
||||||
|
|
||||||
assert data != null;
|
try {
|
||||||
Uri uri = data.getData();
|
|
||||||
|
|
||||||
assert uri != null;
|
assert data != null;
|
||||||
OutputStream outputStream = getContentResolver().openOutputStream(uri);
|
Uri uri = data.getData();
|
||||||
|
|
||||||
byte[] dataAsBytes = Base64.decode(tinyDb.getString("downloadFileContents"), 0);
|
assert uri != null;
|
||||||
|
OutputStream outputStream = getContentResolver().openOutputStream(uri);
|
||||||
|
|
||||||
assert outputStream != null;
|
byte[] dataAsBytes = Base64.decode(tinyDB.getString("downloadFileContents"), 0);
|
||||||
outputStream.write(dataAsBytes);
|
|
||||||
outputStream.close();
|
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.downloadFileSaved));
|
assert outputStream != null;
|
||||||
|
outputStream.write(dataAsBytes);
|
||||||
|
outputStream.close();
|
||||||
|
|
||||||
|
Toasty.success(ctx, getString(R.string.downloadFileSaved));
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(IOException e) {
|
||||||
|
|
||||||
|
Log.e("errorFileDownloading", Objects.requireNonNull(e.getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(IOException e) {
|
|
||||||
|
|
||||||
Log.e("errorFileDownloading", Objects.requireNonNull(e.getMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -50,11 +47,11 @@ import org.mian.gitnex.helpers.Authorization;
|
|||||||
import org.mian.gitnex.helpers.ClickListener;
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
import org.mian.gitnex.helpers.ColorInverter;
|
import org.mian.gitnex.helpers.ColorInverter;
|
||||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||||
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.UserMentions;
|
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.Collaborators;
|
import org.mian.gitnex.models.Collaborators;
|
||||||
import org.mian.gitnex.models.Issues;
|
import org.mian.gitnex.models.Issues;
|
||||||
@ -62,30 +59,15 @@ import org.mian.gitnex.models.Labels;
|
|||||||
import org.mian.gitnex.models.UpdateIssueAssignees;
|
import org.mian.gitnex.models.UpdateIssueAssignees;
|
||||||
import org.mian.gitnex.models.WatchInfo;
|
import org.mian.gitnex.models.WatchInfo;
|
||||||
import org.mian.gitnex.viewmodels.IssueCommentsViewModel;
|
import org.mian.gitnex.viewmodels.IssueCommentsViewModel;
|
||||||
|
import org.mian.gitnex.views.ReactionList;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
|
||||||
import io.noties.markwon.Markwon;
|
|
||||||
import io.noties.markwon.core.CorePlugin;
|
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
|
||||||
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.DefaultMediaDecoder;
|
|
||||||
import io.noties.markwon.image.ImageItem;
|
|
||||||
import io.noties.markwon.image.ImagesPlugin;
|
|
||||||
import io.noties.markwon.image.SchemeHandler;
|
|
||||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
|
||||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -97,13 +79,7 @@ import retrofit2.Response;
|
|||||||
public class IssueDetailActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener, BottomSheetSingleIssueFragment.BottomSheetListener {
|
public class IssueDetailActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener, BottomSheetSingleIssueFragment.BottomSheetListener {
|
||||||
|
|
||||||
private IssueCommentsAdapter adapter;
|
private IssueCommentsAdapter adapter;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
|
||||||
private String instanceToken;
|
|
||||||
private String repoOwner;
|
private String repoOwner;
|
||||||
private String repoName;
|
private String repoName;
|
||||||
private int issueIndex;
|
private int issueIndex;
|
||||||
@ -135,21 +111,16 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityIssueDetailBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityIssueDetailBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repoOwner = parts[0];
|
repoOwner = parts[0];
|
||||||
repoName = parts[1];
|
repoName = parts[1];
|
||||||
issueIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
issueIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
setSupportActionBar(viewBinding.toolbar);
|
setSupportActionBar(viewBinding.toolbar);
|
||||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repoName);
|
Objects.requireNonNull(getSupportActionBar()).setTitle(repoName);
|
||||||
@ -162,12 +133,18 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(viewBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(viewBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||||
viewBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
viewBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
viewBinding.addNewComment.setOnClickListener(v -> BottomSheetReplyFragment.newInstance(new Bundle()).show(getSupportFragmentManager(), "replyBottomSheet"));
|
viewBinding.addNewComment.setOnClickListener(v -> {
|
||||||
|
|
||||||
|
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(new Bundle());
|
||||||
|
bottomSheetReplyFragment.setOnInteractedListener(this::onResume);
|
||||||
|
bottomSheetReplyFragment.show(getSupportFragmentManager(), "replyBottomSheet");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
labelsAdapter = new LabelsListAdapter(labelsList, IssueDetailActivity.this, currentLabelsIds);
|
labelsAdapter = new LabelsListAdapter(labelsList, IssueDetailActivity.this, currentLabelsIds);
|
||||||
assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, IssueDetailActivity.this, currentAssignees);
|
assigneesAdapter = new AssigneesListAdapter(ctx, assigneesList, IssueDetailActivity.this, currentAssignees);
|
||||||
LabelsActions.getCurrentIssueLabels(ctx, instanceUrl, loginUid, instanceToken, repoOwner, repoName, issueIndex, currentLabelsIds);
|
LabelsActions.getCurrentIssueLabels(ctx, repoOwner, repoName, issueIndex, currentLabelsIds);
|
||||||
AssigneesActions.getCurrentIssueAssignees(ctx, instanceUrl, loginUid, instanceToken, repoOwner, repoName, issueIndex, currentAssignees);
|
AssigneesActions.getCurrentIssueAssignees(ctx, repoOwner, repoName, issueIndex, currentAssignees);
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
|
||||||
@ -196,14 +173,14 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
viewBinding.pullToRefresh.setRefreshing(false);
|
viewBinding.pullToRefresh.setRefreshing(false);
|
||||||
IssueCommentsViewModel
|
IssueCommentsViewModel
|
||||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||||
ctx);
|
ctx);
|
||||||
|
|
||||||
}, 500));
|
}, 500));
|
||||||
|
|
||||||
Typeface myTypeface;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDB.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(ctx).getAssets(), "fonts/manroperegular.ttf");
|
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(ctx).getAssets(), "fonts/manroperegular.ttf");
|
||||||
@ -222,8 +199,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
viewBinding.toolbarTitle.setTypeface(myTypeface);
|
viewBinding.toolbarTitle.setTypeface(myTypeface);
|
||||||
viewBinding.toolbarTitle.setText(repoName);
|
viewBinding.toolbarTitle.setText(repoName);
|
||||||
|
|
||||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||||
fetchDataAsync(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
fetchDataAsync(repoOwner, repoName, issueIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,6 +209,10 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
switch(text) {
|
switch(text) {
|
||||||
|
|
||||||
|
case "onResume":
|
||||||
|
onResume();
|
||||||
|
break;
|
||||||
|
|
||||||
case "showLabels":
|
case "showLabels":
|
||||||
showLabels();
|
showLabels();
|
||||||
break;
|
break;
|
||||||
@ -292,7 +273,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AssigneesActions.getRepositoryAssignees(ctx, instanceUrl, instanceToken, repoOwner, repoName, assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
dialogAssignees.show();
|
||||||
|
AssigneesActions.getRepositoryAssignees(ctx, repoOwner, repoName, assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showLabels() {
|
public void showLabels() {
|
||||||
@ -328,7 +310,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
LabelsActions.getRepositoryLabels(ctx, instanceUrl, instanceToken, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
dialogLabels.show();
|
||||||
|
LabelsActions.getRepositoryLabels(ctx, repoOwner, repoName, labelsList, dialogLabels, labelsAdapter, labelsBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateIssueAssignees() {
|
private void updateIssueAssignees() {
|
||||||
@ -338,9 +321,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
Call<JsonElement> call3;
|
Call<JsonElement> call3;
|
||||||
|
|
||||||
call3 = RetrofitClient
|
call3 = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.patchIssueAssignees(Authorization.get(ctx), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
||||||
.patchIssueAssignees(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
|
||||||
|
|
||||||
call3.enqueue(new Callback<JsonElement>() {
|
call3.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -355,9 +337,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
viewBinding.frameAssignees.removeAllViews();
|
viewBinding.frameAssignees.removeAllViews();
|
||||||
viewBinding.frameLabels.removeAllViews();
|
viewBinding.frameLabels.removeAllViews();
|
||||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||||
currentAssignees.clear();
|
currentAssignees.clear();
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> AssigneesActions.getCurrentIssueAssignees(ctx, instanceUrl, loginUid, instanceToken, repoOwner, repoName, issueIndex, currentAssignees), 1000);
|
new Handler(Looper.getMainLooper()).postDelayed(() -> AssigneesActions.getCurrentIssueAssignees(ctx, repoOwner, repoName, issueIndex, currentAssignees), 1000);
|
||||||
}
|
}
|
||||||
else if(response2.code() == 401) {
|
else if(response2.code() == 401) {
|
||||||
|
|
||||||
@ -394,9 +376,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
Labels patchIssueLabels = new Labels(labelsIds);
|
Labels patchIssueLabels = new Labels(labelsIds);
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.updateIssueLabels(Authorization.get(ctx), repoOwner, repoName, issueIndex, patchIssueLabels);
|
||||||
.updateIssueLabels(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, patchIssueLabels);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -410,9 +391,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
viewBinding.frameAssignees.removeAllViews();
|
viewBinding.frameAssignees.removeAllViews();
|
||||||
viewBinding.frameLabels.removeAllViews();
|
viewBinding.frameLabels.removeAllViews();
|
||||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||||
currentLabelsIds.clear();
|
currentLabelsIds.clear();
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> LabelsActions.getCurrentIssueLabels(ctx, instanceUrl, loginUid, instanceToken, repoOwner, repoName, issueIndex, currentLabelsIds), 1000);
|
new Handler(Looper.getMainLooper()).postDelayed(() -> LabelsActions.getCurrentIssueLabels(ctx, repoOwner, repoName, issueIndex, currentLabelsIds), 1000);
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -457,18 +438,21 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
switch(id) {
|
if(id == android.R.id.home) {
|
||||||
case android.R.id.home:
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
case R.id.genericMenu:
|
|
||||||
BottomSheetSingleIssueFragment bottomSheet = new BottomSheetSingleIssueFragment();
|
|
||||||
bottomSheet.show(getSupportFragmentManager(), "singleIssueBottomSheet");
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(id == R.id.genericMenu) {
|
||||||
|
|
||||||
|
BottomSheetSingleIssueFragment bottomSheet = new BottomSheetSingleIssueFragment();
|
||||||
|
bottomSheet.show(getSupportFragmentManager(), "singleIssueBottomSheet");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -476,84 +460,87 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if(tinyDb.getBoolean("commentPosted")) {
|
if(tinyDB.getBoolean("commentPosted")) {
|
||||||
|
|
||||||
viewBinding.scrollViewComments.post(() -> {
|
viewBinding.scrollViewComments.post(() -> {
|
||||||
|
|
||||||
IssueCommentsViewModel
|
IssueCommentsViewModel
|
||||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||||
ctx);
|
ctx);
|
||||||
|
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN), 1000);
|
new Handler(Looper.getMainLooper()).postDelayed(() -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN), 1000);
|
||||||
|
|
||||||
tinyDb.putBoolean("commentPosted", false);
|
tinyDB.putBoolean("commentPosted", false);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getBoolean("commentEdited")) {
|
if(tinyDB.getBoolean("commentEdited")) {
|
||||||
|
|
||||||
viewBinding.scrollViewComments.post(() -> {
|
viewBinding.scrollViewComments.post(() -> {
|
||||||
|
|
||||||
IssueCommentsViewModel
|
IssueCommentsViewModel
|
||||||
.loadIssueComments(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex,
|
.loadIssueComments(Authorization.get(ctx), repoOwner, repoName, issueIndex,
|
||||||
ctx);
|
ctx);
|
||||||
tinyDb.putBoolean("commentEdited", false);
|
tinyDB.putBoolean("commentEdited", false);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getBoolean("singleIssueUpdate")) {
|
if(tinyDB.getBoolean("singleIssueUpdate")) {
|
||||||
|
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
viewBinding.frameAssignees.removeAllViews();
|
viewBinding.frameAssignees.removeAllViews();
|
||||||
viewBinding.frameLabels.removeAllViews();
|
viewBinding.frameLabels.removeAllViews();
|
||||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||||
tinyDb.putBoolean("singleIssueUpdate", false);
|
tinyDB.putBoolean("singleIssueUpdate", false);
|
||||||
|
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getBoolean("issueEdited")) {
|
if(tinyDB.getBoolean("issueEdited")) {
|
||||||
|
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
viewBinding.frameAssignees.removeAllViews();
|
viewBinding.frameAssignees.removeAllViews();
|
||||||
viewBinding.frameLabels.removeAllViews();
|
viewBinding.frameLabels.removeAllViews();
|
||||||
getSingleIssue(instanceUrl, instanceToken, repoOwner, repoName, issueIndex, loginUid);
|
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||||
tinyDb.putBoolean("issueEdited", false);
|
tinyDB.putBoolean("issueEdited", false);
|
||||||
|
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String owner, String repo, int index, String loginUid) {
|
private void fetchDataAsync(String owner, String repo, int index) {
|
||||||
|
|
||||||
IssueCommentsViewModel issueCommentsModel = new ViewModelProvider(this).get(IssueCommentsViewModel.class);
|
IssueCommentsViewModel issueCommentsModel = new ViewModelProvider(this).get(IssueCommentsViewModel.class);
|
||||||
|
|
||||||
issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), owner, repo, index, ctx)
|
issueCommentsModel.getIssueCommentList(Authorization.get(ctx), owner, repo, index, ctx)
|
||||||
.observe(this, issueCommentsMain -> {
|
.observe(this, issueCommentsMain -> {
|
||||||
|
|
||||||
assert issueCommentsMain != null;
|
assert issueCommentsMain != null;
|
||||||
|
|
||||||
if(issueCommentsMain.size() > 0) {
|
if(issueCommentsMain.size() > 0) {
|
||||||
|
|
||||||
viewBinding.divider.setVisibility(View.VISIBLE);
|
viewBinding.divider.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter = new IssueCommentsAdapter(ctx, getSupportFragmentManager(), issueCommentsMain);
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("repoOwner", repoOwner);
|
||||||
|
bundle.putString("repoName", repoName);
|
||||||
|
bundle.putInt("issueNumber", issueIndex);
|
||||||
|
|
||||||
|
adapter = new IssueCommentsAdapter(ctx, bundle, issueCommentsMain, getSupportFragmentManager(), this::onResume);
|
||||||
|
|
||||||
viewBinding.recyclerView.setAdapter(adapter);
|
viewBinding.recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getSingleIssue(String instanceUrl, String instanceToken, String repoOwner, String repoName, int issueIndex, String loginUid) {
|
private void getSingleIssue(String repoOwner, String repoName, int issueIndex) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
Call<Issues> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
Call<Issues> call = RetrofitClient.getApiInterface(ctx)
|
||||||
.getIssueByIndex(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
.getIssueByIndex(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||||
|
|
||||||
call.enqueue(new Callback<Issues>() {
|
call.enqueue(new Callback<Issues>() {
|
||||||
|
|
||||||
@ -566,6 +553,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
assert singleIssue != null;
|
assert singleIssue != null;
|
||||||
|
|
||||||
viewBinding.issuePrState.setVisibility(View.VISIBLE);
|
viewBinding.issuePrState.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if(singleIssue.getPull_request() != null) {
|
if(singleIssue.getPull_request() != null) {
|
||||||
|
|
||||||
if(singleIssue.getPull_request().isMerged()) { // merged
|
if(singleIssue.getPull_request().isMerged()) { // merged
|
||||||
@ -586,49 +574,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue_closed_red);
|
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue_closed_red);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create())
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
.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() {
|
|
||||||
|
|
||||||
@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();
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
tinyDb.putString("issueState", singleIssue.getState());
|
tinyDb.putString("issueState", singleIssue.getState());
|
||||||
@ -641,8 +587,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
.getString(R.string.hash) + singleIssue.getNumber() + "</font>";
|
.getString(R.string.hash) + singleIssue.getNumber() + "</font>";
|
||||||
viewBinding.issueTitle.setText(Html.fromHtml(issueNumber_ + " " + singleIssue.getTitle()));
|
viewBinding.issueTitle.setText(Html.fromHtml(issueNumber_ + " " + singleIssue.getTitle()));
|
||||||
String cleanIssueDescription = singleIssue.getBody().trim();
|
String cleanIssueDescription = singleIssue.getBody().trim();
|
||||||
Spanned bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(cleanIssueDescription));
|
|
||||||
markwon.setParsedMarkdown(viewBinding.issueDescription, UserMentions.UserMentionsFunc(ctx, bodyWithMD, cleanIssueDescription));
|
new Markdown(ctx, EmojiParser.parseToUnicode(cleanIssueDescription), viewBinding.issueDescription);
|
||||||
|
|
||||||
RelativeLayout.LayoutParams paramsDesc = (RelativeLayout.LayoutParams) viewBinding.issueDescription.getLayoutParams();
|
RelativeLayout.LayoutParams paramsDesc = (RelativeLayout.LayoutParams) viewBinding.issueDescription.getLayoutParams();
|
||||||
|
|
||||||
@ -650,7 +596,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
params1.setMargins(15, 0, 0, 0);
|
params1.setMargins(15, 0, 0, 0);
|
||||||
|
|
||||||
if(singleIssue.getAssignees() != null) {
|
if(singleIssue.getAssignees() != null) {
|
||||||
|
|
||||||
viewBinding.assigneesScrollView.setVisibility(View.VISIBLE);
|
viewBinding.assigneesScrollView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
for(int i = 0; i < singleIssue.getAssignees().size(); i++) {
|
for(int i = 0; i < singleIssue.getAssignees().size(); i++) {
|
||||||
|
|
||||||
ImageView assigneesView = new ImageView(ctx);
|
ImageView assigneesView = new ImageView(ctx);
|
||||||
@ -662,17 +610,19 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
viewBinding.frameAssignees.addView(assigneesView);
|
viewBinding.frameAssignees.addView(assigneesView);
|
||||||
assigneesView.setLayoutParams(params1);
|
assigneesView.setLayoutParams(params1);
|
||||||
if(!singleIssue.getAssignees().get(i).getFull_name().equals("")) {
|
if(!singleIssue.getAssignees().get(i).getFull_name().equals("")) {
|
||||||
|
|
||||||
assigneesView.setOnClickListener(
|
assigneesView.setOnClickListener(
|
||||||
new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getFull_name()), ctx));
|
new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getFull_name()), ctx));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
assigneesView.setOnClickListener(
|
assigneesView.setOnClickListener(
|
||||||
new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getLogin()), ctx));
|
new ClickListener(getString(R.string.assignedTo, singleIssue.getAssignees().get(i).getLogin()), ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
viewBinding.assigneesScrollView.setVisibility(View.GONE);
|
viewBinding.assigneesScrollView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,6 +631,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
params.setMargins(0, 0, 15, 0);
|
params.setMargins(0, 0, 15, 0);
|
||||||
|
|
||||||
if(singleIssue.getLabels() != null) {
|
if(singleIssue.getLabels() != null) {
|
||||||
|
|
||||||
viewBinding.labelsScrollView.setVisibility(View.VISIBLE);
|
viewBinding.labelsScrollView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
for(int i = 0; i < singleIssue.getLabels().size(); i++) {
|
for(int i = 0; i < singleIssue.getLabels().size(); i++) {
|
||||||
@ -704,16 +655,17 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
labelsView.setImageDrawable(drawable);
|
labelsView.setImageDrawable(drawable);
|
||||||
viewBinding.frameLabels.addView(labelsView);
|
viewBinding.frameLabels.addView(labelsView);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
viewBinding.labelsScrollView.setVisibility(View.GONE);
|
viewBinding.labelsScrollView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(singleIssue.getDue_date() != null) {
|
if(singleIssue.getDue_date() != null) {
|
||||||
|
|
||||||
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
|
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
|
||||||
|
|
||||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
|
||||||
String dueDate = formatter.format(singleIssue.getDue_date());
|
String dueDate = formatter.format(singleIssue.getDue_date());
|
||||||
viewBinding.issueDueDate.setText(dueDate);
|
viewBinding.issueDueDate.setText(dueDate);
|
||||||
@ -721,11 +673,11 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getDue_date()), ctx));
|
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getDue_date()), ctx));
|
||||||
}
|
}
|
||||||
else if(timeFormat.equals("normal1")) {
|
else if(timeFormat.equals("normal1")) {
|
||||||
|
|
||||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale));
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale));
|
||||||
String dueDate = formatter.format(singleIssue.getDue_date());
|
String dueDate = formatter.format(singleIssue.getDue_date());
|
||||||
viewBinding.issueDueDate.setText(dueDate);
|
viewBinding.issueDueDate.setText(dueDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -735,6 +687,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
String edited;
|
String edited;
|
||||||
|
|
||||||
if(!singleIssue.getUpdated_at().equals(singleIssue.getCreated_at())) {
|
if(!singleIssue.getUpdated_at().equals(singleIssue.getCreated_at())) {
|
||||||
|
|
||||||
edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
|
edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
|
||||||
viewBinding.issueModified.setVisibility(View.VISIBLE);
|
viewBinding.issueModified.setVisibility(View.VISIBLE);
|
||||||
viewBinding.issueModified.setText(edited);
|
viewBinding.issueModified.setText(edited);
|
||||||
@ -742,22 +695,27 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getUpdated_at()), ctx));
|
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getUpdated_at()), ctx));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
viewBinding.issueModified.setVisibility(View.INVISIBLE);
|
viewBinding.issueModified.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((singleIssue.getDue_date() == null && singleIssue.getMilestone() == null) && singleIssue.getAssignees() != null) {
|
if((singleIssue.getDue_date() == null && singleIssue.getMilestone() == null) && singleIssue.getAssignees() != null) {
|
||||||
|
|
||||||
paramsDesc.setMargins(0, 35, 0, 0);
|
paramsDesc.setMargins(0, 35, 0, 0);
|
||||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||||
}
|
}
|
||||||
else if(singleIssue.getDue_date() == null && singleIssue.getMilestone() == null) {
|
else if(singleIssue.getDue_date() == null && singleIssue.getMilestone() == null) {
|
||||||
|
|
||||||
paramsDesc.setMargins(0, 55, 0, 0);
|
paramsDesc.setMargins(0, 55, 0, 0);
|
||||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||||
}
|
}
|
||||||
else if(singleIssue.getAssignees() == null) {
|
else if(singleIssue.getAssignees() == null) {
|
||||||
|
|
||||||
paramsDesc.setMargins(0, 35, 0, 0);
|
paramsDesc.setMargins(0, 35, 0, 0);
|
||||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
paramsDesc.setMargins(0, 15, 0, 0);
|
paramsDesc.setMargins(0, 15, 0, 0);
|
||||||
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
viewBinding.issueDescription.setLayoutParams(paramsDesc);
|
||||||
}
|
}
|
||||||
@ -766,30 +724,51 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
viewBinding.issueCreatedTime.setVisibility(View.VISIBLE);
|
viewBinding.issueCreatedTime.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if(timeFormat.equals("pretty")) {
|
if(timeFormat.equals("pretty")) {
|
||||||
|
|
||||||
viewBinding.issueCreatedTime
|
viewBinding.issueCreatedTime
|
||||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), ctx));
|
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("repoOwner", repoOwner);
|
||||||
|
bundle.putString("repoName", repoName);
|
||||||
|
bundle.putInt("issueId", singleIssue.getNumber());
|
||||||
|
|
||||||
|
ReactionList reactionList = new ReactionList(ctx, bundle);
|
||||||
|
|
||||||
|
viewBinding.commentReactionBadges.removeAllViews();
|
||||||
|
viewBinding.commentReactionBadges.addView(reactionList);
|
||||||
|
|
||||||
|
reactionList.setOnReactionAddedListener(() -> {
|
||||||
|
|
||||||
|
if(viewBinding.commentReactionBadges.getVisibility() != View.VISIBLE) {
|
||||||
|
viewBinding.commentReactionBadges.post(() -> viewBinding.commentReactionBadges.setVisibility(View.VISIBLE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if(singleIssue.getMilestone() != null) {
|
if(singleIssue.getMilestone() != null) {
|
||||||
|
|
||||||
|
viewBinding.issueMilestone.setVisibility(View.VISIBLE);
|
||||||
viewBinding.issueMilestone.setText(getString(R.string.issueMilestone, singleIssue.getMilestone().getTitle()));
|
viewBinding.issueMilestone.setText(getString(R.string.issueMilestone, singleIssue.getMilestone().getTitle()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
viewBinding.issueMilestone.setVisibility(View.GONE);
|
viewBinding.issueMilestone.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!singleIssue.getUser().getFull_name().equals("")) {
|
if(!singleIssue.getUser().getFull_name().equals("")) {
|
||||||
|
|
||||||
viewBinding.assigneeAvatar.setOnClickListener(
|
viewBinding.assigneeAvatar.setOnClickListener(
|
||||||
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getFull_name(), ctx));
|
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getFull_name(), ctx));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
viewBinding.assigneeAvatar.setOnClickListener(
|
viewBinding.assigneeAvatar.setOnClickListener(
|
||||||
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getLogin(), ctx));
|
new ClickListener(ctx.getResources().getString(R.string.issueCreator) + singleIssue.getUser().getLogin(), ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
viewBinding.progressBar.setVisibility(View.GONE);
|
viewBinding.progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||||
@ -798,7 +777,21 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
|
if(tinyDb.getString("issueType").equals("Issue")) {
|
||||||
|
|
||||||
|
Toasty.warning(ctx, getResources().getString(R.string.noDataIssueTab));
|
||||||
|
}
|
||||||
|
else if(tinyDb.getString("issueType").equals("Pull")) {
|
||||||
|
|
||||||
|
Toasty.warning(ctx, getResources().getString(R.string.noDataPullRequests));
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent mainIntent = new Intent(ctx, MainActivity.class);
|
||||||
|
ctx.startActivity(mainIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -811,8 +804,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||||
|
|
||||||
Call<WatchInfo> call2 = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
Call<WatchInfo> call2 = RetrofitClient.getApiInterface(appCtx)
|
||||||
.checkIssueWatchStatus(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
.checkIssueWatchStatus(Authorization.get(ctx), repoOwner, repoName, issueIndex);
|
||||||
|
|
||||||
call2.enqueue(new Callback<WatchInfo>() {
|
call2.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
@ -823,21 +816,17 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||||||
|
|
||||||
assert response.body() != null;
|
assert response.body() != null;
|
||||||
tinyDb.putBoolean("issueSubscribed", response.body().getSubscribed());
|
tinyDb.putBoolean("issueSubscribed", response.body().getSubscribed());
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
tinyDb.putBoolean("issueSubscribed", false);
|
tinyDb.putBoolean("issueSubscribed", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
tinyDb.putBoolean("issueSubscribed", false);
|
tinyDb.putBoolean("issueSubscribed", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
@ -19,7 +18,7 @@ import org.mian.gitnex.clients.RetrofitClient;
|
|||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.NetworkObserver;
|
import org.mian.gitnex.helpers.NetworkStatusObserver;
|
||||||
import org.mian.gitnex.helpers.PathsHelper;
|
import org.mian.gitnex.helpers.PathsHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
@ -47,16 +46,12 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
private enum LoginType {BASIC, TOKEN}
|
private enum LoginType {BASIC, TOKEN}
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private Context ctx = this;
|
|
||||||
private TinyDB tinyDB;
|
|
||||||
|
|
||||||
private Button loginButton;
|
private Button loginButton;
|
||||||
private EditText instanceUrlET, loginUidET, loginPassword, otpCode, loginTokenCode;
|
private EditText instanceUrlET, loginUidET, loginPassword, otpCode, loginTokenCode;
|
||||||
private Spinner protocolSpinner;
|
private AutoCompleteTextView protocolSpinner;
|
||||||
private TextView otpInfo;
|
|
||||||
private RadioGroup loginMethod;
|
private RadioGroup loginMethod;
|
||||||
private String device_id = "token";
|
private String device_id = "token";
|
||||||
|
private String selectedProtocol;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
@ -68,70 +63,77 @@ public class LoginActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
tinyDB = new TinyDB(appCtx);
|
NetworkStatusObserver networkStatusObserver = NetworkStatusObserver.get(ctx);
|
||||||
NetworkObserver networkMonitor = new NetworkObserver(ctx);
|
|
||||||
|
|
||||||
loginButton = findViewById(R.id.login_button);
|
loginButton = findViewById(R.id.login_button);
|
||||||
instanceUrlET = findViewById(R.id.instance_url);
|
instanceUrlET = findViewById(R.id.instance_url);
|
||||||
loginUidET = findViewById(R.id.login_uid);
|
loginUidET = findViewById(R.id.login_uid);
|
||||||
loginPassword = findViewById(R.id.login_passwd);
|
loginPassword = findViewById(R.id.login_passwd);
|
||||||
otpCode = findViewById(R.id.otpCode);
|
otpCode = findViewById(R.id.otpCode);
|
||||||
otpInfo = findViewById(R.id.otpInfo);
|
|
||||||
protocolSpinner = findViewById(R.id.httpsSpinner);
|
protocolSpinner = findViewById(R.id.httpsSpinner);
|
||||||
loginMethod = findViewById(R.id.loginMethod);
|
loginMethod = findViewById(R.id.loginMethod);
|
||||||
loginTokenCode = findViewById(R.id.loginTokenCode);
|
loginTokenCode = findViewById(R.id.loginTokenCode);
|
||||||
|
|
||||||
((TextView) findViewById(R.id.appVersion)).setText(AppUtil.getAppVersion(appCtx));
|
((TextView) findViewById(R.id.appVersion)).setText(AppUtil.getAppVersion(appCtx));
|
||||||
|
|
||||||
ArrayAdapter<Protocol> adapterProtocols = new ArrayAdapter<>(LoginActivity.this, R.layout.spinner_item, Protocol.values());
|
ArrayAdapter<Protocol> adapterProtocols = new ArrayAdapter<>(LoginActivity.this, R.layout.list_spinner_items, Protocol.values());
|
||||||
adapterProtocols.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
|
||||||
|
|
||||||
protocolSpinner.setAdapter(adapterProtocols);
|
protocolSpinner.setAdapter(adapterProtocols);
|
||||||
protocolSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
protocolSpinner.setSelection(0);
|
||||||
|
protocolSpinner.setOnItemClickListener((parent, view, position, id) -> {
|
||||||
|
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
selectedProtocol = String.valueOf(parent.getItemAtPosition(position));
|
||||||
|
|
||||||
if(protocolSpinner.getSelectedItem() == Protocol.HTTP) {
|
if(selectedProtocol.equals(String.valueOf(Protocol.HTTP))) {
|
||||||
Toasty.warning(ctx, getResources().getString(R.string.protocolError));
|
|
||||||
}
|
Toasty.warning(ctx, getResources().getString(R.string.protocolError));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(R.id.loginToken == loginMethod.getCheckedRadioButtonId()) {
|
||||||
|
|
||||||
|
AppUtil.setMultiVisibility(View.GONE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||||
|
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
AppUtil.setMultiVisibility(View.VISIBLE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||||
|
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
loginMethod.setOnCheckedChangeListener((group, checkedId) -> {
|
loginMethod.setOnCheckedChangeListener((group, checkedId) -> {
|
||||||
|
|
||||||
if(checkedId == R.id.loginToken) {
|
if(checkedId == R.id.loginToken) {
|
||||||
|
|
||||||
AppUtil.setMultiVisibility(View.GONE, loginUidET, loginPassword, otpCode, otpInfo);
|
AppUtil.setMultiVisibility(View.GONE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||||
loginTokenCode.setVisibility(View.VISIBLE);
|
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
AppUtil.setMultiVisibility(View.VISIBLE, loginUidET, loginPassword, otpCode, otpInfo);
|
AppUtil.setMultiVisibility(View.VISIBLE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||||
loginTokenCode.setVisibility(View.GONE);
|
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
networkMonitor.onInternetStateListener(isAvailable -> {
|
Handler handler = new Handler(getMainLooper());
|
||||||
|
|
||||||
if(isAvailable) {
|
networkStatusObserver.registerNetworkStatusListener(hasNetworkConnection -> {
|
||||||
|
|
||||||
enableProcessButton();
|
handler.post(() -> {
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
disableProcessButton();
|
if(hasNetworkConnection) {
|
||||||
loginButton.setText(getResources().getString(R.string.btnLogin));
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
disableProcessButton();
|
||||||
|
loginButton.setText(getResources().getString(R.string.btnLogin));
|
||||||
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
loadDefaults();
|
loadDefaults();
|
||||||
@ -140,25 +142,29 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
login();
|
login();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void login() {
|
private void login() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
if(selectedProtocol == null) {
|
||||||
|
|
||||||
|
Toasty.error(ctx, getResources().getString(R.string.protocolEmptyError));
|
||||||
|
enableProcessButton();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String loginUid = loginUidET.getText().toString();
|
String loginUid = loginUidET.getText().toString();
|
||||||
String loginPass = loginPassword.getText().toString();
|
String loginPass = loginPassword.getText().toString();
|
||||||
String loginToken = loginTokenCode.getText().toString().trim();
|
String loginToken = loginTokenCode.getText().toString().trim();
|
||||||
|
|
||||||
Protocol protocol = (Protocol) protocolSpinner.getSelectedItem();
|
|
||||||
LoginType loginType = (loginMethod.getCheckedRadioButtonId() == R.id.loginUsernamePassword) ? LoginType.BASIC : LoginType.TOKEN;
|
LoginType loginType = (loginMethod.getCheckedRadioButtonId() == R.id.loginUsernamePassword) ? LoginType.BASIC : LoginType.TOKEN;
|
||||||
|
|
||||||
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET.getText().toString(), "http")).toUri();
|
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET.getText().toString(), "http")).toUri();
|
||||||
|
|
||||||
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(protocol.name().toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/"))
|
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(selectedProtocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/"))
|
||||||
.toUri();
|
.toUri();
|
||||||
|
|
||||||
tinyDB.putString("loginType", loginType.name().toLowerCase());
|
tinyDB.putString("loginType", loginType.name().toLowerCase());
|
||||||
@ -170,7 +176,6 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldURL));
|
Toasty.error(ctx, getResources().getString(R.string.emptyFieldURL));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loginType == LoginType.BASIC) {
|
if(loginType == LoginType.BASIC) {
|
||||||
@ -180,14 +185,12 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Toasty.warning(ctx, getResources().getString(R.string.loginOTPTypeError));
|
Toasty.warning(ctx, getResources().getString(R.string.loginOTPTypeError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rawInstanceUrl.getUserInfo() != null) {
|
if(rawInstanceUrl.getUserInfo() != null) {
|
||||||
|
|
||||||
tinyDB.putString("basicAuthPassword", loginPass);
|
tinyDB.putString("basicAuthPassword", loginPass);
|
||||||
tinyDB.putBoolean("basicAuthFlag", true);
|
tinyDB.putBoolean("basicAuthFlag", true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loginUid.equals("")) {
|
if(loginUid.equals("")) {
|
||||||
@ -195,7 +198,6 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldUsername));
|
Toasty.error(ctx, getResources().getString(R.string.emptyFieldUsername));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loginPass.equals("")) {
|
if(loginPass.equals("")) {
|
||||||
@ -203,13 +205,12 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldPassword));
|
Toasty.error(ctx, getResources().getString(R.string.emptyFieldPassword));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int loginOTP = (otpCode.length() > 0) ? Integer.parseInt(otpCode.getText().toString().trim()) : 0;
|
int loginOTP = (otpCode.length() > 0) ? Integer.parseInt(otpCode.getText().toString().trim()) : 0;
|
||||||
tinyDB.putString("loginUid", loginUid);
|
tinyDB.putString("loginUid", loginUid);
|
||||||
|
|
||||||
versionCheck(instanceUrl.toString(), loginUid, loginPass, loginOTP, loginToken, loginType);
|
versionCheck(loginUid, loginPass, loginOTP, loginToken, loginType);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -219,11 +220,9 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Toasty.error(ctx, getResources().getString(R.string.loginTokenError));
|
Toasty.error(ctx, getResources().getString(R.string.loginTokenError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
versionCheck(instanceUrl.toString(), loginUid, loginPass, 123, loginToken, loginType);
|
versionCheck(loginUid, loginPass, 123, loginToken, loginType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -232,27 +231,25 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Log.e("onFailure-login", e.toString());
|
Log.e("onFailure-login", e.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.malformedUrl));
|
Toasty.error(ctx, getResources().getString(R.string.malformedUrl));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void versionCheck(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP, final String loginToken,
|
private void versionCheck(final String loginUid, final String loginPass, final int loginOTP, final String loginToken,
|
||||||
final LoginType loginType) {
|
final LoginType loginType) {
|
||||||
|
|
||||||
Call<GiteaVersion> callVersion;
|
Call<GiteaVersion> callVersion;
|
||||||
|
|
||||||
if(!loginToken.equals("")) {
|
if(!loginToken.equals("")) {
|
||||||
|
|
||||||
callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken("token " + loginToken);
|
callVersion = RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithToken("token " + loginToken);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
callVersion =
|
callVersion =
|
||||||
(loginOTP != 0) ? RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithOTP(credential, loginOTP) :
|
(loginOTP != 0) ? RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithOTP(credential, loginOTP) :
|
||||||
RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithBasic(credential);
|
RetrofitClient.getApiInterface(appCtx).getGiteaVersionWithBasic(credential);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
@ -263,9 +260,10 @@ public class LoginActivity extends BaseActivity {
|
|||||||
if(responseVersion.code() == 200) {
|
if(responseVersion.code() == 200) {
|
||||||
|
|
||||||
GiteaVersion version = responseVersion.body();
|
GiteaVersion version = responseVersion.body();
|
||||||
|
|
||||||
assert version != null;
|
assert version != null;
|
||||||
|
|
||||||
if(!Version.valid(version.getVersion())) {
|
if(!Version.valid(version.getVersion())) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
|
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
return;
|
return;
|
||||||
@ -276,8 +274,10 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(gitea_version.less(getString(R.string.versionLow))) {
|
if(gitea_version.less(getString(R.string.versionLow))) {
|
||||||
|
|
||||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx)
|
||||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setIcon(R.drawable.ic_warning)
|
.setTitle(getString(R.string.versionAlertDialogHeader))
|
||||||
|
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion()))
|
||||||
|
.setIcon(R.drawable.ic_warning)
|
||||||
.setCancelable(true);
|
.setCancelable(true);
|
||||||
|
|
||||||
alertDialogBuilder.setNegativeButton(getString(R.string.cancelButton), (dialog, which) -> {
|
alertDialogBuilder.setNegativeButton(getString(R.string.cancelButton), (dialog, which) -> {
|
||||||
@ -289,7 +289,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
alertDialogBuilder.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
alertDialogBuilder.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||||
});
|
});
|
||||||
|
|
||||||
alertDialogBuilder.create().show();
|
alertDialogBuilder.create().show();
|
||||||
@ -297,32 +297,34 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
else if(gitea_version.lessOrEqual(getString(R.string.versionHigh))) {
|
else if(gitea_version.lessOrEqual(getString(R.string.versionHigh))) {
|
||||||
|
|
||||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.warning(ctx, getResources().getString(R.string.versionUnsupportedNew));
|
Toasty.warning(ctx, getResources().getString(R.string.versionUnsupportedNew));
|
||||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(responseVersion.code() == 403) {
|
else if(responseVersion.code() == 403) {
|
||||||
|
|
||||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void login(LoginType loginType, String instanceUrl, String loginUid, String loginPass, int loginOTP, String loginToken) {
|
private void login(LoginType loginType, String loginUid, String loginPass, int loginOTP, String loginToken) {
|
||||||
|
|
||||||
// ToDo: before store/create token: get UserInfo to check DB/AccountManager if there already exist a token
|
// ToDo: before store/create token: get UserInfo to check DB/AccountManager if there already exist a token
|
||||||
// the setup methods then can better handle all different cases
|
// the setup methods then can better handle all different cases
|
||||||
|
|
||||||
if(loginType == LoginType.BASIC) {
|
if(loginType == LoginType.BASIC) {
|
||||||
setup(instanceUrl, loginUid, loginPass, loginOTP);
|
|
||||||
|
setup(loginUid, loginPass, loginOTP);
|
||||||
}
|
}
|
||||||
else if(loginType == LoginType.TOKEN) { // Token
|
else if(loginType == LoginType.TOKEN) { // Token
|
||||||
setupUsingExistingToken(instanceUrl, loginToken);
|
|
||||||
|
setupUsingExistingToken(loginToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,9 +338,9 @@ public class LoginActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupUsingExistingToken(String instanceUrl, final String loginToken) {
|
private void setupUsingExistingToken(final String loginToken) {
|
||||||
|
|
||||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserInfo("token " + loginToken);
|
Call<UserInfo> call = RetrofitClient.getApiInterface(appCtx).getUserInfo("token " + loginToken);
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
|
|
||||||
@ -350,6 +352,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
switch(response.code()) {
|
switch(response.code()) {
|
||||||
|
|
||||||
case 200:
|
case 200:
|
||||||
|
|
||||||
assert userDetails != null;
|
assert userDetails != null;
|
||||||
tinyDB.putBoolean("loggedInMode", true);
|
tinyDB.putBoolean("loggedInMode", true);
|
||||||
tinyDB.putString(userDetails.getLogin() + "-token", loginToken);
|
tinyDB.putString(userDetails.getLogin() + "-token", loginToken);
|
||||||
@ -357,14 +360,14 @@ public class LoginActivity extends BaseActivity {
|
|||||||
tinyDB.putString("userLogin", userDetails.getUsername());
|
tinyDB.putString("userLogin", userDetails.getUsername());
|
||||||
|
|
||||||
// insert new account to db if does not exist
|
// insert new account to db if does not exist
|
||||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
String accountName = userDetails.getUsername() + "@" + TinyDB.getInstance(ctx).getString("instanceUrl");
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||||
int checkAccount = userAccountsApi.getCount(accountName);
|
int checkAccount = userAccountsApi.getCount(accountName);
|
||||||
long accountId;
|
long accountId;
|
||||||
|
|
||||||
if(checkAccount == 0) {
|
if(checkAccount == 0) {
|
||||||
|
|
||||||
accountId = userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
accountId = userAccountsApi.insertNewAccount(accountName, TinyDB.getInstance(ctx).getString("instanceUrl"), userDetails.getUsername(), loginToken, "");
|
||||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -378,18 +381,16 @@ public class LoginActivity extends BaseActivity {
|
|||||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 401:
|
case 401:
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
|
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -398,13 +399,12 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP) {
|
private void setup(final String loginUid, final String loginPass, final int loginOTP) {
|
||||||
|
|
||||||
final String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
final String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||||
final String tokenName = "gitnex-app-" + device_id;
|
final String tokenName = "gitnex-app-" + device_id;
|
||||||
@ -412,11 +412,11 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Call<List<UserTokens>> call;
|
Call<List<UserTokens>> call;
|
||||||
if(loginOTP != 0) {
|
if(loginOTP != 0) {
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserTokensWithOTP(credential, loginOTP, loginUid);
|
call = RetrofitClient.getApiInterface(appCtx).getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserTokens(credential, loginUid);
|
call = RetrofitClient.getApiInterface(appCtx).getUserTokens(credential, loginUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
call.enqueue(new Callback<List<UserTokens>>() {
|
call.enqueue(new Callback<List<UserTokens>>() {
|
||||||
@ -429,7 +429,9 @@ public class LoginActivity extends BaseActivity {
|
|||||||
if(response.code() == 200) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
assert userTokens != null;
|
assert userTokens != null;
|
||||||
|
|
||||||
for(UserTokens t : userTokens) {
|
for(UserTokens t : userTokens) {
|
||||||
|
|
||||||
if(t.getName().equals(tokenName)) {
|
if(t.getName().equals(tokenName)) {
|
||||||
|
|
||||||
// this app had created an token on this instance before
|
// this app had created an token on this instance before
|
||||||
@ -438,13 +440,14 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Call<Void> delcall;
|
Call<Void> delcall;
|
||||||
if(loginOTP != 0) {
|
if(loginOTP != 0) {
|
||||||
|
|
||||||
delcall = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
delcall = RetrofitClient.getApiInterface(ctx)
|
||||||
.deleteTokenWithOTP(credential, loginOTP, loginUid, t.getId());
|
.deleteTokenWithOTP(credential, loginOTP, loginUid, t.getId());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
delcall = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().deleteToken(credential, loginUid, t.getId());
|
delcall = RetrofitClient.getApiInterface(ctx).deleteToken(credential, loginUid, t.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
delcall.enqueue(new Callback<Void>() {
|
delcall.enqueue(new Callback<Void>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -452,13 +455,12 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(response.code() == 204) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
setupToken(instanceUrl, loginUid, loginPass, loginOTP, tokenName);
|
setupToken(loginUid, loginPass, loginOTP, tokenName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,20 +470,18 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Log.e("onFailure-login", t.toString());
|
Log.e("onFailure-login", t.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
|
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setupToken(instanceUrl, loginUid, loginPass, loginOTP, tokenName);
|
setupToken(loginUid, loginPass, loginOTP, tokenName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,13 +491,12 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Log.e("onFailure-login", t.toString());
|
Log.e("onFailure-login", t.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
|
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupToken(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP, final String tokenName) {
|
private void setupToken(final String loginUid, final String loginPass, final int loginOTP, final String tokenName) {
|
||||||
|
|
||||||
final String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
final String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
@ -506,12 +505,13 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(loginOTP != 0) {
|
if(loginOTP != 0) {
|
||||||
|
|
||||||
callCreateToken = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
callCreateToken = RetrofitClient.getApiInterface(ctx)
|
||||||
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
callCreateToken = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().createNewToken(credential, loginUid, createUserToken);
|
callCreateToken = RetrofitClient.getApiInterface(ctx)
|
||||||
|
.createNewToken(credential, loginUid, createUserToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
callCreateToken.enqueue(new Callback<UserTokens>() {
|
callCreateToken.enqueue(new Callback<UserTokens>() {
|
||||||
@ -526,7 +526,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(!newToken.getSha1().equals("")) {
|
if(!newToken.getSha1().equals("")) {
|
||||||
|
|
||||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface()
|
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx)
|
||||||
.getUserInfo("token " + newToken.getSha1());
|
.getUserInfo("token " + newToken.getSha1());
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
@ -539,6 +539,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
switch(response.code()) {
|
switch(response.code()) {
|
||||||
|
|
||||||
case 200:
|
case 200:
|
||||||
|
|
||||||
assert userDetails != null;
|
assert userDetails != null;
|
||||||
tinyDB.remove("loginPass");
|
tinyDB.remove("loginPass");
|
||||||
tinyDB.putBoolean("loggedInMode", true);
|
tinyDB.putBoolean("loggedInMode", true);
|
||||||
@ -547,7 +548,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
tinyDB.putString(loginUid + "-token-last-eight", newToken.getToken_last_eight());
|
tinyDB.putString(loginUid + "-token-last-eight", newToken.getToken_last_eight());
|
||||||
|
|
||||||
// insert new account to db if does not exist
|
// insert new account to db if does not exist
|
||||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
String accountName = userDetails.getUsername() + "@" + TinyDB.getInstance(ctx).getString("instanceUrl");
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||||
int checkAccount = userAccountsApi.getCount(accountName);
|
int checkAccount = userAccountsApi.getCount(accountName);
|
||||||
long accountId;
|
long accountId;
|
||||||
@ -555,7 +556,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
if(checkAccount == 0) {
|
if(checkAccount == 0) {
|
||||||
|
|
||||||
accountId = userAccountsApi
|
accountId = userAccountsApi
|
||||||
.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), newToken.getSha1(), "");
|
.insertNewAccount(accountName, TinyDB.getInstance(ctx).getString("instanceUrl"), userDetails.getUsername(), newToken.getSha1(), "");
|
||||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -568,18 +569,16 @@ public class LoginActivity extends BaseActivity {
|
|||||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 401:
|
case 401:
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
|
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -588,7 +587,6 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -597,7 +595,6 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + responseCreate.code());
|
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + responseCreate.code());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,17 +610,21 @@ public class LoginActivity extends BaseActivity {
|
|||||||
private void loadDefaults() {
|
private void loadDefaults() {
|
||||||
|
|
||||||
if(tinyDB.getString("loginType").equals(LoginType.BASIC.name().toLowerCase())) {
|
if(tinyDB.getString("loginType").equals(LoginType.BASIC.name().toLowerCase())) {
|
||||||
|
|
||||||
loginMethod.check(R.id.loginUsernamePassword);
|
loginMethod.check(R.id.loginUsernamePassword);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
loginMethod.check(R.id.loginToken);
|
loginMethod.check(R.id.loginToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tinyDB.getString("instanceUrlRaw").equals("")) {
|
if(!tinyDB.getString("instanceUrlRaw").equals("")) {
|
||||||
|
|
||||||
instanceUrlET.setText(tinyDB.getString("instanceUrlRaw"));
|
instanceUrlET.setText(tinyDB.getString("instanceUrlRaw"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tinyDB.getString("loginUid").equals("")) {
|
if(!tinyDB.getString("loginUid").equals("")) {
|
||||||
|
|
||||||
loginUidET.setText(tinyDB.getString("loginUid"));
|
loginUidET.setText(tinyDB.getString("loginUid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,9 +635,11 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!tinyDB.getString("uniqueAppId").isEmpty()) {
|
if(!tinyDB.getString("uniqueAppId").isEmpty()) {
|
||||||
|
|
||||||
device_id = tinyDB.getString("uniqueAppId");
|
device_id = tinyDB.getString("uniqueAppId");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
device_id = UUID.randomUUID().toString();
|
device_id = UUID.randomUUID().toString();
|
||||||
tinyDB.putString("uniqueAppId", device_id);
|
tinyDB.putString("uniqueAppId", device_id);
|
||||||
}
|
}
|
||||||
|
@ -77,11 +77,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
private ImageView userAvatarBackground;
|
private ImageView userAvatarBackground;
|
||||||
private ViewGroup navHeaderFrame;
|
private ViewGroup navHeaderFrame;
|
||||||
private TextView toolbarTitle;
|
private TextView toolbarTitle;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private Typeface myTypeface;
|
private Typeface myTypeface;
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
|
|
||||||
@ -99,63 +96,69 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
tinyDB.putBoolean("noConnection", false);
|
||||||
tinyDb.putBoolean("noConnection", false);
|
|
||||||
|
String currentVersion = tinyDB.getString("giteaVersion");
|
||||||
|
|
||||||
Intent mainIntent = getIntent();
|
Intent mainIntent = getIntent();
|
||||||
String launchFragment = mainIntent.getStringExtra("launchFragment");
|
String launchFragment = mainIntent.getStringExtra("launchFragment");
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
if(tinyDb.getString("dateFormat").isEmpty()) {
|
if(tinyDB.getString("dateFormat").isEmpty()) {
|
||||||
tinyDb.putString("dateFormat", "pretty");
|
|
||||||
|
tinyDB.putString("dateFormat", "pretty");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getString("codeBlockStr").isEmpty()) {
|
if(tinyDB.getString("codeBlockStr").isEmpty()) {
|
||||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
|
|
||||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
tinyDB.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
|
||||||
|
tinyDB.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getString("enableCounterIssueBadgeInit").isEmpty()) {
|
if(tinyDB.getString("enableCounterIssueBadgeInit").isEmpty()) {
|
||||||
tinyDb.putBoolean("enableCounterIssueBadge", true);
|
|
||||||
|
tinyDB.putBoolean("enableCounterIssueBadge", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getString("homeScreenStr").isEmpty()) {
|
if(tinyDB.getString("homeScreenStr").isEmpty()) {
|
||||||
tinyDb.putInt("homeScreenId", 0);
|
|
||||||
|
tinyDB.putString("homeScreenStr", "yes");
|
||||||
|
tinyDB.putInt("homeScreenId", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
if(!tinyDb.getBoolean("loggedInMode")) {
|
if(!tinyDB.getBoolean("loggedInMode")) {
|
||||||
|
|
||||||
logout(this, ctx);
|
logout(this, ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getInt("currentActiveAccountId") <= 0) {
|
if(tinyDB.getInt("currentActiveAccountId") <= 0) {
|
||||||
|
|
||||||
AlertDialogs.forceLogoutDialog(ctx, getResources().getString(R.string.forceLogoutDialogHeader), getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
AlertDialogs.forceLogoutDialog(ctx, getResources().getString(R.string.forceLogoutDialogHeader), getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDB.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/roboto.ttf");
|
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/roboto.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodeproregular.ttf");
|
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/manroperegular.ttf");
|
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/manroperegular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbarTitle.setTypeface(myTypeface);
|
toolbarTitle.setTypeface(myTypeface);
|
||||||
@ -165,37 +168,47 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
Fragment fragmentById = fm.findFragmentById(R.id.fragment_container);
|
Fragment fragmentById = fm.findFragmentById(R.id.fragment_container);
|
||||||
|
|
||||||
if(fragmentById instanceof SettingsFragment) {
|
if(fragmentById instanceof SettingsFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof MyRepositoriesFragment) {
|
else if(fragmentById instanceof MyRepositoriesFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof StarredRepositoriesFragment) {
|
else if(fragmentById instanceof StarredRepositoriesFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof OrganizationsFragment) {
|
else if(fragmentById instanceof OrganizationsFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof ExploreFragment) {
|
else if(fragmentById instanceof ExploreFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof NotificationsFragment) {
|
else if(fragmentById instanceof NotificationsFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(R.string.pageTitleNotifications);
|
toolbarTitle.setText(R.string.pageTitleNotifications);
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof ProfileFragment) {
|
else if(fragmentById instanceof ProfileFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof DraftsFragment) {
|
else if(fragmentById instanceof DraftsFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof AdministrationFragment) {
|
else if(fragmentById instanceof AdministrationFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof UserAccountsFragment) {
|
else if(fragmentById instanceof UserAccountsFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
||||||
}
|
}
|
||||||
|
|
||||||
getNotificationsCount(instanceUrl, instanceToken);
|
getNotificationsCount(instanceToken);
|
||||||
|
|
||||||
drawer = findViewById(R.id.drawer_layout);
|
drawer = findViewById(R.id.drawer_layout);
|
||||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||||
@ -213,20 +226,15 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
@Override
|
@Override
|
||||||
public void onDrawerOpened(@NonNull View drawerView) {
|
public void onDrawerOpened(@NonNull View drawerView) {
|
||||||
|
|
||||||
getNotificationsCount(instanceUrl, instanceToken);
|
if(tinyDB.getBoolean("noConnection")) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
|
||||||
|
|
||||||
if(tinyDb.getBoolean("noConnection")) {
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
tinyDb.putBoolean("noConnection", false);
|
tinyDB.putBoolean("noConnection", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
String userEmailNav = tinyDb.getString("userEmail");
|
String userEmailNav = tinyDB.getString("userEmail");
|
||||||
String userFullNameNav = tinyDb.getString("userFullname");
|
String userFullNameNav = tinyDB.getString("userFullname");
|
||||||
String userAvatarNav = tinyDb.getString("userAvatar");
|
String userAvatarNav = tinyDB.getString("userAvatar");
|
||||||
|
|
||||||
blurView = hView.findViewById(R.id.blurView);
|
blurView = hView.findViewById(R.id.blurView);
|
||||||
userEmail = hView.findViewById(R.id.userEmail);
|
userEmail = hView.findViewById(R.id.userEmail);
|
||||||
@ -252,17 +260,18 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
userAccountsList.addAll(userAccounts);
|
userAccountsList.addAll(userAccounts);
|
||||||
navRecyclerViewUserAccounts.setAdapter(adapterUserAccounts);
|
navRecyclerViewUserAccounts.setAdapter(adapterUserAccounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
userEmail.setTypeface(myTypeface);
|
userEmail.setTypeface(myTypeface);
|
||||||
userFullName.setTypeface(myTypeface);
|
userFullName.setTypeface(myTypeface);
|
||||||
|
|
||||||
if(!userEmailNav.equals("")) {
|
if(!userEmailNav.equals("")) {
|
||||||
|
|
||||||
userEmail.setText(userEmailNav);
|
userEmail.setText(userEmailNav);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!userFullNameNav.equals("")) {
|
if(!userFullNameNav.equals("")) {
|
||||||
|
|
||||||
userFullName.setText(userFullNameNav);
|
userFullName.setText(userFullNameNav);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,14 +300,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
.setBlurAlgorithm(new RenderScriptBlur(ctx))
|
.setBlurAlgorithm(new RenderScriptBlur(ctx))
|
||||||
.setBlurRadius(5)
|
.setBlurRadius(5)
|
||||||
.setHasFixedTransformationMatrix(false);
|
.setHasFixedTransformationMatrix(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception e) {}
|
public void onError(Exception e) {}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
userAvatar.setOnClickListener(v -> {
|
userAvatar.setOnClickListener(v -> {
|
||||||
@ -309,9 +315,13 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
drawer.closeDrawers();
|
drawer.closeDrawers();
|
||||||
});
|
});
|
||||||
|
|
||||||
String currentVersion = tinyDb.getString("giteaVersion");
|
getNotificationsCount(instanceToken);
|
||||||
|
}
|
||||||
|
|
||||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(tinyDb.getBoolean("userIsAdmin"));
|
@Override
|
||||||
|
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
||||||
|
|
||||||
|
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"));
|
navigationView.getMenu().findItem(R.id.nav_notifications).setVisible(new Version(currentVersion).higherOrEqual("1.12.3"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,98 +343,128 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
switch(launchFragment) {
|
switch(launchFragment) {
|
||||||
|
|
||||||
case "drafts":
|
case "drafts":
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case "notifications":
|
case "notifications":
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_notifications);
|
navigationView.setCheckedItem(R.id.nav_notifications);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String launchFragmentByHandler = mainIntent.getStringExtra("launchFragmentByLinkHandler");
|
||||||
|
|
||||||
|
if(launchFragmentByHandler != null) {
|
||||||
|
|
||||||
|
mainIntent.removeExtra("launchFragmentByLinkHandler");
|
||||||
|
|
||||||
|
switch(launchFragmentByHandler) {
|
||||||
|
|
||||||
|
case "repos":
|
||||||
|
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
|
||||||
|
navigationView.setCheckedItem(R.id.nav_repositories);
|
||||||
|
return;
|
||||||
|
case "org":
|
||||||
|
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
|
||||||
|
navigationView.setCheckedItem(R.id.nav_organizations);
|
||||||
|
return;
|
||||||
|
case "notification":
|
||||||
|
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
||||||
|
navigationView.setCheckedItem(R.id.nav_notifications);
|
||||||
|
return;
|
||||||
|
case "explore":
|
||||||
|
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
|
||||||
|
navigationView.setCheckedItem(R.id.nav_explore);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(savedInstanceState == null) {
|
if(savedInstanceState == null) {
|
||||||
|
|
||||||
if(!new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
if(!new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||||
|
|
||||||
if(tinyDb.getInt("homeScreenId") == 7) {
|
if(tinyDB.getInt("homeScreenId") == 7) {
|
||||||
|
|
||||||
tinyDb.putInt("homeScreenId", 0);
|
tinyDB.putInt("homeScreenId", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(tinyDb.getInt("homeScreenId")) {
|
switch(tinyDB.getInt("homeScreenId")) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_starred_repos);
|
navigationView.setCheckedItem(R.id.nav_starred_repos);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_organizations);
|
navigationView.setCheckedItem(R.id.nav_organizations);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleRepositories));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleRepositories));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_repositories);
|
navigationView.setCheckedItem(R.id.nav_repositories);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_profile);
|
navigationView.setCheckedItem(R.id.nav_profile);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_explore);
|
navigationView.setCheckedItem(R.id.nav_explore);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_notifications);
|
navigationView.setCheckedItem(R.id.nav_notifications);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_home);
|
navigationView.setCheckedItem(R.id.nav_home);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!connToInternet) {
|
if(!connToInternet) {
|
||||||
|
|
||||||
if(!tinyDb.getBoolean("noConnection")) {
|
if(!tinyDB.getBoolean("noConnection")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putBoolean("noConnection", true);
|
tinyDB.putBoolean("noConnection", true);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
loadUserInfo(instanceUrl, instanceToken, loginUid);
|
loadUserInfo(instanceToken, loginUid);
|
||||||
giteaVersion(instanceUrl);
|
giteaVersion();
|
||||||
tinyDb.putBoolean("noConnection", false);
|
tinyDB.putBoolean("noConnection", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changelog popup
|
// Changelog popup
|
||||||
@ -440,10 +480,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
Log.e("changelogDialog", Objects.requireNonNull(e.getMessage()));
|
Log.e("changelogDialog", Objects.requireNonNull(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(versionCode > tinyDb.getInt("versionCode")) {
|
if(versionCode > tinyDB.getInt("versionCode")) {
|
||||||
|
|
||||||
tinyDb.putInt("versionCode", versionCode);
|
tinyDB.putInt("versionCode", versionCode);
|
||||||
tinyDb.putBoolean("versionFlag", true);
|
tinyDB.putBoolean("versionFlag", true);
|
||||||
|
|
||||||
ChangeLog changelogDialog = new ChangeLog(this);
|
ChangeLog changelogDialog = new ChangeLog(this);
|
||||||
changelogDialog.showDialog();
|
changelogDialog.showDialog();
|
||||||
@ -458,7 +498,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
@Override
|
@Override
|
||||||
public void onButtonClicked(String text) {
|
public void onButtonClicked(String text) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(ctx);
|
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
|
|
||||||
if("deleteDrafts".equals(text)) {
|
if("deleteDrafts".equals(text)) {
|
||||||
@ -482,14 +522,15 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
|
|
||||||
})
|
})
|
||||||
.setNeutralButton(R.string.cancelButton, null).show();
|
.setNeutralButton(R.string.cancelButton, null).show();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,74 +542,74 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
|
|
||||||
if(drawer.isDrawerOpen(GravityCompat.START)) {
|
if(drawer.isDrawerOpen(GravityCompat.START)) {
|
||||||
|
|
||||||
drawer.closeDrawer(GravityCompat.START);
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
|
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
|
||||||
|
|
||||||
switch(menuItem.getItemId()) {
|
int id = menuItem.getItemId();
|
||||||
|
|
||||||
case R.id.nav_home:
|
if(id == 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.pageTitleMyRepos));
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
|
}
|
||||||
break;
|
else if(id == R.id.nav_organizations) {
|
||||||
|
|
||||||
case R.id.nav_profile:
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OrganizationsFragment()).commit();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
}
|
||||||
break;
|
else if(id == R.id.nav_profile) {
|
||||||
|
|
||||||
case R.id.nav_repositories:
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleRepositories));
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
|
}
|
||||||
break;
|
else if(id == R.id.nav_repositories) {
|
||||||
|
|
||||||
case R.id.nav_settings:
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleRepositories));
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new RepositoriesFragment()).commit();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).commit();
|
}
|
||||||
break;
|
else if(id == R.id.nav_settings) {
|
||||||
|
|
||||||
case R.id.nav_logout:
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
|
||||||
logout(this, ctx);
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).commit();
|
||||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
}
|
||||||
break;
|
else if(id == R.id.nav_logout) {
|
||||||
|
|
||||||
case R.id.nav_starred_repos:
|
logout(this, ctx);
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
|
}
|
||||||
break;
|
else if(id == R.id.nav_starred_repos) {
|
||||||
|
|
||||||
case R.id.nav_explore:
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
|
}
|
||||||
break;
|
else if(id == R.id.nav_explore) {
|
||||||
|
|
||||||
case R.id.nav_notifications:
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
||||||
toolbarTitle.setText(R.string.pageTitleNotifications);
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
}
|
||||||
break;
|
else if(id == R.id.nav_notifications) {
|
||||||
|
|
||||||
case R.id.nav_comments_draft:
|
toolbarTitle.setText(R.string.pageTitleNotifications);
|
||||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
}
|
||||||
break;
|
else if(id == R.id.nav_comments_draft) {
|
||||||
|
|
||||||
case R.id.nav_administration:
|
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AdministrationFragment()).commit();
|
}
|
||||||
break;
|
else if(id == R.id.nav_administration) {
|
||||||
|
|
||||||
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AdministrationFragment()).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
drawer.closeDrawer(GravityCompat.START);
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
@ -577,14 +618,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
|
|
||||||
public static void logout(Activity activity, Context ctx) {
|
public static void logout(Activity activity, Context ctx) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(ctx.getApplicationContext());
|
TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||||
tinyDb.putBoolean("loggedInMode", false);
|
|
||||||
tinyDb.remove("basicAuthPassword");
|
tinyDB.putBoolean("loggedInMode", false);
|
||||||
tinyDb.putBoolean("basicAuthFlag", false);
|
tinyDB.remove("basicAuthPassword");
|
||||||
|
tinyDB.putBoolean("basicAuthFlag", false);
|
||||||
//tinyDb.clear();
|
//tinyDb.clear();
|
||||||
activity.finish();
|
activity.finish();
|
||||||
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -593,22 +634,22 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
if(id == R.id.genericMenu) {
|
if(id == R.id.genericMenu) {
|
||||||
|
|
||||||
BottomSheetDraftsFragment bottomSheet = new BottomSheetDraftsFragment();
|
BottomSheetDraftsFragment bottomSheet = new BottomSheetDraftsFragment();
|
||||||
bottomSheet.show(getSupportFragmentManager(), "draftsBottomSheet");
|
bottomSheet.show(getSupportFragmentManager(), "draftsBottomSheet");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void giteaVersion(final String instanceUrl) {
|
private void giteaVersion() {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
Call<GiteaVersion> callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken(token);
|
Call<GiteaVersion> callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken(token);
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
|
|
||||||
@ -621,7 +662,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
assert version != null;
|
assert version != null;
|
||||||
|
|
||||||
tinyDb.putString("giteaVersion", version.getVersion());
|
tinyDb.putString("giteaVersion", version.getVersion());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,16 +670,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
|
|
||||||
Log.e("onFailure-version", t.toString());
|
Log.e("onFailure-version", t.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadUserInfo(String instanceUrl, String token, String loginUid) {
|
private void loadUserInfo(String token, String loginUid) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserInfo(Authorization.returnAuthentication(ctx, loginUid, token));
|
Call<UserInfo> call = RetrofitClient.getApiInterface(ctx).getUserInfo(Authorization.get(ctx));
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
|
|
||||||
@ -655,6 +693,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
assert userDetails != null;
|
assert userDetails != null;
|
||||||
|
|
||||||
if(userDetails.getIs_admin() != null) {
|
if(userDetails.getIs_admin() != null) {
|
||||||
|
|
||||||
tinyDb.putBoolean("userIsAdmin", userDetails.getIs_admin());
|
tinyDb.putBoolean("userIsAdmin", userDetails.getIs_admin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,9 +701,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
tinyDb.putInt("userId", userDetails.getId());
|
tinyDb.putInt("userId", userDetails.getId());
|
||||||
|
|
||||||
if(!userDetails.getFullname().equals("")) {
|
if(!userDetails.getFullname().equals("")) {
|
||||||
|
|
||||||
tinyDb.putString("userFullname", userDetails.getFullname());
|
tinyDb.putString("userFullname", userDetails.getFullname());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
tinyDb.putString("userFullname", userDetails.getLogin());
|
tinyDb.putString("userFullname", userDetails.getLogin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,9 +713,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
tinyDb.putString("userAvatar", userDetails.getAvatar());
|
tinyDb.putString("userAvatar", userDetails.getAvatar());
|
||||||
|
|
||||||
if(userDetails.getLang() != null) {
|
if(userDetails.getLang() != null) {
|
||||||
|
|
||||||
tinyDb.putString("userLang", userDetails.getLang());
|
tinyDb.putString("userLang", userDetails.getLang());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
tinyDb.putString("userLang", "");
|
tinyDb.putString("userLang", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -682,15 +725,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
else if(response.code() == 401) {
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
||||||
Toasty.error(ctx, toastError);
|
Toasty.error(ctx, toastError);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -702,9 +742,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getNotificationsCount(String instanceUrl, String token) {
|
private void getNotificationsCount(String token) {
|
||||||
|
|
||||||
Call<NotificationCount> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkUnreadNotifications(token);
|
Call<NotificationCount> call = RetrofitClient.getApiInterface(ctx).checkUnreadNotifications(token);
|
||||||
|
|
||||||
call.enqueue(new Callback<NotificationCount>() {
|
call.enqueue(new Callback<NotificationCount>() {
|
||||||
|
|
||||||
|
@ -6,30 +6,24 @@ import android.os.Bundle;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.hendraanggrian.appcompat.socialview.Mention;
|
|
||||||
import com.hendraanggrian.appcompat.widget.MentionArrayAdapter;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.databinding.ActivityMergePullRequestBinding;
|
import org.mian.gitnex.databinding.ActivityMergePullRequestBinding;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.Collaborators;
|
|
||||||
import org.mian.gitnex.models.MergePullRequest;
|
import org.mian.gitnex.models.MergePullRequest;
|
||||||
import org.mian.gitnex.models.MergePullRequestSpinner;
|
import org.mian.gitnex.models.MergePullRequestSpinner;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.Objects;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -38,11 +32,13 @@ import retrofit2.Response;
|
|||||||
public class MergePullRequestActivity extends BaseActivity {
|
public class MergePullRequestActivity extends BaseActivity {
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
private String repoOwner;
|
||||||
|
private String repoName;
|
||||||
|
private int prIndex;
|
||||||
|
|
||||||
private ActivityMergePullRequestBinding viewBinding;
|
private ActivityMergePullRequestBinding viewBinding;
|
||||||
|
|
||||||
private ArrayAdapter<Mention> defaultMentionAdapter;
|
|
||||||
private String Do;
|
private String Do;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,14 +52,18 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
viewBinding = ActivityMergePullRequestBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityMergePullRequestBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
|
|
||||||
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
|
String[] parts = repoFullName.split("/");
|
||||||
|
repoOwner = parts[0];
|
||||||
|
repoName = parts[1];
|
||||||
|
prIndex = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
@ -73,53 +73,37 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
setMergeAdapter();
|
setMergeAdapter();
|
||||||
|
|
||||||
viewBinding.mergeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
if(!tinyDB.getString("issueTitle").isEmpty()) {
|
||||||
|
|
||||||
@Override
|
viewBinding.toolbarTitle.setText(tinyDB.getString("issueTitle"));
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
viewBinding.mergeTitle.setText(tinyDB.getString("issueTitle") + " (#" + tinyDB.getString("issueNumber") + ")");
|
||||||
|
|
||||||
MergePullRequestSpinner mergeId = (MergePullRequestSpinner) parent.getSelectedItem();
|
|
||||||
Do = mergeId.getId();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
defaultMentionAdapter = new MentionArrayAdapter<>(this);
|
|
||||||
loadCollaboratorsList();
|
|
||||||
|
|
||||||
viewBinding.mergeDescription.setMentionAdapter(defaultMentionAdapter);
|
|
||||||
|
|
||||||
if(!tinyDb.getString("issueTitle").isEmpty()) {
|
|
||||||
viewBinding.toolbarTitle.setText(tinyDb.getString("issueTitle"));
|
|
||||||
viewBinding.mergeTitle.setText(tinyDb.getString("issueTitle") + " (#" + tinyDb.getString("issueNumber") + ")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
viewBinding.close.setOnClickListener(onClickListener);
|
viewBinding.close.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
// if gitea version is greater/equal(1.12.0) than user installed version (installed.higherOrEqual(compareVer))
|
// if gitea version is greater/equal(1.12.0) than user installed version (installed.higherOrEqual(compareVer))
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||||
|
|
||||||
viewBinding.deleteBranch.setVisibility(View.VISIBLE);
|
viewBinding.deleteBranch.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getString("prMergeable").equals("false")) {
|
if(tinyDB.getString("prMergeable").equals("false")) {
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
viewBinding.mergeInfoDisabledMessage.setVisibility(View.VISIBLE);
|
viewBinding.mergeInfoDisabledMessage.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
viewBinding.mergeInfoDisabledMessage.setVisibility(View.GONE);
|
viewBinding.mergeInfoDisabledMessage.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getString("prIsFork").equals("true")) {
|
if(tinyDB.getString("prIsFork").equals("true")) {
|
||||||
|
|
||||||
viewBinding.deleteBranchForkInfo.setVisibility(View.VISIBLE);
|
viewBinding.deleteBranchForkInfo.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
viewBinding.deleteBranchForkInfo.setVisibility(View.GONE);
|
viewBinding.deleteBranchForkInfo.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,70 +120,25 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void setMergeAdapter() {
|
private void setMergeAdapter() {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ArrayList<MergePullRequestSpinner> mergeList = new ArrayList<>();
|
ArrayList<MergePullRequestSpinner> mergeList = new ArrayList<>();
|
||||||
|
|
||||||
mergeList.add(new MergePullRequestSpinner("merge", getResources().getString(R.string.mergeOptionMerge)));
|
mergeList.add(new MergePullRequestSpinner("merge", getResources().getString(R.string.mergeOptionMerge)));
|
||||||
mergeList.add(new MergePullRequestSpinner("rebase", getResources().getString(R.string.mergeOptionRebase)));
|
mergeList.add(new MergePullRequestSpinner("rebase", getResources().getString(R.string.mergeOptionRebase)));
|
||||||
mergeList.add(new MergePullRequestSpinner("rebase-merge", getResources().getString(R.string.mergeOptionRebaseCommit)));
|
mergeList.add(new MergePullRequestSpinner("rebase-merge", getResources().getString(R.string.mergeOptionRebaseCommit)));
|
||||||
// squash merge works only on gitea > v1.11.4 due to a bug
|
// squash merge works only on gitea > v1.11.4 due to a bug
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higher("1.11.4")) {
|
if(new Version(tinyDB.getString("giteaVersion")).higher("1.11.4")) {
|
||||||
|
|
||||||
mergeList.add(new MergePullRequestSpinner("squash", getResources().getString(R.string.mergeOptionSquash)));
|
mergeList.add(new MergePullRequestSpinner("squash", getResources().getString(R.string.mergeOptionSquash)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayAdapter<MergePullRequestSpinner> adapter = new ArrayAdapter<>(MergePullRequestActivity.this, R.layout.spinner_item, mergeList);
|
ArrayAdapter<MergePullRequestSpinner> adapter = new ArrayAdapter<>(MergePullRequestActivity.this, R.layout.list_spinner_items, mergeList);
|
||||||
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
|
||||||
viewBinding.mergeSpinner.setAdapter(adapter);
|
viewBinding.mergeSpinner.setAdapter(adapter);
|
||||||
|
|
||||||
}
|
viewBinding.mergeSpinner.setOnItemClickListener ((parent, view, position, id) -> {
|
||||||
|
|
||||||
public void loadCollaboratorsList() {
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Collaborators>>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull Response<List<Collaborators>> response) {
|
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
|
||||||
|
|
||||||
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 {
|
|
||||||
|
|
||||||
Log.i("onResponse", String.valueOf(response.code()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
|
||||||
|
|
||||||
Log.i("onFailure", t.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Do = mergeList.get(position).getId();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
@ -207,12 +146,12 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
onClickListener = view -> finish();
|
onClickListener = view -> finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener mergePullRequest = v -> processMergePullRequest();
|
private final View.OnClickListener mergePullRequest = v -> processMergePullRequest();
|
||||||
|
|
||||||
private void processMergePullRequest() {
|
private void processMergePullRequest() {
|
||||||
|
|
||||||
String mergePRDesc = viewBinding.mergeDescription.getText().toString();
|
String mergePRDesc = Objects.requireNonNull(viewBinding.mergeDescription.getText()).toString();
|
||||||
String mergePRTitle = viewBinding.mergeTitle.getText().toString();
|
String mergePRTitle = Objects.requireNonNull(viewBinding.mergeTitle.getText()).toString();
|
||||||
boolean deleteBranch = viewBinding.deleteBranch.isChecked();
|
boolean deleteBranch = viewBinding.deleteBranch.isChecked();
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
@ -221,30 +160,24 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
disableProcessButton();
|
if(Do == null) {
|
||||||
mergeFunction(Do, mergePRDesc, mergePRTitle, deleteBranch);
|
|
||||||
|
|
||||||
|
Toasty.error(ctx, getResources().getString(R.string.selectMergeStrategy));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
disableProcessButton();
|
||||||
|
mergeFunction(Do, mergePRDesc, mergePRTitle, deleteBranch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeFunction(String Do, String mergePRDT, String mergeTitle, boolean deleteBranch) {
|
private void mergeFunction(String Do, String mergePRDT, String mergeTitle, boolean deleteBranch) {
|
||||||
|
|
||||||
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 prIndex = Integer.parseInt(tinyDb.getString("issueNumber"));
|
|
||||||
|
|
||||||
MergePullRequest mergePR = new MergePullRequest(Do, mergePRDT, mergeTitle);
|
MergePullRequest mergePR = new MergePullRequest(Do, mergePRDT, mergeTitle);
|
||||||
|
|
||||||
Call<ResponseBody> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().mergePullRequest(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, prIndex, mergePR);
|
Call<ResponseBody> call = RetrofitClient.getApiInterface(ctx).mergePullRequest(Authorization.get(ctx), repoOwner, repoName, prIndex, mergePR);
|
||||||
|
|
||||||
call.enqueue(new Callback<ResponseBody>() {
|
call.enqueue(new Callback<ResponseBody>() {
|
||||||
|
|
||||||
@ -255,9 +188,9 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
if(deleteBranch) {
|
if(deleteBranch) {
|
||||||
|
|
||||||
if(tinyDb.getString("prIsFork").equals("true")) {
|
if(tinyDB.getString("prIsFork").equals("true")) {
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("prForkFullName");
|
String repoFullName = tinyDB.getString("prForkFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
@ -265,14 +198,13 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
deleteBranchFunction(repoOwner, repoName);
|
deleteBranchFunction(repoOwner, repoName);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||||
tinyDb.putBoolean("prMerged", true);
|
tinyDB.putBoolean("prMerged", true);
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
tinyDB.putBoolean("resumePullRequests", true);
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
@ -280,20 +212,18 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
deleteBranchFunction(repoOwner, repoName);
|
deleteBranchFunction(repoOwner, repoName);
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||||
tinyDb.putBoolean("prMerged", true);
|
tinyDB.putBoolean("prMerged", true);
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
tinyDB.putBoolean("resumePullRequests", true);
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||||
tinyDb.putBoolean("prMerged", true);
|
tinyDB.putBoolean("prMerged", true);
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
tinyDB.putBoolean("resumePullRequests", true);
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -301,19 +231,21 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 404) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, getString(R.string.mergePR404ErrorMsg));
|
Toasty.warning(ctx, getString(R.string.mergePR404ErrorMsg));
|
||||||
|
}
|
||||||
|
else if(response.code() == 405) {
|
||||||
|
|
||||||
|
enableProcessButton();
|
||||||
|
Toasty.warning(ctx, getString(R.string.mergeNotAllowed));;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.genericError));
|
Toasty.error(ctx, getString(R.string.genericError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -331,17 +263,11 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void deleteBranchFunction(String repoOwner, String repoName) {
|
private void deleteBranchFunction(String repoOwner, String repoName) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
String branchName = tinyDB.getString("prHeadBranch");
|
||||||
|
|
||||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
String loginUid = tinyDb.getString("loginUid");
|
|
||||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
String branchName = tinyDb.getString("prHeadBranch");
|
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient
|
Call<JsonElement> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
.deleteBranch(Authorization.get(ctx), repoOwner, repoName, branchName);
|
||||||
.deleteBranch(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, branchName);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@ -351,9 +277,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
if(response.code() == 204) {
|
if(response.code() == 204) {
|
||||||
|
|
||||||
Log.i("deleteBranch", "Branch deleted successfully");
|
Log.i("deleteBranch", "Branch deleted successfully");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -361,7 +285,6 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -25,8 +25,9 @@ public class OpenRepoInBrowserActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
appCtx = getApplicationContext();
|
appCtx = getApplicationContext();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -46,9 +47,9 @@ public class OpenRepoInBrowserActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
catch(URISyntaxException e) {
|
catch(URISyntaxException e) {
|
||||||
|
|
||||||
Toasty.error(appCtx, getString(R.string.genericError));
|
Toasty.error(appCtx, getString(R.string.genericError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.fragments.BottomSheetOrganizationFragment;
|
import org.mian.gitnex.fragments.BottomSheetOrganizationFragment;
|
||||||
import org.mian.gitnex.fragments.MembersByOrgFragment;
|
import org.mian.gitnex.fragments.MembersByOrgFragment;
|
||||||
import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
||||||
|
import org.mian.gitnex.fragments.OrganizationLabelsFragment;
|
||||||
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
||||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import io.mikael.urlbuilder.UrlBuilder;
|
import io.mikael.urlbuilder.UrlBuilder;
|
||||||
@ -36,10 +36,6 @@ import io.mikael.urlbuilder.UrlBuilder;
|
|||||||
|
|
||||||
public class OrganizationDetailActivity extends BaseActivity implements BottomSheetOrganizationFragment.BottomSheetListener {
|
public class OrganizationDetailActivity extends BaseActivity implements BottomSheetOrganizationFragment.BottomSheetListener {
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
return R.layout.activity_org_detail;
|
return R.layout.activity_org_detail;
|
||||||
@ -49,11 +45,8 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
String orgName = tinyDB.getString("orgName");
|
||||||
String orgName = tinyDb.getString("orgName");
|
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||||
@ -71,20 +64,20 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
|
|
||||||
Typeface myTypeface;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDB.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/roboto.ttf");
|
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/roboto.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/manroperegular.ttf");
|
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/manroperegular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbarTitle.setTypeface(myTypeface);
|
toolbarTitle.setTypeface(myTypeface);
|
||||||
@ -92,12 +85,18 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
|
|
||||||
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
||||||
int tabsCount = vg.getChildCount();
|
int tabsCount = vg.getChildCount();
|
||||||
|
|
||||||
for (int j = 0; j < tabsCount; j++) {
|
for (int j = 0; j < tabsCount; j++) {
|
||||||
|
|
||||||
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
|
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
|
||||||
int tabChildCount = vgTab.getChildCount();
|
int tabChildCount = vgTab.getChildCount();
|
||||||
|
|
||||||
for (int i = 0; i < tabChildCount; i++) {
|
for (int i = 0; i < tabChildCount; i++) {
|
||||||
|
|
||||||
View tabViewChild = vgTab.getChildAt(i);
|
View tabViewChild = vgTab.getChildAt(i);
|
||||||
|
|
||||||
if (tabViewChild instanceof TextView) {
|
if (tabViewChild instanceof TextView) {
|
||||||
|
|
||||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,7 +104,6 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
|
|
||||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -122,18 +120,21 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
|
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
switch (id) {
|
if(id == android.R.id.home) {
|
||||||
case android.R.id.home:
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
case R.id.repoMenu:
|
|
||||||
BottomSheetOrganizationFragment bottomSheet = new BottomSheetOrganizationFragment();
|
|
||||||
bottomSheet.show(getSupportFragmentManager(), "orgBottomSheet");
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(id == R.id.repoMenu) {
|
||||||
|
|
||||||
|
BottomSheetOrganizationFragment bottomSheet = new BottomSheetOrganizationFragment();
|
||||||
|
bottomSheet.show(getSupportFragmentManager(), "orgBottomSheet");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -142,20 +143,27 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
switch (text) {
|
switch (text) {
|
||||||
case "repository":
|
case "repository":
|
||||||
|
|
||||||
tinyDb.putBoolean("organizationAction", true);
|
tinyDB.putBoolean("organizationAction", true);
|
||||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
||||||
break;
|
break;
|
||||||
|
case "label":
|
||||||
|
|
||||||
|
Intent intent = new Intent(ctx, CreateLabelActivity.class);
|
||||||
|
intent.putExtra("orgName", getIntent().getStringExtra("orgName"));
|
||||||
|
intent.putExtra("type", "org");
|
||||||
|
ctx.startActivity(intent);
|
||||||
|
break;
|
||||||
case "team":
|
case "team":
|
||||||
|
|
||||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class));
|
startActivity(new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class));
|
||||||
break;
|
break;
|
||||||
case "copyOrgUrl":
|
case "copyOrgUrl":
|
||||||
|
|
||||||
String url = UrlBuilder.fromString(tinyDb.getString("instanceUrl"))
|
String url = UrlBuilder.fromString(tinyDB.getString("instanceUrl"))
|
||||||
.withPath("/")
|
.withPath("/")
|
||||||
.toString();
|
.toString();
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
ClipData clip = ClipData.newPlainText("orgUrl", url + tinyDb.getString("orgName"));
|
ClipData clip = ClipData.newPlainText("orgUrl", url + tinyDB.getString("orgName"));
|
||||||
assert clipboard != null;
|
assert clipboard != null;
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||||
@ -175,25 +183,34 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||||||
|
|
||||||
String orgName;
|
String orgName;
|
||||||
if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) {
|
if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) {
|
||||||
|
|
||||||
orgName = getIntent().getStringExtra("orgName");
|
orgName = getIntent().getStringExtra("orgName");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
orgName = tinyDb.getString("orgName");
|
|
||||||
|
orgName = tinyDB.getString("orgName");
|
||||||
}
|
}
|
||||||
|
|
||||||
Fragment fragment = null;
|
Fragment fragment = null;
|
||||||
switch (position) {
|
switch (position) {
|
||||||
|
|
||||||
case 0: // info
|
case 0: // info
|
||||||
|
|
||||||
return OrganizationInfoFragment.newInstance(orgName);
|
return OrganizationInfoFragment.newInstance(orgName);
|
||||||
case 1: // repos
|
case 1: // repos
|
||||||
return RepositoriesByOrgFragment.newInstance(orgName);
|
|
||||||
case 2: // teams
|
return RepositoriesByOrgFragment.newInstance(orgName);
|
||||||
|
case 2: // labels
|
||||||
|
|
||||||
|
return OrganizationLabelsFragment.newInstance(orgName);
|
||||||
|
case 3: // teams
|
||||||
|
|
||||||
return TeamsByOrgFragment.newInstance(orgName);
|
return TeamsByOrgFragment.newInstance(orgName);
|
||||||
case 3: // members
|
case 4: // members
|
||||||
|
|
||||||
return MembersByOrgFragment.newInstance(orgName);
|
return MembersByOrgFragment.newInstance(orgName);
|
||||||
}
|
}
|
||||||
return fragment;
|
return fragment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -33,9 +32,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
private GridView mGridView;
|
private GridView mGridView;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
private String teamId;
|
private String teamId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,15 +43,10 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||||
noDataMembers = findViewById(R.id.noDataMembers);
|
noDataMembers = findViewById(R.id.noDataMembers);
|
||||||
@ -66,52 +57,55 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
if(getIntent().getStringExtra("teamTitle") != null && !Objects.requireNonNull(getIntent().getStringExtra("teamTitle")).equals("")) {
|
if(getIntent().getStringExtra("teamTitle") != null && !Objects.requireNonNull(getIntent().getStringExtra("teamTitle")).equals("")) {
|
||||||
toolbarTitle.setText(getIntent().getStringExtra("teamTitle"));
|
|
||||||
|
toolbarTitle.setText(getIntent().getStringExtra("teamTitle"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toolbarTitle.setText(R.string.orgTeamMembers);
|
|
||||||
|
toolbarTitle.setText(R.string.orgTeamMembers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getIntent().getStringExtra("teamId") != null && !Objects.requireNonNull(getIntent().getStringExtra("teamId")).equals("")){
|
if(getIntent().getStringExtra("teamId") != null && !Objects.requireNonNull(getIntent().getStringExtra("teamId")).equals("")){
|
||||||
teamId = getIntent().getStringExtra("teamId");
|
|
||||||
|
teamId = getIntent().getStringExtra("teamId");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
teamId = "0";
|
|
||||||
|
teamId = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
assert teamId != null;
|
assert teamId != null;
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), Integer.parseInt(teamId));
|
fetchDataAsync(Authorization.get(ctx), Integer.parseInt(teamId));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
if(tinyDb.getBoolean("teamActionFlag")) {
|
if(tinyDb.getBoolean("teamActionFlag")) {
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), Integer.parseInt(teamId));
|
|
||||||
|
fetchDataAsync(Authorization.get(ctx), Integer.parseInt(teamId));
|
||||||
tinyDb.putBoolean("teamActionFlag", false);
|
tinyDb.putBoolean("teamActionFlag", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchDataAsync(String instanceUrl, String instanceToken, int teamId) {
|
private void fetchDataAsync(String instanceToken, int teamId) {
|
||||||
|
|
||||||
TeamMembersByOrgViewModel teamMembersModel = new ViewModelProvider(this).get(TeamMembersByOrgViewModel.class);
|
TeamMembersByOrgViewModel teamMembersModel = new ViewModelProvider(this).get(TeamMembersByOrgViewModel.class);
|
||||||
|
|
||||||
teamMembersModel.getMembersByOrgList(instanceUrl, instanceToken, teamId, ctx).observe(this, teamMembersListMain -> {
|
teamMembersModel.getMembersByOrgList(instanceToken, teamId, ctx).observe(this, teamMembersListMain -> {
|
||||||
|
|
||||||
adapter = new TeamMembersByOrgAdapter(ctx, teamMembersListMain);
|
adapter = new TeamMembersByOrgAdapter(ctx, teamMembersListMain);
|
||||||
|
|
||||||
if(adapter.getCount() > 0) {
|
if(adapter.getCount() > 0) {
|
||||||
|
|
||||||
mGridView.setAdapter(adapter);
|
mGridView.setAdapter(adapter);
|
||||||
noDataMembers.setVisibility(View.GONE);
|
noDataMembers.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
mGridView.setAdapter(adapter);
|
mGridView.setAdapter(adapter);
|
||||||
noDataMembers.setVisibility(View.VISIBLE);
|
noDataMembers.setVisibility(View.VISIBLE);
|
||||||
@ -119,7 +113,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -128,7 +121,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -136,31 +128,32 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
|||||||
|
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
switch(id) {
|
if(id == android.R.id.home) {
|
||||||
case android.R.id.home:
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
case R.id.genericMenu:
|
|
||||||
BottomSheetOrganizationTeamsFragment bottomSheet = new BottomSheetOrganizationTeamsFragment();
|
|
||||||
bottomSheet.show(getSupportFragmentManager(), "orgTeamsBottomSheet");
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(id == R.id.genericMenu) {
|
||||||
|
|
||||||
|
BottomSheetOrganizationTeamsFragment bottomSheet = new BottomSheetOrganizationTeamsFragment();
|
||||||
|
bottomSheet.show(getSupportFragmentManager(), "orgTeamsBottomSheet");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onButtonClicked(String text) {
|
public void onButtonClicked(String text) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
if("newMember".equals(text)) {
|
if("newMember".equals(text)) {
|
||||||
|
|
||||||
Intent intent = new Intent(OrganizationTeamMembersActivity.this, AddNewTeamMemberActivity.class);
|
Intent intent = new Intent(OrganizationTeamMembersActivity.this, AddNewTeamMemberActivity.class);
|
||||||
intent.putExtra("teamId", teamId);
|
intent.putExtra("teamId", teamId);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
@ -33,8 +33,6 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private EditText userEmail;
|
private EditText userEmail;
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private Button addEmailButton;
|
private Button addEmailButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -46,7 +44,6 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
@ -73,19 +70,11 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener addEmailListener = new View.OnClickListener() {
|
private final View.OnClickListener addEmailListener = v -> processAddNewEmail();
|
||||||
public void onClick(View v) {
|
|
||||||
processAddNewEmail();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void processAddNewEmail() {
|
private void processAddNewEmail() {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
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 newUserEmail = userEmail.getText().toString().trim();
|
String newUserEmail = userEmail.getText().toString().trim();
|
||||||
|
|
||||||
@ -93,39 +82,34 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newUserEmail.equals("")) {
|
if(newUserEmail.equals("")) {
|
||||||
|
|
||||||
Toasty.error(ctx, getString(R.string.emailErrorEmpty));
|
Toasty.error(ctx, getString(R.string.emailErrorEmpty));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
else if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
||||||
|
|
||||||
Toasty.warning(ctx, getString(R.string.emailErrorInvalid));
|
Toasty.warning(ctx, getString(R.string.emailErrorInvalid));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> newEmailList = new ArrayList<>(Arrays.asList(newUserEmail.split(",")));
|
List<String> newEmailList = new ArrayList<>(Arrays.asList(newUserEmail.split(",")));
|
||||||
|
|
||||||
disableProcessButton();
|
disableProcessButton();
|
||||||
addNewEmail(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), newEmailList);
|
addNewEmail(Authorization.get(ctx), newEmailList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addNewEmail(final String instanceUrl, final String token, List<String> newUserEmail) {
|
private void addNewEmail(final String token, List<String> newUserEmail) {
|
||||||
|
|
||||||
AddEmail addEmailFunc = new AddEmail(newUserEmail);
|
AddEmail addEmailFunc = new AddEmail(newUserEmail);
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
Call<JsonElement> call;
|
Call<JsonElement> call;
|
||||||
|
|
||||||
call = RetrofitClient
|
call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(appCtx)
|
||||||
.getApiInterface()
|
|
||||||
.addNewEmail(token, addEmailFunc);
|
.addNewEmail(token, addEmailFunc);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
@ -139,7 +123,6 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
tinyDb.putBoolean("emailsRefresh", true);
|
tinyDb.putBoolean("emailsRefresh", true);
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 401) {
|
else if(response.code() == 401) {
|
||||||
|
|
||||||
@ -148,37 +131,32 @@ public class ProfileEmailActivity extends BaseActivity {
|
|||||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
else if(response.code() == 403) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 404) {
|
else if(response.code() == 404) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 422) {
|
else if(response.code() == 422) {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.emailErrorInUse));
|
Toasty.warning(ctx, ctx.getString(R.string.emailErrorInUse));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure", t.toString());
|
Log.e("onFailure", t.toString());
|
||||||
enableProcessButton();
|
enableProcessButton();
|
||||||
}
|
}
|
||||||
|
@ -1,430 +0,0 @@
|
|||||||
package org.mian.gitnex.activities;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
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 java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Callback;
|
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Author M M Arif
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ReplyToIssueActivity extends BaseActivity {
|
|
||||||
|
|
||||||
public ImageView closeActivity;
|
|
||||||
private View.OnClickListener onClickListener;
|
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
private TextView draftSaved;
|
|
||||||
private SocialAutoCompleteTextView addComment;
|
|
||||||
private ArrayAdapter<Mention> defaultMentionAdapter;
|
|
||||||
private Button replyButton;
|
|
||||||
private String TAG = StaticGlobalVariables.replyToIssueActivity;
|
|
||||||
private long draftIdOnCreate;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getLayoutResourceId(){
|
|
||||||
return R.layout.activity_reply_to_issue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
appCtx = getApplicationContext();
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
draftSaved = findViewById(R.id.draftSaved);
|
|
||||||
addComment = findViewById(R.id.addComment);
|
|
||||||
addComment.setShowSoftInputOnFocus(true);
|
|
||||||
|
|
||||||
defaultMentionAdapter = new MentionArrayAdapter<>(ctx);
|
|
||||||
loadCollaboratorsList();
|
|
||||||
|
|
||||||
addComment.setMentionAdapter(defaultMentionAdapter);
|
|
||||||
|
|
||||||
closeActivity = findViewById(R.id.close);
|
|
||||||
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
|
||||||
|
|
||||||
addComment.requestFocus();
|
|
||||||
assert imm != null;
|
|
||||||
imm.showSoftInput(addComment, InputMethodManager.SHOW_IMPLICIT);
|
|
||||||
|
|
||||||
if(!tinyDb.getString("issueTitle").isEmpty()) {
|
|
||||||
toolbar_title.setText(tinyDb.getString("issueTitle"));
|
|
||||||
}
|
|
||||||
|
|
||||||
initCloseListener();
|
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
|
||||||
|
|
||||||
if(getIntent().getStringExtra("draftId") != null) {
|
|
||||||
|
|
||||||
draftIdOnCreate = Long.parseLong(Objects.requireNonNull(getIntent().getStringExtra("draftId")));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
if(getIntent().getStringExtra("commentBody") != null) {
|
|
||||||
draftIdOnCreate = returnDraftId(getIntent().getStringExtra("commentBody"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
draftIdOnCreate = returnDraftId("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
replyButton = findViewById(R.id.replyButton);
|
|
||||||
|
|
||||||
if(getIntent().getStringExtra("commentBody") != null) {
|
|
||||||
|
|
||||||
addComment.setText(getIntent().getStringExtra("commentBody"));
|
|
||||||
|
|
||||||
if(getIntent().getBooleanExtra("cursorToEnd", false)) {
|
|
||||||
addComment.setSelection(addComment.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(getIntent().getStringExtra("draftTitle") != null) {
|
|
||||||
|
|
||||||
toolbar_title.setText(getIntent().getStringExtra("draftTitle"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(getIntent().getStringExtra("commentAction") != null && Objects.equals(getIntent().getStringExtra("commentAction"), "edit") && !Objects.equals(getIntent().getStringExtra("commentId"), "new")) {
|
|
||||||
|
|
||||||
final String commentId = getIntent().getStringExtra("commentId");
|
|
||||||
|
|
||||||
toolbar_title.setText(getResources().getString(R.string.editCommentTitle));
|
|
||||||
replyButton.setText(getResources().getString(R.string.editCommentButtonText));
|
|
||||||
|
|
||||||
addComment.addTextChangedListener(new TextWatcher() {
|
|
||||||
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
||||||
|
|
||||||
saveDraft(addComment.getText().toString(), commentId, draftIdOnCreate);
|
|
||||||
draftSaved.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
replyButton.setOnClickListener(v -> {
|
|
||||||
|
|
||||||
disableProcessButton();
|
|
||||||
assert commentId != null;
|
|
||||||
IssueActions.editIssueComment(ctx, Integer.parseInt(commentId), addComment.getText().toString(), draftIdOnCreate);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
addComment.addTextChangedListener(new TextWatcher() {
|
|
||||||
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
||||||
|
|
||||||
saveDraft(addComment.getText().toString(), "new", draftIdOnCreate);
|
|
||||||
draftSaved.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
if(!connToInternet) {
|
|
||||||
|
|
||||||
disableProcessButton();
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
replyButton.setOnClickListener(replyToIssue);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveDraft(String draftText, String commentId, long draftIdOnCreate) {
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
if(draftIdOnCreate == 0) {
|
|
||||||
|
|
||||||
draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, draftText, StaticGlobalVariables.draftTypeComment, commentId);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
DraftsApi.updateDraft(draftText, (int) draftIdOnCreate, commentId); //updateDraftByIssueIdAsyncTask(draftText, issueNumber, repositoryId, commentId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private long returnDraftId(String draftText) {
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
return draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, draftText, StaticGlobalVariables.draftTypeComment, "");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadCollaboratorsList() {
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Collaborators>>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull Response<List<Collaborators>> response) {
|
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
|
||||||
|
|
||||||
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 {
|
|
||||||
|
|
||||||
Log.i(TAG, String.valueOf(response.code()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
|
||||||
|
|
||||||
Log.e(TAG, t.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initCloseListener() {
|
|
||||||
|
|
||||||
onClickListener = view -> finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
private View.OnClickListener replyToIssue = v -> processNewCommentReply();
|
|
||||||
|
|
||||||
private void processNewCommentReply() {
|
|
||||||
|
|
||||||
String newReplyDT = addComment.getText().toString();
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
|
||||||
|
|
||||||
if(!connToInternet) {
|
|
||||||
|
|
||||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(newReplyDT.equals("")) {
|
|
||||||
|
|
||||||
Toasty.error(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.success(ctx, getString(R.string.commentSuccess));
|
|
||||||
tinyDb.putBoolean("commentPosted", true);
|
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
|
||||||
tinyDb.putBoolean("resumePullRequests", true);
|
|
||||||
|
|
||||||
// delete draft comment
|
|
||||||
if(tinyDb.getBoolean("draftsCommentsDeletionEnabled")) {
|
|
||||||
|
|
||||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
|
||||||
draftsApi.deleteSingleDraft((int) draftIdOnCreate);
|
|
||||||
}
|
|
||||||
|
|
||||||
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.error(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableProcessButton() {
|
|
||||||
|
|
||||||
replyButton.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -42,7 +42,6 @@ import org.mian.gitnex.fragments.PullRequestsFragment;
|
|||||||
import org.mian.gitnex.fragments.ReleasesFragment;
|
import org.mian.gitnex.fragments.ReleasesFragment;
|
||||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.Branches;
|
import org.mian.gitnex.models.Branches;
|
||||||
@ -71,12 +70,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
private FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone;
|
private FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone;
|
||||||
private FragmentRefreshListenerFiles fragmentRefreshListenerFiles;
|
private FragmentRefreshListenerFiles fragmentRefreshListenerFiles;
|
||||||
|
|
||||||
private final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
private TinyDB tinyDB;
|
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
|
|
||||||
@ -96,9 +89,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
tinyDB = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
String[] repoNameParts = tinyDB.getString("repoFullName").split("/");
|
String[] repoNameParts = tinyDB.getString("repoFullName").split("/");
|
||||||
repositoryOwner = repoNameParts[0];
|
repositoryOwner = repoNameParts[0];
|
||||||
@ -113,7 +103,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repositoryName);
|
Objects.requireNonNull(getSupportActionBar()).setTitle(repositoryName);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
instanceUrl = tinyDB.getString("instanceUrl");
|
|
||||||
loginUid = tinyDB.getString("loginUid");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
@ -126,17 +115,17 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
switch(tinyDB.getInt("customFontId", -1)) {
|
switch(tinyDB.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/roboto.ttf");
|
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/roboto.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/manroperegular.ttf");
|
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/manroperegular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbarTitle.setTypeface(myTypeface);
|
toolbarTitle.setTypeface(myTypeface);
|
||||||
@ -156,6 +145,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
View tabViewChild = vgTab.getChildAt(i);
|
View tabViewChild = vgTab.getChildAt(i);
|
||||||
|
|
||||||
if(tabViewChild instanceof TextView) {
|
if(tabViewChild instanceof TextView) {
|
||||||
|
|
||||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,7 +162,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
|
|
||||||
tabsCount--;
|
tabsCount--;
|
||||||
collaboratorTab.setVisibility(View.GONE);
|
collaboratorTab.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mViewPager = findViewById(R.id.container);
|
mViewPager = findViewById(R.id.container);
|
||||||
@ -198,7 +187,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
textViewBadgePull.setVisibility(View.GONE);
|
textViewBadgePull.setVisibility(View.GONE);
|
||||||
textViewBadgeRelease.setVisibility(View.GONE);
|
textViewBadgeRelease.setVisibility(View.GONE);
|
||||||
|
|
||||||
getRepoInfo(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
getRepoInfo(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||||
ColorStateList textColor = tabLayout.getTabTextColors();
|
ColorStateList textColor = tabLayout.getTabTextColors();
|
||||||
|
|
||||||
// Issue count
|
// Issue count
|
||||||
@ -209,7 +198,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
assert tabOpenIssues != null; // FIXME This should be cleaned up
|
assert tabOpenIssues != null; // FIXME This should be cleaned up
|
||||||
TextView openIssueTabView = Objects.requireNonNull(tabOpenIssues.getCustomView()).findViewById(R.id.counterBadgeIssueText);
|
TextView openIssueTabView = Objects.requireNonNull(tabOpenIssues.getCustomView()).findViewById(R.id.counterBadgeIssueText);
|
||||||
openIssueTabView.setTextColor(textColor);
|
openIssueTabView.setTextColor(textColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pull request count
|
// Pull request count
|
||||||
@ -220,7 +208,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
assert tabOpenPulls != null; // FIXME This should be cleaned up
|
assert tabOpenPulls != null; // FIXME This should be cleaned up
|
||||||
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
|
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
|
||||||
openPullTabView.setTextColor(textColor);
|
openPullTabView.setTextColor(textColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release count
|
// Release count
|
||||||
@ -233,14 +220,31 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
assert tabOpenRelease != null; // FIXME This should be cleaned up
|
assert tabOpenRelease != null; // FIXME This should be cleaned up
|
||||||
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
|
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
|
||||||
openReleaseTabView.setTextColor(textColor);
|
openReleaseTabView.setTextColor(textColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkRepositoryStarStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
Intent mainIntent = getIntent();
|
||||||
checkRepositoryWatchStatus(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
String goToSection = mainIntent.getStringExtra("goToSection");
|
||||||
|
String goToSectionType = mainIntent.getStringExtra("goToSectionType");
|
||||||
|
|
||||||
|
if(goToSection != null) {
|
||||||
|
|
||||||
|
mainIntent.removeExtra("goToSection");
|
||||||
|
mainIntent.removeExtra("goToSectionType");
|
||||||
|
|
||||||
|
if(goToSectionType.equals("issue")) {
|
||||||
|
|
||||||
|
RepoDetailActivity.mViewPager.setCurrentItem(2);
|
||||||
|
}
|
||||||
|
else if(goToSectionType.equals("pull")) {
|
||||||
|
|
||||||
|
RepoDetailActivity.mViewPager.setCurrentItem(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRepositoryStarStatus(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||||
|
checkRepositoryWatchStatus(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -250,9 +254,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
|
|
||||||
if(tinyDB.getBoolean("enableCounterIssueBadge")) {
|
if(tinyDB.getBoolean("enableCounterIssueBadge")) {
|
||||||
|
|
||||||
getRepoInfo(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repositoryOwner, repositoryName);
|
getRepoInfo(Authorization.get(ctx), repositoryOwner, repositoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -261,7 +264,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.repo_dotted_menu, menu);
|
inflater.inflate(R.menu.repo_dotted_menu, menu);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -318,106 +320,111 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
switch(text) {
|
switch(text) {
|
||||||
|
|
||||||
case "label":
|
case "label":
|
||||||
|
|
||||||
startActivity(new Intent(RepoDetailActivity.this, CreateLabelActivity.class));
|
startActivity(new Intent(RepoDetailActivity.this, CreateLabelActivity.class));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "newIssue":
|
case "newIssue":
|
||||||
|
|
||||||
startActivity(new Intent(RepoDetailActivity.this, CreateIssueActivity.class));
|
startActivity(new Intent(RepoDetailActivity.this, CreateIssueActivity.class));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "newMilestone":
|
case "newMilestone":
|
||||||
|
|
||||||
startActivity(new Intent(RepoDetailActivity.this, CreateMilestoneActivity.class));
|
startActivity(new Intent(RepoDetailActivity.this, CreateMilestoneActivity.class));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "addCollaborator":
|
case "addCollaborator":
|
||||||
|
|
||||||
startActivity(new Intent(RepoDetailActivity.this, AddCollaboratorToRepositoryActivity.class));
|
startActivity(new Intent(RepoDetailActivity.this, AddCollaboratorToRepositoryActivity.class));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "chooseBranch":
|
case "chooseBranch":
|
||||||
|
|
||||||
chooseBranch();
|
chooseBranch();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "createRelease":
|
case "createRelease":
|
||||||
|
|
||||||
startActivity(new Intent(RepoDetailActivity.this, CreateReleaseActivity.class));
|
startActivity(new Intent(RepoDetailActivity.this, CreateReleaseActivity.class));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "openWebRepo":
|
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);
|
startActivity(i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "shareRepo":
|
case "shareRepo":
|
||||||
|
|
||||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||||
sharingIntent.setType("text/plain");
|
sharingIntent.setType("text/plain");
|
||||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, tinyDB.getString("repoHtmlUrl"));
|
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, tinyDB.getString("repoHtmlUrl"));
|
||||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, tinyDB.getString("repoHtmlUrl"));
|
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, tinyDB.getString("repoHtmlUrl"));
|
||||||
startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl")));
|
startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl")));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "copyRepoUrl":
|
case "copyRepoUrl":
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
ClipData clip = ClipData.newPlainText("repoUrl", tinyDB.getString("repoHtmlUrl"));
|
ClipData clip = ClipData.newPlainText("repoUrl", tinyDB.getString("repoHtmlUrl"));
|
||||||
assert clipboard != null;
|
assert clipboard != null;
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "newFile":
|
case "newFile":
|
||||||
|
|
||||||
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
|
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "openIssues":
|
case "openIssues":
|
||||||
|
|
||||||
if(getFragmentRefreshListener() != null) {
|
if(getFragmentRefreshListener() != null) {
|
||||||
|
|
||||||
getFragmentRefreshListener().onRefresh("open");
|
getFragmentRefreshListener().onRefresh("open");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "closedIssues":
|
case "closedIssues":
|
||||||
|
|
||||||
if(getFragmentRefreshListener() != null) {
|
if(getFragmentRefreshListener() != null) {
|
||||||
|
|
||||||
getFragmentRefreshListener().onRefresh("closed");
|
getFragmentRefreshListener().onRefresh("closed");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "openPr":
|
case "openPr":
|
||||||
|
|
||||||
if(getFragmentRefreshListenerPr() != null) {
|
if(getFragmentRefreshListenerPr() != null) {
|
||||||
|
|
||||||
getFragmentRefreshListenerPr().onRefresh("open");
|
getFragmentRefreshListenerPr().onRefresh("open");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "closedPr":
|
case "closedPr":
|
||||||
|
|
||||||
if(getFragmentRefreshListenerPr() != null) {
|
if(getFragmentRefreshListenerPr() != null) {
|
||||||
|
|
||||||
getFragmentRefreshListenerPr().onRefresh("closed");
|
getFragmentRefreshListenerPr().onRefresh("closed");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "openMilestone":
|
case "openMilestone":
|
||||||
|
|
||||||
if(getFragmentRefreshListenerMilestone() != null) {
|
if(getFragmentRefreshListenerMilestone() != null) {
|
||||||
|
|
||||||
getFragmentRefreshListenerMilestone().onRefresh("open");
|
getFragmentRefreshListenerMilestone().onRefresh("open");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "closedMilestone":
|
case "closedMilestone":
|
||||||
|
|
||||||
if(getFragmentRefreshListenerMilestone() != null) {
|
if(getFragmentRefreshListenerMilestone() != null) {
|
||||||
|
|
||||||
getFragmentRefreshListenerMilestone().onRefresh("closed");
|
getFragmentRefreshListenerMilestone().onRefresh("closed");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "repoSettings":
|
case "repoSettings":
|
||||||
|
|
||||||
startActivity(new Intent(RepoDetailActivity.this, RepositorySettingsActivity.class));
|
startActivity(new Intent(RepoDetailActivity.this, RepositorySettingsActivity.class));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "newPullRequest":
|
case "newPullRequest":
|
||||||
|
|
||||||
startActivity(new Intent(RepoDetailActivity.this, CreatePullRequestActivity.class));
|
startActivity(new Intent(RepoDetailActivity.this, CreatePullRequestActivity.class));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chooseBranch() {
|
private void chooseBranch() {
|
||||||
|
|
||||||
Call<List<Branches>> call = RetrofitClient.getInstance(instanceUrl, ctx)
|
Call<List<Branches>> call = RetrofitClient
|
||||||
.getApiInterface()
|
.getApiInterface(ctx)
|
||||||
.getBranches(instanceToken, repositoryOwner, repositoryName);
|
.getBranches(instanceToken, repositoryOwner, repositoryName);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Branches>>() {
|
call.enqueue(new Callback<List<Branches>>() {
|
||||||
@ -451,7 +458,9 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
|
||||||
tinyDB.putString("repoBranch", branchesList.get(i));
|
tinyDB.putString("repoBranch", branchesList.get(i));
|
||||||
|
|
||||||
if(getFragmentRefreshListenerFiles() != null) {
|
if(getFragmentRefreshListenerFiles() != null) {
|
||||||
|
|
||||||
getFragmentRefreshListenerFiles().onRefresh(branchesList.get(i));
|
getFragmentRefreshListenerFiles().onRefresh(branchesList.get(i));
|
||||||
}
|
}
|
||||||
dialogInterface.dismiss();
|
dialogInterface.dismiss();
|
||||||
@ -460,9 +469,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
pBuilder.setNeutralButton(R.string.cancelButton, null);
|
pBuilder.setNeutralButton(R.string.cancelButton, null);
|
||||||
|
|
||||||
pBuilder.create().show();
|
pBuilder.create().show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -490,37 +497,36 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
switch(position) {
|
switch(position) {
|
||||||
|
|
||||||
case 0: // Repository details
|
case 0: // Repository details
|
||||||
|
|
||||||
return RepoInfoFragment.newInstance(repositoryOwner, repositoryName);
|
return RepoInfoFragment.newInstance(repositoryOwner, repositoryName);
|
||||||
|
|
||||||
case 1: // Files
|
case 1: // Files
|
||||||
return FilesFragment.newInstance(repositoryOwner, repositoryName, tinyDB.getString("repoBranch"));
|
|
||||||
|
|
||||||
|
return FilesFragment.newInstance(repositoryOwner, repositoryName, tinyDB.getString("repoBranch"));
|
||||||
case 2: // Issues
|
case 2: // Issues
|
||||||
|
|
||||||
fragment = new IssuesFragment();
|
fragment = new IssuesFragment();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // Pull requests
|
case 3: // Pull requests
|
||||||
|
|
||||||
fragment = new PullRequestsFragment();
|
fragment = new PullRequestsFragment();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: // Releases
|
case 4: // Releases
|
||||||
return ReleasesFragment.newInstance(repositoryOwner, repositoryName);
|
|
||||||
|
|
||||||
|
return ReleasesFragment.newInstance(repositoryOwner, repositoryName);
|
||||||
case 5: // Milestones
|
case 5: // Milestones
|
||||||
|
|
||||||
fragment = new MilestonesFragment();
|
fragment = new MilestonesFragment();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6: // Labels
|
case 6: // Labels
|
||||||
|
|
||||||
return LabelsFragment.newInstance(repositoryOwner, repositoryName);
|
return LabelsFragment.newInstance(repositoryOwner, repositoryName);
|
||||||
|
|
||||||
case 7: // Collaborators
|
case 7: // Collaborators
|
||||||
return CollaboratorsFragment.newInstance(repositoryOwner, repositoryName);
|
|
||||||
|
|
||||||
|
return CollaboratorsFragment.newInstance(repositoryOwner, repositoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert fragment != null;
|
assert fragment != null;
|
||||||
return fragment;
|
return fragment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -528,12 +534,11 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
|
|
||||||
return tabsCount;
|
return tabsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo) {
|
private void getRepoInfo(String token, final String owner, String repo) {
|
||||||
|
|
||||||
Call<UserRepositories> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserRepository(token, owner, repo);
|
Call<UserRepositories> call = RetrofitClient.getApiInterface(ctx).getUserRepository(token, owner, repo);
|
||||||
call.enqueue(new Callback<UserRepositories>() {
|
call.enqueue(new Callback<UserRepositories>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -544,6 +549,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
if(response.code() == 200) {
|
if(response.code() == 200) {
|
||||||
|
|
||||||
if(tinyDB.getBoolean("enableCounterBadges")) {
|
if(tinyDB.getBoolean("enableCounterBadges")) {
|
||||||
|
|
||||||
assert repoInfo != null;
|
assert repoInfo != null;
|
||||||
|
|
||||||
if(repoInfo.getOpen_issues_count() != null) {
|
if(repoInfo.getOpen_issues_count() != null) {
|
||||||
@ -570,7 +576,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
|
|
||||||
Log.e("onFailure", String.valueOf(response.code()));
|
Log.e("onFailure", String.valueOf(response.code()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -583,16 +588,15 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkRepositoryStarStatus(String instanceUrl, String instanceToken, final String owner, String repo) {
|
private void checkRepositoryStarStatus(String instanceToken, final String owner, String repo) {
|
||||||
|
|
||||||
Call<JsonElement> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkRepoStarStatus(instanceToken, owner, repo);
|
Call<JsonElement> call = RetrofitClient.getApiInterface(ctx).checkRepoStarStatus(instanceToken, owner, repo);
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||||
|
|
||||||
tinyDB.putInt("repositoryStarStatus", response.code());
|
tinyDB.putInt("repositoryStarStatus", response.code());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -604,11 +608,11 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkRepositoryWatchStatus(String instanceUrl, String instanceToken, final String owner, String repo) {
|
private void checkRepositoryWatchStatus(String instanceToken, final String owner, String repo) {
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
Call<WatchInfo> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkRepoWatchStatus(instanceToken, owner, repo);
|
call = RetrofitClient.getApiInterface(ctx).checkRepoWatchStatus(instanceToken, owner, repo);
|
||||||
call.enqueue(new Callback<WatchInfo>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -619,15 +623,14 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
assert response.body() != null;
|
assert response.body() != null;
|
||||||
|
|
||||||
if(response.body().getSubscribed()) {
|
if(response.body().getSubscribed()) {
|
||||||
|
|
||||||
tinyDB.putBoolean("repositoryWatchStatus", true);
|
tinyDB.putBoolean("repositoryWatchStatus", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
tinyDB.putBoolean("repositoryWatchStatus", false);
|
tinyDB.putBoolean("repositoryWatchStatus", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@ -42,8 +41,6 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class RepoForksActivity extends BaseActivity {
|
public class RepoForksActivity extends BaseActivity {
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
@ -67,14 +64,11 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
String repoFullNameForForks = getIntent().getStringExtra("repoFullNameForForks");
|
String repoFullNameForForks = getIntent().getStringExtra("repoFullNameForForks");
|
||||||
assert repoFullNameForForks != null;
|
assert repoFullNameForForks != null;
|
||||||
@ -97,6 +91,7 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
|
|
||||||
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
|
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12")) {
|
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12")) {
|
||||||
|
|
||||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +105,7 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
|
||||||
swipeRefresh.setRefreshing(false);
|
swipeRefresh.setRefreshing(false);
|
||||||
loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
|
loadInitial(Authorization.get(ctx), repoOwner, repoName, pageSize, resultLimit);
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
|
|
||||||
}, 200));
|
}, 200));
|
||||||
@ -121,25 +116,21 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
if(forksList.size() == resultLimit || pageSize == resultLimit) {
|
if(forksList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
|
||||||
int page = (forksList.size() + resultLimit) / resultLimit;
|
int page = (forksList.size() + resultLimit) / resultLimit;
|
||||||
loadMore(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, resultLimit);
|
loadMore(Authorization.get(ctx), repoOwner, repoName, page, resultLimit);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
|
loadInitial(Authorization.get(ctx), repoOwner, repoName, pageSize, resultLimit);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadInitial(String instanceUrl, String instanceToken, String repoOwner, String repoName, int pageSize, int resultLimit) {
|
private void loadInitial(String instanceToken, String repoOwner, String repoName, int pageSize, int resultLimit) {
|
||||||
|
|
||||||
Call<List<UserRepositories>> call = RetrofitClient
|
Call<List<UserRepositories>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.getRepositoryForks(instanceToken, repoOwner, repoName, pageSize, resultLimit);
|
.getRepositoryForks(instanceToken, repoOwner, repoName, pageSize, resultLimit);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||||
@ -150,29 +141,27 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
assert response.body() != null;
|
assert response.body() != null;
|
||||||
|
|
||||||
if(response.body().size() > 0) {
|
if(response.body().size() > 0) {
|
||||||
|
|
||||||
forksList.clear();
|
forksList.clear();
|
||||||
forksList.addAll(response.body());
|
forksList.addAll(response.body());
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
noData.setVisibility(View.GONE);
|
noData.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
forksList.clear();
|
forksList.clear();
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
noData.setVisibility(View.VISIBLE);
|
noData.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Log.e(TAG, String.valueOf(response.code()));
|
Log.e(TAG, String.valueOf(response.code()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -180,18 +169,16 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
|
|
||||||
Log.e(TAG, t.toString());
|
Log.e(TAG, t.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadMore(String instanceUrl, String instanceToken, String repoOwner, String repoName, int page, int resultLimit) {
|
private void loadMore(String instanceToken, String repoOwner, String repoName, int page, int resultLimit) {
|
||||||
|
|
||||||
progressLoadMore.setVisibility(View.VISIBLE);
|
progressLoadMore.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
Call<List<UserRepositories>> call = RetrofitClient
|
Call<List<UserRepositories>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.getRepositoryForks(instanceToken, repoOwner, repoName, page, resultLimit);
|
.getRepositoryForks(instanceToken, repoOwner, repoName, page, resultLimit);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||||
@ -205,37 +192,31 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
forksList.remove(forksList.size() - 1);
|
forksList.remove(forksList.size() - 1);
|
||||||
|
|
||||||
List<UserRepositories> result = response.body();
|
List<UserRepositories> result = response.body();
|
||||||
|
|
||||||
assert result != null;
|
assert result != null;
|
||||||
|
|
||||||
if(result.size() > 0) {
|
if(result.size() > 0) {
|
||||||
|
|
||||||
pageSize = result.size();
|
pageSize = result.size();
|
||||||
forksList.addAll(result);
|
forksList.addAll(result);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
adapter.setMoreDataAvailable(false);
|
adapter.setMoreDataAvailable(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
progressLoadMore.setVisibility(View.GONE);
|
progressLoadMore.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Log.e(TAG, String.valueOf(response.code()));
|
Log.e(TAG, String.valueOf(response.code()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e(TAG, t.toString());
|
Log.e(TAG, t.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -270,7 +251,6 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filter(String text) {
|
private void filter(String text) {
|
||||||
@ -278,7 +258,9 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
List<UserRepositories> arr = new ArrayList<>();
|
List<UserRepositories> arr = new ArrayList<>();
|
||||||
|
|
||||||
for(UserRepositories d : forksList) {
|
for(UserRepositories d : forksList) {
|
||||||
|
|
||||||
if(d.getName().toLowerCase().contains(text) || d.getDescription().toLowerCase().contains(text)) {
|
if(d.getName().toLowerCase().contains(text) || d.getDescription().toLowerCase().contains(text)) {
|
||||||
|
|
||||||
arr.add(d);
|
arr.add(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,6 +271,7 @@ public class RepoForksActivity extends BaseActivity {
|
|||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
|
||||||
onClickListener = view -> {
|
onClickListener = view -> {
|
||||||
|
|
||||||
getIntent().removeExtra("repoFullNameForForks");
|
getIntent().removeExtra("repoFullNameForForks");
|
||||||
finish();
|
finish();
|
||||||
};
|
};
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.GridView;
|
import android.widget.GridView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.lifecycle.Observer;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.RepoStargazersAdapter;
|
import org.mian.gitnex.adapters.RepoStargazersAdapter;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.models.UserInfo;
|
|
||||||
import org.mian.gitnex.viewmodels.RepoStargazersViewModel;
|
import org.mian.gitnex.viewmodels.RepoStargazersViewModel;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -30,9 +24,6 @@ public class RepoStargazersActivity extends BaseActivity {
|
|||||||
private GridView mGridView;
|
private GridView mGridView;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
return R.layout.activity_repo_stargazers;
|
return R.layout.activity_repo_stargazers;
|
||||||
@ -42,12 +33,6 @@ public class RepoStargazersActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||||
@ -65,29 +50,30 @@ public class RepoStargazersActivity extends BaseActivity {
|
|||||||
|
|
||||||
toolbarTitle.setText(R.string.repoStargazersInMenu);
|
toolbarTitle.setText(R.string.repoStargazersInMenu);
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
fetchDataAsync(Authorization.get(ctx), repoOwner, repoName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String repoOwner, String repoName) {
|
private void fetchDataAsync(String instanceToken, String repoOwner, String repoName) {
|
||||||
|
|
||||||
RepoStargazersViewModel repoStargazersModel = new ViewModelProvider(this).get(RepoStargazersViewModel.class);
|
RepoStargazersViewModel repoStargazersModel = new ViewModelProvider(this).get(RepoStargazersViewModel.class);
|
||||||
|
|
||||||
repoStargazersModel.getRepoStargazers(instanceUrl, instanceToken, repoOwner, repoName, ctx).observe(this, new Observer<List<UserInfo>>() {
|
repoStargazersModel.getRepoStargazers(instanceToken, repoOwner, repoName, ctx).observe(this, stargazersListMain -> {
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable List<UserInfo> stargazersListMain) {
|
adapter = new RepoStargazersAdapter(ctx, stargazersListMain);
|
||||||
adapter = new RepoStargazersAdapter(ctx, stargazersListMain);
|
|
||||||
if(adapter.getCount() > 0) {
|
if(adapter.getCount() > 0) {
|
||||||
mGridView.setAdapter(adapter);
|
|
||||||
noDataStargazers.setVisibility(View.GONE);
|
mGridView.setAdapter(adapter);
|
||||||
}
|
noDataStargazers.setVisibility(View.GONE);
|
||||||
else {
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
mGridView.setAdapter(adapter);
|
|
||||||
noDataStargazers.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
mGridView.setAdapter(adapter);
|
||||||
|
noDataStargazers.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
mProgressBar.setVisibility(View.GONE);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.GridView;
|
import android.widget.GridView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.lifecycle.Observer;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.RepoWatchersAdapter;
|
import org.mian.gitnex.adapters.RepoWatchersAdapter;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.models.UserInfo;
|
|
||||||
import org.mian.gitnex.viewmodels.RepoWatchersViewModel;
|
import org.mian.gitnex.viewmodels.RepoWatchersViewModel;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -30,9 +24,6 @@ public class RepoWatchersActivity extends BaseActivity {
|
|||||||
private GridView mGridView;
|
private GridView mGridView;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
|
|
||||||
final Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId(){
|
protected int getLayoutResourceId(){
|
||||||
return R.layout.activity_repo_watchers;
|
return R.layout.activity_repo_watchers;
|
||||||
@ -42,12 +33,6 @@ public class RepoWatchersActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||||
@ -65,29 +50,30 @@ public class RepoWatchersActivity extends BaseActivity {
|
|||||||
|
|
||||||
toolbarTitle.setText(R.string.repoWatchersInMenu);
|
toolbarTitle.setText(R.string.repoWatchersInMenu);
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
fetchDataAsync(Authorization.get(ctx), repoOwner, repoName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String repoOwner, String repoName) {
|
private void fetchDataAsync(String instanceToken, String repoOwner, String repoName) {
|
||||||
|
|
||||||
RepoWatchersViewModel repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
|
RepoWatchersViewModel repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
|
||||||
|
|
||||||
repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName, ctx).observe(this, new Observer<List<UserInfo>>() {
|
repoWatchersModel.getRepoWatchers(instanceToken, repoOwner, repoName, ctx).observe(this, watchersListMain -> {
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable List<UserInfo> watchersListMain) {
|
adapter = new RepoWatchersAdapter(ctx, watchersListMain);
|
||||||
adapter = new RepoWatchersAdapter(ctx, watchersListMain);
|
|
||||||
if(adapter.getCount() > 0) {
|
if(adapter.getCount() > 0) {
|
||||||
mGridView.setAdapter(adapter);
|
|
||||||
noDataWatchers.setVisibility(View.GONE);
|
mGridView.setAdapter(adapter);
|
||||||
}
|
noDataWatchers.setVisibility(View.GONE);
|
||||||
else {
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
mGridView.setAdapter(adapter);
|
|
||||||
noDataWatchers.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
mGridView.setAdapter(adapter);
|
||||||
|
noDataWatchers.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
mProgressBar.setVisibility(View.GONE);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
@ -18,7 +17,6 @@ import org.mian.gitnex.databinding.ActivityRepositorySettingsBinding;
|
|||||||
import org.mian.gitnex.databinding.CustomRepositoryDeleteDialogBinding;
|
import org.mian.gitnex.databinding.CustomRepositoryDeleteDialogBinding;
|
||||||
import org.mian.gitnex.databinding.CustomRepositoryEditPropertiesDialogBinding;
|
import org.mian.gitnex.databinding.CustomRepositoryEditPropertiesDialogBinding;
|
||||||
import org.mian.gitnex.databinding.CustomRepositoryTransferDialogBinding;
|
import org.mian.gitnex.databinding.CustomRepositoryTransferDialogBinding;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
import org.mian.gitnex.helpers.Version;
|
||||||
import org.mian.gitnex.models.RepositoryTransfer;
|
import org.mian.gitnex.models.RepositoryTransfer;
|
||||||
@ -40,11 +38,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
private Dialog dialogDeleteRepository;
|
private Dialog dialogDeleteRepository;
|
||||||
private Dialog dialogTransferRepository;
|
private Dialog dialogTransferRepository;
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private Context ctx = this;
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDb;
|
|
||||||
|
|
||||||
private String instanceUrl;
|
|
||||||
private String loginUid;
|
private String loginUid;
|
||||||
private String instanceToken;
|
private String instanceToken;
|
||||||
|
|
||||||
@ -60,20 +54,17 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
viewBinding = ActivityRepositorySettingsBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityRepositorySettingsBinding.inflate(getLayoutInflater());
|
||||||
View view = viewBinding.getRoot();
|
View view = viewBinding.getRoot();
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
|
|
||||||
instanceUrl = tinyDb.getString("instanceUrl");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
loginUid = tinyDb.getString("loginUid");
|
String repoFullName = tinyDB.getString("repoFullName");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
repositoryOwner = parts[0];
|
repositoryOwner = parts[0];
|
||||||
repositoryName = parts[1];
|
repositoryName = parts[1];
|
||||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
@ -81,23 +72,16 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
// require gitea 1.12 or higher
|
// require gitea 1.12 or higher
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||||
|
|
||||||
viewBinding.transferOwnerFrame.setVisibility(View.VISIBLE);
|
viewBinding.transferOwnerFrame.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
viewBinding.editProperties.setOnClickListener(editProperties -> {
|
viewBinding.editProperties.setOnClickListener(editProperties -> showRepositoryProperties());
|
||||||
showRepositoryProperties();
|
|
||||||
});
|
|
||||||
|
|
||||||
viewBinding.deleteRepository.setOnClickListener(deleteRepository -> {
|
viewBinding.deleteRepository.setOnClickListener(deleteRepository -> showDeleteRepository());
|
||||||
showDeleteRepository();
|
|
||||||
});
|
|
||||||
|
|
||||||
viewBinding.transferOwnerFrame.setOnClickListener(transferRepositoryOwnership -> {
|
|
||||||
showTransferRepository();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
viewBinding.transferOwnerFrame.setOnClickListener(transferRepositoryOwnership -> showTransferRepository());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showTransferRepository() {
|
private void showTransferRepository() {
|
||||||
@ -114,9 +98,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
View view = transferRepoBinding.getRoot();
|
View view = transferRepoBinding.getRoot();
|
||||||
dialogTransferRepository.setContentView(view);
|
dialogTransferRepository.setContentView(view);
|
||||||
|
|
||||||
transferRepoBinding.cancel.setOnClickListener(editProperties -> {
|
transferRepoBinding.cancel.setOnClickListener(editProperties -> dialogTransferRepository.dismiss());
|
||||||
dialogTransferRepository.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
transferRepoBinding.transfer.setOnClickListener(deleteRepo -> {
|
transferRepoBinding.transfer.setOnClickListener(deleteRepo -> {
|
||||||
|
|
||||||
@ -145,8 +127,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
RepositoryTransfer repositoryTransfer = new RepositoryTransfer(newOwner);
|
RepositoryTransfer repositoryTransfer = new RepositoryTransfer(newOwner);
|
||||||
|
|
||||||
Call<JsonElement> transferCall = RetrofitClient
|
Call<JsonElement> transferCall = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.transferRepository(instanceToken, repositoryOwner, repositoryName, repositoryTransfer);
|
.transferRepository(instanceToken, repositoryOwner, repositoryName, repositoryTransfer);
|
||||||
|
|
||||||
transferCall.enqueue(new Callback<JsonElement>() {
|
transferCall.enqueue(new Callback<JsonElement>() {
|
||||||
@ -163,7 +144,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
RepositoriesApi.deleteRepository((int) tinyDb.getLong("repositoryId", 0));
|
RepositoriesApi.deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
||||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||||
RepositorySettingsActivity.this.startActivity(intent);
|
RepositorySettingsActivity.this.startActivity(intent);
|
||||||
}
|
}
|
||||||
@ -197,6 +178,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
dialogDeleteRepository = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
dialogDeleteRepository = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||||
|
|
||||||
if (dialogDeleteRepository.getWindow() != null) {
|
if (dialogDeleteRepository.getWindow() != null) {
|
||||||
|
|
||||||
dialogDeleteRepository.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
dialogDeleteRepository.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,9 +187,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
View view = deleteRepoBinding.getRoot();
|
View view = deleteRepoBinding.getRoot();
|
||||||
dialogDeleteRepository.setContentView(view);
|
dialogDeleteRepository.setContentView(view);
|
||||||
|
|
||||||
deleteRepoBinding.cancel.setOnClickListener(editProperties -> {
|
deleteRepoBinding.cancel.setOnClickListener(editProperties -> dialogDeleteRepository.dismiss());
|
||||||
dialogDeleteRepository.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
deleteRepoBinding.delete.setOnClickListener(deleteRepo -> {
|
deleteRepoBinding.delete.setOnClickListener(deleteRepo -> {
|
||||||
|
|
||||||
@ -227,8 +207,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
private void deleteRepository() {
|
private void deleteRepository() {
|
||||||
|
|
||||||
Call<JsonElement> deleteCall = RetrofitClient
|
Call<JsonElement> deleteCall = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.deleteRepository(instanceToken, repositoryOwner, repositoryName);
|
.deleteRepository(instanceToken, repositoryOwner, repositoryName);
|
||||||
|
|
||||||
deleteCall.enqueue(new Callback<JsonElement>() {
|
deleteCall.enqueue(new Callback<JsonElement>() {
|
||||||
@ -245,7 +224,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
RepositoriesApi.deleteRepository((int) tinyDb.getLong("repositoryId", 0));
|
RepositoriesApi.deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
||||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||||
RepositorySettingsActivity.this.startActivity(intent);
|
RepositorySettingsActivity.this.startActivity(intent);
|
||||||
}
|
}
|
||||||
@ -273,6 +252,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
dialogProp = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
dialogProp = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||||
|
|
||||||
if (dialogProp.getWindow() != null) {
|
if (dialogProp.getWindow() != null) {
|
||||||
|
|
||||||
dialogProp.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
dialogProp.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,13 +261,10 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
View view = propBinding.getRoot();
|
View view = propBinding.getRoot();
|
||||||
dialogProp.setContentView(view);
|
dialogProp.setContentView(view);
|
||||||
|
|
||||||
propBinding.cancel.setOnClickListener(editProperties -> {
|
propBinding.cancel.setOnClickListener(editProperties -> dialogProp.dismiss());
|
||||||
dialogProp.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
Call<UserRepositories> call = RetrofitClient
|
Call<UserRepositories> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.getUserRepository(instanceToken, repositoryOwner, repositoryName);
|
.getUserRepository(instanceToken, repositoryOwner, repositoryName);
|
||||||
|
|
||||||
call.enqueue(new Callback<UserRepositories>() {
|
call.enqueue(new Callback<UserRepositories>() {
|
||||||
@ -314,19 +291,24 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
propBinding.repoEnableIssues.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
propBinding.repoEnableIssues.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
|
|
||||||
propBinding.repoEnableTimer.setVisibility(View.VISIBLE);
|
propBinding.repoEnableTimer.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(repoInfo.getInternal_tracker() != null) {
|
if(repoInfo.getInternal_tracker() != null) {
|
||||||
|
|
||||||
propBinding.repoEnableTimer.setChecked(repoInfo.getInternal_tracker().isEnable_time_tracker());
|
propBinding.repoEnableTimer.setChecked(repoInfo.getInternal_tracker().isEnable_time_tracker());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
propBinding.repoEnableWiki.setChecked(repoInfo.isHas_wiki());
|
propBinding.repoEnableWiki.setChecked(repoInfo.isHas_wiki());
|
||||||
propBinding.repoEnablePr.setChecked(repoInfo.isHas_pull_requests());
|
propBinding.repoEnablePr.setChecked(repoInfo.isHas_pull_requests());
|
||||||
propBinding.repoEnableMerge.setChecked(repoInfo.isAllow_merge_commits());
|
propBinding.repoEnableMerge.setChecked(repoInfo.isAllow_merge_commits());
|
||||||
@ -359,7 +341,6 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
propBinding.repoEnableSquash.isChecked(), propBinding.repoEnableForceMerge.isChecked()));
|
propBinding.repoEnableSquash.isChecked(), propBinding.repoEnableForceMerge.isChecked()));
|
||||||
|
|
||||||
dialogProp.show();
|
dialogProp.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveRepositoryProperties(String repoName, String repoWebsite, String repoDescription,
|
private void saveRepositoryProperties(String repoName, String repoWebsite, String repoDescription,
|
||||||
@ -370,18 +351,20 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
UserRepositories.internalTimeTrackerObject repoPropsTimeTracker = new UserRepositories.internalTimeTrackerObject(repoEnableTimer);
|
UserRepositories.internalTimeTrackerObject repoPropsTimeTracker = new UserRepositories.internalTimeTrackerObject(repoEnableTimer);
|
||||||
|
|
||||||
UserRepositories repoProps;
|
UserRepositories repoProps;
|
||||||
|
|
||||||
if(!repoEnableIssues) {
|
if(!repoEnableIssues) {
|
||||||
|
|
||||||
repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoEnableMerge,
|
repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoEnableMerge,
|
||||||
repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
|
repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoPropsTimeTracker, repoEnableMerge,
|
repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoPropsTimeTracker, repoEnableMerge,
|
||||||
repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
|
repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
|
||||||
}
|
}
|
||||||
|
|
||||||
Call<UserRepositories> propsCall = RetrofitClient
|
Call<UserRepositories> propsCall = RetrofitClient
|
||||||
.getInstance(instanceUrl, ctx)
|
.getApiInterface(ctx)
|
||||||
.getApiInterface()
|
|
||||||
.updateRepositoryProperties(instanceToken, repositoryOwner, repositoryName, repoProps);
|
.updateRepositoryProperties(instanceToken, repositoryOwner, repositoryName, repoProps);
|
||||||
|
|
||||||
propsCall.enqueue(new Callback<UserRepositories>() {
|
propsCall.enqueue(new Callback<UserRepositories>() {
|
||||||
@ -394,8 +377,8 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
|
|
||||||
if (response.code() == 200) {
|
if (response.code() == 200) {
|
||||||
|
|
||||||
tinyDb.putBoolean("hasIssues", repoEnableIssues);
|
tinyDB.putBoolean("hasIssues", repoEnableIssues);
|
||||||
tinyDb.putBoolean("hasPullRequests", repoEnablePr);
|
tinyDB.putBoolean("hasPullRequests", repoEnablePr);
|
||||||
|
|
||||||
dialogProp.dismiss();
|
dialogProp.dismiss();
|
||||||
Toasty.success(ctx, getString(R.string.repoPropertiesSaveSuccess));
|
Toasty.success(ctx, getString(R.string.repoPropertiesSaveSuccess));
|
||||||
@ -403,10 +386,9 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
if(!repositoryName.equals(repoName)) {
|
if(!repositoryName.equals(repoName)) {
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
RepositoriesApi.updateRepositoryOwnerAndName(repositoryOwner, repoName, (int) tinyDb.getLong("repositoryId", 0));
|
RepositoriesApi.updateRepositoryOwnerAndName(repositoryOwner, repoName, (int) tinyDB.getLong("repositoryId", 0));
|
||||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||||
RepositorySettingsActivity.this.startActivity(intent);
|
RepositorySettingsActivity.this.startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -415,7 +397,6 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
propBinding.processingRequest.setVisibility(View.GONE);
|
propBinding.processingRequest.setVisibility(View.GONE);
|
||||||
Toasty.error(ctx, getString(R.string.genericError));
|
Toasty.error(ctx, getString(R.string.genericError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -19,23 +16,15 @@ import org.mian.gitnex.helpers.Version;
|
|||||||
|
|
||||||
public class SettingsAppearanceActivity extends BaseActivity {
|
public class SettingsAppearanceActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
private static String[] timeList = {"Pretty", "Normal"};
|
private static final String[] timeList = {"Pretty", "Normal"};
|
||||||
private static int timeSelectedChoice = 0;
|
private static int timeSelectedChoice = 0;
|
||||||
|
|
||||||
private static String[] codeBlockList = {"Green - Black", "White - Black", "Grey - Black", "White - Grey", "Dark - White"};
|
private static final String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
|
||||||
private static int codeBlockSelectedChoice = 0;
|
|
||||||
|
|
||||||
private static String[] homeScreenList = {"My Repositories", "Starred Repositories", "Organizations", "Repositories", "Profile", "Explore", "Drafts"};
|
|
||||||
private static String[] homeScreenListNew = {"My Repositories", "Starred Repositories", "Organizations", "Repositories", "Profile", "Explore", "Drafts", "Notifications"};
|
|
||||||
private static int homeScreenSelectedChoice = 0;
|
|
||||||
|
|
||||||
private static String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
|
|
||||||
private static int customFontSelectedChoice = 0;
|
private static int customFontSelectedChoice = 0;
|
||||||
|
|
||||||
private static String[] themeList = {"Dark", "Light", "Auto (Light / Dark)", "Retro", "Auto (Retro / Dark)"};
|
private static final String[] themeList = {"Dark", "Light", "Auto (Light / Dark)", "Retro", "Auto (Retro / Dark)", "Pitch Black"};
|
||||||
private static int themeSelectedChoice = 0;
|
private static int themeSelectedChoice = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,93 +37,59 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
final TextView tvDateTimeSelected = findViewById(R.id.tvDateTimeSelected); // setter for time
|
final TextView tvDateTimeSelected = findViewById(R.id.tvDateTimeSelected); // setter for time
|
||||||
final TextView codeBlockSelected = findViewById(R.id.codeBlockSelected); // setter for code block
|
|
||||||
final TextView homeScreenSelected = findViewById(R.id.homeScreenSelected); // setter for home screen
|
|
||||||
final TextView customFontSelected = findViewById(R.id.customFontSelected); // setter for custom font
|
final TextView customFontSelected = findViewById(R.id.customFontSelected); // setter for custom font
|
||||||
final TextView themeSelected = findViewById(R.id.themeSelected); // setter for theme
|
final TextView themeSelected = findViewById(R.id.themeSelected); // setter for theme
|
||||||
|
|
||||||
LinearLayout timeFrame = findViewById(R.id.timeFrame);
|
LinearLayout timeFrame = findViewById(R.id.timeFrame);
|
||||||
LinearLayout codeBlockFrame = findViewById(R.id.codeBlockFrame);
|
|
||||||
LinearLayout homeScreenFrame = findViewById(R.id.homeScreenFrame);
|
|
||||||
LinearLayout customFontFrame = findViewById(R.id.customFontFrame);
|
LinearLayout customFontFrame = findViewById(R.id.customFontFrame);
|
||||||
LinearLayout themeFrame = findViewById(R.id.themeSelectionFrame);
|
LinearLayout themeFrame = findViewById(R.id.themeSelectionFrame);
|
||||||
|
|
||||||
Switch counterBadgesSwitch = findViewById(R.id.switchCounterBadge);
|
SwitchMaterial counterBadgesSwitch = findViewById(R.id.switchCounterBadge);
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
if(!tinyDB.getString("timeStr").isEmpty()) {
|
||||||
|
|
||||||
homeScreenList = homeScreenListNew;
|
tvDateTimeSelected.setText(tinyDB.getString("timeStr"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tinyDb.getString("timeStr").isEmpty()) {
|
if(!tinyDB.getString("customFontStr").isEmpty()) {
|
||||||
tvDateTimeSelected.setText(tinyDb.getString("timeStr"));
|
|
||||||
|
customFontSelected.setText(tinyDB.getString("customFontStr"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tinyDb.getString("codeBlockStr").isEmpty()) {
|
if(!tinyDB.getString("themeStr").isEmpty()) {
|
||||||
codeBlockSelected.setText(tinyDb.getString("codeBlockStr"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!tinyDb.getString("homeScreenStr").isEmpty()) {
|
themeSelected.setText(tinyDB.getString("themeStr"));
|
||||||
homeScreenSelected.setText(tinyDb.getString("homeScreenStr"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!tinyDb.getString("customFontStr").isEmpty()) {
|
|
||||||
customFontSelected.setText(tinyDb.getString("customFontStr"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!tinyDb.getString("themeStr").isEmpty()) {
|
|
||||||
themeSelected.setText(tinyDb.getString("themeStr"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(timeSelectedChoice == 0) {
|
if(timeSelectedChoice == 0) {
|
||||||
timeSelectedChoice = tinyDb.getInt("timeId");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(codeBlockSelectedChoice == 0) {
|
timeSelectedChoice = tinyDB.getInt("timeId");
|
||||||
codeBlockSelectedChoice = tinyDb.getInt("codeBlockId");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(homeScreenSelectedChoice == 0) {
|
|
||||||
homeScreenSelectedChoice = tinyDb.getInt("homeScreenId");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(customFontSelectedChoice == 0) {
|
if(customFontSelectedChoice == 0) {
|
||||||
customFontSelectedChoice = tinyDb.getInt("customFontId", 1);
|
|
||||||
|
customFontSelectedChoice = tinyDB.getInt("customFontId", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(themeSelectedChoice == 0) {
|
if(themeSelectedChoice == 0) {
|
||||||
themeSelectedChoice = tinyDb.getInt("themeId");
|
|
||||||
|
themeSelectedChoice = tinyDB.getInt("themeId");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getBoolean("enableCounterBadges")) {
|
counterBadgesSwitch.setChecked(tinyDB.getBoolean("enableCounterBadges"));
|
||||||
counterBadgesSwitch.setChecked(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
counterBadgesSwitch.setChecked(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// counter badge switcher
|
// counter badge switcher
|
||||||
counterBadgesSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
counterBadgesSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
if (isChecked) {
|
tinyDB.putBoolean("enableCounterBadges", isChecked);
|
||||||
tinyDb.putBoolean("enableCounterBadges", true);
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tinyDb.putBoolean("enableCounterBadges", false);
|
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// theme selection dialog
|
// theme selection dialog
|
||||||
@ -143,31 +98,24 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
||||||
|
|
||||||
tsBuilder.setTitle(getResources().getString(R.string.themeSelectorDialogTitle));
|
tsBuilder.setTitle(getResources().getString(R.string.themeSelectorDialogTitle));
|
||||||
if(themeSelectedChoice != -1) {
|
tsBuilder.setCancelable(themeSelectedChoice != -1);
|
||||||
tsBuilder.setCancelable(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tsBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
tsBuilder.setSingleChoiceItems(themeList, themeSelectedChoice, (dialogInterfaceTheme, i) -> {
|
tsBuilder.setSingleChoiceItems(themeList, themeSelectedChoice, (dialogInterfaceTheme, i) -> {
|
||||||
|
|
||||||
themeSelectedChoice = i;
|
themeSelectedChoice = i;
|
||||||
themeSelected.setText(themeList[i]);
|
themeSelected.setText(themeList[i]);
|
||||||
tinyDb.putString("themeStr", themeList[i]);
|
tinyDB.putString("themeStr", themeList[i]);
|
||||||
tinyDb.putInt("themeId", i);
|
tinyDB.putInt("themeId", i);
|
||||||
|
|
||||||
tinyDb.putBoolean("refreshParent", true);
|
tinyDB.putBoolean("refreshParent", true);
|
||||||
this.recreate();
|
this.recreate();
|
||||||
this.overridePendingTransition(0, 0);
|
this.overridePendingTransition(0, 0);
|
||||||
dialogInterfaceTheme.dismiss();
|
dialogInterfaceTheme.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AlertDialog cfDialog = tsBuilder.create();
|
AlertDialog cfDialog = tsBuilder.create();
|
||||||
cfDialog.show();
|
cfDialog.show();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// custom font dialog
|
// custom font dialog
|
||||||
@ -176,114 +124,24 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
AlertDialog.Builder cfBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
AlertDialog.Builder cfBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
||||||
|
|
||||||
cfBuilder.setTitle(R.string.settingsCustomFontSelectorDialogTitle);
|
cfBuilder.setTitle(R.string.settingsCustomFontSelectorDialogTitle);
|
||||||
if(customFontSelectedChoice != -1) {
|
cfBuilder.setCancelable(customFontSelectedChoice != -1);
|
||||||
cfBuilder.setCancelable(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cfBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
cfBuilder.setSingleChoiceItems(customFontList, customFontSelectedChoice, (dialogInterfaceCustomFont, i) -> {
|
cfBuilder.setSingleChoiceItems(customFontList, customFontSelectedChoice, (dialogInterfaceCustomFont, i) -> {
|
||||||
|
|
||||||
customFontSelectedChoice = i;
|
customFontSelectedChoice = i;
|
||||||
customFontSelected.setText(customFontList[i]);
|
customFontSelected.setText(customFontList[i]);
|
||||||
tinyDb.putString("customFontStr", customFontList[i]);
|
tinyDB.putString("customFontStr", customFontList[i]);
|
||||||
tinyDb.putInt("customFontId", i);
|
tinyDB.putInt("customFontId", i);
|
||||||
|
|
||||||
tinyDb.putBoolean("refreshParent", true);
|
tinyDB.putBoolean("refreshParent", true);
|
||||||
this.recreate();
|
this.recreate();
|
||||||
this.overridePendingTransition(0, 0);
|
this.overridePendingTransition(0, 0);
|
||||||
dialogInterfaceCustomFont.dismiss();
|
dialogInterfaceCustomFont.dismiss();
|
||||||
Toasty.success(appCtx, appCtx.getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, appCtx.getResources().getString(R.string.settingsSave));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AlertDialog cfDialog = cfBuilder.create();
|
AlertDialog cfDialog = cfBuilder.create();
|
||||||
cfDialog.show();
|
cfDialog.show();
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// home screen dialog
|
|
||||||
homeScreenFrame.setOnClickListener(view -> {
|
|
||||||
|
|
||||||
AlertDialog.Builder hsBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
|
||||||
|
|
||||||
hsBuilder.setTitle(R.string.settingsHomeScreenSelectorDialogTitle);
|
|
||||||
if(homeScreenSelectedChoice != -1) {
|
|
||||||
hsBuilder.setCancelable(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
hsBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
hsBuilder.setSingleChoiceItems(homeScreenList, homeScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
|
|
||||||
|
|
||||||
homeScreenSelectedChoice = i;
|
|
||||||
homeScreenSelected.setText(homeScreenList[i]);
|
|
||||||
tinyDb.putString("homeScreenStr", homeScreenList[i]);
|
|
||||||
tinyDb.putInt("homeScreenId", i);
|
|
||||||
|
|
||||||
dialogInterfaceHomeScreen.dismiss();
|
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
AlertDialog hsDialog = hsBuilder.create();
|
|
||||||
hsDialog.show();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// code block dialog
|
|
||||||
codeBlockFrame.setOnClickListener(view -> {
|
|
||||||
|
|
||||||
AlertDialog.Builder cBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
|
||||||
|
|
||||||
cBuilder.setTitle(R.string.settingsCodeBlockSelectorDialogTitle);
|
|
||||||
if(codeBlockSelectedChoice != -1) {
|
|
||||||
cBuilder.setCancelable(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
cBuilder.setSingleChoiceItems(codeBlockList, codeBlockSelectedChoice, (dialogInterfaceCodeBlock, i) -> {
|
|
||||||
|
|
||||||
codeBlockSelectedChoice = i;
|
|
||||||
codeBlockSelected.setText(codeBlockList[i]);
|
|
||||||
tinyDb.putString("codeBlockStr", codeBlockList[i]);
|
|
||||||
tinyDb.putInt("codeBlockId", i);
|
|
||||||
|
|
||||||
switch(codeBlockList[i]) {
|
|
||||||
case "White - Black":
|
|
||||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorWhite));
|
|
||||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
|
||||||
break;
|
|
||||||
case "Grey - Black":
|
|
||||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorAccent));
|
|
||||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
|
||||||
break;
|
|
||||||
case "White - Grey":
|
|
||||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorWhite));
|
|
||||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorAccent));
|
|
||||||
break;
|
|
||||||
case "Dark - White":
|
|
||||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorPrimary));
|
|
||||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorWhite));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
|
|
||||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dialogInterfaceCodeBlock.dismiss();
|
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
AlertDialog cDialog = cBuilder.create();
|
|
||||||
cDialog.show();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// time and date dialog
|
// time and date dialog
|
||||||
@ -292,36 +150,30 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||||||
AlertDialog.Builder tBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
AlertDialog.Builder tBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
||||||
|
|
||||||
tBuilder.setTitle(R.string.settingsTimeSelectorDialogTitle);
|
tBuilder.setTitle(R.string.settingsTimeSelectorDialogTitle);
|
||||||
if(timeSelectedChoice != -1) {
|
tBuilder.setCancelable(timeSelectedChoice != -1);
|
||||||
tBuilder.setCancelable(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
tBuilder.setSingleChoiceItems(timeList, timeSelectedChoice, (dialogInterfaceTime, i) -> {
|
tBuilder.setSingleChoiceItems(timeList, timeSelectedChoice, (dialogInterfaceTime, i) -> {
|
||||||
|
|
||||||
timeSelectedChoice = i;
|
timeSelectedChoice = i;
|
||||||
tvDateTimeSelected.setText(timeList[i]);
|
tvDateTimeSelected.setText(timeList[i]);
|
||||||
tinyDb.putString("timeStr", timeList[i]);
|
tinyDB.putString("timeStr", timeList[i]);
|
||||||
tinyDb.putInt("timeId", i);
|
tinyDB.putInt("timeId", i);
|
||||||
|
|
||||||
if("Normal".equals(timeList[i])) {
|
if("Normal".equals(timeList[i])) {
|
||||||
tinyDb.putString("dateFormat", "normal");
|
|
||||||
|
tinyDB.putString("dateFormat", "normal");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tinyDb.putString("dateFormat", "pretty");
|
|
||||||
|
tinyDB.putString("dateFormat", "pretty");
|
||||||
}
|
}
|
||||||
|
|
||||||
dialogInterfaceTime.dismiss();
|
dialogInterfaceTime.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AlertDialog tDialog = tBuilder.create();
|
AlertDialog tDialog = tBuilder.create();
|
||||||
tDialog.show();
|
tDialog.show();
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Switch;
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -15,7 +13,6 @@ import org.mian.gitnex.helpers.TinyDB;
|
|||||||
|
|
||||||
public class SettingsDraftsActivity extends BaseActivity {
|
public class SettingsDraftsActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,36 +25,21 @@ public class SettingsDraftsActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
Switch commentsDeletionSwitch = findViewById(R.id.commentsDeletionSwitch);
|
SwitchMaterial commentsDeletionSwitch = findViewById(R.id.commentsDeletionSwitch);
|
||||||
|
|
||||||
if(tinyDb.getBoolean("draftsCommentsDeletionEnabled")) {
|
commentsDeletionSwitch.setChecked(tinyDB.getBoolean("draftsCommentsDeletionEnabled"));
|
||||||
commentsDeletionSwitch.setChecked(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
commentsDeletionSwitch.setChecked(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete comments on submit switcher
|
// delete comments on submit switcher
|
||||||
commentsDeletionSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
commentsDeletionSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
if(isChecked) {
|
tinyDB.putBoolean("draftsCommentsDeletionEnabled", isChecked);
|
||||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", false);
|
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,10 +16,9 @@ import org.mian.gitnex.helpers.Toasty;
|
|||||||
|
|
||||||
public class SettingsFileViewerActivity extends BaseActivity {
|
public class SettingsFileViewerActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
private static String[] fileViewerSourceCodeThemesList = {"Sublime", "Arduino Light", "Github", "Far ", "Ir Black", "Android Studio"};
|
private static final String[] fileViewerSourceCodeThemesList = {"Sublime", "Arduino Light", "Github", "Far ", "Ir Black", "Android Studio"};
|
||||||
private static int fileViewerSourceCodeThemesSelectedChoice = 0;
|
private static int fileViewerSourceCodeThemesSelectedChoice = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,9 +31,6 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
@ -47,22 +41,17 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
|||||||
|
|
||||||
LinearLayout sourceCodeThemeFrame = findViewById(R.id.sourceCodeThemeFrame);
|
LinearLayout sourceCodeThemeFrame = findViewById(R.id.sourceCodeThemeFrame);
|
||||||
|
|
||||||
Switch pdfModeSwitch = findViewById(R.id.switchPdfMode);
|
SwitchMaterial pdfModeSwitch = findViewById(R.id.switchPdfMode);
|
||||||
|
|
||||||
if(!tinyDb.getString("fileviewerSourceCodeThemeStr").isEmpty()) {
|
if(!tinyDB.getString("fileviewerSourceCodeThemeStr").isEmpty()) {
|
||||||
fileViewerSourceCodeThemesSelected.setText(tinyDb.getString("fileviewerSourceCodeThemeStr"));
|
fileViewerSourceCodeThemesSelected.setText(tinyDB.getString("fileviewerSourceCodeThemeStr"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fileViewerSourceCodeThemesSelectedChoice == 0) {
|
if(fileViewerSourceCodeThemesSelectedChoice == 0) {
|
||||||
fileViewerSourceCodeThemesSelectedChoice = tinyDb.getInt("fileviewerThemeId");
|
fileViewerSourceCodeThemesSelectedChoice = tinyDB.getInt("fileviewerThemeId");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDb.getBoolean("enablePdfMode")) {
|
pdfModeSwitch.setChecked(tinyDB.getBoolean("enablePdfMode"));
|
||||||
pdfModeSwitch.setChecked(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pdfModeSwitch.setChecked(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fileviewer srouce code theme selection dialog
|
// fileviewer srouce code theme selection dialog
|
||||||
sourceCodeThemeFrame.setOnClickListener(view -> {
|
sourceCodeThemeFrame.setOnClickListener(view -> {
|
||||||
@ -70,19 +59,14 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
|||||||
AlertDialog.Builder fvtsBuilder = new AlertDialog.Builder(SettingsFileViewerActivity.this);
|
AlertDialog.Builder fvtsBuilder = new AlertDialog.Builder(SettingsFileViewerActivity.this);
|
||||||
|
|
||||||
fvtsBuilder.setTitle(R.string.fileviewerSourceCodeThemeSelectorDialogTitle);
|
fvtsBuilder.setTitle(R.string.fileviewerSourceCodeThemeSelectorDialogTitle);
|
||||||
if(fileViewerSourceCodeThemesSelectedChoice != -1) {
|
fvtsBuilder.setCancelable(fileViewerSourceCodeThemesSelectedChoice != -1);
|
||||||
fvtsBuilder.setCancelable(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fvtsBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
fvtsBuilder.setSingleChoiceItems(fileViewerSourceCodeThemesList, fileViewerSourceCodeThemesSelectedChoice, (dialogInterfaceTheme, i) -> {
|
fvtsBuilder.setSingleChoiceItems(fileViewerSourceCodeThemesList, fileViewerSourceCodeThemesSelectedChoice, (dialogInterfaceTheme, i) -> {
|
||||||
|
|
||||||
fileViewerSourceCodeThemesSelectedChoice = i;
|
fileViewerSourceCodeThemesSelectedChoice = i;
|
||||||
fileViewerSourceCodeThemesSelected.setText(fileViewerSourceCodeThemesList[i]);
|
fileViewerSourceCodeThemesSelected.setText(fileViewerSourceCodeThemesList[i]);
|
||||||
tinyDb.putString("fileviewerSourceCodeThemeStr", fileViewerSourceCodeThemesList[i]);
|
tinyDB.putString("fileviewerSourceCodeThemeStr", fileViewerSourceCodeThemesList[i]);
|
||||||
tinyDb.putInt("fileviewerSourceCodeThemeId", i);
|
tinyDB.putInt("fileviewerSourceCodeThemeId", i);
|
||||||
|
|
||||||
dialogInterfaceTheme.dismiss();
|
dialogInterfaceTheme.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
@ -91,25 +75,15 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
|||||||
|
|
||||||
AlertDialog cfDialog = fvtsBuilder.create();
|
AlertDialog cfDialog = fvtsBuilder.create();
|
||||||
cfDialog.show();
|
cfDialog.show();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// pdf night mode switcher
|
// pdf night mode switcher
|
||||||
pdfModeSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
pdfModeSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
if(isChecked) {
|
tinyDB.putBoolean("enablePdfMode", isChecked);
|
||||||
tinyDb.putBoolean("enablePdfMode", true);
|
tinyDB.putString("enablePdfModeInit", "yes");
|
||||||
tinyDb.putString("enablePdfModeInit", "yes");
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tinyDb.putBoolean("enablePdfMode", false);
|
|
||||||
tinyDb.putString("enablePdfModeInit", "yes");
|
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
@ -0,0 +1,176 @@
|
|||||||
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.databinding.ActivitySettingsGeneralBinding;
|
||||||
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.mian.gitnex.helpers.Version;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SettingsGeneralActivity extends BaseActivity {
|
||||||
|
|
||||||
|
private ActivitySettingsGeneralBinding viewBinding;
|
||||||
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
|
private List<String> homeScreenList;
|
||||||
|
private static int homeScreenSelectedChoice = 0;
|
||||||
|
|
||||||
|
private List<String> defaultScreen;
|
||||||
|
private static int defaultLinkHandlerScreenSelectedChoice = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutResourceId() {
|
||||||
|
|
||||||
|
return R.layout.activity_settings_general;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
viewBinding = ActivitySettingsGeneralBinding.inflate(getLayoutInflater());
|
||||||
|
View view = viewBinding.getRoot();
|
||||||
|
setContentView(view);
|
||||||
|
|
||||||
|
initCloseListener();
|
||||||
|
viewBinding.close.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
|
// home screen
|
||||||
|
String[] homeDefaultScreen_ = {getResources().getString(R.string.pageTitleMyRepos), getResources().getString(R.string.pageTitleStarredRepos), getResources().getString(R.string.pageTitleOrganizations),
|
||||||
|
getResources().getString(R.string.pageTitleRepositories), getResources().getString(R.string.pageTitleProfile), getResources().getString(R.string.pageTitleExplore),
|
||||||
|
getResources().getString(R.string.titleDrafts)};
|
||||||
|
|
||||||
|
String[] homeDefaultScreenNew = {getResources().getString(R.string.pageTitleMyRepos), getResources().getString(R.string.pageTitleStarredRepos), getResources().getString(R.string.pageTitleOrganizations),
|
||||||
|
getResources().getString(R.string.pageTitleRepositories), getResources().getString(R.string.pageTitleProfile), getResources().getString(R.string.pageTitleExplore),
|
||||||
|
getResources().getString(R.string.titleDrafts), getResources().getString(R.string.pageTitleNotifications)};
|
||||||
|
|
||||||
|
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||||
|
|
||||||
|
homeDefaultScreen_ = homeDefaultScreenNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
homeScreenList = new ArrayList<>(Arrays.asList(homeDefaultScreen_));
|
||||||
|
String[] homeScreenArray = new String[homeScreenList.size()];
|
||||||
|
homeScreenList.toArray(homeScreenArray);
|
||||||
|
|
||||||
|
if(homeScreenSelectedChoice == 0) {
|
||||||
|
|
||||||
|
homeScreenSelectedChoice = tinyDB.getInt("homeScreenId");
|
||||||
|
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(homeScreenSelectedChoice == 1) {
|
||||||
|
|
||||||
|
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||||
|
}
|
||||||
|
else if(homeScreenSelectedChoice == 2) {
|
||||||
|
|
||||||
|
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleOrganizations));
|
||||||
|
}
|
||||||
|
else if(homeScreenSelectedChoice == 3) {
|
||||||
|
|
||||||
|
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleRepositories));
|
||||||
|
}
|
||||||
|
else if(homeScreenSelectedChoice == 4) {
|
||||||
|
|
||||||
|
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleProfile));
|
||||||
|
}
|
||||||
|
else if(homeScreenSelectedChoice == 5) {
|
||||||
|
|
||||||
|
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleExplore));
|
||||||
|
}
|
||||||
|
else if(homeScreenSelectedChoice == 6) {
|
||||||
|
|
||||||
|
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.titleDrafts));
|
||||||
|
}
|
||||||
|
else if(homeScreenSelectedChoice == 7) {
|
||||||
|
|
||||||
|
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.pageTitleNotifications));
|
||||||
|
}
|
||||||
|
|
||||||
|
viewBinding.homeScreenFrame.setOnClickListener(setDefaultHomeScreen -> {
|
||||||
|
|
||||||
|
AlertDialog.Builder hsBuilder = new AlertDialog.Builder(SettingsGeneralActivity.this);
|
||||||
|
|
||||||
|
hsBuilder.setTitle(R.string.settingsHomeScreenSelectorDialogTitle);
|
||||||
|
hsBuilder.setCancelable(homeScreenSelectedChoice != -1);
|
||||||
|
|
||||||
|
hsBuilder.setSingleChoiceItems(homeScreenArray, homeScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
|
||||||
|
|
||||||
|
homeScreenSelectedChoice = i;
|
||||||
|
viewBinding.homeScreenSelected.setText(homeScreenArray[i]);
|
||||||
|
tinyDB.putInt("homeScreenId", i);
|
||||||
|
|
||||||
|
dialogInterfaceHomeScreen.dismiss();
|
||||||
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog hsDialog = hsBuilder.create();
|
||||||
|
hsDialog.show();
|
||||||
|
});
|
||||||
|
// home screen
|
||||||
|
|
||||||
|
// link handler
|
||||||
|
String[] defaultScreen_ = {getResources().getString(R.string.generalDeepLinkSelectedText), getResources().getString(R.string.navRepos), getResources().getString(R.string.navOrgs), getResources().getString(R.string.pageTitleNotifications), getResources().getString(R.string.navExplore)};
|
||||||
|
defaultScreen = new ArrayList<>(Arrays.asList(defaultScreen_));
|
||||||
|
|
||||||
|
String[] linksArray = new String[defaultScreen.size()];
|
||||||
|
defaultScreen.toArray(linksArray);
|
||||||
|
|
||||||
|
if(defaultLinkHandlerScreenSelectedChoice == 0) {
|
||||||
|
|
||||||
|
defaultLinkHandlerScreenSelectedChoice = tinyDB.getInt("defaultScreenId");
|
||||||
|
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.generalDeepLinkSelectedText));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(defaultLinkHandlerScreenSelectedChoice == 1) {
|
||||||
|
|
||||||
|
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.navRepos));
|
||||||
|
}
|
||||||
|
else if(defaultLinkHandlerScreenSelectedChoice == 2) {
|
||||||
|
|
||||||
|
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.navOrgs));
|
||||||
|
}
|
||||||
|
else if(defaultLinkHandlerScreenSelectedChoice == 3) {
|
||||||
|
|
||||||
|
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.pageTitleNotifications));
|
||||||
|
}
|
||||||
|
else if(defaultLinkHandlerScreenSelectedChoice == 4) {
|
||||||
|
|
||||||
|
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.navExplore));
|
||||||
|
}
|
||||||
|
|
||||||
|
viewBinding.setDefaultLinkHandler.setOnClickListener(setDefaultLinkHandler -> {
|
||||||
|
|
||||||
|
AlertDialog.Builder dlBuilder = new AlertDialog.Builder(SettingsGeneralActivity.this);
|
||||||
|
dlBuilder.setTitle(R.string.linkSelectorDialogTitle);
|
||||||
|
|
||||||
|
dlBuilder.setCancelable(defaultLinkHandlerScreenSelectedChoice != -1);
|
||||||
|
|
||||||
|
dlBuilder.setSingleChoiceItems(linksArray, defaultLinkHandlerScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
|
||||||
|
|
||||||
|
defaultLinkHandlerScreenSelectedChoice = i;
|
||||||
|
viewBinding.generalDeepLinkSelected.setText(linksArray[i]);
|
||||||
|
tinyDB.putInt("defaultScreenId", i);
|
||||||
|
|
||||||
|
dialogInterfaceHomeScreen.dismiss();
|
||||||
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog dlDialog = dlBuilder.create();
|
||||||
|
dlDialog.show();
|
||||||
|
});
|
||||||
|
// link handler
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initCloseListener() { onClickListener = view -> finish(); }
|
||||||
|
}
|
@ -0,0 +1,123 @@
|
|||||||
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.NumberPicker;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import com.pes.androidmaterialcolorpickerdialog.ColorPicker;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.databinding.ActivitySettingsNotificationsBinding;
|
||||||
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.mian.gitnex.notifications.NotificationsMaster;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template Author M M Arif
|
||||||
|
* Author opyale
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SettingsNotificationsActivity extends BaseActivity {
|
||||||
|
|
||||||
|
private ActivitySettingsNotificationsBinding viewBinding;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutResourceId() {
|
||||||
|
|
||||||
|
return R.layout.activity_settings_notifications;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
viewBinding = ActivitySettingsNotificationsBinding.inflate(getLayoutInflater());
|
||||||
|
View view = viewBinding.getRoot();
|
||||||
|
setContentView(view);
|
||||||
|
|
||||||
|
View.OnClickListener onClickListener = viewClose -> finish();
|
||||||
|
|
||||||
|
viewBinding.close.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
|
viewBinding.pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), tinyDB.getInt("pollingDelayMinutes", StaticGlobalVariables.defaultPollingDelay)));
|
||||||
|
viewBinding.chooseColorState.setCardBackgroundColor(tinyDB.getInt("notificationsLightColor", Color.GREEN));
|
||||||
|
|
||||||
|
viewBinding.enableNotificationsMode.setChecked(tinyDB.getBoolean("notificationsEnabled", true));
|
||||||
|
viewBinding.enableLightsMode.setChecked(tinyDB.getBoolean("notificationsEnableLights", true));
|
||||||
|
viewBinding.enableVibrationMode.setChecked(tinyDB.getBoolean("notificationsEnableVibration", true));
|
||||||
|
|
||||||
|
viewBinding.enableNotificationsMode.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
|
tinyDB.putBoolean("notificationsEnabled", isChecked);
|
||||||
|
if(!isChecked) NotificationsMaster.fireWorker(ctx);
|
||||||
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// polling delay
|
||||||
|
viewBinding.pollingDelayFrame.setOnClickListener(v -> {
|
||||||
|
|
||||||
|
NumberPicker numberPicker = new NumberPicker(ctx);
|
||||||
|
numberPicker.setMinValue(StaticGlobalVariables.minimumPollingDelay);
|
||||||
|
numberPicker.setMaxValue(StaticGlobalVariables.maximumPollingDelay);
|
||||||
|
numberPicker.setValue(tinyDB.getInt("pollingDelayMinutes", StaticGlobalVariables.defaultPollingDelay));
|
||||||
|
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);
|
||||||
|
|
||||||
|
viewBinding.pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), numberPicker.getValue()));
|
||||||
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
|
||||||
|
builder.setView(numberPicker);
|
||||||
|
builder.create().show();
|
||||||
|
});
|
||||||
|
|
||||||
|
// lights switcher
|
||||||
|
viewBinding.enableLightsMode.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
|
tinyDB.putBoolean("notificationsEnableLights", isChecked);
|
||||||
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// lights color chooser
|
||||||
|
viewBinding.chooseColorFrame.setOnClickListener(v -> {
|
||||||
|
|
||||||
|
ColorPicker colorPicker = new ColorPicker(SettingsNotificationsActivity.this);
|
||||||
|
colorPicker.setColor(tinyDB.getInt("notificationsLightColor", Color.GREEN));
|
||||||
|
colorPicker.setCallback(color -> {
|
||||||
|
|
||||||
|
tinyDB.putInt("notificationsLightColor", color);
|
||||||
|
viewBinding.chooseColorState.setCardBackgroundColor(color);
|
||||||
|
colorPicker.dismiss();
|
||||||
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
});
|
||||||
|
|
||||||
|
colorPicker.show();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// vibration switcher
|
||||||
|
viewBinding.enableVibrationMode.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
|
tinyDB.putBoolean("notificationsEnableVibration", isChecked);
|
||||||
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,10 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Switch;
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,7 +13,6 @@ import org.mian.gitnex.helpers.Toasty;
|
|||||||
|
|
||||||
public class SettingsReportsActivity extends BaseActivity {
|
public class SettingsReportsActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,38 +25,22 @@ public class SettingsReportsActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
initCloseListener();
|
initCloseListener();
|
||||||
closeActivity.setOnClickListener(onClickListener);
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
Switch crashReportsSwitch = findViewById(R.id.crashReportsSwitch);
|
SwitchMaterial crashReportsSwitch = findViewById(R.id.crashReportsSwitch);
|
||||||
|
|
||||||
if(tinyDb.getBoolean("crashReportingEnabled")) {
|
crashReportsSwitch.setChecked(tinyDB.getBoolean("crashReportingEnabled"));
|
||||||
crashReportsSwitch.setChecked(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
crashReportsSwitch.setChecked(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// crash reports switcher
|
// crash reports switcher
|
||||||
crashReportsSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
crashReportsSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
if(isChecked) {
|
tinyDB.putBoolean("crashReportingEnabled", isChecked);
|
||||||
tinyDb.putBoolean("crashReportingEnabled", true);
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tinyDb.putBoolean("crashReportingEnabled", false);
|
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
@ -7,16 +7,12 @@ import android.util.Log;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.NumberPicker;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.Version;
|
|
||||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||||
import org.mian.gitnex.notifications.NotificationsMaster;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -26,21 +22,14 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class SettingsSecurityActivity extends BaseActivity {
|
public class SettingsSecurityActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private Context ctx = this;
|
|
||||||
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
private static String[] cacheSizeDataList = {"50 MB", "100 MB", "250 MB", "500 MB", "1 GB"};
|
private static final String[] cacheSizeDataList = {"50 MB", "100 MB", "250 MB", "500 MB", "1 GB"};
|
||||||
private static int cacheSizeDataSelectedChoice = 0;
|
private static int cacheSizeDataSelectedChoice = 0;
|
||||||
|
|
||||||
private static String[] cacheSizeImagesList = {"50 MB", "100 MB", "250 MB", "500 MB", "1 GB"};
|
private static final String[] cacheSizeImagesList = {"50 MB", "100 MB", "250 MB", "500 MB", "1 GB"};
|
||||||
private static int cacheSizeImagesSelectedChoice = 0;
|
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
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
|
|
||||||
@ -51,10 +40,6 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
String currentVersion = tinyDb.getString("giteaVersion");
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
@ -64,36 +49,32 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
TextView cacheSizeDataSelected = findViewById(R.id.cacheSizeDataSelected); // setter for data cache size
|
TextView cacheSizeDataSelected = findViewById(R.id.cacheSizeDataSelected); // setter for data cache size
|
||||||
TextView cacheSizeImagesSelected = findViewById(R.id.cacheSizeImagesSelected); // setter for images cache size
|
TextView cacheSizeImagesSelected = findViewById(R.id.cacheSizeImagesSelected); // setter for images cache size
|
||||||
TextView clearCacheSelected = findViewById(R.id.clearCacheSelected); // setter for clear cache
|
TextView clearCacheSelected = findViewById(R.id.clearCacheSelected); // setter for clear cache
|
||||||
TextView pollingDelaySelected = findViewById(R.id.pollingDelaySelected);
|
|
||||||
|
|
||||||
LinearLayout certsFrame = findViewById(R.id.certsFrame);
|
LinearLayout certsFrame = findViewById(R.id.certsFrame);
|
||||||
LinearLayout pollingDelayFrame = findViewById(R.id.pollingDelayFrame);
|
|
||||||
LinearLayout cacheSizeDataFrame = findViewById(R.id.cacheSizeDataSelectionFrame);
|
LinearLayout cacheSizeDataFrame = findViewById(R.id.cacheSizeDataSelectionFrame);
|
||||||
LinearLayout cacheSizeImagesFrame = findViewById(R.id.cacheSizeImagesSelectionFrame);
|
LinearLayout cacheSizeImagesFrame = findViewById(R.id.cacheSizeImagesSelectionFrame);
|
||||||
LinearLayout clearCacheFrame = findViewById(R.id.clearCacheSelectionFrame);
|
LinearLayout clearCacheFrame = findViewById(R.id.clearCacheSelectionFrame);
|
||||||
|
|
||||||
if(!tinyDb.getString("cacheSizeStr").isEmpty()) {
|
if(!tinyDB.getString("cacheSizeStr").isEmpty()) {
|
||||||
cacheSizeDataSelected.setText(tinyDb.getString("cacheSizeStr"));
|
|
||||||
|
cacheSizeDataSelected.setText(tinyDB.getString("cacheSizeStr"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tinyDb.getString("cacheSizeImagesStr").isEmpty()) {
|
if(!tinyDB.getString("cacheSizeImagesStr").isEmpty()) {
|
||||||
cacheSizeImagesSelected.setText(tinyDb.getString("cacheSizeImagesStr"));
|
|
||||||
|
cacheSizeImagesSelected.setText(tinyDB.getString("cacheSizeImagesStr"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cacheSizeDataSelectedChoice == 0) {
|
if(cacheSizeDataSelectedChoice == 0) {
|
||||||
cacheSizeDataSelectedChoice = tinyDb.getInt("cacheSizeId");
|
|
||||||
|
cacheSizeDataSelectedChoice = tinyDB.getInt("cacheSizeId");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cacheSizeImagesSelectedChoice == 0) {
|
if(cacheSizeImagesSelectedChoice == 0) {
|
||||||
cacheSizeImagesSelectedChoice = tinyDb.getInt("cacheSizeImagesId");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(new Version(currentVersion).less("1.12.3")) {
|
cacheSizeImagesSelectedChoice = tinyDB.getInt("cacheSizeImagesId");
|
||||||
pollingDelayFrame.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), tinyDb.getInt("pollingDelayMinutes", DEFAULT_POLLING_DELAY)));
|
|
||||||
|
|
||||||
// clear cache setter
|
// clear cache setter
|
||||||
File cacheDir = appCtx.getCacheDir();
|
File cacheDir = appCtx.getCacheDir();
|
||||||
clearCacheSelected.setText(FileUtils.byteCountToDisplaySize((int) FileUtils.sizeOfDirectory(cacheDir)));
|
clearCacheSelected.setText(FileUtils.byteCountToDisplaySize((int) FileUtils.sizeOfDirectory(cacheDir)));
|
||||||
@ -113,14 +94,11 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
FileUtils.mkdir(cacheDir.getAbsolutePath());
|
FileUtils.mkdir(cacheDir.getAbsolutePath());
|
||||||
this.recreate();
|
this.recreate();
|
||||||
this.overridePendingTransition(0, 0);
|
this.overridePendingTransition(0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
|
|
||||||
Log.e("SettingsSecurity", e.toString());
|
Log.e("SettingsSecurity", e.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
|
builder.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
|
||||||
@ -134,28 +112,21 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(SettingsSecurityActivity.this);
|
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(SettingsSecurityActivity.this);
|
||||||
|
|
||||||
tsBuilder.setTitle(getResources().getString(R.string.cacheSizeImagesDialogHeader));
|
tsBuilder.setTitle(getResources().getString(R.string.cacheSizeImagesDialogHeader));
|
||||||
if(cacheSizeImagesSelectedChoice != -1) {
|
tsBuilder.setCancelable(cacheSizeImagesSelectedChoice != -1);
|
||||||
tsBuilder.setCancelable(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tsBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
tsBuilder.setSingleChoiceItems(cacheSizeImagesList, cacheSizeImagesSelectedChoice, (dialogInterfaceTheme, i) -> {
|
tsBuilder.setSingleChoiceItems(cacheSizeImagesList, cacheSizeImagesSelectedChoice, (dialogInterfaceTheme, i) -> {
|
||||||
|
|
||||||
cacheSizeImagesSelectedChoice = i;
|
cacheSizeImagesSelectedChoice = i;
|
||||||
cacheSizeImagesSelected.setText(cacheSizeImagesList[i]);
|
cacheSizeImagesSelected.setText(cacheSizeImagesList[i]);
|
||||||
tinyDb.putString("cacheSizeImagesStr", cacheSizeImagesList[i]);
|
tinyDB.putString("cacheSizeImagesStr", cacheSizeImagesList[i]);
|
||||||
tinyDb.putInt("cacheSizeImagesId", i);
|
tinyDB.putInt("cacheSizeImagesId", i);
|
||||||
|
|
||||||
dialogInterfaceTheme.dismiss();
|
dialogInterfaceTheme.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AlertDialog cfDialog = tsBuilder.create();
|
AlertDialog cfDialog = tsBuilder.create();
|
||||||
cfDialog.show();
|
cfDialog.show();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// cache size data selection dialog
|
// cache size data selection dialog
|
||||||
@ -164,28 +135,21 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(SettingsSecurityActivity.this);
|
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(SettingsSecurityActivity.this);
|
||||||
|
|
||||||
tsBuilder.setTitle(getResources().getString(R.string.cacheSizeDataDialogHeader));
|
tsBuilder.setTitle(getResources().getString(R.string.cacheSizeDataDialogHeader));
|
||||||
if(cacheSizeDataSelectedChoice != -1) {
|
tsBuilder.setCancelable(cacheSizeDataSelectedChoice != -1);
|
||||||
tsBuilder.setCancelable(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tsBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
tsBuilder.setSingleChoiceItems(cacheSizeDataList, cacheSizeDataSelectedChoice, (dialogInterfaceTheme, i) -> {
|
tsBuilder.setSingleChoiceItems(cacheSizeDataList, cacheSizeDataSelectedChoice, (dialogInterfaceTheme, i) -> {
|
||||||
|
|
||||||
cacheSizeDataSelectedChoice = i;
|
cacheSizeDataSelectedChoice = i;
|
||||||
cacheSizeDataSelected.setText(cacheSizeDataList[i]);
|
cacheSizeDataSelected.setText(cacheSizeDataList[i]);
|
||||||
tinyDb.putString("cacheSizeStr", cacheSizeDataList[i]);
|
tinyDB.putString("cacheSizeStr", cacheSizeDataList[i]);
|
||||||
tinyDb.putInt("cacheSizeId", i);
|
tinyDB.putInt("cacheSizeId", i);
|
||||||
|
|
||||||
dialogInterfaceTheme.dismiss();
|
dialogInterfaceTheme.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AlertDialog cfDialog = tsBuilder.create();
|
AlertDialog cfDialog = tsBuilder.create();
|
||||||
cfDialog.show();
|
cfDialog.show();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// certs deletion
|
// certs deletion
|
||||||
@ -199,53 +163,18 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||||||
|
|
||||||
appCtx.getSharedPreferences(MemorizingTrustManager.KEYSTORE_NAME, Context.MODE_PRIVATE).edit().remove(MemorizingTrustManager.KEYSTORE_KEY).apply();
|
appCtx.getSharedPreferences(MemorizingTrustManager.KEYSTORE_NAME, Context.MODE_PRIVATE).edit().remove(MemorizingTrustManager.KEYSTORE_KEY).apply();
|
||||||
|
|
||||||
tinyDb.putBoolean("loggedInMode", false);
|
tinyDB.putBoolean("loggedInMode", false);
|
||||||
tinyDb.remove("basicAuthPassword");
|
tinyDB.remove("basicAuthPassword");
|
||||||
tinyDb.putBoolean("basicAuthFlag", false);
|
tinyDB.putBoolean("basicAuthFlag", false);
|
||||||
|
|
||||||
Intent loginActivityIntent = new Intent().setClass(appCtx, LoginActivity.class);
|
Intent loginActivityIntent = new Intent().setClass(appCtx, LoginActivity.class);
|
||||||
loginActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
loginActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
appCtx.startActivity(loginActivityIntent);
|
appCtx.startActivity(loginActivityIntent);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
|
builder.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.setNeutralButton(R.string.cancelButton, null);
|
|
||||||
builder.setView(numberPicker);
|
|
||||||
builder.create().show();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -10,7 +9,6 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,7 +17,6 @@ import org.mian.gitnex.helpers.Toasty;
|
|||||||
|
|
||||||
public class SettingsTranslationActivity extends BaseActivity {
|
public class SettingsTranslationActivity extends BaseActivity {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
|
||||||
private static String[] langList = {"English", "Arabic", "Chinese", "Czech", "Finnish", "French", "German", "Italian", "Latvian", "Persian",
|
private static String[] langList = {"English", "Arabic", "Chinese", "Czech", "Finnish", "French", "German", "Italian", "Latvian", "Persian",
|
||||||
@ -36,9 +33,6 @@ public class SettingsTranslationActivity extends BaseActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
appCtx = getApplicationContext();
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(appCtx);
|
|
||||||
|
|
||||||
ImageView closeActivity = findViewById(R.id.close);
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
|
||||||
@ -60,12 +54,14 @@ public class SettingsTranslationActivity extends BaseActivity {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!tinyDb.getString("localeStr").isEmpty()) {
|
if(!tinyDB.getString("localeStr").isEmpty()) {
|
||||||
tvLanguageSelected.setText(tinyDb.getString("localeStr"));
|
|
||||||
|
tvLanguageSelected.setText(tinyDB.getString("localeStr"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(langSelectedChoice == 0) {
|
if(langSelectedChoice == 0) {
|
||||||
langSelectedChoice = tinyDb.getInt("langId");
|
|
||||||
|
langSelectedChoice = tinyDB.getInt("langId");
|
||||||
}
|
}
|
||||||
|
|
||||||
// language dialog
|
// language dialog
|
||||||
@ -74,89 +70,98 @@ public class SettingsTranslationActivity extends BaseActivity {
|
|||||||
AlertDialog.Builder lBuilder = new AlertDialog.Builder(SettingsTranslationActivity.this);
|
AlertDialog.Builder lBuilder = new AlertDialog.Builder(SettingsTranslationActivity.this);
|
||||||
|
|
||||||
lBuilder.setTitle(R.string.settingsLanguageSelectorDialogTitle);
|
lBuilder.setTitle(R.string.settingsLanguageSelectorDialogTitle);
|
||||||
if(langSelectedChoice != -1) {
|
lBuilder.setCancelable(langSelectedChoice != -1);
|
||||||
lBuilder.setCancelable(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lBuilder.setCancelable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
lBuilder.setSingleChoiceItems(langList, langSelectedChoice, (dialogInterface, i) -> {
|
lBuilder.setSingleChoiceItems(langList, langSelectedChoice, (dialogInterface, i) -> {
|
||||||
|
|
||||||
langSelectedChoice = i;
|
langSelectedChoice = i;
|
||||||
tvLanguageSelected.setText(langList[i]);
|
tvLanguageSelected.setText(langList[i]);
|
||||||
tinyDb.putString("localeStr", langList[i]);
|
tinyDB.putString("localeStr", langList[i]);
|
||||||
tinyDb.putInt("langId", i);
|
tinyDB.putInt("langId", i);
|
||||||
|
|
||||||
switch(langList[i]) {
|
switch(langList[i]) {
|
||||||
case "Arabic":
|
case "Arabic":
|
||||||
tinyDb.putString("locale", "ar");
|
|
||||||
|
tinyDB.putString("locale", "ar");
|
||||||
break;
|
break;
|
||||||
case "Chinese":
|
case "Chinese":
|
||||||
tinyDb.putString("locale", "zh");
|
|
||||||
|
tinyDB.putString("locale", "zh");
|
||||||
break;
|
break;
|
||||||
case "Czech":
|
case "Czech":
|
||||||
tinyDb.putString("locale", "cs");
|
|
||||||
|
tinyDB.putString("locale", "cs");
|
||||||
break;
|
break;
|
||||||
case "Finnish":
|
case "Finnish":
|
||||||
tinyDb.putString("locale", "fi");
|
|
||||||
|
tinyDB.putString("locale", "fi");
|
||||||
break;
|
break;
|
||||||
case "French":
|
case "French":
|
||||||
tinyDb.putString("locale", "fr");
|
|
||||||
|
tinyDB.putString("locale", "fr");
|
||||||
break;
|
break;
|
||||||
case "German":
|
case "German":
|
||||||
tinyDb.putString("locale", "de");
|
|
||||||
|
tinyDB.putString("locale", "de");
|
||||||
break;
|
break;
|
||||||
case "Italian":
|
case "Italian":
|
||||||
tinyDb.putString("locale", "it");
|
|
||||||
|
tinyDB.putString("locale", "it");
|
||||||
break;
|
break;
|
||||||
case "Latvian":
|
case "Latvian":
|
||||||
tinyDb.putString("locale", "lv");
|
|
||||||
|
tinyDB.putString("locale", "lv");
|
||||||
break;
|
break;
|
||||||
case "Persian":
|
case "Persian":
|
||||||
tinyDb.putString("locale", "fa");
|
|
||||||
|
tinyDB.putString("locale", "fa");
|
||||||
break;
|
break;
|
||||||
case "Polish":
|
case "Polish":
|
||||||
tinyDb.putString("locale", "pl");
|
|
||||||
|
tinyDB.putString("locale", "pl");
|
||||||
break;
|
break;
|
||||||
case "Portuguese/Brazilian":
|
case "Portuguese/Brazilian":
|
||||||
tinyDb.putString("locale", "pt");
|
|
||||||
|
tinyDB.putString("locale", "pt");
|
||||||
break;
|
break;
|
||||||
case "Russian":
|
case "Russian":
|
||||||
tinyDb.putString("locale", "ru");
|
|
||||||
|
tinyDB.putString("locale", "ru");
|
||||||
break;
|
break;
|
||||||
case "Serbian":
|
case "Serbian":
|
||||||
tinyDb.putString("locale", "sr");
|
|
||||||
|
tinyDB.putString("locale", "sr");
|
||||||
break;
|
break;
|
||||||
case "Spanish":
|
case "Spanish":
|
||||||
tinyDb.putString("locale", "es");
|
|
||||||
|
tinyDB.putString("locale", "es");
|
||||||
break;
|
break;
|
||||||
case "Turkish":
|
case "Turkish":
|
||||||
tinyDb.putString("locale", "tr");
|
|
||||||
|
tinyDB.putString("locale", "tr");
|
||||||
break;
|
break;
|
||||||
case "Ukrainian":
|
case "Ukrainian":
|
||||||
tinyDb.putString("locale", "uk");
|
|
||||||
|
tinyDB.putString("locale", "uk");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tinyDb.putString("locale", "en");
|
|
||||||
|
tinyDB.putString("locale", "en");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putBoolean("refreshParent", true);
|
tinyDB.putBoolean("refreshParent", true);
|
||||||
this.recreate();
|
this.recreate();
|
||||||
this.overridePendingTransition(0, 0);
|
this.overridePendingTransition(0, 0);
|
||||||
dialogInterface.dismiss();
|
dialogInterface.dismiss();
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
lBuilder.setNeutralButton(getString(R.string.cancelButton), null);
|
lBuilder.setNeutralButton(getString(R.string.cancelButton), null);
|
||||||
|
|
||||||
AlertDialog lDialog = lBuilder.create();
|
AlertDialog lDialog = lBuilder.create();
|
||||||
lDialog.show();
|
lDialog.show();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCloseListener() {
|
private void initCloseListener() {
|
||||||
|
@ -50,12 +50,13 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||||||
private ImageView assigneesAvatar;
|
private ImageView assigneesAvatar;
|
||||||
|
|
||||||
private AssigneesViewHolder(View itemView) {
|
private AssigneesViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
this.setIsRecyclable(false);
|
||||||
|
|
||||||
assigneesSelection = itemView.findViewById(R.id.assigneesSelection);
|
assigneesSelection = itemView.findViewById(R.id.assigneesSelection);
|
||||||
assigneesName = itemView.findViewById(R.id.assigneesName);
|
assigneesName = itemView.findViewById(R.id.assigneesName);
|
||||||
assigneesAvatar = itemView.findViewById(R.id.assigneesAvatar);
|
assigneesAvatar = itemView.findViewById(R.id.assigneesAvatar);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,9 +74,11 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||||||
Collaborators currentItem = assigneesList.get(position);
|
Collaborators currentItem = assigneesList.get(position);
|
||||||
|
|
||||||
if(currentItem.getFull_name().equals("")) {
|
if(currentItem.getFull_name().equals("")) {
|
||||||
|
|
||||||
holder.assigneesName.setText(currentItem.getLogin());
|
holder.assigneesName.setText(currentItem.getLogin());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
holder.assigneesName.setText(currentItem.getFull_name());
|
holder.assigneesName.setText(currentItem.getFull_name());
|
||||||
}
|
}
|
||||||
PicassoService
|
PicassoService
|
||||||
@ -90,6 +93,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentAssignees = new ArrayList<>(new LinkedHashSet<>(currentAssignees));
|
currentAssignees = new ArrayList<>(new LinkedHashSet<>(currentAssignees));
|
||||||
|
|
||||||
for(int i = 0; i < currentAssignees.size(); i++) {
|
for(int i = 0; i < currentAssignees.size(); i++) {
|
||||||
|
|
||||||
if(currentAssignees.contains(currentItem.getLogin())) {
|
if(currentAssignees.contains(currentItem.getLogin())) {
|
||||||
@ -98,6 +102,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||||||
assigneesStrings.add(currentAssignees.get(i));
|
assigneesStrings.add(currentAssignees.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assigneesListener.assigneesInterface(assigneesStrings);
|
assigneesListener.assigneesInterface(assigneesStrings);
|
||||||
|
|
||||||
holder.assigneesSelection.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
holder.assigneesSelection.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
@ -119,6 +124,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
||||||
return assigneesList.size();
|
return assigneesList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(Commits commitsModel) {
|
void bindData(Commits commitsModel) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(ctx);
|
final TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.adapters;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
@ -14,9 +15,11 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||||
import org.mian.gitnex.database.api.DraftsApi;
|
import org.mian.gitnex.database.api.DraftsApi;
|
||||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||||
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -28,21 +31,16 @@ import java.util.List;
|
|||||||
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
||||||
|
|
||||||
private List<DraftWithRepository> draftsList;
|
private List<DraftWithRepository> draftsList;
|
||||||
private FragmentManager fragmentManager;
|
private final FragmentManager fragmentManager;
|
||||||
private Context mCtx;
|
private final Context mCtx;
|
||||||
|
|
||||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView draftText;
|
private DraftWithRepository draftWithRepository;
|
||||||
private TextView repoInfo;
|
|
||||||
private TextView repoId;
|
private final TextView draftText;
|
||||||
private TextView draftId;
|
private final TextView repoInfo;
|
||||||
private TextView issueNumber;
|
private final ImageView editCommentStatus;
|
||||||
private TextView issueType;
|
|
||||||
private TextView repoOwner;
|
|
||||||
private TextView repoName;
|
|
||||||
private TextView commentId;
|
|
||||||
private ImageView editCommentStatus;
|
|
||||||
|
|
||||||
private DraftsViewHolder(View itemView) {
|
private DraftsViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -50,19 +48,12 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
|
|
||||||
draftText = itemView.findViewById(R.id.draftText);
|
draftText = itemView.findViewById(R.id.draftText);
|
||||||
repoInfo = itemView.findViewById(R.id.repoInfo);
|
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);
|
|
||||||
commentId = itemView.findViewById(R.id.commentId);
|
|
||||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||||
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
||||||
|
|
||||||
deleteDraft.setOnClickListener(itemDelete -> {
|
deleteDraft.setOnClickListener(itemDelete -> {
|
||||||
|
|
||||||
int getDraftId = Integer.parseInt(draftId.getText().toString());
|
int getDraftId = draftWithRepository.getDraftId();
|
||||||
deleteDraft(getAdapterPosition());
|
deleteDraft(getAdapterPosition());
|
||||||
DraftsApi draftsApi = new DraftsApi(mCtx);
|
DraftsApi draftsApi = new DraftsApi(mCtx);
|
||||||
draftsApi.deleteSingleDraft(getDraftId);
|
draftsApi.deleteSingleDraft(getDraftId);
|
||||||
@ -73,23 +64,26 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
bundle.putString("commentBody", draftText.getText().toString());
|
bundle.putString("commentBody", draftWithRepository.getDraftText());
|
||||||
bundle.putString("issueNumber", issueNumber.getText().toString());
|
bundle.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||||
bundle.putString("repositoryId", repoId.getText().toString());
|
bundle.putString("repositoryId", String.valueOf(draftWithRepository.getRepositoryId()));
|
||||||
bundle.putString("draftTitle", repoInfo.getText().toString());
|
bundle.putString("draftTitle", repoInfo.getText().toString());
|
||||||
bundle.putString("commentId", commentId.getText().toString());
|
bundle.putString("commentId", draftWithRepository.getCommentId());
|
||||||
bundle.putString("draftId", draftId.getText().toString());
|
bundle.putString("draftId", String.valueOf(draftWithRepository.getDraftId()));
|
||||||
|
|
||||||
if(!commentId.getText().toString().isEmpty()) {
|
if(!draftWithRepository.getCommentId().isEmpty()) {
|
||||||
bundle.putString("commentAction", "edit");
|
bundle.putString("commentAction", "edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(mCtx);
|
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||||
tinyDb.putLong("repositoryId", Long.parseLong(repoId.getText().toString()));
|
tinyDb.putLong("repositoryId", draftWithRepository.getRepositoryId());
|
||||||
//tinyDb.putString("issueType", issueType.getText().toString());
|
tinyDb.putString("issueType", draftWithRepository.getIssueType());
|
||||||
|
tinyDb.putString("repoFullName", draftWithRepository.getRepositoryOwner() + "/" + draftWithRepository.getRepositoryName());
|
||||||
|
|
||||||
BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet");
|
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle);
|
||||||
|
bottomSheetReplyFragment.setOnInteractedListener(() -> mCtx.startActivity(new Intent(mCtx, IssueDetailActivity.class)));
|
||||||
|
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -125,18 +119,13 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
|
|
||||||
DraftWithRepository currentItem = draftsList.get(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());
|
|
||||||
holder.commentId.setText(currentItem.getCommentId());
|
|
||||||
|
|
||||||
String issueNumber = "<font color='" + mCtx.getResources().getColor(R.color.lightGray) + "'>" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
String issueNumber = "<font color='" + mCtx.getResources().getColor(R.color.lightGray) + "'>" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||||
Spanned headTitle = Html.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName());
|
Spanned headTitle = Html.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName());
|
||||||
|
|
||||||
holder.repoInfo.setText(headTitle);
|
holder.repoInfo.setText(headTitle);
|
||||||
|
holder.draftWithRepository = currentItem;
|
||||||
|
|
||||||
|
new Markdown(mCtx, currentItem.getDraftText(), holder.draftText);
|
||||||
|
|
||||||
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
||||||
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
||||||
@ -144,7 +133,6 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
else {
|
else {
|
||||||
holder.editCommentStatus.setVisibility(View.GONE);
|
holder.editCommentStatus.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -157,6 +145,4 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
draftsList = list;
|
draftsList = list;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
@ -128,14 +128,13 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchInfo watch = new WatchInfo();
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
Call<WatchInfo> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<WatchInfo>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -15,8 +15,9 @@ import android.widget.TextView;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||||
import org.mian.gitnex.helpers.DiffTextView;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.models.FileDiffView;
|
import org.mian.gitnex.models.FileDiffView;
|
||||||
|
import org.mian.gitnex.views.DiffTextView;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
@ -36,9 +37,9 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
private static int COLOR_SELECTED;
|
private static int COLOR_SELECTED;
|
||||||
private static int COLOR_FONT;
|
private static int COLOR_FONT;
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
private FragmentManager fragmentManager;
|
private final FragmentManager fragmentManager;
|
||||||
private List<FileDiffView> fileDiffViews;
|
private final List<FileDiffView> fileDiffViews;
|
||||||
|
|
||||||
public FilesDiffAdapter(Context context, FragmentManager fragmentManager, List<FileDiffView> fileDiffViews) {
|
public FilesDiffAdapter(Context context, FragmentManager fragmentManager, List<FileDiffView> fileDiffViews) {
|
||||||
|
|
||||||
@ -48,11 +49,11 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
selectedViews = new ConcurrentSkipListMap<>();
|
selectedViews = new ConcurrentSkipListMap<>();
|
||||||
|
|
||||||
COLOR_ADDED = getColorFromAttribute(R.attr.diffAddedColor);
|
COLOR_ADDED = AppUtil.getColorFromAttribute(context, R.attr.diffAddedColor);
|
||||||
COLOR_REMOVED = getColorFromAttribute(R.attr.diffRemovedColor);
|
COLOR_REMOVED = AppUtil.getColorFromAttribute(context, R.attr.diffRemovedColor);
|
||||||
COLOR_NORMAL = getColorFromAttribute(R.attr.primaryBackgroundColor);
|
COLOR_NORMAL = AppUtil.getColorFromAttribute(context, R.attr.primaryBackgroundColor);
|
||||||
COLOR_SELECTED = getColorFromAttribute(R.attr.diffSelectedColor);
|
COLOR_SELECTED = AppUtil.getColorFromAttribute(context, R.attr.diffSelectedColor);
|
||||||
COLOR_FONT = getColorFromAttribute(R.attr.inputTextColor);
|
COLOR_FONT = AppUtil.getColorFromAttribute(context, R.attr.inputTextColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +186,6 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
diffTextView.setOnLongClickListener(v -> {
|
diffTextView.setOnLongClickListener(v -> {
|
||||||
|
|
||||||
if(((DiffTextView) v).getCurrentBackgroundColor() == COLOR_SELECTED) {
|
if(((DiffTextView) v).getCurrentBackgroundColor() == COLOR_SELECTED) {
|
||||||
@ -257,13 +257,4 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getColorFromAttribute(int resid) {
|
|
||||||
|
|
||||||
TypedValue typedValue = new TypedValue();
|
|
||||||
context.getTheme().resolveAttribute(resid, typedValue, true);
|
|
||||||
|
|
||||||
return typedValue.data;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,12 @@ import android.content.ClipData;
|
|||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spanned;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
@ -25,33 +23,18 @@ import org.mian.gitnex.clients.PicassoService;
|
|||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.ClickListener;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.helpers.UserMentions;
|
|
||||||
import org.mian.gitnex.models.IssueComments;
|
import org.mian.gitnex.models.IssueComments;
|
||||||
import java.util.Collection;
|
import org.mian.gitnex.views.ReactionList;
|
||||||
import java.util.Collections;
|
import org.mian.gitnex.views.ReactionSpinner;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
|
||||||
import io.noties.markwon.Markwon;
|
|
||||||
import io.noties.markwon.core.CorePlugin;
|
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
|
||||||
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.DefaultMediaDecoder;
|
|
||||||
import io.noties.markwon.image.ImageItem;
|
|
||||||
import io.noties.markwon.image.ImagesPlugin;
|
|
||||||
import io.noties.markwon.image.SchemeHandler;
|
|
||||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
|
||||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -61,94 +44,115 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> {
|
public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> {
|
||||||
|
|
||||||
private List<IssueComments> issuesComments;
|
private final Context ctx;
|
||||||
private FragmentManager fragmentManager;
|
private final TinyDB tinyDB;
|
||||||
private Context mCtx;
|
private final Bundle bundle;
|
||||||
|
private final List<IssueComments> issuesComments;
|
||||||
|
private final FragmentManager fragmentManager;
|
||||||
|
private final BottomSheetReplyFragment.OnInteractedListener onInteractedListener;
|
||||||
|
|
||||||
public IssueCommentsAdapter(Context mCtx, FragmentManager fragmentManager, List<IssueComments> issuesCommentsMain) {
|
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, BottomSheetReplyFragment.OnInteractedListener onInteractedListener) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.ctx = ctx;
|
||||||
this.fragmentManager = fragmentManager;
|
this.bundle = bundle;
|
||||||
this.issuesComments = issuesCommentsMain;
|
this.issuesComments = issuesCommentsMain;
|
||||||
|
this.fragmentManager = fragmentManager;
|
||||||
|
this.onInteractedListener = onInteractedListener;
|
||||||
|
|
||||||
|
tinyDB = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView issueNumber;
|
private IssueComments issueComment;
|
||||||
private TextView commendId;
|
|
||||||
private ImageView issueCommenterAvatar;
|
|
||||||
private TextView issueComment;
|
|
||||||
private TextView issueCommentDate;
|
|
||||||
private TextView commendBodyRaw;
|
|
||||||
private TextView commentModified;
|
|
||||||
private TextView commenterUsername;
|
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private IssueCommentViewHolder(View itemView) {
|
private final ImageView avatar;
|
||||||
|
private final TextView author;
|
||||||
|
private final TextView information;
|
||||||
|
private final TextView comment;
|
||||||
|
private final LinearLayout commentReactionBadges;
|
||||||
|
|
||||||
super(itemView);
|
private IssueCommentViewHolder(View view) {
|
||||||
|
|
||||||
issueNumber = itemView.findViewById(R.id.issueNumber);
|
super(view);
|
||||||
commendId = itemView.findViewById(R.id.commendId);
|
|
||||||
issueCommenterAvatar = itemView.findViewById(R.id.issueCommenterAvatar);
|
|
||||||
issueComment = itemView.findViewById(R.id.issueComment);
|
|
||||||
issueCommentDate = itemView.findViewById(R.id.issueCommentDate);
|
|
||||||
ImageView commentsOptionsMenu = itemView.findViewById(R.id.commentsOptionsMenu);
|
|
||||||
commendBodyRaw = itemView.findViewById(R.id.commendBodyRaw);
|
|
||||||
commentModified = itemView.findViewById(R.id.commentModified);
|
|
||||||
commenterUsername = itemView.findViewById(R.id.commenterUsername);
|
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
|
||||||
|
|
||||||
commentsOptionsMenu.setOnClickListener(v -> {
|
avatar = view.findViewById(R.id.avatar);
|
||||||
|
author = view.findViewById(R.id.author);
|
||||||
|
information = view.findViewById(R.id.information);
|
||||||
|
ImageView menu = view.findViewById(R.id.menu);
|
||||||
|
comment = view.findViewById(R.id.comment);
|
||||||
|
commentReactionBadges = view.findViewById(R.id.commentReactionBadges);
|
||||||
|
|
||||||
|
menu.setOnClickListener(v -> {
|
||||||
|
|
||||||
final Context ctx = v.getContext();
|
final Context ctx = v.getContext();
|
||||||
final TinyDB tinyDb = new TinyDB(ctx);
|
final String loginUid = tinyDB.getString("loginUid");
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
|
||||||
|
|
||||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_issue_comments, null);
|
@SuppressLint("InflateParams") View vw = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_issue_comments, null);
|
||||||
|
|
||||||
TextView commentMenuEdit = view.findViewById(R.id.commentMenuEdit);
|
TextView commentMenuEdit = vw.findViewById(R.id.commentMenuEdit);
|
||||||
TextView commentShare = view.findViewById(R.id.issueCommentShare);
|
TextView commentShare = vw.findViewById(R.id.issueCommentShare);
|
||||||
TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote);
|
TextView commentMenuQuote = vw.findViewById(R.id.commentMenuQuote);
|
||||||
TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy);
|
TextView commentMenuCopy = vw.findViewById(R.id.commentMenuCopy);
|
||||||
TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete);
|
TextView commentMenuDelete = vw.findViewById(R.id.commentMenuDelete);
|
||||||
TextView issueCommentCopyUrl = view.findViewById(R.id.issueCommentCopyUrl);
|
TextView issueCommentCopyUrl = vw.findViewById(R.id.issueCommentCopyUrl);
|
||||||
|
|
||||||
if(!loginUid.contentEquals(commenterUsername.getText())) {
|
if(!loginUid.contentEquals(issueComment.getUser().getUsername())) {
|
||||||
commentMenuEdit.setVisibility(View.GONE);
|
commentMenuEdit.setVisibility(View.GONE);
|
||||||
commentMenuDelete.setVisibility(View.GONE);
|
commentMenuDelete.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(issueComment.getText().toString().isEmpty()) {
|
if(issueComment.getBody().isEmpty()) {
|
||||||
commentMenuCopy.setVisibility(View.GONE);
|
commentMenuCopy.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(ctx);
|
BottomSheetDialog dialog = new BottomSheetDialog(ctx);
|
||||||
dialog.setContentView(view);
|
dialog.setContentView(vw);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
commentMenuEdit.setOnClickListener(ediComment -> {
|
LinearLayout linearLayout = vw.findViewById(R.id.commentReactionButtons);
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle1 = new Bundle();
|
||||||
bundle.putString("commentId", commendId.getText().toString());
|
bundle1.putAll(bundle);
|
||||||
bundle.putString("commentAction", "edit");
|
bundle1.putInt("commentId", issueComment.getId());
|
||||||
bundle.putString("commentBody", commendBodyRaw.getText().toString());
|
|
||||||
|
|
||||||
BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet");
|
ReactionSpinner reactionSpinner = new ReactionSpinner(ctx, bundle1);
|
||||||
|
reactionSpinner.setOnInteractedListener(() -> {
|
||||||
|
|
||||||
|
tinyDB.putBoolean("commentEdited", true);
|
||||||
|
|
||||||
|
onInteractedListener.onInteracted();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
commentShare.setOnClickListener(ediComment -> {
|
linearLayout.addView(reactionSpinner);
|
||||||
|
|
||||||
|
commentMenuEdit.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt("commentId", issueComment.getId());
|
||||||
|
bundle.putString("commentAction", "edit");
|
||||||
|
bundle.putString("commentBody", issueComment.getBody());
|
||||||
|
|
||||||
|
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle);
|
||||||
|
bottomSheetReplyFragment.setOnInteractedListener(onInteractedListener);
|
||||||
|
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||||
|
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
commentShare.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
// get comment Url
|
// get comment Url
|
||||||
CharSequence commentUrl = htmlUrl.getText();
|
CharSequence commentUrl = issueComment.getHtml_url();
|
||||||
|
|
||||||
// share issue comment
|
// share issue comment
|
||||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||||
sharingIntent.setType("text/plain");
|
sharingIntent.setType("text/plain");
|
||||||
String intentHeader = tinyDb.getString("issueNumber") + ctx.getResources().getString(R.string.hash) + "issuecomment-" + commendId.getText() + " " + tinyDb.getString("issueTitle");
|
String intentHeader = tinyDB.getString("issueNumber") + ctx.getResources().getString(R.string.hash) + "issuecomment-" + issueComment.getId() + " " + tinyDB.getString("issueTitle");
|
||||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, intentHeader);
|
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, intentHeader);
|
||||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, commentUrl);
|
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, commentUrl);
|
||||||
ctx.startActivity(Intent.createChooser(sharingIntent, intentHeader));
|
ctx.startActivity(Intent.createChooser(sharingIntent, intentHeader));
|
||||||
@ -157,10 +161,10 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
issueCommentCopyUrl.setOnClickListener(ediComment -> {
|
issueCommentCopyUrl.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
// comment Url
|
// comment Url
|
||||||
CharSequence commentUrl = htmlUrl.getText();
|
CharSequence commentUrl = issueComment.getHtml_url();
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
assert clipboard != null;
|
assert clipboard != null;
|
||||||
@ -176,14 +180,14 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
commentMenuQuote.setOnClickListener(v1 -> {
|
commentMenuQuote.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
String commenterName = commenterUsername.getText().toString();
|
String commenterName = issueComment.getUser().getUsername();
|
||||||
|
|
||||||
if(!commenterName.equals(tinyDb.getString("userLogin"))) {
|
if(!commenterName.equals(tinyDB.getString("userLogin"))) {
|
||||||
|
|
||||||
stringBuilder.append("@").append(commenterName).append("\n\n");
|
stringBuilder.append("@").append(commenterName).append("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] lines = commendBodyRaw.getText().toString().split("\\R");
|
String[] lines = issueComment.getBody().split("\\R");
|
||||||
|
|
||||||
for(String line : lines) {
|
for(String line : lines) {
|
||||||
|
|
||||||
@ -201,12 +205,12 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
commentMenuCopy.setOnClickListener(view1 -> {
|
commentMenuCopy.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
assert clipboard != null;
|
assert clipboard != null;
|
||||||
|
|
||||||
ClipData clip = ClipData.newPlainText("Comment on issue #" + issueNumber.getText().toString(), issueComment.getText().toString());
|
ClipData clip = ClipData.newPlainText("Comment on issue #" + tinyDB.getString("issueNumber"), issueComment.getBody());
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
@ -214,9 +218,9 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
commentMenuDelete.setOnClickListener(deleteComment -> {
|
commentMenuDelete.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
deleteIssueComment(ctx, Integer.parseInt(commendId.getText().toString()), getAdapterPosition());
|
deleteIssueComment(ctx, issueComment.getId(), getAdapterPosition());
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -237,22 +241,19 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
|
|
||||||
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(ctx);
|
final String loginUid = tinyDB.getString("loginUid");
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
final String instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
String[] repoFullName = tinyDb.getString("repoFullName").split("/");
|
|
||||||
if (repoFullName.length != 2) {
|
if (repoFullName.length != 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String repoOwner = repoFullName[0];
|
final String repoOwner = repoFullName[0];
|
||||||
final String repoName = repoFullName[1];
|
final String repoName = repoFullName[1];
|
||||||
|
|
||||||
Call<JsonElement> call;
|
Call<JsonElement> call = RetrofitClient
|
||||||
|
.getApiInterface(ctx)
|
||||||
call = RetrofitClient
|
|
||||||
.getInstance(instanceUrl, ctx)
|
|
||||||
.getApiInterface()
|
|
||||||
.deleteComment(instanceToken, repoOwner, repoName, commentId);
|
.deleteComment(instanceToken, repoOwner, repoName, commentId);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonElement>() {
|
call.enqueue(new Callback<JsonElement>() {
|
||||||
@ -260,47 +261,40 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||||
|
|
||||||
if(response.code() == 204) {
|
switch(response.code()) {
|
||||||
|
|
||||||
updateAdapter(position);
|
case 204:
|
||||||
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
updateAdapter(position);
|
||||||
|
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
case 401:
|
||||||
else if(response.code() == 401) {
|
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||||
|
|
||||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
|
||||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 403:
|
||||||
|
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 404:
|
||||||
|
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(response.code() == 403) {
|
|
||||||
|
|
||||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(response.code() == 404) {
|
|
||||||
|
|
||||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -311,109 +305,70 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
|
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
String timeFormat = tinyDB.getString("dateFormat");
|
||||||
final String locale = tinyDb.getString("locale");
|
IssueComments issueComment = issuesComments.get(position);
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
|
||||||
|
|
||||||
IssueComments currentItem = issuesComments.get(position);
|
holder.issueComment = issueComment;
|
||||||
|
holder.author.setText(issueComment.getUser().getUsername());
|
||||||
|
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
PicassoService.getInstance(ctx).get()
|
||||||
holder.commenterUsername.setText(currentItem.getUser().getUsername());
|
.load(issueComment.getUser().getAvatar_url())
|
||||||
holder.commendId.setText(String.valueOf(currentItem.getId()));
|
.placeholder(R.drawable.loader_animated)
|
||||||
holder.commendBodyRaw.setText(currentItem.getBody());
|
.transform(new RoundedTransformation(4, 0))
|
||||||
|
.resize(AppUtil.getPixelsFromDensity(ctx, 35), AppUtil.getPixelsFromDensity(ctx, 35))
|
||||||
|
.centerCrop()
|
||||||
|
.into(holder.avatar);
|
||||||
|
|
||||||
if(!currentItem.getUser().getFull_name().equals("")) {
|
new Markdown(ctx, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment);
|
||||||
holder.issueCommenterAvatar.setOnClickListener(new ClickListener(mCtx.getResources().getString(R.string.issueCommenter) + currentItem.getUser().getFull_name(), mCtx));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.issueCommenterAvatar.setOnClickListener(new ClickListener(mCtx.getResources().getString(R.string.issueCommenter) + currentItem.getUser().getLogin(), mCtx));
|
|
||||||
}
|
|
||||||
|
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getUser().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.issueCommenterAvatar);
|
StringBuilder informationBuilder = null;
|
||||||
|
if(issueComment.getCreated_at() != null) {
|
||||||
|
|
||||||
String cleanIssueComments = currentItem.getBody().trim();
|
if(timeFormat.equals("pretty")) {
|
||||||
|
|
||||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(mCtx)).usePlugin(CorePlugin.create()).usePlugin(ImagesPlugin.create(new ImagesPlugin.ImagesConfigure() {
|
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "pretty", ctx));
|
||||||
|
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreated_at()));
|
||||||
@Override
|
|
||||||
public void configureImages(@NonNull ImagesPlugin 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 Drawable drawable = mCtx.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(mCtx.getResources()));
|
|
||||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
|
||||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(mCtx.getResources()));
|
|
||||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})).usePlugin(new AbstractMarkwonPlugin() {
|
else if(timeFormat.equals("normal")) {
|
||||||
|
|
||||||
@Override
|
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "normal", ctx));
|
||||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
|
||||||
|
|
||||||
builder.codeTextColor(tinyDb.getInt("codeBlockColor")).codeBackgroundColor(tinyDb.getInt("codeBlockBackground")).linkColor(mCtx.getResources().getColor(R.color.lightBlue));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}).usePlugin(TablePlugin.create(mCtx)).usePlugin(TaskListPlugin.create(mCtx)).usePlugin(HtmlPlugin.create()).usePlugin(StrikethroughPlugin.create()).usePlugin(LinkifyPlugin.create()).build();
|
if(!issueComment.getCreated_at().equals(issueComment.getUpdated_at())) {
|
||||||
|
|
||||||
Spanned bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(cleanIssueComments));
|
if(informationBuilder != null) {
|
||||||
markwon.setParsedMarkdown(holder.issueComment, UserMentions.UserMentionsFunc(mCtx, bodyWithMD, cleanIssueComments));
|
|
||||||
|
|
||||||
String edited;
|
|
||||||
|
|
||||||
if(!currentItem.getUpdated_at().equals(currentItem.getCreated_at())) {
|
|
||||||
|
|
||||||
edited = mCtx.getResources().getString(R.string.colorfulBulletSpan) + mCtx.getResources().getString(R.string.modifiedText);
|
|
||||||
holder.commentModified.setVisibility(View.VISIBLE);
|
|
||||||
holder.commentModified.setText(edited);
|
|
||||||
holder.commentModified.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), mCtx));
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
holder.commentModified.setVisibility(View.INVISIBLE);
|
|
||||||
|
|
||||||
|
informationBuilder.append(ctx.getString(R.string.colorfulBulletSpan)).append(ctx.getString(R.string.modifiedText));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.issueCommentDate.setText(TimeHelper.formatTime(currentItem.getCreated_at(), new Locale(locale), timeFormat, mCtx));
|
holder.information.setText(informationBuilder);
|
||||||
|
|
||||||
|
Bundle bundle1 = new Bundle();
|
||||||
|
bundle1.putAll(bundle);
|
||||||
|
bundle1.putInt("commentId", issueComment.getId());
|
||||||
|
|
||||||
|
ReactionList reactionList = new ReactionList(ctx, bundle1);
|
||||||
|
|
||||||
|
holder.commentReactionBadges.addView(reactionList);
|
||||||
|
reactionList.setOnReactionAddedListener(() -> {
|
||||||
|
|
||||||
|
if(holder.commentReactionBadges.getVisibility() != View.VISIBLE) {
|
||||||
|
holder.commentReactionBadges.post(() -> holder.commentReactionBadges.setVisibility(View.VISIBLE));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if(timeFormat.equals("pretty")) {
|
|
||||||
holder.issueCommentDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), mCtx));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
||||||
return issuesComments.size();
|
return issuesComments.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||||
intent.putExtra("issueNumber", issueNumber.getText());
|
intent.putExtra("issueNumber", issueNumber.getText());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||||
tinyDb.putString("issueType", "Issue");
|
tinyDb.putString("issueType", "Issue");
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
@ -136,7 +136,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||||
intent.putExtra("issueNumber", issueNumber.getText());
|
intent.putExtra("issueNumber", issueNumber.getText());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||||
tinyDb.putString("issueType", "Issue");
|
tinyDb.putString("issueType", "Issue");
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
@ -148,7 +148,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(Issues issuesModel) {
|
void bindData(Issues issuesModel) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||||||
private List<Labels> labelsList;
|
private List<Labels> labelsList;
|
||||||
final private Context mCtx;
|
final private Context mCtx;
|
||||||
private ArrayList<Integer> labelsArray = new ArrayList<>();
|
private ArrayList<Integer> labelsArray = new ArrayList<>();
|
||||||
|
private static String type;
|
||||||
|
private static String orgName;
|
||||||
|
|
||||||
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@ -77,6 +79,8 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||||||
intent.putExtra("labelTitle", labelTitle.getText());
|
intent.putExtra("labelTitle", labelTitle.getText());
|
||||||
intent.putExtra("labelColor", labelColor.getText());
|
intent.putExtra("labelColor", labelColor.getText());
|
||||||
intent.putExtra("labelAction", "edit");
|
intent.putExtra("labelAction", "edit");
|
||||||
|
intent.putExtra("type", type);
|
||||||
|
intent.putExtra("orgName", orgName);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
@ -87,8 +91,9 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||||||
AlertDialogs.labelDeleteDialog(context, labelTitle.getText().toString(), labelId.getText().toString(),
|
AlertDialogs.labelDeleteDialog(context, labelTitle.getText().toString(), labelId.getText().toString(),
|
||||||
context.getResources().getString(R.string.labelDeleteTitle),
|
context.getResources().getString(R.string.labelDeleteTitle),
|
||||||
context.getResources().getString(R.string.labelDeleteMessage),
|
context.getResources().getString(R.string.labelDeleteMessage),
|
||||||
context.getResources().getString(R.string.labelDeletePositiveButton),
|
context.getResources().getString(R.string.labelDeleteTitle),
|
||||||
context.getResources().getString(R.string.labelDeleteNegativeButton));
|
context.getResources().getString(R.string.labelDeleteNegativeButton),
|
||||||
|
type, orgName);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -98,9 +103,12 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LabelsAdapter(Context mCtx, List<Labels> labelsMain) {
|
public LabelsAdapter(Context mCtx, List<Labels> labelsMain, String type, String orgName) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.mCtx = mCtx;
|
||||||
this.labelsList = labelsMain;
|
this.labelsList = labelsMain;
|
||||||
|
LabelsAdapter.type = type;
|
||||||
|
LabelsAdapter.orgName = orgName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -48,12 +48,13 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
|||||||
private ImageView labelColor;
|
private ImageView labelColor;
|
||||||
|
|
||||||
private LabelsViewHolder(View itemView) {
|
private LabelsViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
this.setIsRecyclable(false);
|
||||||
|
|
||||||
labelSelection = itemView.findViewById(R.id.labelSelection);
|
labelSelection = itemView.findViewById(R.id.labelSelection);
|
||||||
labelText = itemView.findViewById(R.id.labelText);
|
labelText = itemView.findViewById(R.id.labelText);
|
||||||
labelColor = itemView.findViewById(R.id.labelColor);
|
labelColor = itemView.findViewById(R.id.labelColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +86,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentLabelsIds = new ArrayList<>(new LinkedHashSet<>(currentLabelsIds));
|
currentLabelsIds = new ArrayList<>(new LinkedHashSet<>(currentLabelsIds));
|
||||||
|
|
||||||
for(int i = 0; i < currentLabelsIds.size(); i++) {
|
for(int i = 0; i < currentLabelsIds.size(); i++) {
|
||||||
|
|
||||||
if(currentLabelsIds.contains(currentItem.getId())) {
|
if(currentLabelsIds.contains(currentItem.getId())) {
|
||||||
@ -93,6 +95,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
|||||||
labelsIds.add(currentLabelsIds.get(i));
|
labelsIds.add(currentLabelsIds.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
labelsListener.labelsIdsInterface(labelsIds);
|
labelsListener.labelsIdsInterface(labelsIds);
|
||||||
|
|
||||||
holder.labelSelection.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
holder.labelSelection.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
@ -117,6 +120,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
||||||
return labels.size();
|
return labels.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,6 @@ package org.mian.gitnex.adapters;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.text.Spanned;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -19,6 +16,7 @@ import com.vdurmont.emoji.EmojiParser;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.actions.MilestoneActions;
|
import org.mian.gitnex.actions.MilestoneActions;
|
||||||
import org.mian.gitnex.helpers.ClickListener;
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
@ -26,27 +24,9 @@ import org.mian.gitnex.models.Milestones;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
|
||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
|
||||||
import io.noties.markwon.Markwon;
|
|
||||||
import io.noties.markwon.core.CorePlugin;
|
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
|
||||||
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.DefaultMediaDecoder;
|
|
||||||
import io.noties.markwon.image.ImageItem;
|
|
||||||
import io.noties.markwon.image.ImagesPlugin;
|
|
||||||
import io.noties.markwon.image.SchemeHandler;
|
|
||||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
|
||||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -177,71 +157,18 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(Milestones dataModel) {
|
void bindData(Milestones dataModel) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
milestoneId.setText(String.valueOf(dataModel.getId()));
|
milestoneId.setText(String.valueOf(dataModel.getId()));
|
||||||
milestoneStatus.setText(dataModel.getState());
|
milestoneStatus.setText(dataModel.getState());
|
||||||
|
|
||||||
Markwon markwon = Markwon.builder(Objects.requireNonNull(context)).usePlugin(CorePlugin.create()).usePlugin(ImagesPlugin.create(plugin -> {
|
new Markdown(context, dataModel.getTitle(), msTitle);
|
||||||
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.getDescription().equals("")) {
|
if(!dataModel.getDescription().equals("")) {
|
||||||
|
|
||||||
CharSequence bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(dataModel.getDescription()));
|
new Markdown(context, EmojiParser.parseToUnicode(dataModel.getDescription()), msDescription);
|
||||||
msDescription.setText(bodyWithMD);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
@ -125,14 +125,13 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchInfo watch = new WatchInfo();
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
Call<WatchInfo> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<WatchInfo>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
|||||||
|
|
||||||
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
|
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
|
||||||
|
|
||||||
this.tinyDb = new TinyDB(context);
|
this.tinyDb = TinyDB.getInstance(context);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.notificationThreads = notificationThreads;
|
this.notificationThreads = notificationThreads;
|
||||||
this.onMoreClickedListener = onMoreClickedListener;
|
this.onMoreClickedListener = onMoreClickedListener;
|
||||||
|
@ -45,27 +45,23 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
|||||||
image = itemView.findViewById(R.id.imageAvatar);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
organizationId = itemView.findViewById(R.id.organizationId);
|
organizationId = itemView.findViewById(R.id.organizationId);
|
||||||
|
|
||||||
itemView.setOnClickListener(new View.OnClickListener() {
|
itemView.setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||||
intent.putExtra("orgName", mTextView1.getText().toString());
|
intent.putExtra("orgName", mTextView1.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("orgName", mTextView1.getText().toString());
|
tinyDb.putString("orgName", mTextView1.getText().toString());
|
||||||
tinyDb.putString("organizationId", organizationId.getText().toString());
|
tinyDb.putString("organizationId", organizationId.getText().toString());
|
||||||
tinyDb.putBoolean("organizationAction", true);
|
tinyDb.putBoolean("organizationAction", true);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrganizationsListAdapter(Context mCtx, List<UserOrganizations> orgsListMain) {
|
public OrganizationsListAdapter(Context mCtx, List<UserOrganizations> orgsListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.mCtx = mCtx;
|
||||||
this.orgList = orgsListMain;
|
this.orgList = orgsListMain;
|
||||||
orgListFull = new ArrayList<>(orgList);
|
orgListFull = new ArrayList<>(orgList);
|
||||||
@ -74,6 +70,7 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public OrganizationsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public OrganizationsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
|
||||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_organizations, parent, false);
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_organizations, parent, false);
|
||||||
return new OrganizationsViewHolder(v);
|
return new OrganizationsViewHolder(v);
|
||||||
}
|
}
|
||||||
@ -88,11 +85,12 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
|||||||
|
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
||||||
holder.mTextView1.setText(currentItem.getUsername());
|
holder.mTextView1.setText(currentItem.getUsername());
|
||||||
|
|
||||||
if (!currentItem.getDescription().equals("")) {
|
if (!currentItem.getDescription().equals("")) {
|
||||||
|
|
||||||
holder.mTextView2.setVisibility(View.VISIBLE);
|
holder.mTextView2.setVisibility(View.VISIBLE);
|
||||||
holder.mTextView2.setText(currentItem.getDescription());
|
holder.mTextView2.setText(currentItem.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,14 +103,19 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
|||||||
return orgFilter;
|
return orgFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Filter orgFilter = new Filter() {
|
private final Filter orgFilter = new Filter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
|
|
||||||
List<UserOrganizations> filteredList = new ArrayList<>();
|
List<UserOrganizations> filteredList = new ArrayList<>();
|
||||||
|
|
||||||
if (constraint == null || constraint.length() == 0) {
|
if (constraint == null || constraint.length() == 0) {
|
||||||
|
|
||||||
filteredList.addAll(orgListFull);
|
filteredList.addAll(orgListFull);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||||
|
|
||||||
for (UserOrganizations item : orgListFull) {
|
for (UserOrganizations item : orgListFull) {
|
||||||
@ -130,6 +133,7 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||||
|
|
||||||
orgList.clear();
|
orgList.clear();
|
||||||
orgList.addAll((List) results.values);
|
orgList.addAll((List) results.values);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
|
@ -130,7 +130,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
intent.putExtra("prMergeable", prMergeable.getText());
|
intent.putExtra("prMergeable", prMergeable.getText());
|
||||||
intent.putExtra("prHeadBranch", prHeadBranch.getText());
|
intent.putExtra("prHeadBranch", prHeadBranch.getText());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
||||||
tinyDb.putString("prMergeable", prMergeable.getText().toString());
|
tinyDb.putString("prMergeable", prMergeable.getText().toString());
|
||||||
tinyDb.putString("prHeadBranch", prHeadBranch.getText().toString());
|
tinyDb.putString("prHeadBranch", prHeadBranch.getText().toString());
|
||||||
@ -149,7 +149,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
intent.putExtra("prMergeable", prMergeable.getText());
|
intent.putExtra("prMergeable", prMergeable.getText());
|
||||||
intent.putExtra("prHeadBranch", prHeadBranch.getText());
|
intent.putExtra("prHeadBranch", prHeadBranch.getText());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
tinyDb.putString("issueNumber", prNumber.getText().toString());
|
||||||
tinyDb.putString("prMergeable", prMergeable.getText().toString());
|
tinyDb.putString("prMergeable", prMergeable.getText().toString());
|
||||||
tinyDb.putString("prHeadBranch", prHeadBranch.getText().toString());
|
tinyDb.putString("prHeadBranch", prHeadBranch.getText().toString());
|
||||||
@ -165,7 +165,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(PullRequests prModel) {
|
void bindData(PullRequests prModel) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -16,34 +13,16 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.vdurmont.emoji.EmojiParser;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.helpers.ClickListener;
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.models.Releases;
|
import org.mian.gitnex.models.Releases;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
|
||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
|
||||||
import io.noties.markwon.Markwon;
|
|
||||||
import io.noties.markwon.core.CorePlugin;
|
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
|
||||||
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.DefaultMediaDecoder;
|
|
||||||
import io.noties.markwon.image.ImageItem;
|
|
||||||
import io.noties.markwon.image.ImagesPlugin;
|
|
||||||
import io.noties.markwon.image.SchemeHandler;
|
|
||||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
|
||||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -111,7 +90,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
@ -149,58 +128,8 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||||||
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublished_at()), mCtx));
|
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(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 Drawable drawable = mCtx.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(mCtx.getResources()));
|
|
||||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
|
||||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(mCtx.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(mCtx.getResources().getColor(R.color.lightBlue));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.usePlugin(TablePlugin.create(mCtx))
|
|
||||||
.usePlugin(TaskListPlugin.create(mCtx))
|
|
||||||
.usePlugin(HtmlPlugin.create())
|
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
|
||||||
.usePlugin(LinkifyPlugin.create())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Spanned bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(currentItem.getBody()));
|
|
||||||
|
|
||||||
if(!currentItem.getBody().equals("")) {
|
if(!currentItem.getBody().equals("")) {
|
||||||
markwon.setParsedMarkdown(holder.releaseBodyContent, bodyWithMD);
|
new Markdown(mCtx, currentItem.getBody(), holder.releaseBodyContent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
|
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
|
||||||
|
@ -211,7 +211,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
@ -244,14 +244,13 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchInfo watch = new WatchInfo();
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
Call<WatchInfo> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<WatchInfo>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class RepoStargazersAdapter extends BaseAdapter {
|
|||||||
UserInfo currentItem = stargazersList.get(position);
|
UserInfo currentItem = stargazersList.get(position);
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||||
Typeface myTypeface;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDb.getInt("customFontId", -1)) {
|
||||||
|
@ -81,7 +81,7 @@ public class RepoWatchersAdapter extends BaseAdapter {
|
|||||||
UserInfo currentItem = watchersList.get(position);
|
UserInfo currentItem = watchersList.get(position);
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||||
Typeface myTypeface;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDb.getInt("customFontId", -1)) {
|
||||||
|
@ -23,9 +23,9 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -94,7 +94,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
@ -127,14 +127,13 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchInfo watch = new WatchInfo();
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
Call<WatchInfo> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<WatchInfo>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -91,7 +91,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", fullName.getText().toString());
|
intent.putExtra("repoFullName", fullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
@ -124,12 +124,11 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
Call<WatchInfo> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<WatchInfo>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
|
|||||||
|
|
||||||
this.mCtx = mCtx;
|
this.mCtx = mCtx;
|
||||||
this.searchedList = dataList;
|
this.searchedList = dataList;
|
||||||
this.tinyDb = new TinyDB(mCtx);
|
this.tinyDb = TinyDB.getInstance(mCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SearchViewHolder extends RecyclerView.ViewHolder {
|
class SearchViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@ -23,9 +23,9 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -91,7 +91,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", fullName.getText().toString());
|
intent.putExtra("repoFullName", fullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
@ -124,14 +124,13 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
|
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchInfo watch = new WatchInfo();
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
Call<WatchInfo> call;
|
Call<WatchInfo> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<WatchInfo>() {
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
|
|||||||
UserInfo currentItem = teamMembersList.get(position);
|
UserInfo currentItem = teamMembersList.get(position);
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||||
Typeface myTypeface;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDb.getInt("customFontId", -1)) {
|
||||||
|
@ -125,7 +125,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
||||||
|
|
||||||
UserAccount currentItem = userAccountsList.get(position);
|
UserAccount currentItem = userAccountsList.get(position);
|
||||||
tinyDB = new TinyDB(mCtx);
|
tinyDB = TinyDB.getInstance(mCtx);
|
||||||
|
|
||||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||||
.withPath("/")
|
.withPath("/")
|
||||||
|
@ -31,7 +31,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
|
|||||||
|
|
||||||
super(mCtx, resource, userAccounts);
|
super(mCtx, resource, userAccounts);
|
||||||
|
|
||||||
tinyDB = new TinyDB(mCtx);
|
tinyDB = TinyDB.getInstance(mCtx);
|
||||||
this.userAccounts = userAccounts;
|
this.userAccounts = userAccounts;
|
||||||
this.mCtx = mCtx;
|
this.mCtx = mCtx;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||||||
|
|
||||||
private void customDialogUserAccountsList(List<UserAccount> allAccountsList) {
|
private void customDialogUserAccountsList(List<UserAccount> allAccountsList) {
|
||||||
|
|
||||||
TinyDB tinyDB = new TinyDB(mCtx);
|
TinyDB tinyDB = TinyDB.getInstance(mCtx);
|
||||||
Dialog dialog = new Dialog(mCtx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
Dialog dialog = new Dialog(mCtx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||||
dialog.setContentView(R.layout.custom_user_accounts_dialog);
|
dialog.setContentView(R.layout.custom_user_accounts_dialog);
|
||||||
|
|
||||||
|
@ -146,19 +146,16 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
|||||||
|
|
||||||
if(getItemCount() > 0) {
|
if(getItemCount() > 0) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(mCtx);
|
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
Call<Collaborators> call = RetrofitClient
|
Call<Collaborators> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, mCtx)
|
.getApiInterface(mCtx)
|
||||||
.getApiInterface()
|
.checkRepoCollaborator(Authorization.get(mCtx), repoOwner, repoName, currentItem.getUsername());
|
||||||
.checkRepoCollaborator(Authorization.returnAuthentication(mCtx, loginUid, instanceToken), repoOwner, repoName, currentItem.getUsername());
|
|
||||||
|
|
||||||
call.enqueue(new Callback<Collaborators>() {
|
call.enqueue(new Callback<Collaborators>() {
|
||||||
|
|
||||||
|
@ -116,8 +116,7 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
|||||||
|
|
||||||
if(getItemCount() > 0) {
|
if(getItemCount() > 0) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(mCtx);
|
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
@ -125,9 +124,8 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
|||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
Call<UserInfo> call = RetrofitClient
|
Call<UserInfo> call = RetrofitClient
|
||||||
.getInstance(instanceUrl, mCtx)
|
.getApiInterface(mCtx)
|
||||||
.getApiInterface()
|
.checkTeamMember(Authorization.get(mCtx), teamId, currentItem.getLogin());
|
||||||
.checkTeamMember(Authorization.returnAuthentication(mCtx, loginUid, instanceToken), teamId, currentItem.getLogin());
|
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
|
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
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 java.io.File;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
import okhttp3.Cache;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.logging.HttpLoggingInterceptor;
|
|
||||||
import retrofit2.Retrofit;
|
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Author M M Arif
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class AppApiService {
|
|
||||||
|
|
||||||
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context ctx) {
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(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);
|
|
||||||
|
|
||||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
|
||||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
|
||||||
|
|
||||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
|
||||||
sslContext.init(null, new X509TrustManager[]{memorizingTrustManager}, new SecureRandom());
|
|
||||||
|
|
||||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
||||||
.cache(cache)
|
|
||||||
//.addInterceptor(logging)
|
|
||||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
|
||||||
.hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()))
|
|
||||||
.addInterceptor(chain -> {
|
|
||||||
|
|
||||||
Request request = chain.request();
|
|
||||||
if(connToInternet) {
|
|
||||||
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
|
||||||
}
|
|
||||||
return chain.proceed(request);
|
|
||||||
|
|
||||||
}).build();
|
|
||||||
|
|
||||||
Retrofit.Builder builder = new Retrofit.Builder()
|
|
||||||
.baseUrl(instanceURL)
|
|
||||||
.client(okHttpClient)
|
|
||||||
.addConverterFactory(GsonConverterFactory.create());
|
|
||||||
|
|
||||||
Retrofit retrofit = builder.build();
|
|
||||||
return retrofit.create(serviceClass);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
Log.e("onFailure", e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -20,7 +20,7 @@ import okhttp3.OkHttpClient;
|
|||||||
public class PicassoService {
|
public class PicassoService {
|
||||||
|
|
||||||
private static PicassoService picassoService;
|
private static PicassoService picassoService;
|
||||||
private static File cachePath;
|
private final File cachePath;
|
||||||
private Picasso picasso;
|
private Picasso picasso;
|
||||||
|
|
||||||
private PicassoService(Context context) {
|
private PicassoService(Context context) {
|
||||||
@ -54,7 +54,6 @@ public class PicassoService {
|
|||||||
|
|
||||||
Log.e("PicassoService", e.toString());
|
Log.e("PicassoService", e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Picasso get() {
|
public Picasso get() {
|
||||||
|
@ -10,6 +10,8 @@ import org.mian.gitnex.interfaces.ApiInterface;
|
|||||||
import org.mian.gitnex.interfaces.WebInterface;
|
import org.mian.gitnex.interfaces.WebInterface;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
@ -27,15 +29,15 @@ import retrofit2.converter.scalars.ScalarsConverterFactory;
|
|||||||
|
|
||||||
public class RetrofitClient {
|
public class RetrofitClient {
|
||||||
|
|
||||||
private Retrofit retrofit;
|
private static final Map<String, ApiInterface> apiInterfaces = new ConcurrentHashMap<>();
|
||||||
|
private static final Map<String, WebInterface> webInterfaces = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private RetrofitClient(String instanceUrl, Context ctx) {
|
private static Retrofit createRetrofit(Context context, String instanceUrl) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(ctx);
|
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||||
final boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
|
||||||
int cacheSize = FilesData.returnOnlyNumber(tinyDb.getString("cacheSizeStr")) * 1024 * 1024;
|
int cacheSize = FilesData.returnOnlyNumber(tinyDB.getString("cacheSizeStr")) * 1024 * 1024;
|
||||||
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
Cache cache = new Cache(new File(context.getCacheDir(), "responses"), cacheSize);
|
||||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
|
||||||
|
|
||||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||||
@ -44,47 +46,80 @@ public class RetrofitClient {
|
|||||||
|
|
||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||||
|
|
||||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(context);
|
||||||
sslContext.init(null, new X509TrustManager[]{memorizingTrustManager}, new SecureRandom());
|
sslContext.init(null, new X509TrustManager[]{ memorizingTrustManager }, new SecureRandom());
|
||||||
|
|
||||||
OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder().cache(cache)
|
OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder().cache(cache)
|
||||||
//.addInterceptor(logging)
|
//.addInterceptor(logging)
|
||||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager).hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier())).addInterceptor(chain -> {
|
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
||||||
|
.hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()))
|
||||||
|
.addInterceptor(chain -> {
|
||||||
|
|
||||||
Request request = chain.request();
|
Request request = chain.request();
|
||||||
if(connToInternet) {
|
|
||||||
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
|
||||||
}
|
|
||||||
return chain.proceed(request);
|
|
||||||
});
|
|
||||||
|
|
||||||
Retrofit.Builder builder = new Retrofit.Builder().baseUrl(instanceUrl).client(okHttpClient.build()).addConverterFactory(ScalarsConverterFactory.create()).addConverterFactory(GsonConverterFactory.create());
|
request = AppUtil.hasNetworkConnection(context) ?
|
||||||
|
request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build() :
|
||||||
|
request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
||||||
|
|
||||||
retrofit = builder.build();
|
return chain.proceed(request);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Retrofit.Builder()
|
||||||
|
.baseUrl(instanceUrl)
|
||||||
|
.client(okHttpClient.build())
|
||||||
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
Log.e("onFailure", e.toString());
|
|
||||||
|
Log.e("onFailureRetrofit", e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized RetrofitClient getInstance(String instanceUrl, Context ctx) {
|
public static ApiInterface getApiInterface(Context context) {
|
||||||
|
|
||||||
return new RetrofitClient(instanceUrl, ctx);
|
return getApiInterface(context, TinyDB.getInstance(context).getString("instanceUrl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiInterface getApiInterface() {
|
public static WebInterface getWebInterface(Context context) {
|
||||||
|
|
||||||
|
String instanceUrl = TinyDB.getInstance(context).getString("instanceUrl");
|
||||||
|
instanceUrl = instanceUrl.substring(0, instanceUrl.lastIndexOf("api/v1/"));
|
||||||
|
|
||||||
|
return getWebInterface(context, instanceUrl);
|
||||||
|
|
||||||
return retrofit.create(ApiInterface.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebInterface getWebInterface() {
|
public static ApiInterface getApiInterface(Context context, String url) {
|
||||||
|
if(!apiInterfaces.containsKey(url)) {
|
||||||
|
|
||||||
return retrofit.create(WebInterface.class);
|
ApiInterface apiInterface = createRetrofit(context, url)
|
||||||
|
.create(ApiInterface.class);
|
||||||
|
|
||||||
|
apiInterfaces.put(url, apiInterface);
|
||||||
|
return apiInterface;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiInterfaces.get(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WebInterface getWebInterface(Context context, String url) {
|
||||||
|
if(!webInterfaces.containsKey(url)) {
|
||||||
|
|
||||||
|
WebInterface webInterface = createRetrofit(context, url)
|
||||||
|
.create(WebInterface.class);
|
||||||
|
|
||||||
|
webInterfaces.put(url, webInterface);
|
||||||
|
return webInterface;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return webInterfaces.get(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class DraftsApi {
|
|||||||
draftsDao = db.draftsDao();
|
draftsDao = db.draftsDao();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long insertDraft(int repositoryId, int draftAccountId, int issueId, String draftText, String draftType, String commentId) {
|
public long insertDraft(int repositoryId, int draftAccountId, int issueId, String draftText, String draftType, String commentId, String issueType) {
|
||||||
|
|
||||||
Draft draft = new Draft();
|
Draft draft = new Draft();
|
||||||
draft.setDraftRepositoryId(repositoryId);
|
draft.setDraftRepositoryId(repositoryId);
|
||||||
@ -35,7 +35,8 @@ public class DraftsApi {
|
|||||||
draft.setIssueId(issueId);
|
draft.setIssueId(issueId);
|
||||||
draft.setDraftText(draftText);
|
draft.setDraftText(draftText);
|
||||||
draft.setDraftType(draftType);
|
draft.setDraftType(draftType);
|
||||||
draft.setCommentId(draftType);
|
draft.setCommentId(commentId);
|
||||||
|
draft.setIssueType(issueType);
|
||||||
|
|
||||||
return insertDraftAsyncTask(draft);
|
return insertDraftAsyncTask(draft);
|
||||||
}
|
}
|
||||||
@ -50,7 +51,7 @@ public class DraftsApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.draftsRepository, e.toString());
|
Log.e(StaticGlobalVariables.draftsApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return draftId;
|
return draftId;
|
||||||
@ -66,7 +67,7 @@ public class DraftsApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.draftsRepository, e.toString());
|
Log.e(StaticGlobalVariables.draftsApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return draftId;
|
return draftId;
|
||||||
@ -82,7 +83,7 @@ public class DraftsApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.draftsRepository, e.toString());
|
Log.e(StaticGlobalVariables.draftsApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkDraftFlag;
|
return checkDraftFlag;
|
||||||
|
@ -47,7 +47,7 @@ public class RepositoriesApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
Log.e(StaticGlobalVariables.repositoriesApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return repositoryId;
|
return repositoryId;
|
||||||
@ -63,7 +63,7 @@ public class RepositoriesApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
Log.e(StaticGlobalVariables.repositoriesApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return repository;
|
return repository;
|
||||||
@ -89,7 +89,7 @@ public class RepositoriesApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
Log.e(StaticGlobalVariables.repositoriesApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkRepository;
|
return checkRepository;
|
||||||
@ -105,7 +105,7 @@ public class RepositoriesApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
Log.e(StaticGlobalVariables.repositoriesApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return repository;
|
return repository;
|
||||||
@ -121,7 +121,7 @@ public class RepositoriesApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.repositoriesRepository, e.toString());
|
Log.e(StaticGlobalVariables.repositoriesApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return repository;
|
return repository;
|
||||||
|
@ -17,6 +17,7 @@ public class UserAccountsApi {
|
|||||||
|
|
||||||
private static UserAccountsDao userAccountsDao;
|
private static UserAccountsDao userAccountsDao;
|
||||||
private static UserAccount userAccount;
|
private static UserAccount userAccount;
|
||||||
|
private static List<UserAccount> userAccounts;
|
||||||
private static Integer checkAccount;
|
private static Integer checkAccount;
|
||||||
private static long accountId;
|
private static long accountId;
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ public class UserAccountsApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.userAccountsRepository, e.toString());
|
Log.e(StaticGlobalVariables.userAccountsApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return accountId;
|
return accountId;
|
||||||
@ -80,7 +81,7 @@ public class UserAccountsApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.userAccountsRepository, e.toString());
|
Log.e(StaticGlobalVariables.userAccountsApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return userAccount;
|
return userAccount;
|
||||||
@ -96,7 +97,7 @@ public class UserAccountsApi {
|
|||||||
}
|
}
|
||||||
catch(InterruptedException e) {
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
Log.e(StaticGlobalVariables.userAccountsRepository, e.toString());
|
Log.e(StaticGlobalVariables.userAccountsApi, e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkAccount;
|
return checkAccount;
|
||||||
@ -107,6 +108,22 @@ public class UserAccountsApi {
|
|||||||
return userAccountsDao.fetchAllAccounts();
|
return userAccountsDao.fetchAllAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<UserAccount> usersAccounts() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Thread thread = new Thread(() -> userAccounts = userAccountsDao.userAccounts());
|
||||||
|
thread.start();
|
||||||
|
thread.join();
|
||||||
|
}
|
||||||
|
catch(InterruptedException e) {
|
||||||
|
|
||||||
|
Log.e(StaticGlobalVariables.userAccountsApi, e.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return userAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteAccount(final int accountId) {
|
public void deleteAccount(final int accountId) {
|
||||||
|
|
||||||
new Thread(() -> userAccountsDao.deleteAccount(accountId)).start();
|
new Thread(() -> userAccountsDao.deleteAccount(accountId)).start();
|
||||||
|
@ -20,6 +20,9 @@ public interface UserAccountsDao {
|
|||||||
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
||||||
LiveData<List<UserAccount>> fetchAllAccounts();
|
LiveData<List<UserAccount>> fetchAllAccounts();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
||||||
|
List<UserAccount> userAccounts();
|
||||||
|
|
||||||
@Query("SELECT COUNT(accountId) FROM UserAccounts WHERE accountName = :accountName")
|
@Query("SELECT COUNT(accountId) FROM UserAccounts WHERE accountName = :accountName")
|
||||||
Integer getCount(String accountName);
|
Integer getCount(String accountName);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import org.mian.gitnex.database.models.UserAccount;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
||||||
version = 2, exportSchema = false)
|
version = 3, exportSchema = false)
|
||||||
public abstract class GitnexDatabase extends RoomDatabase {
|
public abstract class GitnexDatabase extends RoomDatabase {
|
||||||
|
|
||||||
private static GitnexDatabase gitnexDatabase;
|
private static GitnexDatabase gitnexDatabase;
|
||||||
@ -27,10 +27,11 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||||
|
|
||||||
if (gitnexDatabase == null) {
|
if (gitnexDatabase == null) {
|
||||||
|
|
||||||
String DB_NAME = "gitnex";
|
String DB_NAME = "gitnex";
|
||||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||||
//.fallbackToDestructiveMigration()
|
//.fallbackToDestructiveMigration()
|
||||||
.addMigrations(MIGRATION_1_2)
|
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +50,14 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||||||
|
|
||||||
//database.execSQL("DROP TABLE Drafts");
|
//database.execSQL("DROP TABLE Drafts");
|
||||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final Migration MIGRATION_2_3 = new Migration(2, 3) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
|
||||||
|
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'issueType' TEXT");
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ public class Draft implements Serializable {
|
|||||||
private String draftType;
|
private String draftType;
|
||||||
@Nullable
|
@Nullable
|
||||||
private String commentId;
|
private String commentId;
|
||||||
|
@Nullable
|
||||||
|
private String issueType;
|
||||||
|
|
||||||
public int getDraftId() {
|
public int getDraftId() {
|
||||||
|
|
||||||
@ -99,4 +101,15 @@ public class Draft implements Serializable {
|
|||||||
this.commentId = commentId;
|
this.commentId = commentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getIssueType() {
|
||||||
|
|
||||||
|
return issueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIssueType(@Nullable String issueType) {
|
||||||
|
|
||||||
|
this.issueType = issueType;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ public class DraftWithRepository {
|
|||||||
private String draftText;
|
private String draftText;
|
||||||
private String draftType;
|
private String draftType;
|
||||||
private String commentId;
|
private String commentId;
|
||||||
|
private String issueType;
|
||||||
|
|
||||||
public int getRepositoryId() {
|
public int getRepositoryId() {
|
||||||
|
|
||||||
@ -130,4 +131,14 @@ public class DraftWithRepository {
|
|||||||
this.commentId = commentId;
|
this.commentId = commentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getIssueType() {
|
||||||
|
|
||||||
|
return issueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIssueType(String issueType) {
|
||||||
|
|
||||||
|
this.issueType = issueType;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class AboutFragment extends Fragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
FragmentAboutBinding viewBinding = FragmentAboutBinding.inflate(inflater, container, false);
|
FragmentAboutBinding viewBinding = FragmentAboutBinding.inflate(inflater, container, false);
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
TinyDB tinyDb = TinyDB.getInstance(getContext());
|
||||||
|
|
||||||
viewBinding.appVersion.setText(AppUtil.getAppVersion(requireContext()));
|
viewBinding.appVersion.setText(AppUtil.getAppVersion(requireContext()));
|
||||||
viewBinding.userServerVersion.setText(tinyDb.getString("giteaVersion"));
|
viewBinding.userServerVersion.setText(tinyDb.getString("giteaVersion"));
|
||||||
@ -32,15 +32,6 @@ public class AboutFragment extends Fragment {
|
|||||||
|
|
||||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.pageTitleAbout));
|
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.pageTitleAbout));
|
||||||
|
|
||||||
viewBinding.donationLinkLiberapay.setOnClickListener(v1 -> {
|
|
||||||
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
|
||||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
|
||||||
intent.setData(Uri.parse(getResources().getString(R.string.supportLink)));
|
|
||||||
startActivity(intent);
|
|
||||||
});
|
|
||||||
|
|
||||||
viewBinding.donationLinkPatreon.setOnClickListener(v12 -> {
|
viewBinding.donationLinkPatreon.setOnClickListener(v12 -> {
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
@ -72,7 +63,6 @@ public class AboutFragment extends Fragment {
|
|||||||
|
|
||||||
viewBinding.supportHeader.setVisibility(View.GONE);
|
viewBinding.supportHeader.setVisibility(View.GONE);
|
||||||
viewBinding.dividerSupport.setVisibility(View.GONE);
|
viewBinding.dividerSupport.setVisibility(View.GONE);
|
||||||
viewBinding.donationLinkLiberapay.setVisibility(View.GONE);
|
|
||||||
viewBinding.donationLinkPatreon.setVisibility(View.GONE);
|
viewBinding.donationLinkPatreon.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.AdminGetUsersActivity;
|
import org.mian.gitnex.activities.AdminGetUsersActivity;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -23,8 +22,6 @@ public class AdministrationFragment extends Fragment {
|
|||||||
|
|
||||||
View v = inflater.inflate(R.layout.fragment_administration, container, false);
|
View v = inflater.inflate(R.layout.fragment_administration, container, false);
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
|
||||||
|
|
||||||
TextView adminUsers = v.findViewById(R.id.adminUsers);
|
TextView adminUsers = v.findViewById(R.id.adminUsers);
|
||||||
|
|
||||||
adminUsers.setOnClickListener(v1 -> startActivity(new Intent(getContext(), AdminGetUsersActivity.class)));
|
adminUsers.setOnClickListener(v1 -> startActivity(new Intent(getContext(), AdminGetUsersActivity.class)));
|
||||||
|
@ -24,7 +24,7 @@ public class BottomSheetNotificationsFilterFragment extends BottomSheetDialogFra
|
|||||||
@Override
|
@Override
|
||||||
public void onAttach(@NonNull Context context) {
|
public void onAttach(@NonNull Context context) {
|
||||||
|
|
||||||
this.tinyDB = new TinyDB(context);
|
this.tinyDB = TinyDB.getInstance(context);
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
|||||||
TextView createTeam = v.findViewById(R.id.createTeam);
|
TextView createTeam = v.findViewById(R.id.createTeam);
|
||||||
TextView createRepository = v.findViewById(R.id.createRepository);
|
TextView createRepository = v.findViewById(R.id.createRepository);
|
||||||
TextView copyOrgUrl = v.findViewById(R.id.copyOrgUrl);
|
TextView copyOrgUrl = v.findViewById(R.id.copyOrgUrl);
|
||||||
|
TextView createLabel = v.findViewById(R.id.createLabel);
|
||||||
|
|
||||||
createTeam.setOnClickListener(v1 -> {
|
createTeam.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
@ -35,6 +36,12 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
|||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
createLabel.setOnClickListener(v1 -> {
|
||||||
|
|
||||||
|
bmListener.onButtonClicked("label");
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
createRepository.setOnClickListener(v12 -> {
|
createRepository.setOnClickListener(v12 -> {
|
||||||
|
|
||||||
bmListener.onButtonClicked("repository");
|
bmListener.onButtonClicked("repository");
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user