Format files (#1179)
use https://codeberg.org/qwerty287/woodpecker-intellij-formatter Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1179 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
151cb8429c
commit
a7d9918b67
|
@ -13,6 +13,7 @@ line_comment = //
|
|||
block_comment_start = /*
|
||||
block_comment = *
|
||||
block_comment_end = */
|
||||
max_line_length = 220
|
||||
|
||||
[*.json]
|
||||
indent_size = 2
|
||||
|
|
|
@ -9,6 +9,7 @@ labels:
|
|||
---
|
||||
|
||||
## # Describe your matter briefly
|
||||
|
||||
<br><br>
|
||||
|
||||
##### What did you expect?
|
||||
|
@ -24,7 +25,7 @@ labels:
|
|||
* 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):
|
||||
<br>
|
||||
<br>
|
||||
|
||||
##### We would appreciate some screenshots or stacktrace's, but this is also not required.
|
||||
---
|
||||
|
@ -32,6 +33,6 @@ labels:
|
|||
<br><br>
|
||||
|
||||
- [ ] I carefully read the [contribution guidelines](https://codeberg.org/gitnex/GitNex/wiki/Contributing).
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<!-- Thank you for your time. -->
|
||||
|
|
|
@ -9,9 +9,10 @@ labels:
|
|||
---
|
||||
|
||||
## # Describe your matter briefly
|
||||
|
||||
<br><br>
|
||||
|
||||
- [ ] I carefully read the [contribution guidelines](https://codeberg.org/gitnex/GitNex/wiki/Contributing).
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<!-- Thank you for your time. -->
|
||||
|
|
|
@ -9,6 +9,7 @@ labels:
|
|||
---
|
||||
|
||||
## # Describe your matter briefly
|
||||
|
||||
<br><br>
|
||||
|
||||
##### What did you expect?
|
||||
|
@ -24,7 +25,7 @@ labels:
|
|||
* 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):
|
||||
<br>
|
||||
<br>
|
||||
|
||||
##### We would appreciate some screenshots or stacktrace's, but this is also not required.
|
||||
---
|
||||
|
@ -32,6 +33,6 @@ labels:
|
|||
<br><br>
|
||||
|
||||
- [ ] I carefully read the [contribution guidelines](https://codeberg.org/gitnex/GitNex/wiki/Contributing).
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<!-- Thank you for your time. -->
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
### Describe what your pull request does and which issue you’re targeting
|
||||
|
||||
<!-- Create a new issue, if it doesn't exist yet -->
|
||||
<br><br>
|
||||
|
||||
|
@ -6,4 +7,5 @@
|
|||
|
||||
- [ ] I carefully read the [contribution guidelines](https://codeberg.org/GitNex/GitNex/src/branch/main/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/main/LICENSE).
|
||||
- [ ] 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/main/LICENSE).
|
|
@ -3,72 +3,56 @@
|
|||
<JavaCodeStyleSettings>
|
||||
<option name="IMPORT_LAYOUT_TABLE">
|
||||
<value>
|
||||
<package name="android" withSubpackages="true" static="false" />
|
||||
<package name="androidx" withSubpackages="true" static="false" />
|
||||
<package name="com" withSubpackages="true" static="false" />
|
||||
<package name="junit" withSubpackages="true" static="false" />
|
||||
<package name="net" withSubpackages="true" static="false" />
|
||||
<package name="org" withSubpackages="true" static="false" />
|
||||
<package name="java" withSubpackages="true" static="false" />
|
||||
<package name="javax" withSubpackages="true" static="false" />
|
||||
<package name="" withSubpackages="true" static="false" />
|
||||
<package name="" withSubpackages="true" static="true" />
|
||||
<package name="android" withSubpackages="true" static="false"/>
|
||||
<package name="androidx" withSubpackages="true" static="false"/>
|
||||
<package name="com" withSubpackages="true" static="false"/>
|
||||
<package name="junit" withSubpackages="true" static="false"/>
|
||||
<package name="net" withSubpackages="true" static="false"/>
|
||||
<package name="org" withSubpackages="true" static="false"/>
|
||||
<package name="java" withSubpackages="true" static="false"/>
|
||||
<package name="javax" withSubpackages="true" static="false"/>
|
||||
<package name="" withSubpackages="true" static="false"/>
|
||||
<package name="" withSubpackages="true" static="true"/>
|
||||
</value>
|
||||
</option>
|
||||
</JavaCodeStyleSettings>
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JetCodeStyleSettings>
|
||||
<XML>
|
||||
<option name="XML_ALIGN_ATTRIBUTES" value="false"/>
|
||||
</XML>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="RIGHT_MARGIN" value="220" />
|
||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
|
||||
<option name="BLANK_LINES_AROUND_FIELD_IN_INTERFACE" value="1" />
|
||||
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" />
|
||||
<option name="BLANK_LINES_AFTER_ANONYMOUS_CLASS_HEADER" value="1" />
|
||||
<option name="BLANK_LINES_BEFORE_CLASS_END" value="1" />
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_TRY_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SYNCHRONIZED_PARENTHESES" value="false" />
|
||||
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="1" />
|
||||
<option name="THROWS_LIST_WRAP" value="1" />
|
||||
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
|
||||
<option name="TERNARY_OPERATION_WRAP" value="1" />
|
||||
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="RIGHT_MARGIN" value="220"/>
|
||||
<option name="KEEP_LINE_BREAKS" value="false"/>
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false"/>
|
||||
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false"/>
|
||||
<option name="BLANK_LINES_AROUND_FIELD_IN_INTERFACE" value="1"/>
|
||||
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1"/>
|
||||
<option name="BLANK_LINES_BEFORE_CLASS_END" value="1"/>
|
||||
<option name="ELSE_ON_NEW_LINE" value="true"/>
|
||||
<option name="CATCH_ON_NEW_LINE" value="true"/>
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true"/>
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false"/>
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_TRY_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_SYNCHRONIZED_PARENTHESES" value="false"/>
|
||||
<option name="CALL_PARAMETERS_WRAP" value="1"/>
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="1"/>
|
||||
<option name="THROWS_LIST_WRAP" value="1"/>
|
||||
<option name="METHOD_CALL_CHAIN_WRAP" value="1"/>
|
||||
<option name="TERNARY_OPERATION_WRAP" value="1"/>
|
||||
<option name="ARRAY_INITIALIZER_WRAP" value="1"/>
|
||||
<option name="IF_BRACE_FORCE" value="3"/>
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="SMART_TABS" value="true" />
|
||||
<option name="USE_TAB_CHARACTER" value="true"/>
|
||||
<option name="SMART_TABS" value="true"/>
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4"/>
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
|
@ -77,7 +61,7 @@
|
|||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_ATTRIBUTE/>
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
|
@ -88,7 +72,7 @@
|
|||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_ATTRIBUTE/>
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
|
@ -100,7 +84,7 @@
|
|||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_ATTRIBUTE/>
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
|
@ -111,7 +95,7 @@
|
|||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_ATTRIBUTE/>
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
|
@ -122,7 +106,7 @@
|
|||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_ATTRIBUTE/>
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
|
@ -133,7 +117,7 @@
|
|||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_ATTRIBUTE/>
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
|
@ -144,7 +128,7 @@
|
|||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_ATTRIBUTE/>
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
|
@ -156,7 +140,7 @@
|
|||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_ATTRIBUTE/>
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
|
@ -168,7 +152,7 @@
|
|||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_ATTRIBUTE/>
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true"/>
|
||||
</state>
|
||||
</component>
|
|
@ -1,6 +1,7 @@
|
|||
pipeline:
|
||||
author-header:
|
||||
image: qwerty287/woodpecker-regex-check
|
||||
group: check
|
||||
settings:
|
||||
pattern: "*.java"
|
||||
regex: " \\\\* \\\\@author [\\\\S\\\\s]+"
|
||||
|
@ -8,3 +9,7 @@ pipeline:
|
|||
|
||||
style:
|
||||
image: qwerty287/woodpecker-intellij-formatter
|
||||
group: check
|
||||
settings:
|
||||
file_pattern: "*.java"
|
||||
path: "app/"
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# Changelog
|
||||
|
||||
[Check out the release notes](https://codeberg.org/gitnex/GitNex/releases)
|
||||
|
|
22
README.md
22
README.md
|
@ -4,26 +4,33 @@
|
|||
|
||||
# GitNex - Android client for Gitea
|
||||
|
||||
GitNex is a free/paid, open-source Android client for Git repository management tool Gitea. Gitea is a community managed fork of Gogs, lightweight code hosting solution written in Go.
|
||||
GitNex is a free/paid, open-source Android client for Git repository management tool Gitea. Gitea is a community managed fork of Gogs, lightweight
|
||||
code hosting solution written in Go.
|
||||
|
||||
GitNex is licensed under GPLv3 License. See the LICENSE file for the full license text. **No trackers are used** and source code is available here for anyone to audit.
|
||||
GitNex is licensed under GPLv3 License. See the LICENSE file for the full license text. **No trackers are used** and source code is available here for
|
||||
anyone to audit.
|
||||
|
||||
## Downloads
|
||||
|
||||
[<img alt='Get it on F-Droid' src='https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/fdroid.png' height="80"/>](https://f-droid.org/en/packages/org.mian.gitnex/)
|
||||
[<img alt='Get it on Google Play' src='https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/google-play.png' height="80"/>](https://play.google.com/store/apps/details?id=org.mian.gitnex.pro)
|
||||
[<img alt='Download builds and releases' src='https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/apk-badge.png' height="82"/>](https://cloud.swatian.com/s/DN7E5xxtaw4fRbE)
|
||||
|
||||
## Note about Gitea version
|
||||
|
||||
Please make sure that you are on latest stable release or later for better app experience.
|
||||
|
||||
Check the versions [compatibility page](https://codeberg.org/gitnex/GitNex/wiki/Compatibility) which lists all the supported versions with compatibility ratio.
|
||||
Check the versions [compatibility page](https://codeberg.org/gitnex/GitNex/wiki/Compatibility) which lists all the supported versions with
|
||||
compatibility ratio.
|
||||
|
||||
## Build from source
|
||||
|
||||
Option 1 - Download the source code, open it in Android Studio and build it there.
|
||||
|
||||
Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew assembleFree`.
|
||||
|
||||
## Features
|
||||
|
||||
- Multiple accounts support
|
||||
- File and directory browser
|
||||
- File viewer
|
||||
|
@ -37,12 +44,15 @@ Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew assemb
|
|||
- [& more...](https://codeberg.org/gitnex/GitNex/wiki/Features)
|
||||
|
||||
## Contributing
|
||||
|
||||
[Contributing](https://codeberg.org/gitnex/GitNex/wiki/Contributing)
|
||||
|
||||
## Translation
|
||||
|
||||
Help us translate GitNex to your native language.
|
||||
|
||||
We use [Crowdin](https://crowdin.com/project/gitnex) for translation. If your language is not listed, please request [here](https://codeberg.org/gitnex/GitNex/issues) to add it to the project.
|
||||
We use [Crowdin](https://crowdin.com/project/gitnex) for translation. If your language is not listed, please
|
||||
request [here](https://codeberg.org/gitnex/GitNex/issues) to add it to the project.
|
||||
|
||||
**Link: https://crowdin.com/project/GitNex**
|
||||
|
||||
|
@ -53,6 +63,7 @@ We use [Crowdin](https://crowdin.com/project/gitnex) for translation. If your la
|
|||
[<img src="https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/005.png" alt="005.png" width="200"/>](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/005.png) | [<img src="https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/006.png" alt="006.png" width="200"/>](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/006.png) | [<img src="https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/007.png" alt="007.png" width="200"/>](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/007.png) | [<img src="https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/008.png" alt="008.png" width="200"/>](https://codeberg.org/gitnex/GitNex/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/008.png)
|
||||
|
||||
## Links
|
||||
|
||||
[Website](https://gitnex.com)
|
||||
|
||||
[Wiki](https://codeberg.org/gitnex/GitNex/wiki/Home)
|
||||
|
@ -64,9 +75,11 @@ We use [Crowdin](https://crowdin.com/project/gitnex) for translation. If your la
|
|||
[Release Blog](https://gitnex.codeberg.page)
|
||||
|
||||
## Thanks
|
||||
|
||||
Thanks to all the open source libraries, contributors and donators.
|
||||
|
||||
#### Open source libraries
|
||||
|
||||
- [square/retrofit](https://github.com/square/retrofit)
|
||||
- [google/gson](https://github.com/google/gson)
|
||||
- [square/okhttp](https://github.com/square/okhttp)
|
||||
|
@ -89,6 +102,7 @@ Thanks to all the open source libraries, contributors and donators.
|
|||
- [AmrDeveloper/CodeView](https://github.com/AmrDeveloper/CodeView)
|
||||
|
||||
#### Icon sets
|
||||
|
||||
- [lucide-icons/lucide](https://github.com/lucide-icons/lucide)
|
||||
- [primer/octicons](https://github.com/primer/octicons)
|
||||
- [google/material-design-icons](https://github.com/google/material-design-icons)
|
||||
|
|
|
@ -39,7 +39,7 @@ android {
|
|||
lint {
|
||||
abortOnError false
|
||||
}
|
||||
defaultConfig{
|
||||
defaultConfig {
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author qwerty287
|
||||
|
@ -109,5 +107,6 @@ public class AppUtilTest {
|
|||
assertEquals("https://gitnex.com", AppUtil.changeScheme(Uri.parse("http://gitnex.com"), "https").toString());
|
||||
assertEquals("ssh://codeberg.org/gitnex/GitNex", AppUtil.changeScheme(Uri.parse("http://codeberg.org/gitnex/GitNex"), "ssh").toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="org.mian.gitnex">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
|
||||
|
||||
<application
|
||||
android:name=".core.MainApplication"
|
||||
|
@ -20,182 +20,183 @@
|
|||
tools:targetApi="n">
|
||||
<activity
|
||||
android:name=".activities.MergePullRequestActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.FileViewActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.CreateFileActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.RepoWatchersActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.RepoStargazersActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.AdminGetUsersActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AdminUnadoptedReposActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateReleaseActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.EditIssueActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateNewUserActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.MyProfileEmailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AddCollaboratorToRepositoryActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateTeamByOrgActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.OrganizationTeamInfoActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.OrganizationDetailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.CreateLabelActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateIssueActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateMilestoneActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.IssueDetailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:windowSoftInputMode="adjustNothing" />
|
||||
android:windowSoftInputMode="adjustNothing"/>
|
||||
<activity
|
||||
android:name=".activities.RepoDetailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.MainActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@android:style/Theme.NoTitleBar"
|
||||
android:exported="true">
|
||||
android:exported="true"
|
||||
android:theme="@android:style/Theme.NoTitleBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.LoginActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@android:style/Theme.NoTitleBar" />
|
||||
android:theme="@android:style/Theme.NoTitleBar"/>
|
||||
<activity
|
||||
android:name=".activities.CreateRepoActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateOrganizationActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.DiffActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@android:style/Theme.NoTitleBar" />
|
||||
android:theme="@android:style/Theme.NoTitleBar"/>
|
||||
<activity
|
||||
android:name=".activities.CommitsActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CommitDetailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@android:style/Theme.NoTitleBar" />
|
||||
android:theme="@android:style/Theme.NoTitleBar"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsAppearanceActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.ProfileActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsSecurityActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsTranslationActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsReportsActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AddNewTeamMemberActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AddNewTeamRepoActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsDraftsActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.RepoForksActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AddNewAccountActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.RepositorySettingsActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreatePullRequestActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsGeneralActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsNotificationsActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AdminCronTasksActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.WikiActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:name=".activities.CodeEditorActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:windowSoftInputMode="adjustResize"/>
|
||||
|
||||
<meta-data
|
||||
android:name="com.samsung.android.keepalive.density"
|
||||
android:value="true" /> <!-- Version >= 3.0. DeX Dual Mode support -->
|
||||
android:value="true"/> <!-- Version >= 3.0. DeX Dual Mode support -->
|
||||
<meta-data
|
||||
android:name="com.samsung.android.multidisplay.keep_process_alive"
|
||||
android:value="true" /> <!-- deep links -->
|
||||
android:value="true"/> <!-- deep links -->
|
||||
<activity
|
||||
android:name=".activities.DeepLinksActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:noHistory="true"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
android:exported="true">
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<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" />
|
||||
<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>
|
||||
</application>
|
||||
|
|
|
@ -14,11 +14,8 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class ActionResult<R> {
|
||||
|
||||
public enum Status { SUCCESS, FAILED }
|
||||
|
||||
private final BlockingQueue<Boolean> blockingQueue;
|
||||
private final List<OnFinishedListener<R>> onFinishedListeners;
|
||||
|
||||
private boolean invalidated = false;
|
||||
|
||||
public ActionResult() {
|
||||
|
@ -42,13 +39,17 @@ public class ActionResult<R> {
|
|||
onFinishedListener.onFinished(status, result);
|
||||
}
|
||||
|
||||
} catch (InterruptedException ignored) {}
|
||||
}
|
||||
catch(InterruptedException ignored) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
|
||||
if(invalidated) throw new IllegalStateException("Already invalidated");
|
||||
if(invalidated) {
|
||||
throw new IllegalStateException("Already invalidated");
|
||||
}
|
||||
this.invalidated = true;
|
||||
|
||||
}
|
||||
|
@ -70,11 +71,16 @@ public class ActionResult<R> {
|
|||
|
||||
}
|
||||
|
||||
public static class None {}
|
||||
public enum Status {SUCCESS, FAILED}
|
||||
|
||||
public interface OnFinishedListener<R> {
|
||||
|
||||
void onFinished(Status status, R result);
|
||||
|
||||
}
|
||||
|
||||
public static class None {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,9 +24,7 @@ public class AssigneesActions {
|
|||
|
||||
public static void getCurrentIssueAssignees(Context ctx, String repoOwner, String repoName, int issueIndex, List<String> currentAssignees) {
|
||||
|
||||
Call<Issue> callSingleIssueLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
Call<Issue> callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -63,11 +61,10 @@ public class AssigneesActions {
|
|||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<User> assigneesList, MaterialAlertDialogBuilder materialAlertDialogBuilder, AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding, ProgressBar progressBar) {
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<User> assigneesList, MaterialAlertDialogBuilder materialAlertDialogBuilder, AssigneesListAdapter assigneesAdapter,
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding, ProgressBar progressBar) {
|
||||
|
||||
Call<List<User>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoGetAssignees(repoOwner, repoName);
|
||||
Call<List<User>> call = RetrofitClient.getApiInterface(ctx).repoGetAssignees(repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -113,4 +110,5 @@ public class AssigneesActions {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,9 +21,7 @@ public class CollaboratorActions {
|
|||
|
||||
public static void deleteCollaborator(final Context context, String userName, RepositoryContext repository) {
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.repoDeleteCollaborator(repository.getOwner(), repository.getName(), userName);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoDeleteCollaborator(repository.getOwner(), repository.getName(), userName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -70,9 +68,7 @@ public class CollaboratorActions {
|
|||
AddCollaboratorOption permissionString = new AddCollaboratorOption();
|
||||
permissionString.setPermission(permission);
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.repoAddCollaborator(repository.getOwner(), repository.getName(), userName, permissionString);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoAddCollaborator(repository.getOwner(), repository.getName(), userName, permissionString);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -112,4 +108,5 @@ public class CollaboratorActions {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,11 +3,7 @@ package org.mian.gitnex.actions;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.Comment;
|
||||
import org.gitnex.tea4j.v2.models.CreateIssueCommentOption;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueCommentOption;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
|
@ -35,10 +31,7 @@ public class IssueActions {
|
|||
EditIssueCommentOption commentObj = new EditIssueCommentOption();
|
||||
commentObj.setBody(comment);
|
||||
|
||||
Call<Comment> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.issueEditComment(issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), (long) commentId, commentObj);
|
||||
Call<Comment> call = RetrofitClient.getApiInterface(context).issueEditComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId, commentObj);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -77,10 +70,7 @@ public class IssueActions {
|
|||
|
||||
EditIssueOption issueStatJson = new EditIssueOption();
|
||||
issueStatJson.setState(issueState);
|
||||
Call<Issue> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueEditIssue(issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), (long) issue.getIssueIndex(), issueStatJson);
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx).issueEditIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueStatJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -113,8 +103,7 @@ public class IssueActions {
|
|||
|
||||
IssueDetailActivity.singleIssueUpdate = true;
|
||||
((IssueDetailActivity) ctx).onResume();
|
||||
if(((Activity) ctx).getIntent().getStringExtra("openedFromLink") == null ||
|
||||
!((Activity) ctx).getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
if(((Activity) ctx).getIntent().getStringExtra("openedFromLink") == null || !((Activity) ctx).getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
}
|
||||
}
|
||||
|
@ -150,10 +139,8 @@ public class IssueActions {
|
|||
|
||||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueAddSubscription(issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueAddSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -193,8 +180,8 @@ public class IssueActions {
|
|||
|
||||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).issueDeleteSubscription(issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueDeleteSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -237,10 +224,7 @@ public class IssueActions {
|
|||
CreateIssueCommentOption issueComment = new CreateIssueCommentOption();
|
||||
issueComment.setBody(comment);
|
||||
|
||||
Call<Comment> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.issueCreateComment(issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), (long) issue.getIssueIndex(), issueComment);
|
||||
Call<Comment> call = RetrofitClient.getApiInterface(context).issueCreateComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueComment);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -275,4 +259,5 @@ public class IssueActions {
|
|||
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,9 +23,7 @@ public class LabelsActions {
|
|||
|
||||
public static void getCurrentIssueLabels(Context ctx, String repoOwner, String repoName, int issueIndex, List<Integer> currentLabelsIds) {
|
||||
|
||||
Call<List<Label>> callSingleIssueLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueGetLabels(repoOwner, repoName, (long) issueIndex);
|
||||
Call<List<Label>> callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetLabels(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -59,11 +57,10 @@ public class LabelsActions {
|
|||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Label> labelsList, MaterialAlertDialogBuilder materialAlertDialogBuilder, LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding, ProgressBar progressBar) {
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Label> labelsList, MaterialAlertDialogBuilder materialAlertDialogBuilder, LabelsListAdapter labelsAdapter,
|
||||
CustomLabelsSelectionDialogBinding labelsBinding, ProgressBar progressBar) {
|
||||
|
||||
Call<List<Label>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueListLabels(repoOwner, repoName, null, null);
|
||||
Call<List<Label>> call = RetrofitClient.getApiInterface(ctx).issueListLabels(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -80,9 +77,7 @@ public class LabelsActions {
|
|||
}
|
||||
|
||||
// Load organization labels
|
||||
Call<List<Label>> callOrgLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.orgListLabels(repoOwner, null, null);
|
||||
Call<List<Label>> callOrgLabels = RetrofitClient.getApiInterface(ctx).orgListLabels(repoOwner, null, null);
|
||||
|
||||
callOrgLabels.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -129,4 +124,5 @@ public class LabelsActions {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,9 +32,7 @@ public class MilestoneActions {
|
|||
|
||||
EditMilestoneOption milestoneStateJson = new EditMilestoneOption();
|
||||
milestoneStateJson.setState(state);
|
||||
Call<Milestone> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueEditMilestone(repository.getOwner(), repository.getName(), String.valueOf(milestoneId_), milestoneStateJson);
|
||||
Call<Milestone> call = RetrofitClient.getApiInterface(ctx).issueEditMilestone(repository.getOwner(), repository.getName(), String.valueOf(milestoneId_), milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
|
|
@ -17,9 +17,7 @@ import retrofit2.Response;
|
|||
public class PullRequestActions {
|
||||
|
||||
public static void deleteHeadBranch(Context context, String repoOwner, String repoName, String headBranch, boolean showToasts) {
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.repoDeleteBranch(repoOwner, repoName, headBranch);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoDeleteBranch(repoOwner, repoName, headBranch);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -79,8 +77,7 @@ public class PullRequestActions {
|
|||
else {
|
||||
strategy = "rebase";
|
||||
}
|
||||
RetrofitClient.getApiInterface(context).repoUpdatePullRequest(repoOwner, repoName, Long.valueOf(index), strategy)
|
||||
.enqueue(new Callback<>() {
|
||||
RetrofitClient.getApiInterface(context).repoUpdatePullRequest(repoOwner, repoName, Long.valueOf(index), strategy).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call call, @NonNull Response response) {
|
||||
|
@ -108,4 +105,5 @@ public class PullRequestActions {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,7 @@ public class RepositoryActions {
|
|||
|
||||
public static void starRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.userCurrentPutStar(repository.getOwner(), repository.getName());
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).userCurrentPutStar(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -64,9 +62,7 @@ public class RepositoryActions {
|
|||
|
||||
public static void unStarRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.userCurrentDeleteStar(repository.getOwner(), repository.getName());
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).userCurrentDeleteStar(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -108,9 +104,7 @@ public class RepositoryActions {
|
|||
|
||||
public static void watchRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<WatchInfo> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.userCurrentPutSubscription(repository.getOwner(), repository.getName());
|
||||
Call<WatchInfo> call = RetrofitClient.getApiInterface(context).userCurrentPutSubscription(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -153,9 +147,7 @@ public class RepositoryActions {
|
|||
|
||||
public static void unWatchRepository(final Context context, RepositoryContext repository) {
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.userCurrentDeleteStar(repository.getOwner(), repository.getName());
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).userCurrentDeleteStar(repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -191,4 +183,5 @@ public class RepositoryActions {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,7 @@ public class TeamActions {
|
|||
|
||||
public static void removeTeamMember(final Context context, String userName, int teamId) {
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.orgRemoveTeamMember((long) teamId, userName);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).orgRemoveTeamMember((long) teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -66,9 +64,7 @@ public class TeamActions {
|
|||
|
||||
public static void addTeamMember(final Context context, String userName, int teamId) {
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.orgAddTeamMember((long) teamId, userName);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).orgAddTeamMember((long) teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -111,9 +107,7 @@ public class TeamActions {
|
|||
|
||||
public static void removeTeamRepo(final Context context, String orgName, int teamId, String repo) {
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.orgRemoveTeamRepository((long) teamId, orgName, repo);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).orgRemoveTeamRepository((long) teamId, orgName, repo);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -158,9 +152,7 @@ public class TeamActions {
|
|||
|
||||
public static void addTeamRepo(final Context context, String orgName, int teamId, String repo) {
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.orgAddTeamRepository((long) teamId, orgName, repo);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).orgAddTeamRepository((long) teamId, orgName, repo);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -201,4 +193,5 @@ public class TeamActions {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||
|
||||
activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.setOnEditorActionListener((v, actionId, event) -> {
|
||||
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
|
||||
if(!Objects.requireNonNull(activityAddCollaboratorToRepositoryBinding.addCollaboratorSearch.getText()).toString().equals("")) {
|
||||
|
||||
|
@ -68,9 +68,7 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||
|
||||
public void loadUserSearchList(String searchKeyword) {
|
||||
|
||||
Call<InlineResponse2001> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.userSearch(searchKeyword, null, 1, 10);
|
||||
Call<InlineResponse2001> call = RetrofitClient.getApiInterface(ctx).userSearch(searchKeyword, null, 1, 10);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -103,8 +101,7 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setHasFixedSize(true);
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.getContext(), DividerItemDecoration.VERTICAL);
|
||||
activityAddCollaboratorToRepositoryBinding.recyclerViewUserSearch.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
activityAddCollaboratorToRepositoryBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
@ -131,4 +128,5 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,11 +17,7 @@ import org.mian.gitnex.database.api.BaseApi;
|
|||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.structs.Protocol;
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
|
@ -61,7 +57,8 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
if(scheme != null && scheme.equals("http")) {
|
||||
viewBinding.protocolSpinner.setText(Protocol.HTTP.toString());
|
||||
spinnerSelectedValue = Protocol.HTTP.toString();
|
||||
} else { // default is https
|
||||
}
|
||||
else { // default is https
|
||||
viewBinding.protocolSpinner.setText(Protocol.HTTPS.toString());
|
||||
spinnerSelectedValue = Protocol.HTTPS.toString();
|
||||
}
|
||||
|
@ -114,8 +111,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
|
||||
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET, "http")).toUri();
|
||||
|
||||
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(protocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/"))
|
||||
.toUri();
|
||||
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(protocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/")).toUri();
|
||||
|
||||
versionCheck(instanceUrl.toString(), loginToken);
|
||||
serverPageLimitSettings();
|
||||
|
@ -152,10 +148,8 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
|
||||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion()))
|
||||
.setNeutralButton(getString(R.string.cancelButton), null)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setNeutralButton(getString(R.string.cancelButton), null)
|
||||
.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||
|
||||
dialog.dismiss();
|
||||
|
@ -290,4 +284,5 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -105,4 +105,5 @@ public class AddNewTeamRepoActivity extends BaseActivity {
|
|||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,13 +20,11 @@ import org.mian.gitnex.viewmodels.AdminCronTasksViewModel;
|
|||
|
||||
public class AdminCronTasksActivity extends BaseActivity {
|
||||
|
||||
private final int PAGE = 1;
|
||||
private AdminCronTasksViewModel adminCronTasksViewModel;
|
||||
private View.OnClickListener onClickListener;
|
||||
private AdminCronTasksAdapter adapter;
|
||||
|
||||
private ActivityAdminCronTasksBinding activityAdminCronTasksBinding;
|
||||
|
||||
private final int PAGE = 1;
|
||||
private int resultLimit;
|
||||
|
||||
@Override
|
||||
|
@ -48,8 +46,7 @@ public class AdminCronTasksActivity extends BaseActivity {
|
|||
activityAdminCronTasksBinding.recyclerView.setHasFixedSize(true);
|
||||
activityAdminCronTasksBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminCronTasksBinding.recyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminCronTasksBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
activityAdminCronTasksBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
activityAdminCronTasksBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
@ -83,4 +80,5 @@ public class AdminCronTasksActivity extends BaseActivity {
|
|||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,8 +55,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
|
||||
activityAdminGetUsersBinding.recyclerView.setHasFixedSize(true);
|
||||
activityAdminGetUsersBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminGetUsersBinding.recyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminGetUsersBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
activityAdminGetUsersBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
activityAdminGetUsersBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
@ -68,7 +67,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
}, 50));
|
||||
|
||||
fetchDataAsync();
|
||||
};
|
||||
}
|
||||
|
||||
private void fetchDataAsync() {
|
||||
|
||||
|
@ -134,7 +133,9 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) { return true; }
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
@ -182,4 +183,5 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,8 +55,7 @@ public class AdminUnadoptedReposActivity extends BaseActivity {
|
|||
binding.recyclerView.setHasFixedSize(true);
|
||||
binding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(binding.recyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(binding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
binding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
binding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
@ -112,4 +111,5 @@ public class AdminUnadoptedReposActivity extends BaseActivity {
|
|||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,12 +45,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
break;
|
||||
case 2:
|
||||
|
||||
if(TimeHelper.timeBetweenHours(
|
||||
tinyDB.getInt("darkThemeTimeHour", 18),
|
||||
tinyDB.getInt("lightThemeTimeHour", 6),
|
||||
tinyDB.getInt("darkThemeTimeMinute", 0),
|
||||
tinyDB.getInt("lightThemeTimeMinute", 0))
|
||||
) {
|
||||
if(TimeHelper.timeBetweenHours(tinyDB.getInt("darkThemeTimeHour", 18), tinyDB.getInt("lightThemeTimeHour", 6), tinyDB.getInt("darkThemeTimeMinute", 0), tinyDB.getInt("lightThemeTimeMinute", 0))) {
|
||||
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
|
@ -64,12 +59,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
setTheme(R.style.AppThemeRetro);
|
||||
break;
|
||||
case 4:
|
||||
if(TimeHelper.timeBetweenHours(
|
||||
tinyDB.getInt("darkThemeTimeHour", 18),
|
||||
tinyDB.getInt("lightThemeTimeHour", 6),
|
||||
tinyDB.getInt("darkThemeTimeMinute", 0),
|
||||
tinyDB.getInt("lightThemeTimeMinute", 0))
|
||||
) {
|
||||
if(TimeHelper.timeBetweenHours(tinyDB.getInt("darkThemeTimeHour", 18), tinyDB.getInt("lightThemeTimeHour", 6), tinyDB.getInt("darkThemeTimeMinute", 0), tinyDB.getInt("lightThemeTimeMinute", 0))) {
|
||||
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
|
@ -91,7 +81,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
String locale = tinyDB.getString("locale");
|
||||
if (locale.isEmpty()) {
|
||||
if(locale.isEmpty()) {
|
||||
AppUtil.setAppLocale(getResources(), Locale.getDefault().getLanguage());
|
||||
}
|
||||
else {
|
||||
|
@ -127,15 +117,14 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
// Authentication failed, close the app
|
||||
@Override public void onAuthenticationFailed() {
|
||||
@Override
|
||||
public void onAuthenticationFailed() {
|
||||
super.onAuthenticationFailed();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
BiometricPrompt.PromptInfo biometricPromptBuilder = new BiometricPrompt.PromptInfo.Builder()
|
||||
.setTitle(getString(R.string.biometricAuthTitle))
|
||||
.setSubtitle(getString(R.string.biometricAuthSubTitle))
|
||||
BiometricPrompt.PromptInfo biometricPromptBuilder = new BiometricPrompt.PromptInfo.Builder().setTitle(getString(R.string.biometricAuthTitle)).setSubtitle(getString(R.string.biometricAuthSubTitle))
|
||||
.setNegativeButtonText(getString(R.string.cancelButton)).build();
|
||||
|
||||
biometricPrompt.authenticate(biometricPromptBuilder);
|
||||
|
@ -146,6 +135,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
public AccountContext getAccount() {
|
||||
return ((MainApplication) getApplication()).currentAccount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,11 +10,7 @@ import com.amrdeveloper.codeview.Code;
|
|||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.databinding.ActivityCodeEditorBinding;
|
||||
import org.mian.gitnex.helpers.codeeditor.CustomCodeViewAdapter;
|
||||
import org.mian.gitnex.helpers.codeeditor.LanguageManager;
|
||||
import org.mian.gitnex.helpers.codeeditor.LanguageName;
|
||||
import org.mian.gitnex.helpers.codeeditor.SourcePositionListener;
|
||||
import org.mian.gitnex.helpers.codeeditor.ThemeName;
|
||||
import org.mian.gitnex.helpers.codeeditor.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -26,10 +22,10 @@ import java.util.Map;
|
|||
|
||||
public class CodeEditorActivity extends BaseActivity {
|
||||
|
||||
private final ThemeName currentTheme = ThemeName.FIVE_COLOR;
|
||||
private ActivityCodeEditorBinding binding;
|
||||
private LanguageManager languageManager;
|
||||
private LanguageName currentLanguage = LanguageName.UNKNOWN;
|
||||
private final ThemeName currentTheme = ThemeName.FIVE_COLOR;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -105,7 +101,7 @@ public class CodeEditorActivity extends BaseActivity {
|
|||
private void configLanguageAutoComplete() {
|
||||
|
||||
boolean useModernAutoCompleteAdapter = true;
|
||||
if (useModernAutoCompleteAdapter) {
|
||||
if(useModernAutoCompleteAdapter) {
|
||||
List<Code> codeList = languageManager.getLanguageCodeList(currentLanguage);
|
||||
|
||||
CustomCodeViewAdapter adapter = new CustomCodeViewAdapter(this, codeList);
|
||||
|
@ -146,4 +142,5 @@ public class CodeEditorActivity extends BaseActivity {
|
|||
binding.sourcePosition.setText(getString(R.string.sourcePosition, line, column));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,20 +29,15 @@ public class CommitDetailActivity extends BaseActivity {
|
|||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if(getSupportFragmentManager().findFragmentById(R.id.fragment_container) instanceof DiffFragment) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment)
|
||||
.commit();
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment).commit();
|
||||
}
|
||||
else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment)
|
||||
.commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment).commit();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -38,17 +38,16 @@ import retrofit2.Response;
|
|||
|
||||
public class CommitsActivity extends BaseActivity {
|
||||
|
||||
private final String TAG = "CommitsActivity";
|
||||
public RepositoryContext repository;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView noData;
|
||||
private ProgressBar progressBar;
|
||||
private final String TAG = "CommitsActivity";
|
||||
private int resultLimit;
|
||||
private int pageSize = 1;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private List<Commit> commitsList;
|
||||
private CommitsAdapter adapter;
|
||||
public RepositoryContext repository;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
|
|
@ -15,12 +15,7 @@ import androidx.activity.result.ActivityResultLauncher;
|
|||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreateFileOptions;
|
||||
import org.gitnex.tea4j.v2.models.DeleteFileOptions;
|
||||
import org.gitnex.tea4j.v2.models.FileDeleteResponse;
|
||||
import org.gitnex.tea4j.v2.models.FileResponse;
|
||||
import org.gitnex.tea4j.v2.models.UpdateFileOptions;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateFileBinding;
|
||||
|
@ -41,19 +36,21 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
private ActivityCreateFileBinding binding;
|
||||
|
||||
public static final int FILE_ACTION_CREATE = 0;
|
||||
public static final int FILE_ACTION_DELETE = 1;
|
||||
public static final int FILE_ACTION_EDIT = 2;
|
||||
|
||||
private final List<String> branches = new ArrayList<>();
|
||||
private ActivityCreateFileBinding binding;
|
||||
ActivityResultLauncher<Intent> codeEditorActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == Activity.RESULT_OK) {
|
||||
Intent data = result.getData();
|
||||
assert data != null;
|
||||
binding.newFileContent.setText(data.getStringExtra("fileContentFromActivity"));
|
||||
}
|
||||
});
|
||||
private int fileAction = FILE_ACTION_CREATE;
|
||||
|
||||
private String filePath;
|
||||
private String fileSha;
|
||||
|
||||
private final List<String> branches = new ArrayList<>();
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
@ -80,8 +77,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 &&
|
||||
(motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
|
@ -124,9 +120,8 @@ public class CreateFileActivity extends BaseActivity {
|
|||
|
||||
disableProcessButton();
|
||||
|
||||
binding.openCodeEditor.setOnClickListener(v ->
|
||||
launchCodeEditorActivityForResult(Objects.requireNonNull(binding.newFileContent.getText()).toString(), FilenameUtils.getExtension(String.valueOf(binding.newFileName.getText())))
|
||||
);
|
||||
binding.openCodeEditor.setOnClickListener(
|
||||
v -> launchCodeEditorActivityForResult(Objects.requireNonNull(binding.newFileContent.getText()).toString(), FilenameUtils.getExtension(String.valueOf(binding.newFileName.getText()))));
|
||||
|
||||
NetworkStatusObserver networkStatusObserver = NetworkStatusObserver.getInstance(ctx);
|
||||
networkStatusObserver.registerNetworkStatusListener(hasNetworkConnection -> runOnUiThread(() -> binding.newFileCreate.setEnabled(hasNetworkConnection)));
|
||||
|
@ -141,15 +136,6 @@ public class CreateFileActivity extends BaseActivity {
|
|||
codeEditorActivityResultLauncher.launch(intent);
|
||||
}
|
||||
|
||||
ActivityResultLauncher<Intent> codeEditorActivityResultLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == Activity.RESULT_OK) {
|
||||
Intent data = result.getData();
|
||||
assert data != null;
|
||||
binding.newFileContent.setText(data.getStringExtra("fileContentFromActivity"));
|
||||
}
|
||||
});
|
||||
|
||||
private void processNewFile() {
|
||||
|
||||
String newFileName = binding.newFileName.getText() != null ? binding.newFileName.getText().toString() : "";
|
||||
|
@ -208,9 +194,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
createNewFileJsonStr.setNewBranch(branchName);
|
||||
}
|
||||
|
||||
Call<FileResponse> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoCreateFile(createNewFileJsonStr, repoOwner, repoName, fileName);
|
||||
Call<FileResponse> call = RetrofitClient.getApiInterface(ctx).repoCreateFile(createNewFileJsonStr, repoOwner, repoName, fileName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -268,9 +252,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
deleteFileJsonStr.setNewBranch(branchName);
|
||||
}
|
||||
|
||||
Call<FileDeleteResponse> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoDeleteFileWithBody(repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||
Call<FileDeleteResponse> call = RetrofitClient.getApiInterface(ctx).repoDeleteFileWithBody(repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -329,9 +311,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
editFileJsonStr.setNewBranch(branchName);
|
||||
}
|
||||
|
||||
Call<FileResponse> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoUpdateFile(editFileJsonStr, repoOwner, repoName, fileName);
|
||||
Call<FileResponse> call = RetrofitClient.getApiInterface(ctx).repoUpdateFile(editFileJsonStr, repoOwner, repoName, fileName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -378,9 +358,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
|
||||
private void getBranches(String repoOwner, String repoName) {
|
||||
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoListBranches(repoOwner, repoName, null, null);
|
||||
Call<List<Branch>> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -410,12 +388,18 @@ public class CreateFileActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private void disableProcessButton() { binding.newFileCreate.setEnabled(false); }
|
||||
private void enableProcessButton() { binding.newFileCreate.setEnabled(true); }
|
||||
private void disableProcessButton() {
|
||||
binding.newFileCreate.setEnabled(false);
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
binding.newFileCreate.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,11 +12,7 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.gitnex.tea4j.v2.models.CreateIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.AssigneesActions;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
|
@ -32,12 +28,7 @@ import org.mian.gitnex.helpers.AppUtil;
|
|||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
@ -47,22 +38,18 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateIssueActivity extends BaseActivity implements View.OnClickListener, LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener {
|
||||
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private ActivityCreateIssueBinding viewBinding;
|
||||
private View.OnClickListener onClickListener;
|
||||
private int milestoneId;
|
||||
private Date currentDate = null;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
private AssigneesListAdapter assigneesAdapter;
|
||||
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private List<String> assigneesListData = new ArrayList<>();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
@ -92,7 +79,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
|
@ -160,23 +147,20 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding = CustomAssigneesSelectionDialogBinding.inflate(
|
||||
LayoutInflater.from(ctx));
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding = CustomAssigneesSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = assigneesBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
materialAlertDialogBuilder.setNeutralButton(R.string.close, null);
|
||||
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repository.getOwner(), repository.getName(), assigneesList, materialAlertDialogBuilder, assigneesAdapter,
|
||||
assigneesBinding, viewBinding.progressBar);
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repository.getOwner(), repository.getName(), assigneesList, materialAlertDialogBuilder, assigneesAdapter, assigneesBinding, viewBinding.progressBar);
|
||||
}
|
||||
|
||||
private void showLabels() {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(
|
||||
LayoutInflater.from(ctx));
|
||||
CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = labelsBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
|
@ -199,7 +183,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
return;
|
||||
}
|
||||
|
||||
if (newIssueTitleForm.equals("")) {
|
||||
if(newIssueTitleForm.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
||||
return;
|
||||
|
@ -224,9 +208,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
createNewIssueJson.setAssignees(assigneesListData);
|
||||
createNewIssueJson.setLabels(labelIds);
|
||||
|
||||
Call<Issue> call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueCreateIssue(repoOwner, repoName, createNewIssueJson);
|
||||
Call<Issue> call3 = RetrofitClient.getApiInterface(ctx).issueCreateIssue(repoOwner, repoName, createNewIssueJson);
|
||||
|
||||
call3.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -273,9 +255,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestone>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
Call<List<Milestone>> call = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -335,15 +315,14 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (v == viewBinding.newIssueDueDate) {
|
||||
if(v == viewBinding.newIssueDueDate) {
|
||||
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int mYear = c.get(Calendar.YEAR);
|
||||
final int mMonth = c.get(Calendar.MONTH);
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this, (view, year, monthOfYear, dayOfMonth) -> {
|
||||
viewBinding.newIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
|
@ -370,4 +349,5 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,9 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
|
||||
private RepositoryContext repository;
|
||||
private String labelColor = "";
|
||||
private final View.OnClickListener createLabelListener = v -> processCreateLabel();
|
||||
private String labelColorDefault = "";
|
||||
private final View.OnClickListener updateLabelListener = v -> processUpdateLabel();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -105,10 +107,6 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private final View.OnClickListener createLabelListener = v -> processCreateLabel();
|
||||
|
||||
private final View.OnClickListener updateLabelListener = v -> processUpdateLabel();
|
||||
|
||||
private void processUpdateLabel() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
@ -144,8 +142,7 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
disableProcessButton();
|
||||
patchLabel(repository, updateLabelName, updateLabelColor, Integer.parseInt(
|
||||
Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
patchLabel(repository, updateLabelName, updateLabelColor, Integer.parseInt(Objects.requireNonNull(getIntent().getStringExtra("labelId"))));
|
||||
}
|
||||
|
||||
private void processCreateLabel() {
|
||||
|
@ -201,7 +198,8 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
else if(repository != null) {
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx).issueCreateLabel(repository.getOwner(), repository.getName(), createLabelFunc);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -361,7 +359,9 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if(repository == null) return;
|
||||
if(repository == null) {
|
||||
return;
|
||||
}
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
private RepositoryContext repository;
|
||||
|
||||
private Date currentDate = null;
|
||||
private final View.OnClickListener createMilestoneListener = v -> processNewMilestone();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
|
@ -70,7 +71,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
|
@ -92,8 +93,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
|
||||
}
|
||||
|
||||
private final View.OnClickListener createMilestoneListener = v -> processNewMilestone();
|
||||
|
||||
private void processNewMilestone() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
@ -115,7 +114,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
|
||||
if(!newMilestoneDescription.equals("")) {
|
||||
|
||||
if (newMilestoneDescription.length() > 255) {
|
||||
if(newMilestoneDescription.length() > 255) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.milestoneDescError));
|
||||
return;
|
||||
|
@ -135,9 +134,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
|
||||
Call<Milestone> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueCreateMilestone(repoOwner, repoName, createMilestone);
|
||||
call = RetrofitClient.getApiInterface(ctx).issueCreateMilestone(repoOwner, repoName, createMilestone);
|
||||
|
||||
call.enqueue(new Callback<Milestone>() {
|
||||
|
||||
|
@ -181,15 +178,14 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (v == milestoneDueDate) {
|
||||
if(v == milestoneDueDate) {
|
||||
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int mYear = c.get(Calendar.YEAR);
|
||||
final int mMonth = c.get(Calendar.MONTH);
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this, (view, year, monthOfYear, dayOfMonth) -> {
|
||||
milestoneDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
|
|
|
@ -33,6 +33,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
private EditText userEmail;
|
||||
private EditText userPassword;
|
||||
private Button createUserButton;
|
||||
private final View.OnClickListener createNewUserListener = v -> processCreateNewUser();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -122,9 +123,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
createUser.setPassword(newUserPassword);
|
||||
createUser.setMustChangePassword(true);
|
||||
|
||||
Call<User> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.adminCreateUser(createUser);
|
||||
Call<User> call = RetrofitClient.getApiInterface(ctx).adminCreateUser(createUser);
|
||||
|
||||
call.enqueue(new Callback<User>() {
|
||||
|
||||
|
@ -174,8 +173,6 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
|
||||
}
|
||||
|
||||
private final View.OnClickListener createNewUserListener = v -> processCreateNewUser();
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
|
|
|
@ -35,6 +35,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
|
||||
private EditText orgName;
|
||||
private EditText orgDesc;
|
||||
private final View.OnClickListener createOrgListener = v -> processNewOrganization();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
|
@ -61,7 +62,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
|
@ -89,8 +90,6 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private final View.OnClickListener createOrgListener = v -> processNewOrganization();
|
||||
|
||||
private void processNewOrganization() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
@ -106,7 +105,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
|
||||
if(!newOrgDesc.equals("")) {
|
||||
|
||||
if (newOrgDesc.length() > 255) {
|
||||
if(newOrgDesc.length() > 255) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.orgDescError));
|
||||
return;
|
||||
|
@ -135,9 +134,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
createOrganization.setDescription(orgDesc);
|
||||
createOrganization.setUsername(orgName);
|
||||
|
||||
Call<Organization> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.orgCreate(createOrganization);
|
||||
Call<Organization> call = RetrofitClient.getApiInterface(ctx).orgCreate(createOrganization);
|
||||
|
||||
call.enqueue(new Callback<Organization>() {
|
||||
|
||||
|
|
|
@ -11,11 +11,7 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreatePullRequestOption;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
import org.mian.gitnex.adapters.LabelsListAdapter;
|
||||
|
@ -26,12 +22,7 @@ import org.mian.gitnex.fragments.PullRequestsFragment;
|
|||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
@ -41,21 +32,18 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private ActivityCreatePrBinding viewBinding;
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<String> assignees = new ArrayList<>();
|
||||
private int milestoneId;
|
||||
private Date currentDate = null;
|
||||
|
||||
private RepositoryContext repository;
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
List<Label> labelsList = new ArrayList<>();
|
||||
private View.OnClickListener onClickListener;
|
||||
private ActivityCreatePrBinding viewBinding;
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private int milestoneId;
|
||||
private Date currentDate = null;
|
||||
private RepositoryContext repository;
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
|
@ -76,7 +64,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
|
@ -90,9 +78,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
viewBinding.prDueDate.setOnClickListener(dueDate ->
|
||||
setDueDate()
|
||||
);
|
||||
viewBinding.prDueDate.setOnClickListener(dueDate -> setDueDate());
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
|
@ -119,7 +105,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
|
||||
assignees.add("");
|
||||
|
||||
if (labelsIds.size() == 0) {
|
||||
if(labelsIds.size() == 0) {
|
||||
|
||||
labelsIds.add(0);
|
||||
}
|
||||
|
@ -163,9 +149,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
createPullRequest.setLabels(labelIds);
|
||||
createPullRequest.setDueDate(currentDate);
|
||||
|
||||
Call<PullRequest> transferCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoCreatePullRequest(repository.getOwner(), repository.getName(), createPullRequest);
|
||||
Call<PullRequest> transferCall = RetrofitClient.getApiInterface(ctx).repoCreatePullRequest(repository.getOwner(), repository.getName(), createPullRequest);
|
||||
|
||||
transferCall.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -224,8 +208,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
private void showLabels() {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(
|
||||
LayoutInflater.from(ctx));
|
||||
CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = labelsBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
|
@ -235,9 +218,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
|
||||
private void getBranches(String repoOwner, String repoName) {
|
||||
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoListBranches(repoOwner, repoName, null, null);
|
||||
Call<List<Branch>> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -277,9 +258,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
private void getMilestones(String repoOwner, String repoName, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestone>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
Call<List<Milestone>> call = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -336,8 +315,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
final int mMonth = c.get(Calendar.MONTH);
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this, (view, year, monthOfYear, dayOfMonth) -> {
|
||||
viewBinding.prDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
|
@ -364,4 +342,5 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,18 +8,9 @@ import android.util.Log;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.CreateReleaseOption;
|
||||
import org.gitnex.tea4j.v2.models.CreateTagOption;
|
||||
import org.gitnex.tea4j.v2.models.Release;
|
||||
import org.gitnex.tea4j.v2.models.Tag;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateReleaseBinding;
|
||||
|
@ -38,8 +29,9 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
public ImageView closeActivity;
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
private View.OnClickListener onClickListener;
|
||||
private EditText releaseTagName;
|
||||
private AutoCompleteTextView releaseBranch;
|
||||
private EditText releaseTitle;
|
||||
|
@ -49,10 +41,8 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
private Button createNewRelease;
|
||||
private String selectedBranch;
|
||||
private Button createNewTag;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
private final View.OnClickListener createReleaseListener = v -> processNewRelease();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
|
@ -84,7 +74,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
|
@ -141,16 +131,14 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
createReleaseJson.setTagName(tagName);
|
||||
createReleaseJson.setTarget(selectedBranch);
|
||||
|
||||
Call<Tag> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoCreateTag(repository.getOwner(), repository.getName(), createReleaseJson);
|
||||
Call<Tag> call = RetrofitClient.getApiInterface(ctx).repoCreateTag(repository.getOwner(), repository.getName(), createReleaseJson);
|
||||
|
||||
call.enqueue(new Callback<Tag>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Tag> call, @NonNull retrofit2.Response<Tag> response) {
|
||||
|
||||
if (response.code() == 201) {
|
||||
if(response.code() == 201) {
|
||||
|
||||
Intent result = new Intent();
|
||||
result.putExtra("updateReleases", true);
|
||||
|
@ -184,8 +172,6 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private final View.OnClickListener createReleaseListener = v -> processNewRelease();
|
||||
|
||||
private void processNewRelease() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
@ -225,8 +211,8 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
createNewReleaseFunc(repository.getOwner(), repository.getName(), newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
|
||||
}
|
||||
|
||||
private void createNewReleaseFunc(String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent,
|
||||
String selectedBranch, boolean newReleaseType, boolean newReleaseDraft) {
|
||||
private void createNewReleaseFunc(String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent, String selectedBranch, boolean newReleaseType,
|
||||
boolean newReleaseDraft) {
|
||||
|
||||
CreateReleaseOption createReleaseJson = new CreateReleaseOption();
|
||||
createReleaseJson.setName(newReleaseTitle);
|
||||
|
@ -236,9 +222,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
createReleaseJson.setPrerelease(newReleaseType);
|
||||
createReleaseJson.setTargetCommitish(selectedBranch);
|
||||
|
||||
Call<Release> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoCreateRelease(repoOwner, repoName, createReleaseJson);
|
||||
Call<Release> call = RetrofitClient.getApiInterface(ctx).repoCreateRelease(repoOwner, repoName, createReleaseJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -285,9 +269,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
|
||||
private void getBranches(final String repoOwner, final String repoName) {
|
||||
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoListBranches(repoOwner, repoName, null, null);
|
||||
Call<List<Branch>> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -347,4 +329,5 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,12 +7,7 @@ import android.os.Looper;
|
|||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.CreateRepoOption;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
|
@ -36,23 +31,20 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
//https://github.com/go-gitea/gitea/blob/52cfd2743c0e85b36081cf80a850e6a5901f1865/models/repo.go#L964-L967
|
||||
final List<String> reservedRepoNames = Arrays.asList(".", "..");
|
||||
final Pattern reservedRepoPatterns = Pattern.compile("\\.(git|wiki)$");
|
||||
public ImageView closeActivity;
|
||||
List<String> organizationsList = new ArrayList<>();
|
||||
private View.OnClickListener onClickListener;
|
||||
private AutoCompleteTextView spinner;
|
||||
private Button createRepo;
|
||||
private EditText repoName;
|
||||
private EditText repoDesc;
|
||||
private CheckBox repoAccess;
|
||||
|
||||
private String loginUid;
|
||||
|
||||
private String selectedOwner;
|
||||
|
||||
List<String> organizationsList = new ArrayList<>();
|
||||
|
||||
//https://github.com/go-gitea/gitea/blob/52cfd2743c0e85b36081cf80a850e6a5901f1865/models/repo.go#L964-L967
|
||||
final List<String> reservedRepoNames = Arrays.asList(".", "..");
|
||||
final Pattern reservedRepoPatterns = Pattern.compile("\\.(git|wiki)$");
|
||||
private final View.OnClickListener createRepoListener = v -> processNewRepo();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -96,8 +88,6 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private final View.OnClickListener createRepoListener = v -> processNewRepo();
|
||||
|
||||
private void processNewRepo() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
@ -114,7 +104,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
|
||||
if(!newRepoDesc.equals("")) {
|
||||
|
||||
if (newRepoDesc.length() > 255) {
|
||||
if(newRepoDesc.length() > 255) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoDescError));
|
||||
return;
|
||||
|
@ -129,11 +119,11 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
|
||||
Toasty.warning(ctx, getString(R.string.repoNameErrorInvalid));
|
||||
}
|
||||
else if (reservedRepoNames.contains(newRepoName)) {
|
||||
else if(reservedRepoNames.contains(newRepoName)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoNameErrorReservedName));
|
||||
}
|
||||
else if (reservedRepoPatterns.matcher(newRepoName).find()) {
|
||||
else if(reservedRepoPatterns.matcher(newRepoName).find()) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoNameErrorReservedPatterns));
|
||||
}
|
||||
|
@ -160,15 +150,11 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
Call<Repository> call;
|
||||
if(selectedOwner.equals(loginUid)) {
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createCurrentUserRepo(createRepository);
|
||||
call = RetrofitClient.getApiInterface(ctx).createCurrentUserRepo(createRepository);
|
||||
}
|
||||
else {
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.createOrgRepo(selectedOwner, createRepository);
|
||||
call = RetrofitClient.getApiInterface(ctx).createOrgRepo(selectedOwner, createRepository);
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<Repository>() {
|
||||
|
@ -211,9 +197,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
|
||||
private void getOrganizations(final String userLogin) {
|
||||
|
||||
Call<List<Organization>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.orgListCurrentUserOrgs(1, 50);
|
||||
Call<List<Organization>> call = RetrofitClient.getApiInterface(ctx).orgListCurrentUserOrgs(1, 50);
|
||||
|
||||
call.enqueue(new Callback<List<Organization>>() {
|
||||
|
||||
|
@ -247,7 +231,7 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
|
||||
spinner.setAdapter(adapter);
|
||||
|
||||
spinner.setOnItemClickListener ((parent, view, position, id) -> selectedOwner = organizationsList.get(position));
|
||||
spinner.setOnItemClickListener((parent, view, position, id) -> selectedOwner = organizationsList.get(position));
|
||||
|
||||
if(getIntent().getBooleanExtra("organizationAction", false) && organizationId != 0) {
|
||||
|
||||
|
|
|
@ -33,6 +33,10 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
private final String[] accessControlsList = new String[]{"Code", "Issues", "Pull Request", "Releases", "Wiki", "External Wiki", "External Issues"};
|
||||
private final boolean[] selectedAccessControlsTrueFalse = new boolean[]{false, false, false, false, false, false, false};
|
||||
public int permissionSelectedChoice = -1;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView teamName;
|
||||
private TextView teamDesc;
|
||||
|
@ -41,31 +45,8 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
private TextView teamAccessControls;
|
||||
private TextView teamAccessControlsArray;
|
||||
private Button createTeamButton;
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
public int permissionSelectedChoice = -1;
|
||||
|
||||
private final String[] accessControlsList = new String[] {
|
||||
"Code",
|
||||
"Issues",
|
||||
"Pull Request",
|
||||
"Releases",
|
||||
"Wiki",
|
||||
"External Wiki",
|
||||
"External Issues"
|
||||
};
|
||||
|
||||
private List<String> pushAccessList;
|
||||
|
||||
private final boolean[] selectedAccessControlsTrueFalse = new boolean[]{
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
|
@ -97,9 +78,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
teamPermission.setOnClickListener(view -> {
|
||||
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilderPerm = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.newTeamPermission)
|
||||
.setCancelable(permissionSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilderPerm = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.newTeamPermission).setCancelable(permissionSelectedChoice != -1)
|
||||
.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
||||
|
||||
permissionSelectedChoice = i;
|
||||
|
@ -139,14 +118,11 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
teamAccessControlsArray.setText("");
|
||||
pushAccessList = Arrays.asList(accessControlsList);
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, (dialog, which, isChecked) -> {})
|
||||
.setTitle(R.string.newTeamAccessControls)
|
||||
.setPositiveButton(R.string.okButton, (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, (dialog, which, isChecked) -> {
|
||||
}).setTitle(R.string.newTeamAccessControls).setPositiveButton(R.string.okButton, (dialog, which) -> {
|
||||
|
||||
int selectedVal = 0;
|
||||
while(selectedVal < selectedAccessControlsTrueFalse.length)
|
||||
{
|
||||
while(selectedVal < selectedAccessControlsTrueFalse.length) {
|
||||
boolean value = selectedAccessControlsTrueFalse[selectedVal];
|
||||
|
||||
String repoCode = "";
|
||||
|
@ -172,7 +148,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
repoCode = "repo.ext_issues";
|
||||
}
|
||||
|
||||
if(value){
|
||||
if(value) {
|
||||
|
||||
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
||||
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
||||
|
@ -231,7 +207,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
return;
|
||||
}
|
||||
|
||||
if (newTeamName.equals("")) {
|
||||
if(newTeamName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.teamNameEmpty));
|
||||
return;
|
||||
|
@ -258,7 +234,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
}
|
||||
}
|
||||
|
||||
if (newTeamPermission.equals("")) {
|
||||
if(newTeamPermission.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.teamPermissionEmpty));
|
||||
return;
|
||||
|
@ -266,7 +242,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
|
||||
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());
|
||||
}
|
||||
|
@ -292,9 +268,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
}
|
||||
createNewTeamJson.setUnits(newTeamAccessControls);
|
||||
|
||||
Call<Team> call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.orgCreateTeam(orgName, createNewTeamJson);
|
||||
Call<Team> call3 = RetrofitClient.getApiInterface(ctx).orgCreateTeam(orgName, createNewTeamJson);
|
||||
|
||||
call3.enqueue(new Callback<Team>() {
|
||||
|
||||
|
|
|
@ -9,11 +9,7 @@ import android.util.Log;
|
|||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gitnex.tea4j.v2.models.ContentsResponse;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
|
@ -95,7 +91,9 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
hostUrlExternal = hostExternal;
|
||||
}
|
||||
|
||||
if (hostUrlExternal == null) hostUrlExternal = "";
|
||||
if(hostUrlExternal == null) {
|
||||
hostUrlExternal = "";
|
||||
}
|
||||
|
||||
if(hostUri.toLowerCase().contains(hostUrlExternal.toLowerCase())) {
|
||||
|
||||
|
@ -131,8 +129,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
finish();
|
||||
}
|
||||
else {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
getUserOrOrg(data.getLastPathSegment()), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> getUserOrOrg(data.getLastPathSegment()), 500);
|
||||
}
|
||||
}
|
||||
else if(data.getPathSegments().size() == 2) {
|
||||
|
@ -159,12 +156,11 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
}
|
||||
else if(!data.getPathSegments().get(0).equals("") & !data.getLastPathSegment().equals("")) { // go to repo
|
||||
String repo = data.getLastPathSegment();
|
||||
if (repo.endsWith(".git")) { // Git clone URL
|
||||
if(repo.endsWith(".git")) { // Git clone URL
|
||||
repo = repo.substring(0, repo.length() - 4);
|
||||
}
|
||||
String finalRepo = repo;
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), finalRepo, "repo"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), finalRepo, "repo"), 500);
|
||||
}
|
||||
else { // no action, show options
|
||||
showNoActionButtons();
|
||||
|
@ -179,15 +175,11 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
issueIntent.putExtra("openedFromLink", "true");
|
||||
|
||||
String[] urlSplitted = data.toString().split("#");
|
||||
if (urlSplitted.length == 2) {
|
||||
if(urlSplitted.length == 2) {
|
||||
issueIntent.putExtra("issueComment", urlSplitted[1]);
|
||||
}
|
||||
|
||||
IssueContext issue = new IssueContext(
|
||||
new RepositoryContext(data.getPathSegments().get(0), data.getPathSegments().get(1), ctx),
|
||||
Integer.parseInt(data.getLastPathSegment()),
|
||||
"Issue"
|
||||
);
|
||||
IssueContext issue = new IssueContext(new RepositoryContext(data.getPathSegments().get(0), data.getPathSegments().get(1), ctx), Integer.parseInt(data.getLastPathSegment()), "Issue");
|
||||
|
||||
issue.getRepository().saveToDB(ctx);
|
||||
|
||||
|
@ -197,12 +189,10 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
finish();
|
||||
}
|
||||
else if(Objects.requireNonNull(data.getLastPathSegment()).contains("issues")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issue"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issue"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("new")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issueNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issueNew"), 500);
|
||||
}
|
||||
else {
|
||||
ctx.startActivity(mainIntent);
|
||||
|
@ -216,7 +206,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
String[] urlSplitted = data.toString().split("#");
|
||||
if (urlSplitted.length == 2) {
|
||||
if(urlSplitted.length == 2) {
|
||||
issueIntent.putExtra("issueComment", urlSplitted[1]);
|
||||
}
|
||||
|
||||
|
@ -225,8 +215,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
|
||||
}
|
||||
else if(Objects.requireNonNull(data.getLastPathSegment()).contains("pulls")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pull"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pull"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("files")) { // pr diff
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
@ -241,36 +230,29 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
else if(data.getPathSegments().get(2).equals("compare")) { // new pull request
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pullNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pullNew"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("commit")) {
|
||||
repoIntent.putExtra("sha", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commit"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commit"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("commits")) { // commits list
|
||||
String branch = data.getLastPathSegment();
|
||||
repoIntent.putExtra("branchName", branch);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commitsList"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commitsList"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestones") && data.getLastPathSegment().equals("new")) { // new milestone
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestonesNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestonesNew"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestones")) { // milestones
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestone")) { // milestone
|
||||
repoIntent.putExtra("milestoneId", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("releases") && data.getLastPathSegment().equals("new")) { // new release
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "newRelease"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "newRelease"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("releases")) { // releases
|
||||
if(data.getPathSegments().size() == 5) {
|
||||
|
@ -278,49 +260,39 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
repoIntent.putExtra("releaseTagName", data.getLastPathSegment());
|
||||
}
|
||||
}
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1),
|
||||
"releases"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "releases"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("labels")) { // labels
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "labels"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "labels"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("settings")) { // repo settings
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "settings"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "settings"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("branches")) { // branches list
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branchesList"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branchesList"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().size() == 5 && data.getPathSegments().get(2).equals("src") && data.getPathSegments().get(3).equals("branch")) { // branch
|
||||
repoIntent.putExtra("selectedBranch", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branch"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branch"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("src") && data.getPathSegments().get(3).equals("branch")) { // file/dir
|
||||
StringBuilder filePath = new StringBuilder();
|
||||
ArrayList<String> segments = new ArrayList<>(data.getPathSegments());
|
||||
segments.subList(0, 5).clear();
|
||||
for (String item : segments) {
|
||||
for(String item : segments) {
|
||||
filePath.append(item);
|
||||
filePath.append("/");
|
||||
}
|
||||
filePath.deleteCharAt(filePath.toString().length() - 1);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
getFile(data.getPathSegments().get(0),
|
||||
data.getPathSegments().get(1), filePath.toString(), data.getPathSegments().get(4)), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> getFile(data.getPathSegments().get(0), data.getPathSegments().get(1), filePath.toString(), data.getPathSegments().get(4)), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("wiki")) { // wiki
|
||||
|
||||
if(data.getQueryParameter("action") != null && data.getQueryParameter("action").equalsIgnoreCase("_new")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() ->
|
||||
goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "wikiNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "wikiNew"), 500);
|
||||
}
|
||||
else {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "wiki"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "wiki"), 500);
|
||||
}
|
||||
}
|
||||
else { // no action, show options
|
||||
|
@ -352,9 +324,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
|
||||
Integer port = data.getPort() >= 0 ? data.getPort() : null;
|
||||
|
||||
URI host = UrlBuilder.fromString(UrlHelper.fixScheme(data.getHost(), "https"))
|
||||
.withPort(port)
|
||||
.toUri();
|
||||
URI host = UrlBuilder.fromString(UrlHelper.fixScheme(data.getHost(), "https")).withPort(port).toUri();
|
||||
|
||||
AppUtil.openUrlInBrowser(this, String.valueOf(host));
|
||||
finish();
|
||||
|
@ -371,9 +341,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
|
||||
private void getPullRequest(String repoOwner, String repoName, int index) {
|
||||
|
||||
Call<PullRequest> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoGetPullRequest(repoOwner, repoName, (long) index);
|
||||
Call<PullRequest> call = RetrofitClient.getApiInterface(ctx).repoGetPullRequest(repoOwner, repoName, (long) index);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -417,9 +385,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
|
||||
private void goToRepoSection(String repoOwner, String repoName, String type) {
|
||||
|
||||
Call<Repository> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoGet(repoOwner, repoName);
|
||||
Call<Repository> call = RetrofitClient.getApiInterface(ctx).repoGet(repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -627,4 +593,5 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,20 +29,15 @@ public class DiffActivity extends BaseActivity {
|
|||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if(getSupportFragmentManager().findFragmentById(R.id.fragment_container) instanceof DiffFragment) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment)
|
||||
.commit();
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment).commit();
|
||||
}
|
||||
else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment)
|
||||
.commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment).commit();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,7 @@ import android.util.Log;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
|
@ -33,12 +28,7 @@ import org.mian.gitnex.helpers.Toasty;
|
|||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
|
@ -48,21 +38,17 @@ import retrofit2.Callback;
|
|||
|
||||
public class EditIssueActivity extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
private final String msState = "open";
|
||||
private final LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
private View.OnClickListener onClickListener;
|
||||
private int resultLimit;
|
||||
|
||||
private EditText editIssueTitle;
|
||||
private EditText editIssueDescription;
|
||||
private TextView editIssueDueDate;
|
||||
private Button editIssueButton;
|
||||
private AutoCompleteTextView editIssueMilestoneSpinner;
|
||||
|
||||
private final String msState = "open";
|
||||
private int milestoneId = 0;
|
||||
private Date currentDate = null;
|
||||
|
||||
private LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
|
||||
private IssueContext issue;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
@ -94,7 +80,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
if((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) {
|
||||
|
||||
touchView.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
|
@ -145,15 +131,14 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
return;
|
||||
}
|
||||
|
||||
if (editIssueTitleForm.equals("")) {
|
||||
if(editIssueTitleForm.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
editIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), editIssueTitleForm, editIssueDescriptionForm,
|
||||
milestoneId);
|
||||
editIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), editIssueTitleForm, editIssueDescriptionForm, milestoneId);
|
||||
}
|
||||
|
||||
private void editIssue(String repoOwner, String repoName, int issueIndex, String title, String description, int milestoneId) {
|
||||
|
@ -164,9 +149,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
issueData.setDueDate(currentDate);
|
||||
issueData.setMilestone((long) milestoneId);
|
||||
|
||||
Call<Issue> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueEditIssue(repoOwner, repoName, (long) issueIndex, issueData);
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx).issueEditIssue(repoOwner, repoName, (long) issueIndex, issueData);
|
||||
|
||||
call.enqueue(new Callback<Issue>() {
|
||||
|
||||
|
@ -216,15 +199,14 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (v == editIssueDueDate) {
|
||||
if(v == editIssueDueDate) {
|
||||
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int mYear = c.get(Calendar.YEAR);
|
||||
final int mMonth = c.get(Calendar.MONTH);
|
||||
final int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(this, (view, year, monthOfYear, dayOfMonth) -> {
|
||||
editIssueDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth));
|
||||
currentDate = new Date(year - 1900, monthOfYear, dayOfMonth);
|
||||
}, mYear, mMonth, mDay);
|
||||
|
@ -239,9 +221,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
|
||||
private void getIssue(final String repoOwner, final String repoName, int issueIndex, int resultLimit) {
|
||||
|
||||
Call<Issue> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx).issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -297,8 +277,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
milestoneId = 0;
|
||||
}
|
||||
else if(view instanceof TextView) {
|
||||
milestoneId = Math.toIntExact(
|
||||
Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
milestoneId = Math.toIntExact(Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -306,7 +285,8 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
if(currentMilestone != null) {
|
||||
milestoneId = Math.toIntExact(currentMilestone.getId());
|
||||
editIssueMilestoneSpinner.setText(currentMilestone.getTitle(), false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
milestoneId = 0;
|
||||
editIssueMilestoneSpinner.setText(getString(R.string.issueCreatedNoMilestone), false);
|
||||
}
|
||||
|
|
|
@ -8,11 +8,7 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.*;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
@ -23,12 +19,7 @@ import org.mian.gitnex.R;
|
|||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityFileViewBinding;
|
||||
import org.mian.gitnex.fragments.BottomSheetFileViewerFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Images;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.notifications.Notifications;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
@ -48,11 +39,68 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
private ActivityFileViewBinding binding;
|
||||
private ContentsResponse file;
|
||||
private RepositoryContext repository;
|
||||
ActivityResultLauncher<Intent> activityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
|
||||
if(result.getResultCode() == Activity.RESULT_OK) {
|
||||
|
||||
assert result.getData() != null;
|
||||
|
||||
try {
|
||||
|
||||
OutputStream outputStream = getContentResolver().openOutputStream(result.getData().getData());
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, ctx.getPackageName()).setContentTitle(getString(R.string.fileViewerNotificationTitleStarted))
|
||||
.setContentText(getString(R.string.fileViewerNotificationDescriptionStarted, file.getName())).setSmallIcon(R.drawable.gitnex_transparent).setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setChannelId(Constants.downloadNotificationChannelId).setProgress(100, 0, false).setOngoing(true);
|
||||
|
||||
int notificationId = Notifications.uniqueNotificationId(ctx);
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
try {
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient.getWebInterface(ctx).getFileContents(repository.getOwner(), repository.getName(), repository.getBranchRef(), file.getPath());
|
||||
|
||||
Response<ResponseBody> response = call.execute();
|
||||
|
||||
assert response.body() != null;
|
||||
|
||||
AppUtil.copyProgress(response.body().byteStream(), outputStream, file.getSize(), progress -> {
|
||||
builder.setProgress(100, progress, false);
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
});
|
||||
|
||||
builder.setContentTitle(getString(R.string.fileViewerNotificationTitleFinished)).setContentText(getString(R.string.fileViewerNotificationDescriptionFinished, file.getName()));
|
||||
|
||||
}
|
||||
catch(IOException ignored) {
|
||||
|
||||
builder.setContentTitle(getString(R.string.fileViewerNotificationTitleFailed)).setContentText(getString(R.string.fileViewerNotificationDescriptionFailed, file.getName()));
|
||||
|
||||
}
|
||||
finally {
|
||||
|
||||
builder.setProgress(0, 0, false).setOngoing(false);
|
||||
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
thread.start();
|
||||
|
||||
}
|
||||
catch(IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
private boolean renderMd = false;
|
||||
private boolean processable = false;
|
||||
|
||||
public ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
public ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
|
@ -93,9 +141,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient
|
||||
.getWebInterface(ctx)
|
||||
.getFileContents(owner, repo, ref, filename);
|
||||
Call<ResponseBody> call = RetrofitClient.getWebInterface(ctx).getFileContents(owner, repo, ref, filename);
|
||||
|
||||
try {
|
||||
|
||||
|
@ -153,7 +199,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
|
||||
binding.contents.setVisibility(View.GONE);
|
||||
binding.markdownFrame.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
binding.markdownFrame.setVisibility(View.GONE);
|
||||
binding.contents.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -178,14 +225,16 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
binding.markdownTv.setTypeface(null, Typeface.BOLD);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
runOnUiThread(() -> {
|
||||
binding.markdownTv.setText("");
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
|
@ -206,7 +255,9 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
|
||||
}
|
||||
}
|
||||
} catch(IOException ignored) {}
|
||||
}
|
||||
catch(IOException ignored) {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@ -221,11 +272,9 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
inflater.inflate(R.menu.markdown_switcher, menu);
|
||||
|
||||
if(!FilenameUtils.getExtension(file.getName())
|
||||
.equalsIgnoreCase("md")) {
|
||||
if(!FilenameUtils.getExtension(file.getName()).equalsIgnoreCase("md")) {
|
||||
|
||||
menu.getItem(0)
|
||||
.setVisible(false);
|
||||
menu.getItem(0).setVisible(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -241,7 +290,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
finish();
|
||||
return true;
|
||||
|
||||
} else if(id == R.id.genericMenu) {
|
||||
}
|
||||
else if(id == R.id.genericMenu) {
|
||||
|
||||
BottomSheetFileViewerFragment bottomSheet = new BottomSheetFileViewerFragment();
|
||||
Bundle opts = repository.getBundle();
|
||||
|
@ -250,7 +300,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
bottomSheet.show(getSupportFragmentManager(), "fileViewerBottomSheet");
|
||||
return true;
|
||||
|
||||
} else if(id == R.id.markdown) {
|
||||
}
|
||||
else if(id == R.id.markdown) {
|
||||
|
||||
if(!renderMd) {
|
||||
if(binding.markdown.getAdapter() == null) {
|
||||
|
@ -261,7 +312,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
binding.markdownFrame.setVisibility(View.VISIBLE);
|
||||
|
||||
renderMd = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
binding.markdownFrame.setVisibility(View.GONE);
|
||||
binding.contents.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -270,7 +322,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
@ -293,8 +346,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
|
||||
if("editFile".equals(text)) {
|
||||
|
||||
if(binding.contents.getContent() != null &&
|
||||
!binding.contents.getContent().isEmpty()) {
|
||||
if(binding.contents.getContent() != null && !binding.contents.getContent().isEmpty()) {
|
||||
|
||||
Intent intent = repository.getIntent(ctx, CreateFileActivity.class);
|
||||
|
||||
|
@ -305,7 +357,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
|
||||
editFileLauncher.launch(intent);
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, getString(R.string.fileTypeCannotBeEdited));
|
||||
}
|
||||
}
|
||||
|
@ -323,72 +376,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
|
||||
}
|
||||
|
||||
ActivityResultLauncher<Intent> activityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
|
||||
if (result.getResultCode() == Activity.RESULT_OK) {
|
||||
|
||||
assert result.getData() != null;
|
||||
|
||||
try {
|
||||
|
||||
OutputStream outputStream = getContentResolver().openOutputStream(result.getData().getData());
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, ctx.getPackageName())
|
||||
.setContentTitle(getString(R.string.fileViewerNotificationTitleStarted))
|
||||
.setContentText(getString(R.string.fileViewerNotificationDescriptionStarted, file.getName()))
|
||||
.setSmallIcon(R.drawable.gitnex_transparent)
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setChannelId(Constants.downloadNotificationChannelId)
|
||||
.setProgress(100, 0, false)
|
||||
.setOngoing(true);
|
||||
|
||||
int notificationId = Notifications.uniqueNotificationId(ctx);
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);;
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
try {
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient
|
||||
.getWebInterface(ctx)
|
||||
.getFileContents(repository.getOwner(), repository.getName(), repository.getBranchRef(), file.getPath());
|
||||
|
||||
Response<ResponseBody> response = call.execute();
|
||||
|
||||
assert response.body() != null;
|
||||
|
||||
AppUtil.copyProgress(response.body().byteStream(), outputStream, file.getSize(), progress -> {
|
||||
builder.setProgress(100, progress, false);
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
});
|
||||
|
||||
builder.setContentTitle(getString(R.string.fileViewerNotificationTitleFinished))
|
||||
.setContentText(getString(R.string.fileViewerNotificationDescriptionFinished, file.getName()));
|
||||
|
||||
} catch(IOException ignored) {
|
||||
|
||||
builder.setContentTitle(getString(R.string.fileViewerNotificationTitleFailed))
|
||||
.setContentText(getString(R.string.fileViewerNotificationDescriptionFailed, file.getName()));
|
||||
|
||||
} finally {
|
||||
|
||||
builder.setProgress(0,0,false)
|
||||
.setOngoing(false);
|
||||
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
thread.start();
|
||||
|
||||
} catch(IOException ignored) {}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
|
@ -8,12 +8,7 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.*;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
@ -31,14 +26,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.gitnex.tea4j.v2.models.EditIssueOption;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.IssueLabelsOption;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.gitnex.tea4j.v2.models.PullRequest;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.gitnex.tea4j.v2.models.WatchInfo;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.AssigneesActions;
|
||||
import org.mian.gitnex.actions.LabelsActions;
|
||||
|
@ -54,29 +42,14 @@ import org.mian.gitnex.databinding.CustomPrInfoDialogBinding;
|
|||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetSingleIssueFragment;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.DividerItemDecorator;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.viewmodels.IssueCommentsViewModel;
|
||||
import org.mian.gitnex.views.ReactionList;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
@ -87,35 +60,32 @@ import retrofit2.Response;
|
|||
|
||||
public class IssueDetailActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener, BottomSheetListener {
|
||||
|
||||
public static boolean singleIssueUpdate = false;
|
||||
public static boolean commentPosted = false;
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
public boolean commentEdited = false;
|
||||
private IssueCommentsAdapter adapter;
|
||||
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private int issueIndex;
|
||||
private String issueCreator;
|
||||
private IssueContext issue;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
private AssigneesListAdapter assigneesAdapter;
|
||||
|
||||
private List<Integer> currentLabelsIds = new ArrayList<>();
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private List<String> assigneesListData = new ArrayList<>();
|
||||
private List<String> currentAssignees = new ArrayList<>();
|
||||
|
||||
private ActivityIssueDetailBinding viewBinding;
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
public static boolean singleIssueUpdate = false;
|
||||
public boolean commentEdited = false;
|
||||
public static boolean commentPosted = false;
|
||||
|
||||
private IssueCommentsViewModel issueCommentsModel;
|
||||
|
||||
public ActivityResultLauncher<Intent> editIssueLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
private Runnable showMenu = () -> {
|
||||
};
|
||||
private boolean loadingFinishedIssue = false;
|
||||
private boolean loadingFinishedPr = false;
|
||||
private boolean loadingFinishedRepo = false;
|
||||
public ActivityResultLauncher<Intent> editIssueLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("issueEdited", false)) {
|
||||
|
@ -174,9 +144,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
issueCommentsModel
|
||||
.loadIssueComments(repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
issueCommentsModel.loadIssueComments(repoOwner, repoName, issueIndex, ctx);
|
||||
|
||||
}, 500));
|
||||
|
||||
|
@ -212,7 +180,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
}
|
||||
|
||||
@Override
|
||||
public void labelsInterface(List<String> data) { }
|
||||
public void labelsInterface(List<String> data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void labelsIdsInterface(List<Integer> data) {
|
||||
|
@ -230,8 +199,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
assigneesAdapter.updateList(currentAssignees);
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding = CustomAssigneesSelectionDialogBinding.inflate(
|
||||
LayoutInflater.from(ctx));
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding = CustomAssigneesSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
View view = assigneesBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
|
@ -279,9 +247,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
EditIssueOption updateAssigneeJson = new EditIssueOption().assignees(assigneesListData);
|
||||
|
||||
Call<Issue> call3 = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueEditIssue(repoOwner, repoName, (long) issueIndex, updateAssigneeJson);
|
||||
Call<Issue> call3 = RetrofitClient.getApiInterface(ctx).issueEditIssue(repoOwner, repoName, (long) issueIndex, updateAssigneeJson);
|
||||
|
||||
call3.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -335,9 +301,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
IssueLabelsOption patchIssueLabels = new IssueLabelsOption();
|
||||
patchIssueLabels.setLabels(labelIds);
|
||||
|
||||
Call<List<Label>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueReplaceLabels(repoOwner, repoName, (long) issueIndex, patchIssueLabels);
|
||||
Call<List<Label>> call = RetrofitClient.getApiInterface(ctx).issueReplaceLabels(repoOwner, repoName, (long) issueIndex, patchIssueLabels);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -383,12 +347,10 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
});
|
||||
}
|
||||
|
||||
private Runnable showMenu = () -> {};
|
||||
private boolean loadingFinishedIssue = false;
|
||||
private boolean loadingFinishedPr = false;
|
||||
private boolean loadingFinishedRepo = false;
|
||||
private void updateMenuState() {
|
||||
if(loadingFinishedIssue && loadingFinishedPr && loadingFinishedRepo) showMenu.run();
|
||||
if(loadingFinishedIssue && loadingFinishedPr && loadingFinishedRepo) {
|
||||
showMenu.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -402,7 +364,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
inflater.inflate(R.menu.pr_info_menu, menu);
|
||||
}
|
||||
}
|
||||
showMenu = () -> {}; // reset Runnable
|
||||
showMenu = () -> {
|
||||
}; // reset Runnable
|
||||
};
|
||||
updateMenuState();
|
||||
return true;
|
||||
|
@ -415,8 +378,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
if(id == android.R.id.home) {
|
||||
|
||||
if(issue.hasIssue() && getIntent().getStringExtra("openedFromLink") != null &&
|
||||
getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
if(issue.hasIssue() && getIntent().getStringExtra("openedFromLink") != null && getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
Intent intent = issue.getRepository().getIntent(ctx, RepoDetailActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
|
@ -466,9 +428,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
issueCommentsModel
|
||||
.loadIssueComments(repoOwner, repoName, issueIndex,
|
||||
ctx, () -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
issueCommentsModel.loadIssueComments(repoOwner, repoName, issueIndex, ctx, () -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
|
||||
commentPosted = false;
|
||||
});
|
||||
|
@ -478,9 +438,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
issueCommentsModel
|
||||
.loadIssueComments(repoOwner, repoName, issueIndex,
|
||||
ctx);
|
||||
issueCommentsModel.loadIssueComments(repoOwner, repoName, issueIndex, ctx);
|
||||
commentEdited = false;
|
||||
});
|
||||
}
|
||||
|
@ -501,8 +459,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
private void fetchDataAsync(String owner, String repo, int index) {
|
||||
|
||||
issueCommentsModel.getIssueCommentList(owner, repo, index, ctx)
|
||||
.observe(this, issueCommentsMain -> {
|
||||
issueCommentsModel.getIssueCommentList(owner, repo, index, ctx).observe(this, issueCommentsMain -> {
|
||||
|
||||
assert issueCommentsMain != null;
|
||||
|
||||
|
@ -531,8 +488,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
return;
|
||||
}
|
||||
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx).issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -575,9 +531,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
}
|
||||
|
||||
private void getSubscribed() {
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueCheckSubscription(repoOwner, repoName, (long) issueIndex)
|
||||
.enqueue(new Callback<>() {
|
||||
RetrofitClient.getApiInterface(ctx).issueCheckSubscription(repoOwner, repoName, (long) issueIndex).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull Response<WatchInfo> response) {
|
||||
|
@ -602,7 +556,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
private void initWithIssue() {
|
||||
if(!issue.getRepository().hasRepository()) {
|
||||
getRepoInfo();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
loadingFinishedRepo = true;
|
||||
}
|
||||
loadingFinishedIssue = true;
|
||||
|
@ -633,7 +588,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
updateMenuState();
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue);
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState, ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconIssuePrClosedColor)));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
loadingFinishedPr = true;
|
||||
updateMenuState();
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue);
|
||||
|
@ -645,10 +601,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
final String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
issueCreator = issue.getIssue().getUser().getLogin();
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewBinding.assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources()
|
||||
.getString(R.string.hash) + issue.getIssue().getNumber() + "</font>";
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop()
|
||||
.into(viewBinding.assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources().getString(R.string.hash) + issue.getIssue().getNumber() + "</font>";
|
||||
viewBinding.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(issue.getIssue().getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
String cleanIssueDescription = issue.getIssue().getBody().trim();
|
||||
|
||||
|
@ -681,9 +636,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
ImageView assigneesView = new ImageView(ctx);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getAssignees().get(i).getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(48, 0)).resize(96, 96).centerCrop()
|
||||
.into(assigneesView);
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getAssignees().get(i).getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(48, 0)).resize(96, 96)
|
||||
.centerCrop().into(assigneesView);
|
||||
|
||||
viewBinding.frameAssignees.addView(assigneesView);
|
||||
assigneesView.setLayoutParams(params1);
|
||||
|
@ -721,8 +675,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
viewBinding.assigneesScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(issue.getIssue().getLabels() != null) {
|
||||
|
@ -743,10 +696,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
int height = AppUtil.getPixelsFromDensity(ctx, 20);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(ctx, 12);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT)
|
||||
.textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(ctx, 10)))
|
||||
.height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 18));
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(ctx, 10))).height(height).endConfig()
|
||||
.buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 18));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
viewBinding.frameLabels.addView(labelsView);
|
||||
|
@ -765,8 +717,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", locale);
|
||||
String dueDate = formatter.format(issue.getIssue().getDueDate());
|
||||
viewBinding.issueDueDate.setText(dueDate);
|
||||
viewBinding.issueDueDate
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getDueDate()), ctx));
|
||||
viewBinding.issueDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getDueDate()), ctx));
|
||||
}
|
||||
else if(timeFormat.equals("normal1")) {
|
||||
|
||||
|
@ -787,8 +738,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
|
||||
viewBinding.issueModified.setVisibility(View.VISIBLE);
|
||||
viewBinding.issueModified.setText(edited);
|
||||
viewBinding.issueModified
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getUpdatedAt()), ctx));
|
||||
viewBinding.issueModified.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getUpdatedAt()), ctx));
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -821,8 +771,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
|
||||
viewBinding.issueCreatedTime
|
||||
.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getCreatedAt()), ctx));
|
||||
viewBinding.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getCreatedAt()), ctx));
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -909,4 +858,5 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,30 +3,17 @@ package org.mian.gitnex.activities;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import org.gitnex.tea4j.v2.models.AccessToken;
|
||||
import org.gitnex.tea4j.v2.models.CreateAccessTokenOption;
|
||||
import org.gitnex.tea4j.v2.models.GeneralAPISettings;
|
||||
import org.gitnex.tea4j.v2.models.ServerVersion;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityLoginBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.NetworkStatusObserver;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.structs.Protocol;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -43,15 +30,12 @@ import retrofit2.Callback;
|
|||
|
||||
public class LoginActivity extends BaseActivity {
|
||||
|
||||
private enum LoginType {BASIC, TOKEN}
|
||||
|
||||
private Button loginButton;
|
||||
private EditText instanceUrlET, loginUidET, loginPassword, otpCode, loginTokenCode;
|
||||
private AutoCompleteTextView protocolSpinner;
|
||||
private RadioGroup loginMethod;
|
||||
private String device_id = "token";
|
||||
private String selectedProtocol;
|
||||
|
||||
private URI instanceUrl;
|
||||
private Version giteaVersion;
|
||||
private int maxResponseItems = 50;
|
||||
|
@ -96,7 +80,8 @@ public class LoginActivity extends BaseActivity {
|
|||
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 {
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -105,7 +90,8 @@ public class LoginActivity extends BaseActivity {
|
|||
if(checkedId == R.id.loginToken) {
|
||||
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 {
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -114,7 +100,8 @@ public class LoginActivity extends BaseActivity {
|
|||
networkStatusObserver.registerNetworkStatusListener(hasNetworkConnection -> runOnUiThread(() -> {
|
||||
if(hasNetworkConnection) {
|
||||
enableProcessButton();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
disableProcessButton();
|
||||
loginButton.setText(getResources().getString(R.string.btnLogin));
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
|
@ -148,8 +135,7 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET.getText().toString().replaceAll("[\\uFEFF|#]", "").trim(), "http")).toUri();
|
||||
|
||||
instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(selectedProtocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/"))
|
||||
.toUri();
|
||||
instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(selectedProtocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/")).toUri();
|
||||
|
||||
// cache values to make them available the next time the user wants to log in
|
||||
tinyDB.putString("loginType", loginType.name().toLowerCase());
|
||||
|
@ -234,8 +220,7 @@ public class LoginActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private void versionCheck(final String loginUid, final String loginPass, final int loginOTP, final String loginToken,
|
||||
final LoginType loginType) {
|
||||
private void versionCheck(final String loginUid, final String loginPass, final int loginOTP, final String loginToken, final LoginType loginType) {
|
||||
|
||||
Call<ServerVersion> callVersion;
|
||||
|
||||
|
@ -247,10 +232,11 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||
|
||||
if (loginOTP != 0) {
|
||||
if(loginOTP != 0) {
|
||||
|
||||
callVersion = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).getVersion(loginOTP);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
callVersion = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).getVersion();
|
||||
}
|
||||
|
@ -277,15 +263,12 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion()))
|
||||
.setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> {
|
||||
|
||||
dialog.dismiss();
|
||||
enableProcessButton();
|
||||
})
|
||||
.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||
}).setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||
|
||||
dialog.dismiss();
|
||||
login(loginType, loginUid, loginPass, loginOTP, loginToken);
|
||||
|
@ -432,8 +415,7 @@ public class LoginActivity extends BaseActivity {
|
|||
Call<Void> delToken;
|
||||
if(loginOTP != 0) {
|
||||
|
||||
delToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null)
|
||||
.userDeleteAccessToken(loginOTP, loginUid, String.valueOf(t.getId()));
|
||||
delToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).userDeleteAccessToken(loginOTP, loginUid, String.valueOf(t.getId()));
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -495,13 +477,11 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
if(loginOTP != 0) {
|
||||
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null)
|
||||
.userCreateToken(loginOTP, loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).userCreateToken(loginOTP, loginUid, createUserToken);
|
||||
}
|
||||
else {
|
||||
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null)
|
||||
.userCreateToken(loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).userCreateToken(loginUid, createUserToken);
|
||||
}
|
||||
|
||||
callCreateToken.enqueue(new Callback<>() {
|
||||
|
@ -539,9 +519,8 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
UserAccount account;
|
||||
if(!userAccountExists) {
|
||||
long accountId = userAccountsApi
|
||||
.createNewAccount(accountName, instanceUrl.toString(), userDetails.getLogin(), newToken.getSha1(),
|
||||
giteaVersion.toString(), maxResponseItems, defaultPagingNumber);
|
||||
long accountId = userAccountsApi.createNewAccount(accountName, instanceUrl.toString(), userDetails.getLogin(), newToken.getSha1(), giteaVersion.toString(), maxResponseItems,
|
||||
defaultPagingNumber);
|
||||
account = userAccountsApi.getAccountById((int) accountId);
|
||||
}
|
||||
else {
|
||||
|
@ -590,7 +569,6 @@ public class LoginActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
private void loadDefaults() {
|
||||
|
||||
if(tinyDB.getString("loginType").equals(LoginType.BASIC.name().toLowerCase())) {
|
||||
|
@ -634,4 +612,6 @@ public class LoginActivity extends BaseActivity {
|
|||
loginButton.setEnabled(true);
|
||||
}
|
||||
|
||||
private enum LoginType {BASIC, TOKEN}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,26 +34,8 @@ import org.mian.gitnex.database.api.BaseApi;
|
|||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityMainBinding;
|
||||
import org.mian.gitnex.fragments.AdministrationFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetDraftsFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetMyIssuesFilterFragment;
|
||||
import org.mian.gitnex.fragments.DraftsFragment;
|
||||
import org.mian.gitnex.fragments.ExploreFragment;
|
||||
import org.mian.gitnex.fragments.MostVisitedReposFragment;
|
||||
import org.mian.gitnex.fragments.MyIssuesFragment;
|
||||
import org.mian.gitnex.fragments.MyProfileFragment;
|
||||
import org.mian.gitnex.fragments.MyRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.NotificationsFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationsFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.SettingsFragment;
|
||||
import org.mian.gitnex.fragments.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ChangeLog;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.fragments.*;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import org.mian.gitnex.structs.FragmentRefreshListener;
|
||||
import java.util.ArrayList;
|
||||
|
@ -98,9 +80,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
Handler handler = new Handler();
|
||||
|
||||
// DO NOT MOVE
|
||||
if(mainIntent.hasExtra("switchAccountId") &&
|
||||
AppUtil.switchToAccount(ctx, BaseApi.getInstance(ctx, UserAccountsApi.class)
|
||||
.getAccountById(mainIntent.getIntExtra("switchAccountId", 0)))) {
|
||||
if(mainIntent.hasExtra("switchAccountId") && AppUtil.switchToAccount(ctx, BaseApi.getInstance(ctx, UserAccountsApi.class).getAccountById(mainIntent.getIntExtra("switchAccountId", 0)))) {
|
||||
|
||||
mainIntent.removeExtra("switchAccountId");
|
||||
recreate();
|
||||
|
@ -208,7 +188,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
userEmail.setTypeface(myTypeface);
|
||||
userFullName.setTypeface(myTypeface);
|
||||
|
||||
if (getAccount().getUserInfo() != null) {
|
||||
if(getAccount().getUserInfo() != null) {
|
||||
String userEmailNav = getAccount().getUserInfo().getEmail();
|
||||
String userFullNameNav = getAccount().getFullName();
|
||||
String userAvatarNav = getAccount().getUserInfo().getAvatarUrl();
|
||||
|
@ -225,10 +205,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
|
||||
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(avatarRadius, 0)).resize(160, 160).centerCrop().into(userAvatar);
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(avatarRadius, 0)).resize(160, 160).centerCrop()
|
||||
.into(userAvatar);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).transform(new BlurTransformation(ctx))
|
||||
.into(userAvatarBackground, new com.squareup.picasso.Callback() {
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).transform(new BlurTransformation(ctx)).into(userAvatarBackground, new com.squareup.picasso.Callback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
@ -262,9 +242,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
@Override
|
||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
||||
|
||||
if (getAccount().getUserInfo() != null) {
|
||||
if(getAccount().getUserInfo() != null) {
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(getAccount().getUserInfo().isIsAdmin());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// hide first
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(false);
|
||||
}
|
||||
|
@ -275,10 +256,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed(@NonNull View drawerView) {}
|
||||
public void onDrawerClosed(@NonNull View drawerView) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerStateChanged(int newState) {}
|
||||
public void onDrawerStateChanged(int newState) {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@ -480,17 +463,13 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
|
||||
if(frag != null) {
|
||||
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.deleteAllDrafts)
|
||||
.setCancelable(false)
|
||||
.setMessage(R.string.deleteAllDraftsDialogMessage)
|
||||
new MaterialAlertDialogBuilder(ctx).setTitle(R.string.deleteAllDrafts).setCancelable(false).setMessage(R.string.deleteAllDraftsDialogMessage)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
frag.deleteAllDrafts(currentActiveAccountId);
|
||||
dialog.dismiss();
|
||||
|
||||
})
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
}).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -761,6 +740,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
}
|
||||
|
||||
// My issues interface
|
||||
public FragmentRefreshListener getFragmentRefreshListener() { return fragmentRefreshListenerMyIssues; }
|
||||
public void setFragmentRefreshListenerMyIssues(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListenerMyIssues = fragmentRefreshListener; }
|
||||
public FragmentRefreshListener getFragmentRefreshListener() {
|
||||
return fragmentRefreshListenerMyIssues;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerMyIssues(FragmentRefreshListener fragmentRefreshListener) {
|
||||
this.fragmentRefreshListenerMyIssues = fragmentRefreshListener;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
private IssueContext issue;
|
||||
private ActivityMergePullRequestBinding viewBinding;
|
||||
private String Do;
|
||||
private final View.OnClickListener mergePullRequest = v -> processMergePullRequest();
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
|
@ -121,7 +122,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
ArrayAdapter<MergePullRequestSpinner> adapter = new ArrayAdapter<>(MergePullRequestActivity.this, R.layout.list_spinner_items, mergeList);
|
||||
viewBinding.mergeSpinner.setAdapter(adapter);
|
||||
|
||||
viewBinding.mergeSpinner.setOnItemClickListener ((parent, view, position, id) -> {
|
||||
viewBinding.mergeSpinner.setOnItemClickListener((parent, view, position, id) -> {
|
||||
|
||||
Do = mergeList.get(position).getId();
|
||||
});
|
||||
|
@ -132,8 +133,6 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private final View.OnClickListener mergePullRequest = v -> processMergePullRequest();
|
||||
|
||||
private void processMergePullRequest() {
|
||||
|
||||
String mergePRDesc = Objects.requireNonNull(viewBinding.mergeDescription.getText()).toString();
|
||||
|
@ -200,8 +199,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
PullRequestActions.deleteHeadBranch(ctx, repoOwner, repoName, issue.getPullRequest().getHead().getRef(), false);
|
||||
}
|
||||
else {
|
||||
PullRequestActions.deleteHeadBranch(ctx, issue.getRepository().getOwner(), issue.getRepository().getName(),
|
||||
issue.getPullRequest().getHead().getRef(), false);
|
||||
PullRequestActions.deleteHeadBranch(ctx, issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getPullRequest().getHead().getRef(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -259,4 +257,5 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
super.onResume();
|
||||
issue.getRepository().checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public class MyProfileEmailActivity extends BaseActivity {
|
|||
private View.OnClickListener onClickListener;
|
||||
private EditText userEmail;
|
||||
private Button addEmailButton;
|
||||
private final View.OnClickListener addEmailListener = v -> processAddNewEmail();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -61,15 +62,14 @@ public class MyProfileEmailActivity extends BaseActivity {
|
|||
if(!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
addEmailButton.setOnClickListener(addEmailListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final View.OnClickListener addEmailListener = v -> processAddNewEmail();
|
||||
|
||||
private void processAddNewEmail() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
@ -104,9 +104,7 @@ public class MyProfileEmailActivity extends BaseActivity {
|
|||
CreateEmailOption addEmailFunc = new CreateEmailOption();
|
||||
addEmailFunc.setEmails(newUserEmail);
|
||||
|
||||
Call<List<Email>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.userAddEmail(addEmailFunc);
|
||||
Call<List<Email>> call = RetrofitClient.getApiInterface(ctx).userAddEmail(addEmailFunc);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
|
|
@ -3,11 +3,7 @@ package org.mian.gitnex.activities;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.*;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
@ -20,12 +16,7 @@ import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetOrganizationFragment;
|
||||
import org.mian.gitnex.fragments.MembersByOrgFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationLabelsFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||
import org.mian.gitnex.fragments.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
import java.util.Objects;
|
||||
|
@ -62,8 +53,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
checkIsMember();
|
||||
|
||||
if(getAccount().requiresVersion("1.16.0")) {
|
||||
RetrofitClient.getApiInterface(this)
|
||||
.orgGetUserPermissions(getAccount().getAccount().getUserName(), orgName).enqueue(new Callback<>() {
|
||||
RetrofitClient.getApiInterface(this).orgGetUserPermissions(getAccount().getAccount().getUserName(), orgName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<OrganizationPermissions> call, @NonNull Response<OrganizationPermissions> response) {
|
||||
|
@ -82,7 +72,8 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
permissions = null;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
permissions = null;
|
||||
}
|
||||
}
|
||||
|
@ -127,16 +118,16 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
||||
int tabsCount = vg.getChildCount();
|
||||
|
||||
for (int j = 0; j < tabsCount; j++) {
|
||||
for(int j = 0; j < tabsCount; j++) {
|
||||
|
||||
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
|
||||
int tabChildCount = vgTab.getChildCount();
|
||||
|
||||
for (int i = 0; i < tabChildCount; i++) {
|
||||
for(int i = 0; i < tabChildCount; i++) {
|
||||
|
||||
View tabViewChild = vgTab.getChildAt(i);
|
||||
|
||||
if (tabViewChild instanceof TextView) {
|
||||
if(tabViewChild instanceof TextView) {
|
||||
|
||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||
}
|
||||
|
@ -180,12 +171,10 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
String url = UrlBuilder.fromString(getAccount().getAccount().getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
String url = UrlBuilder.fromString(getAccount().getAccount().getInstanceUrl()).withPath("/").toString();
|
||||
url = url + getIntent().getStringExtra("orgName");
|
||||
|
||||
switch (text) {
|
||||
switch(text) {
|
||||
case "repository":
|
||||
Intent intentRepo = new Intent(this, CreateRepoActivity.class);
|
||||
intentRepo.putExtra("organizationAction", true);
|
||||
|
@ -230,7 +219,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
String orgName = getIntent().getStringExtra("orgName");
|
||||
|
||||
Fragment fragment = null;
|
||||
switch (position) {
|
||||
switch(position) {
|
||||
|
||||
case 0: // info
|
||||
|
||||
|
@ -245,7 +234,8 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
|
||||
if(isMember) {
|
||||
return TeamsByOrgFragment.newInstance(orgName, permissions);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return MembersByOrgFragment.newInstance(orgName);
|
||||
}
|
||||
case 4: // members
|
||||
|
@ -261,9 +251,12 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
public int getCount() {
|
||||
if(isMember) {
|
||||
return 5;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ public class OrganizationTeamInfoActivity extends BaseActivity implements Bottom
|
|||
binding.close.setOnClickListener(view -> finish());
|
||||
binding.pager.setOffscreenPageLimit(1);
|
||||
binding.pager.setAdapter(new FragmentStateAdapter(getSupportFragmentManager(), getLifecycle()) {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
|
@ -129,7 +130,8 @@ public class OrganizationTeamInfoActivity extends BaseActivity implements Bottom
|
|||
Intent intent = new Intent(OrganizationTeamInfoActivity.this, AddNewTeamMemberActivity.class);
|
||||
intent.putExtra("teamId", team.getId());
|
||||
startActivity(intent);
|
||||
} else if("newRepo".equals(text)) {
|
||||
}
|
||||
else if("newRepo".equals(text)) {
|
||||
Intent intent = new Intent(OrganizationTeamInfoActivity.this, AddNewTeamRepoActivity.class);
|
||||
intent.putExtra("teamId", team.getId());
|
||||
intent.putExtra("teamName", team.getName());
|
||||
|
@ -137,4 +139,5 @@ public class OrganizationTeamInfoActivity extends BaseActivity implements Bottom
|
|||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,12 +19,7 @@ import com.google.android.material.tabs.TabLayoutMediator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetUserProfileFragment;
|
||||
import org.mian.gitnex.fragments.profile.DetailFragment;
|
||||
import org.mian.gitnex.fragments.profile.FollowersFragment;
|
||||
import org.mian.gitnex.fragments.profile.FollowingFragment;
|
||||
import org.mian.gitnex.fragments.profile.OrganizationsFragment;
|
||||
import org.mian.gitnex.fragments.profile.RepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.profile.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.profile.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
@ -74,20 +69,21 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
|
||||
viewPager.setAdapter(new ViewPagerAdapter(this));
|
||||
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.navRepos), ctx.getResources().getString(R.string.navStarredRepos), ctx.getResources().getString(R.string.navOrg), ctx.getResources().getString(R.string.profileTabFollowers), ctx.getResources().getString(R.string.profileTabFollowing)};
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.navRepos), ctx.getResources().getString(R.string.navStarredRepos),
|
||||
ctx.getResources().getString(R.string.navOrg), ctx.getResources().getString(R.string.profileTabFollowers), ctx.getResources().getString(R.string.profileTabFollowing)};
|
||||
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(tabTitles[position])).attach();
|
||||
|
||||
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
||||
int tabsCount = vg.getChildCount();
|
||||
|
||||
for (int j = 0; j < tabsCount; j++) {
|
||||
for(int j = 0; j < tabsCount; j++) {
|
||||
|
||||
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
|
||||
int tabChildCount = vgTab.getChildCount();
|
||||
|
||||
for (int i = 0; i < tabChildCount; i++) {
|
||||
for(int i = 0; i < tabChildCount; i++) {
|
||||
View tabViewChild = vgTab.getChildAt(i);
|
||||
if (tabViewChild instanceof TextView) {
|
||||
if(tabViewChild instanceof TextView) {
|
||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +126,7 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
|
||||
private void followUnfollow() {
|
||||
Call<Void> call;
|
||||
if (following) {
|
||||
if(following) {
|
||||
call = RetrofitClient.getApiInterface(this).userCurrentDeleteFollow(username);
|
||||
}
|
||||
else {
|
||||
|
@ -141,16 +137,17 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if(response.isSuccessful()) {
|
||||
following = !following;
|
||||
if (following) {
|
||||
if(following) {
|
||||
Toasty.success(ProfileActivity.this, String.format(getString(R.string.nowFollowUser), username));
|
||||
}
|
||||
else {
|
||||
Toasty.success(ProfileActivity.this, String.format(getString(R.string.unfollowedUser), username));
|
||||
}
|
||||
} else {
|
||||
if (following) {
|
||||
}
|
||||
else {
|
||||
if(following) {
|
||||
Toasty.error(ProfileActivity.this, getString(R.string.unfollowingFailed));
|
||||
}
|
||||
else {
|
||||
|
@ -161,7 +158,7 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
if (following) {
|
||||
if(following) {
|
||||
Toasty.error(ProfileActivity.this, getString(R.string.unfollowingFailed));
|
||||
}
|
||||
else {
|
||||
|
@ -171,36 +168,6 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
});
|
||||
}
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fa) { super(fa); }
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
switch(position) {
|
||||
case 0: // detail
|
||||
return DetailFragment.newInstance(username);
|
||||
case 1: // repos
|
||||
return RepositoriesFragment.newInstance(username);
|
||||
case 2: // starred repos
|
||||
return StarredRepositoriesFragment.newInstance(username);
|
||||
case 3: // organizations
|
||||
return OrganizationsFragment.newInstance(username);
|
||||
case 4: // followers
|
||||
return FollowersFragment.newInstance(username);
|
||||
case 5: // following
|
||||
return FollowingFragment.newInstance(username);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
|
@ -227,4 +194,37 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fa) {
|
||||
super(fa);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
switch(position) {
|
||||
case 0: // detail
|
||||
return DetailFragment.newInstance(username);
|
||||
case 1: // repos
|
||||
return RepositoriesFragment.newInstance(username);
|
||||
case 2: // starred repos
|
||||
return StarredRepositoriesFragment.newInstance(username);
|
||||
case 3: // organizations
|
||||
return OrganizationsFragment.newInstance(username);
|
||||
case 4: // followers
|
||||
return FollowersFragment.newInstance(username);
|
||||
case 5: // following
|
||||
return FollowingFragment.newInstance(username);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,12 +6,7 @@ import android.content.Intent;
|
|||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.*;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
|
@ -26,27 +21,10 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|||
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import org.gitnex.tea4j.v2.models.Branch;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.gitnex.tea4j.v2.models.Organization;
|
||||
import org.gitnex.tea4j.v2.models.Repository;
|
||||
import org.gitnex.tea4j.v2.models.WatchInfo;
|
||||
import org.gitnex.tea4j.v2.models.*;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetIssuesFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetMilestonesFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetPullRequestFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetReleasesTagsFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetRepoFragment;
|
||||
import org.mian.gitnex.fragments.CollaboratorsFragment;
|
||||
import org.mian.gitnex.fragments.FilesFragment;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.fragments.LabelsFragment;
|
||||
import org.mian.gitnex.fragments.MilestonesFragment;
|
||||
import org.mian.gitnex.fragments.PullRequestsFragment;
|
||||
import org.mian.gitnex.fragments.ReleasesFragment;
|
||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||
import org.mian.gitnex.fragments.WikiFragment;
|
||||
import org.mian.gitnex.fragments.*;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
|
@ -65,63 +43,8 @@ import retrofit2.Response;
|
|||
|
||||
public class RepoDetailActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
private TextView textViewBadgeIssue;
|
||||
private TextView textViewBadgePull;
|
||||
private TextView textViewBadgeRelease;
|
||||
private Typeface myTypeface;
|
||||
|
||||
private FragmentRefreshListener fragmentRefreshListener;
|
||||
private FragmentRefreshListener fragmentRefreshListenerPr;
|
||||
private FragmentRefreshListener fragmentRefreshListenerMilestone;
|
||||
private FragmentRefreshListener fragmentRefreshListenerFiles;
|
||||
private FragmentRefreshListener fragmentRefreshListenerFilterIssuesByMilestone;
|
||||
private FragmentRefreshListener fragmentRefreshListenerReleases;
|
||||
|
||||
public ViewPager2 viewPager;
|
||||
|
||||
public RepositoryContext repository;
|
||||
|
||||
public static boolean updateRepo = false;
|
||||
private Dialog progressDialog;
|
||||
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
|
||||
private Intent intentWiki;
|
||||
|
||||
private final ActivityResultLauncher<Intent> createReleaseLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("updateReleases", false)) {
|
||||
if(fragmentRefreshListenerReleases != null) fragmentRefreshListenerReleases.onRefresh(null);
|
||||
repository.removeRepository();
|
||||
getRepoInfo(repository.getOwner(), repository.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> createMilestoneLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("milestoneCreated", false)) {
|
||||
if(fragmentRefreshListenerMilestone != null) fragmentRefreshListenerMilestone.onRefresh(repository.getMilestoneState().toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
if(fragmentRefreshListenerFiles != null) fragmentRefreshListenerFiles.onRefresh(repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> settingsLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
private final ActivityResultLauncher<Intent> settingsLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("nameChanged", false)) {
|
||||
|
@ -129,6 +52,53 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
}
|
||||
});
|
||||
public ViewPager2 viewPager;
|
||||
public RepositoryContext repository;
|
||||
private TextView textViewBadgeIssue;
|
||||
private TextView textViewBadgePull;
|
||||
private TextView textViewBadgeRelease;
|
||||
private Typeface myTypeface;
|
||||
private FragmentRefreshListener fragmentRefreshListener;
|
||||
private FragmentRefreshListener fragmentRefreshListenerPr;
|
||||
private FragmentRefreshListener fragmentRefreshListenerMilestone;
|
||||
private final ActivityResultLauncher<Intent> createMilestoneLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("milestoneCreated", false)) {
|
||||
if(fragmentRefreshListenerMilestone != null) {
|
||||
fragmentRefreshListenerMilestone.onRefresh(repository.getMilestoneState().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
private FragmentRefreshListener fragmentRefreshListenerFiles;
|
||||
private final ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
if(fragmentRefreshListenerFiles != null) {
|
||||
fragmentRefreshListenerFiles.onRefresh(repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
private FragmentRefreshListener fragmentRefreshListenerFilterIssuesByMilestone;
|
||||
private FragmentRefreshListener fragmentRefreshListenerReleases;
|
||||
private Dialog progressDialog;
|
||||
private final ActivityResultLauncher<Intent> createReleaseLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("updateReleases", false)) {
|
||||
if(fragmentRefreshListenerReleases != null) {
|
||||
fragmentRefreshListenerReleases.onRefresh(null);
|
||||
}
|
||||
repository.removeRepository();
|
||||
getRepoInfo(repository.getOwner(), repository.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
|
||||
private Intent intentWiki;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -204,7 +174,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
finish();
|
||||
}
|
||||
return true;
|
||||
|
@ -389,9 +360,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
progressDialog.setContentView(R.layout.custom_progress_loader);
|
||||
progressDialog.show();
|
||||
|
||||
Call<List<Milestone>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(repository.getOwner(), repository.getName(), "open", null, 1, 50);
|
||||
Call<List<Milestone>> call = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repository.getOwner(), repository.getName(), "open", null, 1, 50);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -419,8 +388,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
}
|
||||
|
||||
materialAlertDialogBuilder.setTitle(R.string.selectMilestone)
|
||||
.setSingleChoiceItems(milestonesList.toArray(new String[0]), selectedMilestone, (dialogInterface, i) -> {
|
||||
materialAlertDialogBuilder.setTitle(R.string.selectMilestone).setSingleChoiceItems(milestonesList.toArray(new String[0]), selectedMilestone, (dialogInterface, i) -> {
|
||||
|
||||
repository.setIssueMilestoneFilterName(milestonesList.get(i));
|
||||
|
||||
|
@ -428,8 +396,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
getFragmentRefreshListenerFilterIssuesByMilestone().onRefresh(milestonesList.get(i));
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
})
|
||||
.setNeutralButton(R.string.cancelButton, null);
|
||||
}).setNeutralButton(R.string.cancelButton, null);
|
||||
materialAlertDialogBuilder.create().show();
|
||||
}
|
||||
}
|
||||
|
@ -457,9 +424,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
progressDialog.setContentView(R.layout.custom_progress_loader);
|
||||
progressDialog.show();
|
||||
|
||||
Call<List<Branch>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoListBranches(repository.getOwner(), repository.getName(), null, null);
|
||||
Call<List<Branch>> call = RetrofitClient.getApiInterface(ctx).repoListBranches(repository.getOwner(), repository.getName(), null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -483,8 +448,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
}
|
||||
|
||||
materialAlertDialogBuilder.setTitle(R.string.pageTitleChooseBranch)
|
||||
.setSingleChoiceItems(branchesList.toArray(new String[0]), selectedBranch, (dialogInterface, i) -> {
|
||||
materialAlertDialogBuilder.setTitle(R.string.pageTitleChooseBranch).setSingleChoiceItems(branchesList.toArray(new String[0]), selectedBranch, (dialogInterface, i) -> {
|
||||
|
||||
repository.setBranchRef(branchesList.get(i));
|
||||
|
||||
|
@ -492,8 +456,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
getFragmentRefreshListenerFiles().onRefresh(branchesList.get(i));
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
})
|
||||
.setNeutralButton(R.string.cancelButton, null);
|
||||
}).setNeutralButton(R.string.cancelButton, null);
|
||||
materialAlertDialogBuilder.create().show();
|
||||
}
|
||||
}
|
||||
|
@ -505,49 +468,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
});
|
||||
}
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fa) { super(fa); }
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
|
||||
Fragment fragment = null;
|
||||
|
||||
switch(position) {
|
||||
case 0: // Repository details
|
||||
return RepoInfoFragment.newInstance(repository);
|
||||
case 1: // Files
|
||||
return FilesFragment.newInstance(repository);
|
||||
case 2: // Issues
|
||||
fragment = IssuesFragment.newInstance(repository);
|
||||
break;
|
||||
case 3: // Pull requests
|
||||
fragment = PullRequestsFragment.newInstance(repository);
|
||||
break;
|
||||
case 4: // Releases
|
||||
return ReleasesFragment.newInstance(repository);
|
||||
case 5: // Wiki
|
||||
return WikiFragment.newInstance(repository);
|
||||
case 6: // Milestones
|
||||
fragment = MilestonesFragment.newInstance(repository);
|
||||
break;
|
||||
case 7: // Labels
|
||||
return LabelsFragment.newInstance(repository);
|
||||
case 8: // Collaborators
|
||||
return CollaboratorsFragment.newInstance(repository);
|
||||
}
|
||||
assert fragment != null;
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
private void getRepoInfo(final String owner, String repo) {
|
||||
|
||||
LinearProgressIndicator loading = findViewById(R.id.loadingIndicator);
|
||||
|
@ -592,7 +512,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
ImageView repoTypeToolbar = findViewById(R.id.repoTypeToolbar);
|
||||
if(repository.getRepository().isPrivate()) {
|
||||
repoTypeToolbar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
repoTypeToolbar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -605,7 +526,9 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
|
||||
viewPager.setAdapter(new ViewPagerAdapter(this));
|
||||
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.tabTextFiles), ctx.getResources().getString(R.string.pageTitleIssues), ctx.getResources().getString(R.string.tabPullRequests), ctx.getResources().getString(R.string.tabTextReleases), ctx.getResources().getString(R.string.wiki), ctx.getResources().getString(R.string.tabTextMl), ctx.getResources().getString(R.string.newIssueLabelsTitle), ctx.getResources().getString(R.string.tabTextCollaborators)};
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.tabTextFiles), ctx.getResources().getString(R.string.pageTitleIssues),
|
||||
ctx.getResources().getString(R.string.tabPullRequests), ctx.getResources().getString(R.string.tabTextReleases), ctx.getResources().getString(R.string.wiki),
|
||||
ctx.getResources().getString(R.string.tabTextMl), ctx.getResources().getString(R.string.newIssueLabelsTitle), ctx.getResources().getString(R.string.tabTextCollaborators)};
|
||||
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(tabTitles[position])).attach();
|
||||
|
||||
ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);
|
||||
|
@ -658,7 +581,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
TextView openIssueTabView = Objects.requireNonNull(tabOpenIssues.getCustomView()).findViewById(R.id.counterBadgeIssueText);
|
||||
openIssueTabView.setTextColor(textColor);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
textViewBadgeIssue.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -674,7 +598,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
|
||||
openPullTabView.setTextColor(textColor);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
textViewBadgePull.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -690,7 +615,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
|
||||
openReleaseTabView.setTextColor(textColor);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
textViewBadgeRelease.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
@ -833,33 +759,104 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
}
|
||||
|
||||
// Issues milestone filter interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerFilterIssuesByMilestone() { return fragmentRefreshListenerFilterIssuesByMilestone; }
|
||||
public FragmentRefreshListener getFragmentRefreshListenerFilterIssuesByMilestone() {
|
||||
return fragmentRefreshListenerFilterIssuesByMilestone;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerFilterIssuesByMilestone(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListenerFilterIssuesByMilestone = fragmentRefreshListener; }
|
||||
public void setFragmentRefreshListenerFilterIssuesByMilestone(FragmentRefreshListener fragmentRefreshListener) {
|
||||
this.fragmentRefreshListenerFilterIssuesByMilestone = fragmentRefreshListener;
|
||||
}
|
||||
|
||||
// Issues interface
|
||||
public FragmentRefreshListener getFragmentRefreshListener() { return fragmentRefreshListener; }
|
||||
public FragmentRefreshListener getFragmentRefreshListener() {
|
||||
return fragmentRefreshListener;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListener(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListener = fragmentRefreshListener; }
|
||||
public void setFragmentRefreshListener(FragmentRefreshListener fragmentRefreshListener) {
|
||||
this.fragmentRefreshListener = fragmentRefreshListener;
|
||||
}
|
||||
|
||||
// Pull request interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerPr() { return fragmentRefreshListenerPr; }
|
||||
public FragmentRefreshListener getFragmentRefreshListenerPr() {
|
||||
return fragmentRefreshListenerPr;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerPr(FragmentRefreshListener fragmentRefreshListenerPr) { this.fragmentRefreshListenerPr = fragmentRefreshListenerPr; }
|
||||
public void setFragmentRefreshListenerPr(FragmentRefreshListener fragmentRefreshListenerPr) {
|
||||
this.fragmentRefreshListenerPr = fragmentRefreshListenerPr;
|
||||
}
|
||||
|
||||
// Milestones interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerMilestone() { return fragmentRefreshListenerMilestone; }
|
||||
public FragmentRefreshListener getFragmentRefreshListenerMilestone() {
|
||||
return fragmentRefreshListenerMilestone;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerMilestone(FragmentRefreshListener fragmentRefreshListenerMilestone) { this.fragmentRefreshListenerMilestone = fragmentRefreshListenerMilestone; }
|
||||
public void setFragmentRefreshListenerMilestone(FragmentRefreshListener fragmentRefreshListenerMilestone) {
|
||||
this.fragmentRefreshListenerMilestone = fragmentRefreshListenerMilestone;
|
||||
}
|
||||
|
||||
// Files interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerFiles() { return fragmentRefreshListenerFiles; }
|
||||
public FragmentRefreshListener getFragmentRefreshListenerFiles() {
|
||||
return fragmentRefreshListenerFiles;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerFiles(FragmentRefreshListener fragmentRefreshListenerFiles) { this.fragmentRefreshListenerFiles = fragmentRefreshListenerFiles; }
|
||||
public void setFragmentRefreshListenerFiles(FragmentRefreshListener fragmentRefreshListenerFiles) {
|
||||
this.fragmentRefreshListenerFiles = fragmentRefreshListenerFiles;
|
||||
}
|
||||
|
||||
//Releases interface
|
||||
public FragmentRefreshListener getFragmentRefreshListenerReleases() { return fragmentRefreshListenerReleases; }
|
||||
public FragmentRefreshListener getFragmentRefreshListenerReleases() {
|
||||
return fragmentRefreshListenerReleases;
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerReleases(FragmentRefreshListener fragmentRefreshListener) {
|
||||
this.fragmentRefreshListenerReleases = fragmentRefreshListener;
|
||||
}
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fa) {
|
||||
super(fa);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
|
||||
Fragment fragment = null;
|
||||
|
||||
switch(position) {
|
||||
case 0: // Repository details
|
||||
return RepoInfoFragment.newInstance(repository);
|
||||
case 1: // Files
|
||||
return FilesFragment.newInstance(repository);
|
||||
case 2: // Issues
|
||||
fragment = IssuesFragment.newInstance(repository);
|
||||
break;
|
||||
case 3: // Pull requests
|
||||
fragment = PullRequestsFragment.newInstance(repository);
|
||||
break;
|
||||
case 4: // Releases
|
||||
return ReleasesFragment.newInstance(repository);
|
||||
case 5: // Wiki
|
||||
return WikiFragment.newInstance(repository);
|
||||
case 6: // Milestones
|
||||
fragment = MilestonesFragment.newInstance(repository);
|
||||
break;
|
||||
case 7: // Labels
|
||||
return LabelsFragment.newInstance(repository);
|
||||
case 8: // Collaborators
|
||||
return CollaboratorsFragment.newInstance(repository);
|
||||
}
|
||||
assert fragment != null;
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setFragmentRefreshListenerReleases(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListenerReleases = fragmentRefreshListener; }
|
||||
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ import retrofit2.Response;
|
|||
|
||||
public class RepoForksActivity extends BaseActivity {
|
||||
|
||||
private final String TAG = "RepositoryForks";
|
||||
private TextView noData;
|
||||
private ProgressBar progressBar;
|
||||
private final String TAG = "RepositoryForks";
|
||||
private int resultLimit;
|
||||
private int pageSize = 1;
|
||||
|
||||
|
@ -113,9 +113,7 @@ public class RepoForksActivity extends BaseActivity {
|
|||
|
||||
private void loadInitial(String repoOwner, String repoName, int pageSize, int resultLimit) {
|
||||
|
||||
Call<List<Repository>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.listForks(repoOwner, repoName, pageSize, resultLimit);
|
||||
Call<List<Repository>> call = RetrofitClient.getApiInterface(ctx).listForks(repoOwner, repoName, pageSize, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -157,9 +155,7 @@ public class RepoForksActivity extends BaseActivity {
|
|||
|
||||
progressLoadMore.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<Repository>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.listForks(repoOwner, repoName, page, resultLimit);
|
||||
Call<List<Repository>> call = RetrofitClient.getApiInterface(ctx).listForks(repoOwner, repoName, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -230,8 +226,7 @@ public class RepoForksActivity extends BaseActivity {
|
|||
List<Repository> userRepositories = new ArrayList<>();
|
||||
|
||||
for(Repository d : forksList) {
|
||||
if(d.getOwner().getLogin().contains(text) || d.getName().toLowerCase().contains(text) ||
|
||||
d.getDescription().toLowerCase().contains(text)) {
|
||||
if(d.getOwner().getLogin().contains(text) || d.getName().toLowerCase().contains(text) || d.getDescription().toLowerCase().contains(text)) {
|
||||
|
||||
userRepositories.add(d);
|
||||
}
|
||||
|
@ -245,4 +240,5 @@ public class RepoForksActivity extends BaseActivity {
|
|||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,9 +116,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
TransferRepoOption repositoryTransfer = new TransferRepoOption();
|
||||
repositoryTransfer.setNewOwner(newOwner);
|
||||
|
||||
Call<Repository> transferCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoTransfer(repositoryTransfer, repository.getOwner(), repository.getName());
|
||||
Call<Repository> transferCall = RetrofitClient.getApiInterface(ctx).repoTransfer(repositoryTransfer, repository.getOwner(), repository.getName());
|
||||
|
||||
transferCall.enqueue(new Callback<Repository>() {
|
||||
|
||||
|
@ -128,7 +126,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
transferRepoBinding.transfer.setVisibility(View.GONE);
|
||||
transferRepoBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 202) {
|
||||
if(response.code() == 202) {
|
||||
|
||||
dialogRepo.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
||||
|
@ -138,7 +136,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
}
|
||||
else if (response.code() == 404) {
|
||||
else if(response.code() == 404) {
|
||||
|
||||
transferRepoBinding.transfer.setVisibility(View.VISIBLE);
|
||||
transferRepoBinding.processingRequest.setVisibility(View.GONE);
|
||||
|
@ -187,9 +185,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
|
||||
private void deleteRepository() {
|
||||
|
||||
Call<Void> deleteCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoDelete(repository.getOwner(), repository.getName());
|
||||
Call<Void> deleteCall = RetrofitClient.getApiInterface(ctx).repoDelete(repository.getOwner(), repository.getName());
|
||||
|
||||
deleteCall.enqueue(new Callback<Void>() {
|
||||
|
||||
|
@ -199,7 +195,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
deleteRepoBinding.delete.setVisibility(View.GONE);
|
||||
deleteRepoBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 204) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
dialogRepo.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
||||
|
@ -251,7 +247,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
|
||||
propBinding.repoEnableIssues.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
if (isChecked) {
|
||||
if(isChecked) {
|
||||
propBinding.repoEnableTimer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
@ -275,22 +271,17 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
propBinding.repoEnableSquash.setChecked(repoInfo.isAllowSquashMerge());
|
||||
propBinding.repoEnableForceMerge.setChecked(repoInfo.isAllowRebaseExplicit());
|
||||
|
||||
propBinding.save.setOnClickListener(saveProperties -> saveRepositoryProperties(String.valueOf(propBinding.repoName.getText()),
|
||||
String.valueOf(propBinding.repoWebsite.getText()),
|
||||
String.valueOf(propBinding.repoDescription.getText()),
|
||||
propBinding.repoPrivate.isChecked(), propBinding.repoAsTemplate.isChecked(),
|
||||
propBinding.repoEnableIssues.isChecked(), propBinding.repoEnableWiki.isChecked(),
|
||||
propBinding.repoEnablePr.isChecked(), propBinding.repoEnableTimer.isChecked(),
|
||||
propBinding.repoEnableMerge.isChecked(), propBinding.repoEnableRebase.isChecked(),
|
||||
propBinding.repoEnableSquash.isChecked(), propBinding.repoEnableForceMerge.isChecked()));
|
||||
propBinding.save.setOnClickListener(
|
||||
saveProperties -> saveRepositoryProperties(String.valueOf(propBinding.repoName.getText()), String.valueOf(propBinding.repoWebsite.getText()), String.valueOf(propBinding.repoDescription.getText()),
|
||||
propBinding.repoPrivate.isChecked(), propBinding.repoAsTemplate.isChecked(), propBinding.repoEnableIssues.isChecked(), propBinding.repoEnableWiki.isChecked(), propBinding.repoEnablePr.isChecked(),
|
||||
propBinding.repoEnableTimer.isChecked(), propBinding.repoEnableMerge.isChecked(), propBinding.repoEnableRebase.isChecked(), propBinding.repoEnableSquash.isChecked(),
|
||||
propBinding.repoEnableForceMerge.isChecked()));
|
||||
|
||||
dialogRepo = materialAlertDialogBuilder.show();
|
||||
}
|
||||
|
||||
private void saveRepositoryProperties(String repoName, String repoWebsite, String repoDescription,
|
||||
boolean repoPrivate, boolean repoAsTemplate, boolean repoEnableIssues, boolean repoEnableWiki,
|
||||
boolean repoEnablePr, boolean repoEnableTimer, boolean repoEnableMerge, boolean repoEnableRebase,
|
||||
boolean repoEnableSquash, boolean repoEnableForceMerge) {
|
||||
private void saveRepositoryProperties(String repoName, String repoWebsite, String repoDescription, boolean repoPrivate, boolean repoAsTemplate, boolean repoEnableIssues, boolean repoEnableWiki, boolean repoEnablePr,
|
||||
boolean repoEnableTimer, boolean repoEnableMerge, boolean repoEnableRebase, boolean repoEnableSquash, boolean repoEnableForceMerge) {
|
||||
|
||||
EditRepoOption repoProps = new EditRepoOption();
|
||||
repoProps.setName(repoName);
|
||||
|
@ -307,9 +298,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
repoProps.setAllowSquashMerge(repoEnableSquash);
|
||||
repoProps.setAllowRebaseExplicit(repoEnableForceMerge);
|
||||
|
||||
Call<Repository> propsCall = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoEdit(repository.getOwner(), repository.getName(), repoProps);
|
||||
Call<Repository> propsCall = RetrofitClient.getApiInterface(ctx).repoEdit(repository.getOwner(), repository.getName(), repoProps);
|
||||
|
||||
propsCall.enqueue(new Callback<Repository>() {
|
||||
|
||||
|
@ -319,7 +308,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
propBinding.save.setVisibility(View.GONE);
|
||||
propBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 200) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
dialogRepo.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoPropertiesSaveSuccess));
|
||||
|
@ -327,8 +316,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
repository.setRepository(response.body());
|
||||
|
||||
if(!repository.getName().equals(repoName)) {
|
||||
Objects.requireNonNull(BaseApi.getInstance(ctx, RepositoriesApi.class))
|
||||
.updateRepositoryOwnerAndName(repository.getOwner(), repoName, repository.getRepositoryId());
|
||||
Objects.requireNonNull(BaseApi.getInstance(ctx, RepositoriesApi.class)).updateRepositoryOwnerAndName(repository.getOwner(), repoName, repository.getRepositoryId());
|
||||
Intent result = new Intent();
|
||||
result.putExtra("nameChanged", true);
|
||||
setResult(200, result);
|
||||
|
|
|
@ -25,16 +25,13 @@ import org.mian.gitnex.helpers.Toasty;
|
|||
|
||||
public class SettingsAppearanceActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static String[] timeList;
|
||||
private static int timeSelectedChoice = 0;
|
||||
|
||||
private static String[] customFontList;
|
||||
private static int customFontSelectedChoice = 0;
|
||||
|
||||
private static String[] themeList;
|
||||
private static int themeSelectedChoice = 0;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -63,22 +60,28 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
|
||||
String lightMinute = String.valueOf(tinyDB.getInt("lightThemeTimeMinute"));
|
||||
String lightHour = String.valueOf(tinyDB.getInt("lightThemeTimeHour"));
|
||||
if(lightMinute.length() == 1) lightMinute = "0" + lightMinute;
|
||||
if(lightHour.length() == 1) lightHour = "0" + lightHour;
|
||||
if(lightMinute.length() == 1) {
|
||||
lightMinute = "0" + lightMinute;
|
||||
}
|
||||
if(lightHour.length() == 1) {
|
||||
lightHour = "0" + lightHour;
|
||||
}
|
||||
|
||||
String darkMinute = String.valueOf(tinyDB.getInt("darkThemeTimeMinute"));
|
||||
String darkHour = String.valueOf(tinyDB.getInt("darkThemeTimeHour"));
|
||||
if(darkMinute.length() == 1) darkMinute = "0" + darkMinute;
|
||||
if(darkHour.length() == 1) darkHour = "0" + darkHour;
|
||||
if(darkMinute.length() == 1) {
|
||||
darkMinute = "0" + darkMinute;
|
||||
}
|
||||
if(darkHour.length() == 1) {
|
||||
darkHour = "0" + darkHour;
|
||||
}
|
||||
|
||||
timeSelectedChoice = tinyDB.getInt("timeId");
|
||||
customFontSelectedChoice = tinyDB.getInt("customFontId", 1);
|
||||
themeSelectedChoice = tinyDB.getInt("themeId", 6); // use system theme as default
|
||||
|
||||
activitySettingsAppearanceBinding.lightThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, lightHour,
|
||||
lightMinute));
|
||||
activitySettingsAppearanceBinding.darkThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, darkHour,
|
||||
darkMinute));
|
||||
activitySettingsAppearanceBinding.lightThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, lightHour, lightMinute));
|
||||
activitySettingsAppearanceBinding.darkThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, darkHour, darkMinute));
|
||||
activitySettingsAppearanceBinding.tvDateTimeSelected.setText(timeList[timeSelectedChoice]);
|
||||
activitySettingsAppearanceBinding.customFontSelected.setText(customFontList[customFontSelectedChoice]);
|
||||
activitySettingsAppearanceBinding.themeSelected.setText(themeList[themeSelectedChoice]);
|
||||
|
@ -110,13 +113,13 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
tinyDB.putBoolean("showLabelsInList", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
activitySettingsAppearanceBinding.labelsInListFrame.setOnClickListener(v -> activitySettingsAppearanceBinding.switchLabelsInListBadge.setChecked(!activitySettingsAppearanceBinding.switchLabelsInListBadge.isChecked()));
|
||||
activitySettingsAppearanceBinding.labelsInListFrame.setOnClickListener(
|
||||
v -> activitySettingsAppearanceBinding.switchLabelsInListBadge.setChecked(!activitySettingsAppearanceBinding.switchLabelsInListBadge.isChecked()));
|
||||
|
||||
// theme selection dialog
|
||||
themeFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.themeSelectorDialogTitle)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.themeSelectorDialogTitle)
|
||||
.setSingleChoiceItems(themeList, themeSelectedChoice, (dialogInterfaceTheme, i) -> {
|
||||
|
||||
themeSelectedChoice = i;
|
||||
|
@ -146,9 +149,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
// custom font dialog
|
||||
customFontFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.settingsCustomFontSelectorDialogTitle)
|
||||
.setCancelable(customFontSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.settingsCustomFontSelectorDialogTitle).setCancelable(customFontSelectedChoice != -1)
|
||||
.setSingleChoiceItems(customFontList, customFontSelectedChoice, (dialogInterfaceCustomFont, i) -> {
|
||||
|
||||
customFontSelectedChoice = i;
|
||||
|
@ -170,9 +171,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
// time and date dialog
|
||||
timeFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.settingsTimeSelectorDialogTitle)
|
||||
.setCancelable(timeSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.settingsTimeSelectorDialogTitle).setCancelable(timeSelectedChoice != -1)
|
||||
.setSingleChoiceItems(timeList, timeSelectedChoice, (dialogInterfaceTime, i) -> {
|
||||
|
||||
timeSelectedChoice = i;
|
||||
|
@ -224,6 +223,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
Toasty.success(requireActivity().getApplicationContext(), requireContext().getResources().getString(R.string.settingsSave));
|
||||
requireActivity().recreate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DarkTimePicker extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
|
||||
|
@ -249,6 +249,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
Toasty.success(requireActivity().getApplicationContext(), requireContext().getResources().getString(R.string.settingsSave));
|
||||
requireActivity().recreate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ public class SettingsDraftsActivity extends BaseActivity {
|
|||
|
||||
}
|
||||
|
||||
private void initCloseListener() { onClickListener = view -> finish(); }
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,14 +16,12 @@ import java.util.List;
|
|||
|
||||
public class SettingsGeneralActivity extends BaseActivity {
|
||||
|
||||
private static int homeScreenSelectedChoice = 0;
|
||||
private static int defaultLinkHandlerScreenSelectedChoice = 0;
|
||||
private ActivitySettingsGeneralBinding viewBinding;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private List<String> homeScreenList;
|
||||
private static int homeScreenSelectedChoice = 0;
|
||||
|
||||
private List<String> linkHandlerDefaultScreen;
|
||||
private static int defaultLinkHandlerScreenSelectedChoice = 0;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -100,9 +98,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
|
||||
viewBinding.homeScreenFrame.setOnClickListener(setDefaultHomeScreen -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.settingsHomeScreenSelectorDialogTitle)
|
||||
.setCancelable(homeScreenSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.settingsHomeScreenSelectorDialogTitle).setCancelable(homeScreenSelectedChoice != -1)
|
||||
.setSingleChoiceItems(homeScreenArray, homeScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
|
||||
|
||||
homeScreenSelectedChoice = i;
|
||||
|
@ -129,9 +125,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
|
||||
viewBinding.setDefaultLinkHandler.setOnClickListener(setDefaultLinkHandler -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.linkSelectorDialogTitle)
|
||||
.setCancelable(defaultLinkHandlerScreenSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.linkSelectorDialogTitle).setCancelable(defaultLinkHandlerScreenSelectedChoice != -1)
|
||||
.setSingleChoiceItems(linksArray, defaultLinkHandlerScreenSelectedChoice, (dialogInterfaceHomeScreen, i) -> {
|
||||
|
||||
defaultLinkHandlerScreenSelectedChoice = i;
|
||||
|
@ -156,5 +150,8 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
// custom tabs
|
||||
}
|
||||
|
||||
private void initCloseListener() { onClickListener = view -> finish(); }
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,12 +42,7 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
viewBinding.enableVibrationMode.setChecked(tinyDB.getBoolean("notificationsEnableVibration", true));
|
||||
|
||||
if(!viewBinding.enableNotificationsMode.isChecked()) {
|
||||
AppUtil.setMultiVisibility(View.GONE,
|
||||
viewBinding.chooseColorFrame,
|
||||
viewBinding.enableLightsFrame,
|
||||
viewBinding.enableVibrationFrame,
|
||||
viewBinding.pollingDelayFrame
|
||||
);
|
||||
AppUtil.setMultiVisibility(View.GONE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame, viewBinding.pollingDelayFrame);
|
||||
}
|
||||
|
||||
if(!viewBinding.enableLightsMode.isChecked()) {
|
||||
|
@ -60,27 +55,17 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
|
||||
if(isChecked) {
|
||||
Notifications.startWorker(ctx);
|
||||
AppUtil.setMultiVisibility(View.VISIBLE,
|
||||
viewBinding.chooseColorFrame,
|
||||
viewBinding.enableLightsFrame,
|
||||
viewBinding.enableVibrationFrame,
|
||||
viewBinding.pollingDelayFrame
|
||||
);
|
||||
} else {
|
||||
AppUtil.setMultiVisibility(View.VISIBLE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame, viewBinding.pollingDelayFrame);
|
||||
}
|
||||
else {
|
||||
Notifications.stopWorker(ctx);
|
||||
AppUtil.setMultiVisibility(View.GONE,
|
||||
viewBinding.chooseColorFrame,
|
||||
viewBinding.enableLightsFrame,
|
||||
viewBinding.enableVibrationFrame,
|
||||
viewBinding.pollingDelayFrame
|
||||
);
|
||||
AppUtil.setMultiVisibility(View.GONE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame, viewBinding.pollingDelayFrame);
|
||||
}
|
||||
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
viewBinding.enableNotificationsFrame.setOnClickListener(
|
||||
v -> viewBinding.enableNotificationsMode.setChecked(!viewBinding.enableNotificationsMode.isChecked()));
|
||||
viewBinding.enableNotificationsFrame.setOnClickListener(v -> viewBinding.enableNotificationsMode.setChecked(!viewBinding.enableNotificationsMode.isChecked()));
|
||||
|
||||
// polling delay
|
||||
viewBinding.pollingDelayFrame.setOnClickListener(v -> {
|
||||
|
@ -91,12 +76,8 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
numberPicker.setValue(tinyDB.getInt("pollingDelayMinutes", Constants.defaultPollingDelay));
|
||||
numberPicker.setWrapSelectorWheel(true);
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.pollingDelayDialogHeaderText)
|
||||
.setMessage(getString(R.string.pollingDelayDialogDescriptionText))
|
||||
.setCancelable(true)
|
||||
.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss())
|
||||
.setPositiveButton(getString(R.string.okButton), (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.pollingDelayDialogHeaderText).setMessage(getString(R.string.pollingDelayDialogDescriptionText))
|
||||
.setCancelable(true).setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).setPositiveButton(getString(R.string.okButton), (dialog, which) -> {
|
||||
|
||||
tinyDB.putInt("pollingDelayMinutes", numberPicker.getValue());
|
||||
|
||||
|
@ -116,7 +97,8 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
|
||||
if(!isChecked) {
|
||||
viewBinding.chooseColorFrame.setVisibility(View.GONE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
viewBinding.chooseColorFrame.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
@ -150,8 +132,7 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
viewBinding.enableVibrationFrame.setOnClickListener(
|
||||
v -> viewBinding.enableVibrationMode.setChecked(!viewBinding.enableVibrationMode.isChecked()));
|
||||
viewBinding.enableVibrationFrame.setOnClickListener(v -> viewBinding.enableVibrationMode.setChecked(!viewBinding.enableVibrationMode.isChecked()));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ public class SettingsReportsActivity extends BaseActivity {
|
|||
tinyDB.putBoolean("crashReportingEnabled", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
activitySettingsReportsBinding.enableSendReports.setOnClickListener(
|
||||
v -> activitySettingsReportsBinding.crashReportsSwitch.setChecked(!activitySettingsReportsBinding.crashReportsSwitch.isChecked()));
|
||||
activitySettingsReportsBinding.enableSendReports.setOnClickListener(v -> activitySettingsReportsBinding.crashReportsSwitch.setChecked(!activitySettingsReportsBinding.crashReportsSwitch.isChecked()));
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
|
|
@ -28,13 +28,11 @@ import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTI
|
|||
|
||||
public class SettingsSecurityActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static String[] cacheSizeDataList;
|
||||
private static int cacheSizeDataSelectedChoice = 0;
|
||||
|
||||
private static String[] cacheSizeImagesList;
|
||||
private static int cacheSizeImagesSelectedChoice = 0;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -86,7 +84,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
BiometricManager biometricManager = BiometricManager.from(ctx);
|
||||
KeyguardManager keyguardManager = (KeyguardManager) ctx.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
|
||||
if (!keyguardManager.isDeviceSecure()) {
|
||||
if(!keyguardManager.isDeviceSecure()) {
|
||||
|
||||
switch(biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL)) {
|
||||
|
||||
|
@ -141,11 +139,8 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
// clear cache
|
||||
clearCacheFrame.setOnClickListener(v1 -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.clearCacheDialogHeader)
|
||||
.setMessage(getResources().getString(R.string.clearCacheDialogMessage))
|
||||
.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss())
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.clearCacheDialogHeader).setMessage(getResources().getString(R.string.clearCacheDialogMessage))
|
||||
.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
try {
|
||||
|
||||
|
@ -154,7 +149,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch(IOException e) {
|
||||
|
||||
Log.e("SettingsSecurity", e.toString());
|
||||
}
|
||||
|
@ -166,9 +161,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
// cache size images selection dialog
|
||||
cacheSizeImagesFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.cacheSizeImagesDialogHeader)
|
||||
.setCancelable(cacheSizeImagesSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.cacheSizeImagesDialogHeader).setCancelable(cacheSizeImagesSelectedChoice != -1)
|
||||
.setSingleChoiceItems(cacheSizeImagesList, cacheSizeImagesSelectedChoice, (dialogInterfaceTheme, i) -> {
|
||||
|
||||
cacheSizeImagesSelectedChoice = i;
|
||||
|
@ -186,9 +179,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
// cache size data selection dialog
|
||||
cacheSizeDataFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.cacheSizeDataDialogHeader)
|
||||
.setCancelable(cacheSizeDataSelectedChoice != -1)
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.cacheSizeDataDialogHeader).setCancelable(cacheSizeDataSelectedChoice != -1)
|
||||
.setSingleChoiceItems(cacheSizeDataList, cacheSizeDataSelectedChoice, (dialogInterfaceTheme, i) -> {
|
||||
|
||||
cacheSizeDataSelectedChoice = i;
|
||||
|
@ -206,11 +197,8 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
// certs deletion
|
||||
certsFrame.setOnClickListener(v1 -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.settingsCertsPopupTitle)
|
||||
.setMessage(getResources().getString(R.string.settingsCertsPopupMessage))
|
||||
.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss())
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.settingsCertsPopupTitle).setMessage(getResources().getString(R.string.settingsCertsPopupMessage))
|
||||
.setNeutralButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
appCtx.getSharedPreferences(MemorizingTrustManager.KEYSTORE_NAME, Context.MODE_PRIVATE).edit().remove(MemorizingTrustManager.KEYSTORE_KEY).apply();
|
||||
AppUtil.logout(this);
|
||||
|
@ -224,4 +212,5 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,14 @@ import java.util.Locale;
|
|||
|
||||
public class SettingsTranslationActivity extends BaseActivity {
|
||||
|
||||
private static int langSelectedChoice = 0;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static int langSelectedChoice = 0;
|
||||
private static String getLanguageDisplayName(String langCode) {
|
||||
Locale english = new Locale("en");
|
||||
Locale translated = new Locale(langCode);
|
||||
return String.format("%s (%s)", translated.getDisplayName(translated), translated.getDisplayName(english));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -58,11 +63,8 @@ public class SettingsTranslationActivity extends BaseActivity {
|
|||
// language dialog
|
||||
langFrame.setOnClickListener(view -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.settingsLanguageSelectorDialogTitle)
|
||||
.setCancelable(langSelectedChoice != -1)
|
||||
.setNeutralButton(getString(R.string.cancelButton), null)
|
||||
.setSingleChoiceItems(langs.values().toArray(new String[0]), langSelectedChoice, (dialogInterface, i) -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(R.string.settingsLanguageSelectorDialogTitle).setCancelable(langSelectedChoice != -1)
|
||||
.setNeutralButton(getString(R.string.cancelButton), null).setSingleChoiceItems(langs.values().toArray(new String[0]), langSelectedChoice, (dialogInterface, i) -> {
|
||||
|
||||
String selectedLanguage = langs.keySet().toArray(new String[0])[i];
|
||||
tinyDB.putInt("langId", i);
|
||||
|
@ -84,10 +86,4 @@ public class SettingsTranslationActivity extends BaseActivity {
|
|||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private static String getLanguageDisplayName(String langCode) {
|
||||
Locale english = new Locale("en");
|
||||
Locale translated = new Locale(langCode);
|
||||
return String.format("%s (%s)", translated.getDisplayName(translated), translated.getDisplayName(english));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -105,9 +105,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
createWikiPageOptions.setTitle(wikiTitle);
|
||||
createWikiPageOptions.setContentBase64(AppUtil.encodeBase64(wikiContent));
|
||||
|
||||
Call<WikiPage> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoCreateWikiPage(repository.getOwner(), repository.getName(), createWikiPageOptions);
|
||||
Call<WikiPage> call = RetrofitClient.getApiInterface(ctx).repoCreateWikiPage(repository.getOwner(), repository.getName(), createWikiPageOptions);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -155,9 +153,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
createWikiPageOptions.setTitle(wikiTitle);
|
||||
createWikiPageOptions.setContentBase64(AppUtil.encodeBase64(wikiContent));
|
||||
|
||||
Call<WikiPage> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoEditWikiPage(repository.getOwner(), repository.getName(), pageName, createWikiPageOptions);
|
||||
Call<WikiPage> call = RetrofitClient.getApiInterface(ctx).repoEditWikiPage(repository.getOwner(), repository.getName(), pageName, createWikiPageOptions);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -201,9 +197,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
|
||||
private void getWikiPageContents() {
|
||||
|
||||
Call<WikiPage> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.repoGetWikiPage(repository.getOwner(), repository.getName(), pageName);
|
||||
Call<WikiPage> call = RetrofitClient.getApiInterface(ctx).repoGetWikiPage(repository.getOwner(), repository.getName(), pageName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -269,12 +263,9 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
|
||||
private void deleteWiki(final String owner, final String repo, final String pageName) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(String.format(ctx.getString(R.string.deleteGenericTitle), pageName))
|
||||
.setMessage(ctx.getString(R.string.deleteWikiPageMessage, pageName))
|
||||
.setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient
|
||||
.getApiInterface(ctx).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(String.format(ctx.getString(R.string.deleteGenericTitle), pageName))
|
||||
.setMessage(ctx.getString(R.string.deleteWikiPageMessage, pageName)).setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(ctx).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
@ -362,8 +353,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
|
||||
if(action.equalsIgnoreCase("edit") || action.equalsIgnoreCase("add")) {
|
||||
if(renderMd) {
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(String.valueOf(
|
||||
Objects.requireNonNull(binding.contentLayout.getEditText()).getText())), binding.markdownPreview, repository);
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(String.valueOf(Objects.requireNonNull(binding.contentLayout.getEditText()).getText())), binding.markdownPreview, repository);
|
||||
|
||||
binding.markdownPreview.setVisibility(View.VISIBLE);
|
||||
binding.contentLayout.setVisibility(View.GONE);
|
||||
|
@ -402,4 +392,5 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,90 +31,13 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
|||
|
||||
private final List<Cron> tasksList;
|
||||
|
||||
static class CronTasksViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Cron cronTasks;
|
||||
|
||||
private final TextView taskName;
|
||||
|
||||
private CronTasksViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
Context ctx = itemView.getContext();
|
||||
|
||||
final Locale locale = ctx.getResources().getConfiguration().locale;
|
||||
final String timeFormat = TinyDB.getInstance(ctx).getString("dateFormat", "pretty");
|
||||
|
||||
ImageView runTask = itemView.findViewById(R.id.runTask);
|
||||
taskName = itemView.findViewById(R.id.taskName);
|
||||
LinearLayout cronTasksInfo = itemView.findViewById(R.id.cronTasksInfo);
|
||||
LinearLayout cronTasksRun = itemView.findViewById(R.id.cronTasksRun);
|
||||
|
||||
cronTasksInfo.setOnClickListener(taskInfo -> {
|
||||
|
||||
String nextRun = "";
|
||||
String lastRun = "";
|
||||
|
||||
if(cronTasks.getNext() != null) {
|
||||
nextRun = TimeHelper.formatTime(cronTasks.getNext(), locale, timeFormat, ctx);
|
||||
}
|
||||
if(cronTasks.getPrev() != null) {
|
||||
lastRun = TimeHelper.formatTime(cronTasks.getPrev(), locale, timeFormat, ctx);
|
||||
}
|
||||
|
||||
View view = LayoutInflater.from(ctx).inflate(R.layout.layout_cron_task_info, null);
|
||||
|
||||
TextView taskScheduleContent = view.findViewById(R.id.taskScheduleContent);
|
||||
TextView nextRunContent = view.findViewById(R.id.nextRunContent);
|
||||
TextView lastRunContent = view.findViewById(R.id.lastRunContent);
|
||||
TextView execTimeContent = view.findViewById(R.id.execTimeContent);
|
||||
|
||||
taskScheduleContent.setText(cronTasks.getSchedule());
|
||||
nextRunContent.setText(nextRun);
|
||||
lastRunContent.setText(lastRun);
|
||||
execTimeContent.setText(String.valueOf(cronTasks.getExecTimes()));
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(StringUtils.capitalize(cronTasks.getName().replace("_", " ")))
|
||||
.setView(view)
|
||||
.setPositiveButton(ctx.getString(R.string.close), null);
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
cronTasksRun.setOnClickListener(taskInfo -> {
|
||||
|
||||
runCronTask(ctx, cronTasks.getName());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public AdminCronTasksAdapter(List<Cron> tasksListMain) {
|
||||
this.tasksList = tasksListMain;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public AdminCronTasksAdapter.CronTasksViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_admin_cron_tasks, parent, false);
|
||||
return new AdminCronTasksAdapter.CronTasksViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull AdminCronTasksAdapter.CronTasksViewHolder holder, int position) {
|
||||
|
||||
Cron currentItem = tasksList.get(position);
|
||||
|
||||
holder.cronTasks = currentItem;
|
||||
holder.taskName.setText(StringUtils.capitalize(currentItem.getName().replace("_", " ")));
|
||||
}
|
||||
|
||||
private static void runCronTask(final Context ctx, final String taskName) {
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.adminCronRun(taskName);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).adminCronRun(taskName);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
|
@ -153,8 +76,82 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
|||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public AdminCronTasksAdapter.CronTasksViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_admin_cron_tasks, parent, false);
|
||||
return new AdminCronTasksAdapter.CronTasksViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull AdminCronTasksAdapter.CronTasksViewHolder holder, int position) {
|
||||
|
||||
Cron currentItem = tasksList.get(position);
|
||||
|
||||
holder.cronTasks = currentItem;
|
||||
holder.taskName.setText(StringUtils.capitalize(currentItem.getName().replace("_", " ")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tasksList.size();
|
||||
}
|
||||
|
||||
static class CronTasksViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView taskName;
|
||||
private Cron cronTasks;
|
||||
|
||||
private CronTasksViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
Context ctx = itemView.getContext();
|
||||
|
||||
final Locale locale = ctx.getResources().getConfiguration().locale;
|
||||
final String timeFormat = TinyDB.getInstance(ctx).getString("dateFormat", "pretty");
|
||||
|
||||
ImageView runTask = itemView.findViewById(R.id.runTask);
|
||||
taskName = itemView.findViewById(R.id.taskName);
|
||||
LinearLayout cronTasksInfo = itemView.findViewById(R.id.cronTasksInfo);
|
||||
LinearLayout cronTasksRun = itemView.findViewById(R.id.cronTasksRun);
|
||||
|
||||
cronTasksInfo.setOnClickListener(taskInfo -> {
|
||||
|
||||
String nextRun = "";
|
||||
String lastRun = "";
|
||||
|
||||
if(cronTasks.getNext() != null) {
|
||||
nextRun = TimeHelper.formatTime(cronTasks.getNext(), locale, timeFormat, ctx);
|
||||
}
|
||||
if(cronTasks.getPrev() != null) {
|
||||
lastRun = TimeHelper.formatTime(cronTasks.getPrev(), locale, timeFormat, ctx);
|
||||
}
|
||||
|
||||
View view = LayoutInflater.from(ctx).inflate(R.layout.layout_cron_task_info, null);
|
||||
|
||||
TextView taskScheduleContent = view.findViewById(R.id.taskScheduleContent);
|
||||
TextView nextRunContent = view.findViewById(R.id.nextRunContent);
|
||||
TextView lastRunContent = view.findViewById(R.id.lastRunContent);
|
||||
TextView execTimeContent = view.findViewById(R.id.execTimeContent);
|
||||
|
||||
taskScheduleContent.setText(cronTasks.getSchedule());
|
||||
nextRunContent.setText(nextRun);
|
||||
lastRunContent.setText(lastRun);
|
||||
execTimeContent.setText(String.valueOf(cronTasks.getExecTimes()));
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(StringUtils.capitalize(cronTasks.getName().replace("_", " "))).setView(view)
|
||||
.setPositiveButton(ctx.getString(R.string.close), null);
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
cronTasksRun.setOnClickListener(taskInfo -> {
|
||||
|
||||
runCronTask(ctx, cronTasks.getName());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,11 +30,43 @@ import java.util.List;
|
|||
|
||||
public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private List<User> usersList;
|
||||
private final List<User> usersListFull;
|
||||
private final Context context;
|
||||
private List<User> usersList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final Filter usersFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(usersListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(User item : usersListFull) {
|
||||
if(item.getEmail().toLowerCase().contains(filterPattern) || item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
usersList.clear();
|
||||
usersList.addAll((List) results.values);
|
||||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public AdminGetUsersAdapter(List<User> usersListMain, Context ctx) {
|
||||
this.context = ctx;
|
||||
|
@ -69,14 +101,50 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
return usersList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<User> list) {
|
||||
usersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return usersFilter;
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class ReposHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private String userLoginId;
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userEmail;
|
||||
private final ImageView userRole;
|
||||
private final TextView userName;
|
||||
private String userLoginId;
|
||||
|
||||
ReposHolder(View itemView) {
|
||||
|
||||
|
@ -126,9 +194,8 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
if(users.isIsAdmin()) {
|
||||
|
||||
userRole.setVisibility(View.VISIBLE);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig()
|
||||
.textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null)).fontSize(60).width(200).height(80)
|
||||
.endConfig().buildRoundRect(context.getResources().getString(R.string.userRoleAdmin).toLowerCase(), ResourcesCompat.getColor(context.getResources(), R.color.releasePre, null), 8);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null)).fontSize(60).width(200).height(80).endConfig()
|
||||
.buildRoundRect(context.getResources().getString(R.string.userRoleAdmin).toLowerCase(), ResourcesCompat.getColor(context.getResources(), R.color.releasePre, null), 8);
|
||||
userRole.setImageDrawable(drawable);
|
||||
}
|
||||
else {
|
||||
|
@ -138,71 +205,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
|
||||
PicassoService.getInstance(context).get().load(users.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<User> list) {
|
||||
usersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return usersFilter;
|
||||
}
|
||||
|
||||
private final Filter usersFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(usersListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (User item : usersListFull) {
|
||||
if (item.getEmail().toLowerCase().contains(filterPattern) || item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
usersList.clear();
|
||||
usersList.addAll((List) results.values);
|
||||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -25,37 +25,11 @@ import retrofit2.Callback;
|
|||
|
||||
public class AdminUnadoptedReposAdapter extends RecyclerView.Adapter<AdminUnadoptedReposAdapter.UnadoptedViewHolder> {
|
||||
|
||||
private List<String> repos;
|
||||
private final Runnable updateList;
|
||||
private final Runnable loadMoreListener;
|
||||
private boolean isLoading = false, hasMore = true;
|
||||
private final ActivityAdminCronTasksBinding activityAdminCronTasksBinding;
|
||||
|
||||
class UnadoptedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private String repoName;
|
||||
private final TextView name;
|
||||
|
||||
private UnadoptedViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
Context ctx = itemView.getContext();
|
||||
|
||||
name = itemView.findViewById(R.id.repo_name);
|
||||
|
||||
itemView.setOnClickListener(taskInfo -> {
|
||||
String[] repoSplit = repoName.split("/");
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(repoName).setMessage(ctx.getString(R.string.unadoptedReposMessage, repoSplit[1], repoSplit[0]))
|
||||
.setNeutralButton(R.string.close, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, ((dialog, which) -> delete(ctx, repoName)))
|
||||
.setNegativeButton(R.string.adoptRepo, ((dialog, which) -> adopt(ctx, repoName, getBindingAdapterPosition())));
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
}
|
||||
}
|
||||
private List<String> repos;
|
||||
private boolean isLoading = false, hasMore = true;
|
||||
|
||||
public AdminUnadoptedReposAdapter(List<String> list, Runnable updateList, Runnable loadMore, ActivityAdminCronTasksBinding activityAdminCronTasksBinding) {
|
||||
this.repos = list;
|
||||
|
@ -95,9 +69,7 @@ public class AdminUnadoptedReposAdapter extends RecyclerView.Adapter<AdminUnadop
|
|||
|
||||
String[] repoSplit = name.split("/");
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.adminDeleteUnadoptedRepository(repoSplit[0], repoSplit[1]);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).adminDeleteUnadoptedRepository(repoSplit[0], repoSplit[1]);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -141,9 +113,7 @@ public class AdminUnadoptedReposAdapter extends RecyclerView.Adapter<AdminUnadop
|
|||
|
||||
String[] repoSplit = name.split("/");
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.adminAdoptRepository(repoSplit[0], repoSplit[1]);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).adminAdoptRepository(repoSplit[0], repoSplit[1]);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -201,4 +171,30 @@ public class AdminUnadoptedReposAdapter extends RecyclerView.Adapter<AdminUnadop
|
|||
this.hasMore = hasMore;
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
class UnadoptedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView name;
|
||||
private String repoName;
|
||||
|
||||
private UnadoptedViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
Context ctx = itemView.getContext();
|
||||
|
||||
name = itemView.findViewById(R.id.repo_name);
|
||||
|
||||
itemView.setOnClickListener(taskInfo -> {
|
||||
String[] repoSplit = repoName.split("/");
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ctx).setTitle(repoName).setMessage(ctx.getString(R.string.unadoptedReposMessage, repoSplit[1], repoSplit[0]))
|
||||
.setNeutralButton(R.string.close, null).setPositiveButton(R.string.menuDeleteText, ((dialog, which) -> delete(ctx, repoName)))
|
||||
.setNegativeButton(R.string.adoptRepo, ((dialog, which) -> adopt(ctx, repoName, getBindingAdapterPosition())));
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,16 +28,10 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||
|
||||
private final Context context;
|
||||
private final List<User> assigneesList;
|
||||
private final AssigneesListAdapterListener assigneesListener;
|
||||
private List<String> assigneesStrings = new ArrayList<>();
|
||||
private List<String> currentAssignees;
|
||||
|
||||
private final AssigneesListAdapterListener assigneesListener;
|
||||
|
||||
public interface AssigneesListAdapterListener {
|
||||
|
||||
void assigneesInterface(List<String> data);
|
||||
}
|
||||
|
||||
public AssigneesListAdapter(Context ctx, List<User> dataMain, AssigneesListAdapterListener assigneesListener, List<String> currentAssignees) {
|
||||
|
||||
this.context = ctx;
|
||||
|
@ -46,23 +40,6 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||
this.currentAssignees = currentAssignees;
|
||||
}
|
||||
|
||||
static class AssigneesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final CheckBox assigneesSelection;
|
||||
private final TextView assigneesName;
|
||||
private final ImageView assigneesAvatar;
|
||||
|
||||
private AssigneesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
this.setIsRecyclable(false);
|
||||
|
||||
assigneesSelection = itemView.findViewById(R.id.assigneesSelection);
|
||||
assigneesName = itemView.findViewById(R.id.assigneesName);
|
||||
assigneesAvatar = itemView.findViewById(R.id.assigneesAvatar);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public AssigneesListAdapter.AssigneesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -85,8 +62,8 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||
|
||||
holder.assigneesName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
PicassoService
|
||||
.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(holder.assigneesAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop()
|
||||
.into(holder.assigneesAvatar);
|
||||
|
||||
for(int i = 0; i < assigneesList.size(); i++) {
|
||||
|
||||
|
@ -138,4 +115,29 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||
currentAssignees = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public interface AssigneesListAdapterListener {
|
||||
|
||||
void assigneesInterface(List<String> data);
|
||||
|
||||
}
|
||||
|
||||
static class AssigneesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final CheckBox assigneesSelection;
|
||||
private final TextView assigneesName;
|
||||
private final ImageView assigneesAvatar;
|
||||
|
||||
private AssigneesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
this.setIsRecyclable(false);
|
||||
|
||||
assigneesSelection = itemView.findViewById(R.id.assigneesSelection);
|
||||
assigneesName = itemView.findViewById(R.id.assigneesName);
|
||||
assigneesAvatar = itemView.findViewById(R.id.assigneesAvatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,66 +47,6 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
|||
this.repository = repository;
|
||||
}
|
||||
|
||||
class CollaboratorSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private User userInfo;
|
||||
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userName;
|
||||
private final ImageView addCollaboratorButtonAdd;
|
||||
private final ImageView addCollaboratorButtonRemove;
|
||||
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
final private int permissionSelectedChoice = 0;
|
||||
|
||||
private CollaboratorSearchViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
userFullName = itemView.findViewById(R.id.userFullName);
|
||||
userName = itemView.findViewById(R.id.userName);
|
||||
addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||
addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||
|
||||
addCollaboratorButtonAdd.setOnClickListener(v -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.newTeamPermission)
|
||||
.setSingleChoiceItems(permissionList, permissionSelectedChoice, null)
|
||||
.setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.addButton, (dialog, which) -> {
|
||||
|
||||
ListView lw = ((AlertDialog)dialog).getListView();
|
||||
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
|
||||
|
||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getLogin(), repository);
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
addCollaboratorButtonRemove.setOnClickListener(v -> AlertDialogs.collaboratorRemoveDialog(context, userInfo.getLogin(), repository));
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
if(!AppUtil.checkGhostUsers(userInfo.getLogin())) {
|
||||
|
||||
userAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userInfo.getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
userAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin()));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CollaboratorSearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -121,7 +61,7 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
|||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
holder.userInfo = currentItem;
|
||||
|
||||
if (!currentItem.getFullName().equals("")) {
|
||||
if(!currentItem.getFullName().equals("")) {
|
||||
|
||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
|
@ -132,17 +72,16 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
|||
|
||||
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
|
||||
if (!currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||
if(!currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.userAvatar);
|
||||
}
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
|
||||
final String loginUid = ((BaseActivity) context).getAccount().getAccount().getUserName();
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.repoCheckCollaborator(repository.getOwner(), repository.getName(), currentItem.getLogin());
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoCheckCollaborator(repository.getOwner(), repository.getName(), currentItem.getLogin());
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
|
@ -183,4 +122,60 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
|||
public int getItemCount() {
|
||||
return usersSearchList.size();
|
||||
}
|
||||
|
||||
class CollaboratorSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userName;
|
||||
private final ImageView addCollaboratorButtonAdd;
|
||||
private final ImageView addCollaboratorButtonRemove;
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
final private int permissionSelectedChoice = 0;
|
||||
private User userInfo;
|
||||
|
||||
private CollaboratorSearchViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
userFullName = itemView.findViewById(R.id.userFullName);
|
||||
userName = itemView.findViewById(R.id.userName);
|
||||
addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||
addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||
|
||||
addCollaboratorButtonAdd.setOnClickListener(v -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context).setTitle(R.string.newTeamPermission).setSingleChoiceItems(permissionList, permissionSelectedChoice, null)
|
||||
.setNeutralButton(R.string.cancelButton, null).setPositiveButton(R.string.addButton, (dialog, which) -> {
|
||||
|
||||
ListView lw = ((AlertDialog) dialog).getListView();
|
||||
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
|
||||
|
||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getLogin(), repository);
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
addCollaboratorButtonRemove.setOnClickListener(v -> AlertDialogs.collaboratorRemoveDialog(context, userInfo.getLogin(), repository));
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
if(!AppUtil.checkGhostUsers(userInfo.getLogin())) {
|
||||
|
||||
userAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userInfo.getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
userAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin()));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,31 +27,6 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
|||
private final List<User> collaboratorsList;
|
||||
private final Context context;
|
||||
|
||||
private class ViewHolder {
|
||||
|
||||
private String userLoginId;
|
||||
|
||||
private final ImageView collaboratorAvatar;
|
||||
private final TextView collaboratorName;
|
||||
|
||||
ViewHolder(View v) {
|
||||
|
||||
collaboratorAvatar = v.findViewById(R.id.collaboratorAvatar);
|
||||
collaboratorName = v.findViewById(R.id.collaboratorName);
|
||||
|
||||
collaboratorAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
collaboratorAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public CollaboratorsAdapter(Context ctx, List<User> collaboratorsListMain) {
|
||||
|
||||
this.context = ctx;
|
||||
|
@ -79,7 +54,7 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
|||
|
||||
ViewHolder viewHolder;
|
||||
|
||||
if (finalView == null) {
|
||||
if(finalView == null) {
|
||||
|
||||
finalView = LayoutInflater.from(context).inflate(R.layout.list_collaborators, null);
|
||||
viewHolder = new ViewHolder(finalView);
|
||||
|
@ -99,7 +74,8 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
|||
int imgRadius = AppUtil.getPixelsFromDensity(context, 90);
|
||||
|
||||
User currentItem = collaboratorsList.get(position);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.collaboratorAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop()
|
||||
.into(viewHolder.collaboratorAvatar);
|
||||
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
|
||||
|
@ -114,4 +90,29 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
|||
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
|
||||
private final ImageView collaboratorAvatar;
|
||||
private final TextView collaboratorName;
|
||||
private String userLoginId;
|
||||
|
||||
ViewHolder(View v) {
|
||||
|
||||
collaboratorAvatar = v.findViewById(R.id.collaboratorAvatar);
|
||||
collaboratorName = v.findViewById(R.id.collaboratorName);
|
||||
|
||||
collaboratorAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
collaboratorAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,6 +71,25 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
return commitsList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Commit> list) {
|
||||
commitsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class CommitsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
View rootView;
|
||||
|
@ -103,55 +122,44 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
|
||||
|
||||
if(!Objects.equals(commitsModel.getCommit().getCommitter().getEmail(), commitsModel.getCommit().getAuthor().getEmail())) {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(context
|
||||
.getString(R.string.commitAuthoredByAndCommittedByWhen, commitsModel.getCommit().getAuthor().getName(), commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper
|
||||
.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty",
|
||||
context)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
} else {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(context
|
||||
.getString(R.string.commitCommittedByWhen, commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper
|
||||
.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty",
|
||||
context)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(
|
||||
context.getString(R.string.commitAuthoredByAndCommittedByWhen, commitsModel.getCommit().getAuthor().getName(), commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty", context)),
|
||||
HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
}
|
||||
else {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(context.getString(R.string.commitCommittedByWhen, commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty", context)),
|
||||
HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
}
|
||||
|
||||
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatarUrl() != null &&
|
||||
!commitsModel.getAuthor().getAvatarUrl().isEmpty()) {
|
||||
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatarUrl() != null && !commitsModel.getAuthor().getAvatarUrl().isEmpty()) {
|
||||
|
||||
commitAuthorAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(commitsModel.getAuthor().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
PicassoService.getInstance(context).get().load(commitsModel.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120)
|
||||
.centerCrop().into(commitAuthorAvatar);
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
commitAuthorAvatar.setImageDrawable(null);
|
||||
commitAuthorAvatar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(commitsModel.getCommitter() != null &&
|
||||
(commitsModel.getAuthor() == null || !commitsModel.getAuthor().getLogin().equals(commitsModel.getCommitter().getLogin())) &&
|
||||
commitsModel.getCommitter().getAvatarUrl() != null &&
|
||||
!commitsModel.getCommitter().getAvatarUrl().isEmpty()) {
|
||||
if(commitsModel.getCommitter() != null && (commitsModel.getAuthor() == null || !commitsModel.getAuthor().getLogin().equals(commitsModel.getCommitter().getLogin())) && commitsModel.getCommitter()
|
||||
.getAvatarUrl() != null && !commitsModel.getCommitter().getAvatarUrl().isEmpty()) {
|
||||
|
||||
commitCommitterAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(commitsModel.getCommitter().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
PicassoService.getInstance(context).get().load(commitsModel.getCommitter().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120)
|
||||
.centerCrop().into(commitCommitterAvatar);
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
commitCommitterAvatar.setImageDrawable(null);
|
||||
commitCommitterAvatar.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -161,33 +169,16 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
Intent intent;
|
||||
if(context instanceof CommitsActivity) {
|
||||
intent = ((CommitsActivity) context).repository.getIntent(context, CommitDetailActivity.class);
|
||||
} else {
|
||||
intent = IssueContext.fromIntent(((DiffActivity) context).getIntent()).getRepository()
|
||||
.getIntent(context, CommitDetailActivity.class);
|
||||
}
|
||||
else {
|
||||
intent = IssueContext.fromIntent(((DiffActivity) context).getIntent()).getRepository().getIntent(context, CommitDetailActivity.class);
|
||||
}
|
||||
intent.putExtra("sha", commitsModel.getSha());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Commit> list) {
|
||||
commitsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,20 +23,18 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class DiffAdapter extends BaseAdapter {
|
||||
|
||||
private final Context context;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final List<String> lines;
|
||||
private final IssueContext issue;
|
||||
|
||||
private final List<Integer> selectedLines;
|
||||
private final Typeface typeface;
|
||||
private final String type;
|
||||
|
||||
private static int COLOR_ADDED;
|
||||
private static int COLOR_REMOVED;
|
||||
private static int COLOR_NORMAL;
|
||||
private static int COLOR_SELECTED;
|
||||
private static int COLOR_FONT;
|
||||
private final Context context;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final List<String> lines;
|
||||
private final IssueContext issue;
|
||||
private final List<Integer> selectedLines;
|
||||
private final Typeface typeface;
|
||||
private final String type;
|
||||
|
||||
public DiffAdapter(Context context, FragmentManager fragmentManager, List<String> lines, IssueContext issue, String type) {
|
||||
|
||||
|
@ -149,10 +147,13 @@ public class DiffAdapter extends BaseAdapter {
|
|||
}
|
||||
|
||||
switch(line.charAt(0)) {
|
||||
case '+': return COLOR_ADDED;
|
||||
case '-': return COLOR_REMOVED;
|
||||
case '+':
|
||||
return COLOR_ADDED;
|
||||
case '-':
|
||||
return COLOR_REMOVED;
|
||||
|
||||
default: return COLOR_NORMAL;
|
||||
default:
|
||||
return COLOR_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ public class DiffFilesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
private static final Pattern statisticsPattern = Pattern.compile("(\\d+).*?,.*?(\\d+)");
|
||||
|
||||
private final Context context;
|
||||
private List<FileDiffView> fileDiffViews;
|
||||
private final IssueContext issue;
|
||||
private final String fragmentType;
|
||||
private List<FileDiffView> fileDiffViews;
|
||||
|
||||
public DiffFilesAdapter(Context context, List<FileDiffView> fileDiffViews, IssueContext issue, String fragmentType) {
|
||||
|
||||
|
@ -53,53 +53,6 @@ public class DiffFilesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
((DiffFilesAdapter.FilesHolder) holder).bindData(fileDiffViews.get(position));
|
||||
}
|
||||
|
||||
class FilesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
FileDiffView diffFilesObject;
|
||||
TextView fileName;
|
||||
TextView fileStatistics;
|
||||
LinearLayout main_frame;
|
||||
|
||||
FilesHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
fileName = itemView.findViewById(R.id.fileName);
|
||||
fileStatistics = itemView.findViewById(R.id.fileStatistics);
|
||||
main_frame = itemView.findViewById(R.id.main_frame);
|
||||
|
||||
main_frame.setOnClickListener(v -> {
|
||||
if(fragmentType.equalsIgnoreCase("commit")){
|
||||
((CommitDetailActivity) context).getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, DiffFragment.newInstance(diffFilesObject, fragmentType))
|
||||
.commit();
|
||||
}
|
||||
else {
|
||||
((DiffActivity) context).getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, DiffFragment.newInstance(diffFilesObject, issue))
|
||||
.commit();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(FileDiffView fileDiffView) {
|
||||
|
||||
this.diffFilesObject = fileDiffView;
|
||||
fileName.setText(fileDiffView.getFileName());
|
||||
|
||||
Matcher matcher = statisticsPattern.matcher(fileDiffView.getFileInfo());
|
||||
|
||||
if(matcher.find() && matcher.groupCount() == 2) {
|
||||
fileStatistics.setText(context.getString(R.string.diffStatistics, matcher.group(1), matcher.group(2)));
|
||||
} else {
|
||||
fileStatistics.setText(fileDiffView.getFileInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
|
@ -118,4 +71,48 @@ public class DiffFilesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class FilesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
FileDiffView diffFilesObject;
|
||||
TextView fileName;
|
||||
TextView fileStatistics;
|
||||
LinearLayout main_frame;
|
||||
|
||||
FilesHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
fileName = itemView.findViewById(R.id.fileName);
|
||||
fileStatistics = itemView.findViewById(R.id.fileStatistics);
|
||||
main_frame = itemView.findViewById(R.id.main_frame);
|
||||
|
||||
main_frame.setOnClickListener(v -> {
|
||||
if(fragmentType.equalsIgnoreCase("commit")) {
|
||||
((CommitDetailActivity) context).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, DiffFragment.newInstance(diffFilesObject, fragmentType)).commit();
|
||||
}
|
||||
else {
|
||||
((DiffActivity) context).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, DiffFragment.newInstance(diffFilesObject, issue)).commit();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(FileDiffView fileDiffView) {
|
||||
|
||||
this.diffFilesObject = fileDiffView;
|
||||
fileName.setText(fileDiffView.getFileName());
|
||||
|
||||
Matcher matcher = statisticsPattern.matcher(fileDiffView.getFileInfo());
|
||||
|
||||
if(matcher.find() && matcher.groupCount() == 2) {
|
||||
fileStatistics.setText(context.getString(R.string.diffStatistics, matcher.group(1), matcher.group(2)));
|
||||
}
|
||||
else {
|
||||
fileStatistics.setText(fileDiffView.getFileInfo());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,17 +33,75 @@ import java.util.List;
|
|||
|
||||
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
||||
|
||||
private List<DraftWithRepository> draftsList;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final Context context;
|
||||
private List<DraftWithRepository> draftsList;
|
||||
|
||||
public DraftsAdapter(Context ctx, FragmentManager fragmentManager, List<DraftWithRepository> draftsListMain) {
|
||||
this.context = ctx;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.draftsList = draftsListMain;
|
||||
}
|
||||
|
||||
private void deleteDraft(int position) {
|
||||
|
||||
draftsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, draftsList.size());
|
||||
Toasty.success(context, context.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DraftsAdapter.DraftsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_drafts, parent, false);
|
||||
return new DraftsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DraftsAdapter.DraftsViewHolder holder, int position) {
|
||||
|
||||
DraftWithRepository currentItem = draftsList.get(position);
|
||||
|
||||
String issueNumber = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||
Spanned headTitle = HtmlCompat.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(), HtmlCompat.FROM_HTML_MODE_LEGACY);
|
||||
|
||||
holder.repoInfo.setText(headTitle);
|
||||
holder.draftWithRepository = currentItem;
|
||||
|
||||
Markdown.render(context, currentItem.getDraftText(), holder.draftText);
|
||||
|
||||
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
||||
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.editCommentStatus.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return draftsList.size();
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void updateList(List<DraftWithRepository> list) {
|
||||
|
||||
draftsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private DraftWithRepository draftWithRepository;
|
||||
|
||||
private final TextView draftText;
|
||||
private final TextView repoInfo;
|
||||
private final ImageView editCommentStatus;
|
||||
private DraftWithRepository draftWithRepository;
|
||||
|
||||
private DraftsViewHolder(View itemView) {
|
||||
|
||||
|
@ -83,80 +141,15 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle, issue);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(() -> {
|
||||
Intent i = new IssueContext(
|
||||
new RepositoryContext(
|
||||
draftWithRepository.getRepositoryOwner(),
|
||||
draftWithRepository.getRepositoryName(),
|
||||
context
|
||||
),
|
||||
draftWithRepository.getIssueId(),
|
||||
draftWithRepository.getIssueType()
|
||||
).getIntent(context, IssueDetailActivity.class);
|
||||
Intent i = new IssueContext(new RepositoryContext(draftWithRepository.getRepositoryOwner(), draftWithRepository.getRepositoryName(), context), draftWithRepository.getIssueId(),
|
||||
draftWithRepository.getIssueType()).getIntent(context, IssueDetailActivity.class);
|
||||
i.putExtra("openedFromLink", "true");
|
||||
context.startActivity(i);
|
||||
});
|
||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DraftsAdapter(Context ctx, FragmentManager fragmentManager, List<DraftWithRepository> draftsListMain) {
|
||||
this.context = ctx;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.draftsList = draftsListMain;
|
||||
}
|
||||
|
||||
private void deleteDraft(int position) {
|
||||
|
||||
draftsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, draftsList.size());
|
||||
Toasty.success(context, context.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DraftsAdapter.DraftsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_drafts, parent, false);
|
||||
return new DraftsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DraftsAdapter.DraftsViewHolder holder, int position) {
|
||||
|
||||
DraftWithRepository currentItem = draftsList.get(position);
|
||||
|
||||
String issueNumber = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||
Spanned headTitle = HtmlCompat
|
||||
.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(), HtmlCompat.FROM_HTML_MODE_LEGACY);
|
||||
|
||||
holder.repoInfo.setText(headTitle);
|
||||
holder.draftWithRepository = currentItem;
|
||||
|
||||
Markdown.render(context, currentItem.getDraftText(), holder.draftText);
|
||||
|
||||
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
||||
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.editCommentStatus.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return draftsList.size();
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void updateList(List<DraftWithRepository> list) {
|
||||
|
||||
draftsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,7 @@ import org.mian.gitnex.R;
|
|||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
|
@ -46,10 +40,10 @@ import java.util.Locale;
|
|||
public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final TinyDB tinyDb;
|
||||
private List<Issue> searchedList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
|
||||
public ExploreIssuesAdapter(List<Issue> dataList, Context ctx) {
|
||||
this.context = ctx;
|
||||
|
@ -84,9 +78,38 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
return searchedList.size();
|
||||
}
|
||||
|
||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
private Issue issue;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Issue> list) {
|
||||
searchedList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView issueAssigneeAvatar;
|
||||
private final TextView issueTitle;
|
||||
|
@ -96,6 +119,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
private final LinearLayout frameLabels;
|
||||
private final HorizontalScrollView labelsScrollViewDots;
|
||||
private final LinearLayout frameLabelsDots;
|
||||
private Issue issue;
|
||||
|
||||
IssuesHolder(View itemView) {
|
||||
|
||||
|
@ -154,21 +178,16 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(issue.getUser().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
.centerCrop()
|
||||
PicassoService.getInstance(context).get().load(issue.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(issueAssigneeAvatar);
|
||||
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + issue.getRepository().getFullName() + context.getResources().getString(R.string.hash) + issue.getNumber() + "</font>";
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + issue.getRepository().getFullName() + context.getResources()
|
||||
.getString(R.string.hash) + issue.getNumber() + "</font>";
|
||||
|
||||
issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + issue.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
issueCommentsCount.setText(String.valueOf(issue.getComments()));
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(issue.getLabels() != null) {
|
||||
|
@ -215,9 +234,9 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
int height = AppUtil.getPixelsFromDensity(context, 20);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(context, 12);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize).width(
|
||||
LabelWidthCalculator
|
||||
.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(context, 18));
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig()
|
||||
.buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(context, 18));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
frameLabels.addView(labelsView);
|
||||
|
@ -252,33 +271,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Issue> list) {
|
||||
searchedList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,7 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
@ -36,10 +32,10 @@ import java.util.Locale;
|
|||
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final TinyDB tinyDb;
|
||||
private List<org.gitnex.tea4j.v2.models.Repository> reposList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
|
||||
public ExploreRepositoriesAdapter(List<org.gitnex.tea4j.v2.models.Repository> dataList, Context ctx) {
|
||||
this.context = ctx;
|
||||
|
@ -73,17 +69,36 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
return reposList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class RepositoriesHolder extends RecyclerView.ViewHolder {
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView repoDescription;
|
||||
private CheckBox isRepoAdmin;
|
||||
private final TextView repoStars;
|
||||
private final TextView repoLastUpdated;
|
||||
private final View spacerView;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
private CheckBox isRepoAdmin;
|
||||
|
||||
RepositoriesHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
@ -126,7 +141,8 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
|
||||
if(userRepositories.getAvatarUrl() != null) {
|
||||
if(!userRepositories.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
PicassoService.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(image);
|
||||
}
|
||||
else {
|
||||
image.setImageDrawable(drawable);
|
||||
|
@ -179,24 +195,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
}
|
||||
isRepoAdmin.setChecked(userRepositories.getPermissions().isAdmin());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,7 @@ import android.content.Context;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -30,19 +26,129 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||
private final Context context;
|
||||
|
||||
private final FilesAdapterListener filesListener;
|
||||
private final Filter filesFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<ContentsResponse> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(originalFiles);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(ContentsResponse item : originalFiles) {
|
||||
if(item.getName().toLowerCase().contains(filterPattern) || item.getPath().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
alteredFiles.clear();
|
||||
alteredFiles.addAll((List) results.values);
|
||||
|
||||
notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public FilesAdapter(Context ctx, FilesAdapterListener filesListener) {
|
||||
|
||||
this.context = ctx;
|
||||
this.filesListener = filesListener;
|
||||
}
|
||||
|
||||
public List<ContentsResponse> getOriginalFiles() {
|
||||
return originalFiles;
|
||||
}
|
||||
|
||||
public void notifyOriginalDataSetChanged() {
|
||||
|
||||
alteredFiles.clear();
|
||||
alteredFiles.addAll(originalFiles);
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FilesAdapter.FilesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_files, parent, false);
|
||||
return new FilesAdapter.FilesViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull FilesAdapter.FilesViewHolder holder, int position) {
|
||||
|
||||
ContentsResponse currentItem = alteredFiles.get(position);
|
||||
|
||||
holder.file = currentItem;
|
||||
holder.fileName.setText(currentItem.getName());
|
||||
|
||||
switch(currentItem.getType()) {
|
||||
|
||||
case "file":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_file));
|
||||
holder.fileInfo.setVisibility(View.VISIBLE);
|
||||
holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(Math.toIntExact(currentItem.getSize())));
|
||||
break;
|
||||
|
||||
case "dir":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_directory));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case "submodule":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_submodule));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case "symlink":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_symlink));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
default:
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_question));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return alteredFiles.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return filesFilter;
|
||||
}
|
||||
|
||||
public interface FilesAdapterListener {
|
||||
|
||||
void onClickFile(ContentsResponse file);
|
||||
|
||||
}
|
||||
|
||||
class FilesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ContentsResponse file;
|
||||
|
||||
private final ImageView fileTypeIs;
|
||||
private final TextView fileName;
|
||||
private final TextView fileInfo;
|
||||
private ContentsResponse file;
|
||||
|
||||
private FilesViewHolder(View itemView) {
|
||||
|
||||
|
@ -121,116 +227,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||
});*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public FilesAdapter(Context ctx, FilesAdapterListener filesListener) {
|
||||
|
||||
this.context = ctx;
|
||||
this.filesListener = filesListener;
|
||||
}
|
||||
|
||||
public List<ContentsResponse> getOriginalFiles() {
|
||||
return originalFiles;
|
||||
}
|
||||
|
||||
public void notifyOriginalDataSetChanged() {
|
||||
|
||||
alteredFiles.clear();
|
||||
alteredFiles.addAll(originalFiles);
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FilesAdapter.FilesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_files, parent, false);
|
||||
return new FilesAdapter.FilesViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull FilesAdapter.FilesViewHolder holder, int position) {
|
||||
|
||||
ContentsResponse currentItem = alteredFiles.get(position);
|
||||
|
||||
holder.file = currentItem;
|
||||
holder.fileName.setText(currentItem.getName());
|
||||
|
||||
switch(currentItem.getType()) {
|
||||
|
||||
case "file":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_file));
|
||||
holder.fileInfo.setVisibility(View.VISIBLE);
|
||||
holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(Math.toIntExact(currentItem.getSize())));
|
||||
break;
|
||||
|
||||
case "dir":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_directory));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case "submodule":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_submodule));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case "symlink":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_symlink));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
default:
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_question));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return alteredFiles.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return filesFilter;
|
||||
}
|
||||
|
||||
private final Filter filesFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<ContentsResponse> filteredList = new ArrayList<>();
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(originalFiles);
|
||||
} else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (ContentsResponse item : originalFiles) {
|
||||
if (item.getName().toLowerCase().contains(filterPattern) || item.getPath().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
alteredFiles.clear();
|
||||
alteredFiles.addAll((List) results.values);
|
||||
|
||||
notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -27,13 +27,7 @@ import org.mian.gitnex.clients.PicassoService;
|
|||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.views.ReactionList;
|
||||
import org.mian.gitnex.views.ReactionSpinner;
|
||||
|
@ -70,16 +64,131 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||
this.issue = issue;
|
||||
}
|
||||
|
||||
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
||||
private void updateAdapter(int position) {
|
||||
|
||||
private String userLoginId;
|
||||
private Comment issueComment;
|
||||
issuesComments.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, issuesComments.size());
|
||||
}
|
||||
|
||||
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).issueDeleteComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
case 204:
|
||||
updateAdapter(position);
|
||||
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
||||
IssuesFragment.resumeIssues = true;
|
||||
break;
|
||||
|
||||
case 401:
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
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));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public IssueCommentsAdapter.IssueCommentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_issue_comments, parent, false);
|
||||
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
||||
|
||||
String timeFormat = tinyDB.getString("dateFormat", "pretty");
|
||||
Comment issueComment = issuesComments.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
holder.userLoginId = issueComment.getUser().getLogin();
|
||||
|
||||
holder.issueComment = issueComment;
|
||||
holder.author.setText(issueComment.getUser().getLogin());
|
||||
|
||||
PicassoService.getInstance(context).get().load(issueComment.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(AppUtil.getPixelsFromDensity(context, 35), AppUtil.getPixelsFromDensity(context, 35)).centerCrop().into(holder.avatar);
|
||||
|
||||
Markdown.render(context, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment, issue.getRepository());
|
||||
|
||||
StringBuilder informationBuilder = null;
|
||||
if(issueComment.getCreatedAt() != null) {
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreatedAt(), locale, "pretty", context));
|
||||
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreatedAt()));
|
||||
}
|
||||
else if(timeFormat.equals("normal")) {
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreatedAt(), locale, "normal", context));
|
||||
}
|
||||
|
||||
if(!issueComment.getCreatedAt().equals(issueComment.getUpdatedAt())) {
|
||||
if(informationBuilder != null) {
|
||||
informationBuilder.append(context.getString(R.string.colorfulBulletSpan)).append(context.getString(R.string.modifiedText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
holder.information.setText(informationBuilder);
|
||||
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putAll(bundle);
|
||||
bundle1.putInt("commentId", Math.toIntExact(issueComment.getId()));
|
||||
|
||||
ReactionList reactionList = new ReactionList(context, bundle1);
|
||||
|
||||
holder.commentReactionBadges.addView(reactionList);
|
||||
reactionList.setOnReactionAddedListener(() -> {
|
||||
|
||||
if(holder.commentReactionBadges.getVisibility() != View.VISIBLE) {
|
||||
holder.commentReactionBadges.post(() -> holder.commentReactionBadges.setVisibility(View.VISIBLE));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return issuesComments.size();
|
||||
}
|
||||
|
||||
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView avatar;
|
||||
private final TextView author;
|
||||
private final TextView information;
|
||||
private final RecyclerView comment;
|
||||
private final LinearLayout commentReactionBadges;
|
||||
private String userLoginId;
|
||||
private Comment issueComment;
|
||||
|
||||
private IssueCommentViewHolder(View view) {
|
||||
|
||||
|
@ -237,128 +346,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
|
||||
issuesComments.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, issuesComments.size());
|
||||
}
|
||||
|
||||
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
||||
|
||||
Call<Void> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.issueDeleteComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
case 204:
|
||||
updateAdapter(position);
|
||||
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
||||
IssuesFragment.resumeIssues = true;
|
||||
break;
|
||||
|
||||
case 401:
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
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));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public IssueCommentsAdapter.IssueCommentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_issue_comments, parent, false);
|
||||
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
|
||||
}
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
||||
|
||||
String timeFormat = tinyDB.getString("dateFormat", "pretty");
|
||||
Comment issueComment = issuesComments.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
holder.userLoginId = issueComment.getUser().getLogin();
|
||||
|
||||
holder.issueComment = issueComment;
|
||||
holder.author.setText(issueComment.getUser().getLogin());
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(issueComment.getUser().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(AppUtil.getPixelsFromDensity(context, 35), AppUtil.getPixelsFromDensity(context, 35))
|
||||
.centerCrop()
|
||||
.into(holder.avatar);
|
||||
|
||||
Markdown.render(context, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment, issue.getRepository());
|
||||
|
||||
StringBuilder informationBuilder = null;
|
||||
if(issueComment.getCreatedAt() != null) {
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreatedAt(), locale, "pretty", context));
|
||||
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreatedAt()));
|
||||
}
|
||||
else if(timeFormat.equals("normal")) {
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreatedAt(), locale, "normal", context));
|
||||
}
|
||||
|
||||
if(!issueComment.getCreatedAt().equals(issueComment.getUpdatedAt())) {
|
||||
if(informationBuilder != null) {
|
||||
informationBuilder.append(context.getString(R.string.colorfulBulletSpan)).append(context.getString(R.string.modifiedText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
holder.information.setText(informationBuilder);
|
||||
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putAll(bundle);
|
||||
bundle1.putInt("commentId", Math.toIntExact(issueComment.getId()));
|
||||
|
||||
ReactionList reactionList = new ReactionList(context, bundle1);
|
||||
|
||||
holder.commentReactionBadges.addView(reactionList);
|
||||
reactionList.setOnReactionAddedListener(() -> {
|
||||
|
||||
if(holder.commentReactionBadges.getVisibility() != View.VISIBLE) {
|
||||
holder.commentReactionBadges.post(() -> holder.commentReactionBadges.setVisibility(View.VISIBLE));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return issuesComments.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,13 +26,7 @@ import org.mian.gitnex.activities.IssueDetailActivity;
|
|||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
@ -47,10 +41,10 @@ import java.util.Locale;
|
|||
public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
TinyDB tinyDb;
|
||||
private List<Issue> issuesList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
TinyDB tinyDb;
|
||||
|
||||
public IssuesAdapter(Context ctx, List<Issue> issuesListMain) {
|
||||
|
||||
|
@ -88,9 +82,26 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
return issuesList.size();
|
||||
}
|
||||
|
||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
private Issue issueObject;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Issue> list) {
|
||||
issuesList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView issueAssigneeAvatar;
|
||||
private final TextView issueTitle;
|
||||
|
@ -100,6 +111,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
private final LinearLayout frameLabels;
|
||||
private final HorizontalScrollView labelsScrollViewDots;
|
||||
private final LinearLayout frameLabelsDots;
|
||||
private Issue issueObject;
|
||||
|
||||
IssuesHolder(View itemView) {
|
||||
|
||||
|
@ -138,12 +150,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(issue.getUser().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
.centerCrop()
|
||||
PicassoService.getInstance(context).get().load(issue.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(issueAssigneeAvatar);
|
||||
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + issue.getNumber() + "</font>";
|
||||
|
@ -158,8 +165,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
frameLabels.setOnClickListener(v -> context.startActivity(intentIssueDetail));
|
||||
frameLabelsDots.setOnClickListener(v -> context.startActivity(intentIssueDetail));
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(issue.getLabels() != null) {
|
||||
|
@ -206,8 +212,9 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
int height = AppUtil.getPixelsFromDensity(context, 20);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(context, 12);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize).width(LabelWidthCalculator
|
||||
.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(context, 18));
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig()
|
||||
.buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(context, 18));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
frameLabels.addView(labelsView);
|
||||
|
@ -241,22 +248,4 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Issue> list) {
|
||||
issuesList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,76 +35,6 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||
private final String type;
|
||||
private final String orgName;
|
||||
|
||||
class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Label labels;
|
||||
|
||||
private final MaterialCardView labelView;
|
||||
private final ImageView labelIcon;
|
||||
private final TextView labelName;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
labelView = itemView.findViewById(R.id.labelView);
|
||||
labelIcon = itemView.findViewById(R.id.labelIcon);
|
||||
labelName = itemView.findViewById(R.id.labelName);
|
||||
ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu);
|
||||
|
||||
if((type.equals("repo") && !((RepoDetailActivity) itemView.getContext()).repository.getPermissions().isPush()) ||
|
||||
(type.equals("org") && (((OrganizationDetailActivity) itemView.getContext()).permissions == null || !((OrganizationDetailActivity) itemView.getContext()).permissions.isIsOwner()))) {
|
||||
labelsOptionsMenu.setVisibility(View.GONE);
|
||||
}
|
||||
labelsOptionsMenu.setOnClickListener(v -> {
|
||||
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_labels_in_list, null);
|
||||
|
||||
TextView labelMenuEdit = view.findViewById(R.id.labelMenuEdit);
|
||||
TextView labelMenuDelete = view.findViewById(R.id.labelMenuDelete);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(labels.getName());
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
labelMenuEdit.setOnClickListener(editLabel -> {
|
||||
|
||||
Intent intent = new Intent(context, CreateLabelActivity.class);
|
||||
intent.putExtra("labelId", String.valueOf(labels.getId()));
|
||||
intent.putExtra("labelTitle", labels.getName());
|
||||
intent.putExtra("labelColor", labels.getColor());
|
||||
intent.putExtra("labelAction", "edit");
|
||||
intent.putExtra("type", type);
|
||||
intent.putExtra("orgName", orgName);
|
||||
if(type.equals("repo")) {
|
||||
intent.putExtra(RepositoryContext.INTENT_EXTRA, ((RepoDetailActivity) itemView.getContext()).repository);
|
||||
}
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
labelMenuDelete.setOnClickListener(deleteLabel -> {
|
||||
RepositoryContext repo;
|
||||
if(type.equals("repo")) {
|
||||
repo = ((RepoDetailActivity) itemView.getContext()).repository;
|
||||
} else {
|
||||
repo = null;
|
||||
}
|
||||
|
||||
AlertDialogs.labelDeleteDialog(context, labels.getName(), String.valueOf(labels.getId()),
|
||||
type, orgName, repo);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public LabelsAdapter(Context ctx, List<Label> labelsMain, String type, String orgName) {
|
||||
|
||||
this.labelsList = labelsMain;
|
||||
|
@ -147,4 +77,74 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final MaterialCardView labelView;
|
||||
private final ImageView labelIcon;
|
||||
private final TextView labelName;
|
||||
private Label labels;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
labelView = itemView.findViewById(R.id.labelView);
|
||||
labelIcon = itemView.findViewById(R.id.labelIcon);
|
||||
labelName = itemView.findViewById(R.id.labelName);
|
||||
ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu);
|
||||
|
||||
if((type.equals("repo") && !((RepoDetailActivity) itemView.getContext()).repository.getPermissions().isPush()) || (type.equals(
|
||||
"org") && (((OrganizationDetailActivity) itemView.getContext()).permissions == null || !((OrganizationDetailActivity) itemView.getContext()).permissions.isIsOwner()))) {
|
||||
labelsOptionsMenu.setVisibility(View.GONE);
|
||||
}
|
||||
labelsOptionsMenu.setOnClickListener(v -> {
|
||||
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_labels_in_list, null);
|
||||
|
||||
TextView labelMenuEdit = view.findViewById(R.id.labelMenuEdit);
|
||||
TextView labelMenuDelete = view.findViewById(R.id.labelMenuDelete);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(labels.getName());
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
labelMenuEdit.setOnClickListener(editLabel -> {
|
||||
|
||||
Intent intent = new Intent(context, CreateLabelActivity.class);
|
||||
intent.putExtra("labelId", String.valueOf(labels.getId()));
|
||||
intent.putExtra("labelTitle", labels.getName());
|
||||
intent.putExtra("labelColor", labels.getColor());
|
||||
intent.putExtra("labelAction", "edit");
|
||||
intent.putExtra("type", type);
|
||||
intent.putExtra("orgName", orgName);
|
||||
if(type.equals("repo")) {
|
||||
intent.putExtra(RepositoryContext.INTENT_EXTRA, ((RepoDetailActivity) itemView.getContext()).repository);
|
||||
}
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
labelMenuDelete.setOnClickListener(deleteLabel -> {
|
||||
RepositoryContext repo;
|
||||
if(type.equals("repo")) {
|
||||
repo = ((RepoDetailActivity) itemView.getContext()).repository;
|
||||
}
|
||||
else {
|
||||
repo = null;
|
||||
}
|
||||
|
||||
AlertDialogs.labelDeleteDialog(context, labels.getName(), String.valueOf(labels.getId()), type, orgName, repo);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,18 +21,11 @@ import java.util.List;
|
|||
|
||||
public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.LabelsViewHolder> {
|
||||
|
||||
private List<Integer> currentLabelsIds;
|
||||
private final List<Label> labels;
|
||||
private final List<String> labelsStrings = new ArrayList<>();
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
|
||||
private final LabelsListAdapterListener labelsListener;
|
||||
|
||||
public interface LabelsListAdapterListener {
|
||||
|
||||
void labelsInterface(List<String> data);
|
||||
void labelsIdsInterface(List<Integer> data);
|
||||
}
|
||||
private List<Integer> currentLabelsIds;
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
|
||||
public LabelsListAdapter(List<Label> labelsMain, LabelsListAdapterListener labelsListener, List<Integer> currentLabelsIds) {
|
||||
|
||||
|
@ -41,23 +34,6 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
|||
this.currentLabelsIds = currentLabelsIds;
|
||||
}
|
||||
|
||||
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final CheckBox labelSelection;
|
||||
private final TextView labelText;
|
||||
private final ImageView labelColor;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
this.setIsRecyclable(false);
|
||||
|
||||
labelSelection = itemView.findViewById(R.id.labelSelection);
|
||||
labelText = itemView.findViewById(R.id.labelText);
|
||||
labelColor = itemView.findViewById(R.id.labelColor);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LabelsListAdapter.LabelsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -129,4 +105,31 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
|||
currentLabelsIds = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public interface LabelsListAdapterListener {
|
||||
|
||||
void labelsInterface(List<String> data);
|
||||
|
||||
void labelsIdsInterface(List<Integer> data);
|
||||
|
||||
}
|
||||
|
||||
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final CheckBox labelSelection;
|
||||
private final TextView labelText;
|
||||
private final ImageView labelColor;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
this.setIsRecyclable(false);
|
||||
|
||||
labelSelection = itemView.findViewById(R.id.labelSelection);
|
||||
labelText = itemView.findViewById(R.id.labelText);
|
||||
labelColor = itemView.findViewById(R.id.labelColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,10 +35,10 @@ import java.util.Locale;
|
|||
public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final RepositoryContext repository;
|
||||
private List<Milestone> dataList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final RepositoryContext repository;
|
||||
|
||||
public MilestonesAdapter(Context ctx, List<Milestone> dataListMain, RepositoryContext repository) {
|
||||
this.repository = repository;
|
||||
|
@ -64,9 +64,54 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
((MilestonesAdapter.DataHolder) holder).bindData(dataList.get(position));
|
||||
}
|
||||
|
||||
class DataHolder extends RecyclerView.ViewHolder {
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
private Milestone milestones;
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataList.size();
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
dataList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, dataList.size());
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Milestone> list) {
|
||||
dataList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class DataHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView msTitle;
|
||||
private final TextView msDescription;
|
||||
|
@ -74,6 +119,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
private final TextView msClosedIssues;
|
||||
private final TextView msDueDate;
|
||||
private final ProgressBar msProgress;
|
||||
private Milestone milestones;
|
||||
|
||||
DataHolder(View itemView) {
|
||||
|
||||
|
@ -211,49 +257,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
msDueDate.setText(context.getString(R.string.milestoneNoDueDate));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataList.size();
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
dataList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, dataList.size());
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Milestone> list) {
|
||||
dataList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,34 +28,6 @@ public class MostVisitedReposAdapter extends RecyclerView.Adapter<MostVisitedRep
|
|||
|
||||
private List<Repository> mostVisitedReposList;
|
||||
|
||||
static class MostVisitedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Repository repository;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView mostVisited;
|
||||
|
||||
private MostVisitedViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
image = itemView.findViewById(R.id.image);
|
||||
repoName = itemView.findViewById(R.id.repo_name);
|
||||
orgName = itemView.findViewById(R.id.org_name);
|
||||
mostVisited = itemView.findViewById(R.id.most_visited);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
Context context = v.getContext();
|
||||
RepositoryContext repositoryContext = new RepositoryContext(repository.getRepositoryOwner(), repository.getRepositoryName(), context);
|
||||
Intent intent = repositoryContext.getIntent(context, RepoDetailActivity.class);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public MostVisitedReposAdapter(List<Repository> reposListMain) {
|
||||
this.mostVisitedReposList = reposListMain;
|
||||
}
|
||||
|
@ -100,4 +72,33 @@ public class MostVisitedReposAdapter extends RecyclerView.Adapter<MostVisitedRep
|
|||
mostVisitedReposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
static class MostVisitedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView mostVisited;
|
||||
private Repository repository;
|
||||
|
||||
private MostVisitedViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
image = itemView.findViewById(R.id.image);
|
||||
repoName = itemView.findViewById(R.id.repo_name);
|
||||
orgName = itemView.findViewById(R.id.org_name);
|
||||
mostVisited = itemView.findViewById(R.id.most_visited);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
Context context = v.getContext();
|
||||
RepositoryContext repositoryContext = new RepositoryContext(repository.getRepositoryOwner(), repository.getRepositoryName(), context);
|
||||
Intent intent = repositoryContext.getIntent(context, RepoDetailActivity.class);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,20 +23,6 @@ public class MyProfileEmailsAdapter extends RecyclerView.Adapter<MyProfileEmails
|
|||
private final List<Email> emailsList;
|
||||
private final Context context;
|
||||
|
||||
static class EmailsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView emailPrimary;
|
||||
private final TextView userEmail;
|
||||
|
||||
private EmailsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
emailPrimary = itemView.findViewById(R.id.emailPrimary);
|
||||
userEmail = itemView.findViewById(R.id.userEmail);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public MyProfileEmailsAdapter(Context ctx, List<Email> emailsListMain) {
|
||||
this.context = ctx;
|
||||
this.emailsList = emailsListMain;
|
||||
|
@ -57,13 +43,7 @@ public class MyProfileEmailsAdapter extends RecyclerView.Adapter<MyProfileEmails
|
|||
holder.userEmail.setText(currentItem.getEmail());
|
||||
|
||||
if(currentItem.isPrimary()) {
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null))
|
||||
.fontSize(36)
|
||||
.width(220)
|
||||
.height(60)
|
||||
.endConfig()
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null)).fontSize(36).width(220).height(60).endConfig()
|
||||
.buildRoundRect(context.getResources().getString(R.string.emailTypeText), ResourcesCompat.getColor(context.getResources(), R.color.tooltipBackground, null), 8);
|
||||
holder.emailPrimary.setImageDrawable(drawable);
|
||||
}
|
||||
|
@ -78,4 +58,19 @@ public class MyProfileEmailsAdapter extends RecyclerView.Adapter<MyProfileEmails
|
|||
return emailsList.size();
|
||||
}
|
||||
|
||||
static class EmailsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView emailPrimary;
|
||||
private final TextView userEmail;
|
||||
|
||||
private EmailsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
emailPrimary = itemView.findViewById(R.id.emailPrimary);
|
||||
userEmail = itemView.findViewById(R.id.userEmail);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ import java.util.List;
|
|||
public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<NotificationThread> notificationThreads;
|
||||
private final OnMoreClickedListener onMoreClickedListener;
|
||||
private final OnNotificationClickedListener onNotificationClickedListener;
|
||||
private List<NotificationThread> notificationThreads;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
|
||||
|
@ -65,14 +65,41 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
return notificationThreads.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void updateList(List<NotificationThread> list) {
|
||||
notificationThreads = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnNotificationClickedListener {
|
||||
|
||||
void onNotificationClicked(NotificationThread notificationThread);
|
||||
|
||||
}
|
||||
|
||||
public interface OnMoreClickedListener {
|
||||
|
||||
void onMoreClicked(NotificationThread notificationThread);
|
||||
|
||||
}
|
||||
|
||||
class NotificationsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final LinearLayout frame;
|
||||
private final TextView subject;
|
||||
private final TextView repository;
|
||||
private final ImageView type;
|
||||
private ImageView pinned;
|
||||
private final ImageView more;
|
||||
private ImageView pinned;
|
||||
|
||||
NotificationsHolder(View itemView) {
|
||||
|
||||
|
@ -92,13 +119,15 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
String subjectId = "";
|
||||
|
||||
if(StringUtils.containsAny(notificationThread.getSubject().getType().toLowerCase(), "pull", "issue")) {
|
||||
subjectId = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + url.substring(url.lastIndexOf("/") + 1) + "</font>";
|
||||
subjectId = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + url.substring(
|
||||
url.lastIndexOf("/") + 1) + "</font>";
|
||||
}
|
||||
|
||||
subject.setText(HtmlCompat.fromHtml(subjectId + " " + notificationThread.getSubject().getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
if(!notificationThread.getSubject().getType().equalsIgnoreCase("repository")) {
|
||||
repository.setText(notificationThread.getRepository().getFullName());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
repository.setVisibility(View.GONE);
|
||||
pinned.setVisibility(View.GONE);
|
||||
pinned = itemView.findViewById(R.id.pinnedVertical);
|
||||
|
@ -151,28 +180,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
|
||||
more.setOnClickListener(v -> onMoreClickedListener.onMoreClicked(notificationThread));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void updateList(List<NotificationThread> list) {
|
||||
notificationThreads = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnNotificationClickedListener {
|
||||
void onNotificationClicked(NotificationThread notificationThread);
|
||||
}
|
||||
|
||||
public interface OnMoreClickedListener {
|
||||
void onMoreClicked(NotificationThread notificationThread);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,121 +28,10 @@ import java.util.List;
|
|||
public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private final Context context;
|
||||
private List<Organization> orgList;
|
||||
private final List<Organization> orgListFull;
|
||||
private List<Organization> orgList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public OrganizationsListAdapter(Context ctx, List<Organization> orgListMain) {
|
||||
this.context = ctx;
|
||||
this.orgList = orgListMain;
|
||||
orgListFull = new ArrayList<>(orgList);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new OrganizationsListAdapter.OrgHolder(inflater.inflate(R.layout.list_organizations, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
|
||||
((OrganizationsListAdapter.OrgHolder) holder).bindData(orgList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return orgList.size();
|
||||
}
|
||||
|
||||
class OrgHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Organization userOrganizations;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView orgName;
|
||||
private final TextView orgDescription;
|
||||
|
||||
OrgHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
orgName = itemView.findViewById(R.id.orgName);
|
||||
orgDescription = itemView.findViewById(R.id.orgDescription);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", userOrganizations.getUsername());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(Organization org) {
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
this.userOrganizations = org;
|
||||
orgName.setText(org.getUsername());
|
||||
|
||||
PicassoService.getInstance(context).get().load(org.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
|
||||
if(!org.getDescription().equals("")) {
|
||||
orgDescription.setVisibility(View.VISIBLE);
|
||||
orgDescription.setText(org.getDescription());
|
||||
}
|
||||
else {
|
||||
orgDescription.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public abstract static class OnLoadMoreListener {
|
||||
protected abstract void onLoadMore();
|
||||
public void onLoadFinished() {}
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Organization> list) {
|
||||
orgList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return orgFilter;
|
||||
}
|
||||
|
||||
private final Filter orgFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
|
@ -179,4 +68,117 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public OrganizationsListAdapter(Context ctx, List<Organization> orgListMain) {
|
||||
this.context = ctx;
|
||||
this.orgList = orgListMain;
|
||||
orgListFull = new ArrayList<>(orgList);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new OrganizationsListAdapter.OrgHolder(inflater.inflate(R.layout.list_organizations, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
|
||||
((OrganizationsListAdapter.OrgHolder) holder).bindData(orgList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return orgList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Organization> list) {
|
||||
orgList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return orgFilter;
|
||||
}
|
||||
|
||||
public abstract static class OnLoadMoreListener {
|
||||
|
||||
protected abstract void onLoadMore();
|
||||
|
||||
public void onLoadFinished() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class OrgHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView orgName;
|
||||
private final TextView orgDescription;
|
||||
private Organization userOrganizations;
|
||||
|
||||
OrgHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
orgName = itemView.findViewById(R.id.orgName);
|
||||
orgDescription = itemView.findViewById(R.id.orgDescription);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", userOrganizations.getUsername());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(Organization org) {
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
this.userOrganizations = org;
|
||||
orgName.setText(org.getUsername());
|
||||
|
||||
PicassoService.getInstance(context).get().load(org.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
|
||||
if(!org.getDescription().equals("")) {
|
||||
orgDescription.setVisibility(View.VISIBLE);
|
||||
orgDescription.setText(org.getDescription());
|
||||
}
|
||||
else {
|
||||
orgDescription.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,13 +26,7 @@ import org.mian.gitnex.activities.IssueDetailActivity;
|
|||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.ColorInverter;
|
||||
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -80,9 +74,26 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
return prList.size();
|
||||
}
|
||||
|
||||
class PullRequestsHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
private PullRequest pullRequestObject;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<PullRequest> list) {
|
||||
prList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class PullRequestsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView assigneeAvatar;
|
||||
private final TextView prTitle;
|
||||
|
@ -92,6 +103,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
private final LinearLayout frameLabels;
|
||||
private final HorizontalScrollView labelsScrollViewDots;
|
||||
private final LinearLayout frameLabelsDots;
|
||||
private PullRequest pullRequestObject;
|
||||
|
||||
PullRequestsHolder(View itemView) {
|
||||
|
||||
|
@ -139,18 +151,12 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(pullRequest.getUser().getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
.centerCrop()
|
||||
PicassoService.getInstance(context).get().load(pullRequest.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(this.assigneeAvatar);
|
||||
|
||||
this.pullRequestObject = pullRequest;
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(pullRequest.getLabels() != null) {
|
||||
|
@ -197,8 +203,9 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
int height = AppUtil.getPixelsFromDensity(context, 20);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(context, 12);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize).width(LabelWidthCalculator
|
||||
.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(context, 18));
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig()
|
||||
.buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(context, 18));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
frameLabels.addView(labelsView);
|
||||
|
@ -220,24 +227,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
this.prCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(pullRequest.getCreatedAt()), context));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<PullRequest> list) {
|
||||
prList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,16 +39,13 @@ public class ReactionAuthorsAdapter extends RecyclerView.Adapter<ReactionAuthors
|
|||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
User userInfo = userInfos.get(position);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(userInfo.getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.resize(240, 240)
|
||||
.transform(new RoundedTransformation(AppUtil.getPixelsFromDensity(context, 6), 0))
|
||||
PicassoService.getInstance(context).get().load(userInfo.getAvatarUrl()).placeholder(R.drawable.loader_animated).resize(240, 240).transform(new RoundedTransformation(AppUtil.getPixelsFromDensity(context, 6), 0))
|
||||
.centerCrop().into(holder.authorAvatar);
|
||||
|
||||
if(userInfo.getFullName() == null || userInfo.getFullName().isEmpty()) {
|
||||
holder.authorFullName.setVisibility(View.GONE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
holder.authorFullName.setText(userInfo.getFullName());
|
||||
holder.authorFullName.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -75,6 +72,7 @@ public class ReactionAuthorsAdapter extends RecyclerView.Adapter<ReactionAuthors
|
|||
authorFullName = itemView.findViewById(R.id.authorFullName);
|
||||
authorLogin = itemView.findViewById(R.id.authorLogin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,13 +23,7 @@ import org.mian.gitnex.activities.RepoDetailActivity;
|
|||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentReleasesBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.structs.FragmentRefreshListener;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -43,89 +37,14 @@ import retrofit2.Response;
|
|||
|
||||
public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.ReleasesViewHolder> {
|
||||
|
||||
private List<Release> releasesList;
|
||||
private final Context context;
|
||||
private final String repoOwner;
|
||||
private final String repoName;
|
||||
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final FragmentRefreshListener startDownload;
|
||||
private final FragmentReleasesBinding fragmentReleasesBinding;
|
||||
|
||||
protected class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Release releases;
|
||||
|
||||
private final TextView releaseType;
|
||||
private final TextView releaseName;
|
||||
private final ImageView authorAvatar;
|
||||
private final TextView authorName;
|
||||
private final TextView releaseTag;
|
||||
private final TextView releaseDate;
|
||||
private final TextView releaseBodyContent;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final RecyclerView downloadList;
|
||||
private final ImageView optionsMenu;
|
||||
|
||||
private ReleasesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
releaseType = itemView.findViewById(R.id.releaseType);
|
||||
releaseName = itemView.findViewById(R.id.releaseName);
|
||||
authorAvatar = itemView.findViewById(R.id.authorAvatar);
|
||||
authorName = itemView.findViewById(R.id.authorName);
|
||||
releaseTag = itemView.findViewById(R.id.releaseTag);
|
||||
TextView releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha);
|
||||
releaseDate = itemView.findViewById(R.id.releaseDate);
|
||||
releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
downloadList = itemView.findViewById(R.id.downloadList);
|
||||
optionsMenu = itemView.findViewById(R.id.releasesOptionsMenu);
|
||||
|
||||
downloadList.setHasFixedSize(true);
|
||||
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
if(!AppUtil.checkGhostUsers(releases.getAuthor().getLogin())) {
|
||||
|
||||
authorAvatar.setOnClickListener(loginId -> {
|
||||
Context context = loginId.getContext();
|
||||
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", releases.getAuthor().getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
|
||||
optionsMenu.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_release_in_list, itemView.findViewById(android.R.id.content), false);
|
||||
|
||||
TextView deleteRelease = view.findViewById(R.id.deleteRelease);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
deleteRelease.setOnClickListener(v1 -> {
|
||||
deleteRelease(context, releases.getName(), releases.getId(), repoOwner, repoName, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
private List<Release> releasesList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public ReleasesAdapter(Context ctx, List<Release> releasesMain, FragmentRefreshListener startDownload, String repoOwner, String repoName, FragmentReleasesBinding fragmentReleasesBinding) {
|
||||
this.context = ctx;
|
||||
|
@ -170,7 +89,8 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||
}
|
||||
|
||||
if(currentItem.getAuthor().getAvatarUrl() != null) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.authorAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.authorAvatar);
|
||||
}
|
||||
|
||||
holder.authorName.setText(context.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getLogin()));
|
||||
|
@ -244,12 +164,6 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
@ -269,10 +183,8 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
materialAlertDialogBuilder.setTitle(String.format(context.getString(R.string.deleteGenericTitle), releaseName))
|
||||
.setMessage(R.string.deleteReleaseConfirmation)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient
|
||||
.getApiInterface(context).repoDeleteRelease(owner, repo, releaseId).enqueue(new Callback<>() {
|
||||
materialAlertDialogBuilder.setTitle(String.format(context.getString(R.string.deleteGenericTitle), releaseName)).setMessage(R.string.deleteReleaseConfirmation)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteRelease(owner, repo, releaseId).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
@ -298,7 +210,89 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}))
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
protected class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView releaseType;
|
||||
private final TextView releaseName;
|
||||
private final ImageView authorAvatar;
|
||||
private final TextView authorName;
|
||||
private final TextView releaseTag;
|
||||
private final TextView releaseDate;
|
||||
private final TextView releaseBodyContent;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final RecyclerView downloadList;
|
||||
private final ImageView optionsMenu;
|
||||
private Release releases;
|
||||
|
||||
private ReleasesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
releaseType = itemView.findViewById(R.id.releaseType);
|
||||
releaseName = itemView.findViewById(R.id.releaseName);
|
||||
authorAvatar = itemView.findViewById(R.id.authorAvatar);
|
||||
authorName = itemView.findViewById(R.id.authorName);
|
||||
releaseTag = itemView.findViewById(R.id.releaseTag);
|
||||
TextView releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha);
|
||||
releaseDate = itemView.findViewById(R.id.releaseDate);
|
||||
releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
downloadList = itemView.findViewById(R.id.downloadList);
|
||||
optionsMenu = itemView.findViewById(R.id.releasesOptionsMenu);
|
||||
|
||||
downloadList.setHasFixedSize(true);
|
||||
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
if(!AppUtil.checkGhostUsers(releases.getAuthor().getLogin())) {
|
||||
|
||||
authorAvatar.setOnClickListener(loginId -> {
|
||||
Context context = loginId.getContext();
|
||||
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", releases.getAuthor().getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
|
||||
optionsMenu.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_release_in_list, itemView.findViewById(android.R.id.content), false);
|
||||
|
||||
TextView deleteRelease = view.findViewById(R.id.deleteRelease);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
deleteRelease.setOnClickListener(v1 -> {
|
||||
deleteRelease(context, releases.getName(), releases.getId(), repoOwner, repoName, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,17 +20,6 @@ public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownl
|
|||
private final List<Attachment> releasesDownloadsList;
|
||||
private final FragmentRefreshListener startDownload;
|
||||
|
||||
static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView downloadName;
|
||||
|
||||
private ReleasesDownloadsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
downloadName = itemView.findViewById(R.id.downloadName);
|
||||
}
|
||||
}
|
||||
|
||||
ReleasesDownloadsAdapter(List<Attachment> releasesDownloadsMain, FragmentRefreshListener startDownload) {
|
||||
|
||||
this.releasesDownloadsList = releasesDownloadsMain;
|
||||
|
@ -62,4 +51,16 @@ public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownl
|
|||
return releasesDownloadsList.size();
|
||||
}
|
||||
|
||||
static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView downloadName;
|
||||
|
||||
private ReleasesDownloadsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
downloadName = itemView.findViewById(R.id.downloadName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,11 +17,7 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
@ -74,17 +70,35 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
return forksList.size();
|
||||
}
|
||||
|
||||
class ForksHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
forksList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class ForksHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView repoDescription;
|
||||
private CheckBox isRepoAdmin;
|
||||
private final TextView repoStars;
|
||||
private final TextView repoLastUpdated;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
private CheckBox isRepoAdmin;
|
||||
|
||||
ForksHolder(View itemView) {
|
||||
|
||||
|
@ -115,13 +129,12 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
int color = generator.getColor(forksModel.getName());
|
||||
String firstCharacter = String.valueOf(forksModel.getFullName().charAt(0));
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28)
|
||||
.endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(forksModel.getAvatarUrl() != null) {
|
||||
if(!forksModel.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(forksModel.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
PicassoService.getInstance(context).get().load(forksModel.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(image);
|
||||
}
|
||||
else {
|
||||
image.setImageDrawable(drawable);
|
||||
|
@ -183,24 +196,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
forksList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,7 @@ import android.graphics.Typeface;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
|
@ -19,11 +15,7 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.*;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
|
@ -39,12 +31,46 @@ import java.util.Locale;
|
|||
public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private final Context context;
|
||||
private List<org.gitnex.tea4j.v2.models.Repository> reposList;
|
||||
private final List<org.gitnex.tea4j.v2.models.Repository> reposListFull;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
public boolean isUserOrg = false;
|
||||
private List<org.gitnex.tea4j.v2.models.Repository> reposList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final Filter reposFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<org.gitnex.tea4j.v2.models.Repository> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(reposListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(org.gitnex.tea4j.v2.models.Repository item : reposListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
reposList.clear();
|
||||
reposList.addAll((List) results.values);
|
||||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public ReposListAdapter(List<org.gitnex.tea4j.v2.models.Repository> reposListMain, Context ctx) {
|
||||
this.context = ctx;
|
||||
|
@ -80,18 +106,53 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
return reposList.size();
|
||||
}
|
||||
|
||||
class ReposHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return reposFilter;
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class ReposHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView repoDescription;
|
||||
private CheckBox isRepoAdmin;
|
||||
private final TextView repoStars;
|
||||
private final TextView repoLastUpdated;
|
||||
private final View spacerView;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
private CheckBox isRepoAdmin;
|
||||
|
||||
ReposHolder(View itemView) {
|
||||
|
||||
|
@ -137,7 +198,8 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
if(repositories.getAvatarUrl() != null) {
|
||||
if(!repositories.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(repositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
PicassoService.getInstance(context).get().load(repositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(image);
|
||||
}
|
||||
else {
|
||||
image.setImageDrawable(drawable);
|
||||
|
@ -190,73 +252,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
}
|
||||
isRepoAdmin.setChecked(repositories.getPermissions().isAdmin());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return reposFilter;
|
||||
}
|
||||
|
||||
private final Filter reposFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<org.gitnex.tea4j.v2.models.Repository> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(reposListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(org.gitnex.tea4j.v2.models.Repository item : reposListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
reposList.clear();
|
||||
reposList.addAll((List) results.values);
|
||||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -31,60 +31,15 @@ import retrofit2.Response;
|
|||
|
||||
public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder> {
|
||||
|
||||
private List<Tag> tags;
|
||||
private final Context context;
|
||||
private final String repo;
|
||||
private final String owner;
|
||||
private final FragmentRefreshListener startDownload;
|
||||
private final FragmentReleasesBinding fragmentReleasesBinding;
|
||||
private List<Tag> tags;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
protected class TagsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Tag tagsHolder;
|
||||
private final TextView tagName;
|
||||
private final TextView tagBody;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final ImageView options;
|
||||
|
||||
private TagsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
tagName = itemView.findViewById(R.id.tagName);
|
||||
tagBody = itemView.findViewById(R.id.tagBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
options = itemView.findViewById(R.id.tagsOptionsMenu);
|
||||
|
||||
options.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_tag_in_list, null);
|
||||
|
||||
TextView delete = view.findViewById(R.id.tagMenuDelete);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
delete.setOnClickListener(v1 -> {
|
||||
tagDeleteDialog(context, tagsHolder.getName(), owner, repo, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public TagsAdapter(Context ctx, List<Tag> releasesMain, String repoOwner, String repoName, FragmentRefreshListener startDownload, FragmentReleasesBinding fragmentReleasesBinding) {
|
||||
this.context = ctx;
|
||||
this.tags = releasesMain;
|
||||
|
@ -162,11 +117,6 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
|||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
@ -184,13 +134,9 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
|||
|
||||
private void tagDeleteDialog(final Context context, final String tagName, final String owner, final String repo, int position) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context)
|
||||
.setTitle(String.format(context.getString(R.string.deleteGenericTitle), tagName))
|
||||
.setMessage(R.string.deleteTagConfirmation)
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient
|
||||
.getApiInterface(context).repoDeleteTag(owner, repo, tagName).enqueue(new Callback<>() {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context).setTitle(String.format(context.getString(R.string.deleteGenericTitle), tagName))
|
||||
.setMessage(R.string.deleteTagConfirmation).setCancelable(false).setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteTag(owner, repo, tagName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
@ -218,9 +164,62 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
|||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}))
|
||||
.setNeutralButton(R.string.cancelButton, null);
|
||||
})).setNeutralButton(R.string.cancelButton, null);
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
protected class TagsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView tagName;
|
||||
private final TextView tagBody;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final ImageView options;
|
||||
private Tag tagsHolder;
|
||||
|
||||
private TagsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
tagName = itemView.findViewById(R.id.tagName);
|
||||
tagBody = itemView.findViewById(R.id.tagBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
options = itemView.findViewById(R.id.tagsOptionsMenu);
|
||||
|
||||
options.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_tag_in_list, null);
|
||||
|
||||
TextView delete = view.findViewById(R.id.tagMenuDelete);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
delete.setOnClickListener(v1 -> {
|
||||
tagDeleteDialog(context, tagsHolder.getName(), owner, repo, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,11 +39,7 @@ public class TeamMembersByOrgPreviewAdapter extends RecyclerView.Adapter<TeamMem
|
|||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
User userInfo = userData.get(position);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(userInfo.getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(AppUtil.getPixelsFromDensity(context, 3), 0))
|
||||
.resize(120, 120)
|
||||
PicassoService.getInstance(context).get().load(userInfo.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(AppUtil.getPixelsFromDensity(context, 3), 0)).resize(120, 120)
|
||||
.centerCrop().into(holder.avatar);
|
||||
}
|
||||
|
||||
|
@ -60,5 +56,7 @@ public class TeamMembersByOrgPreviewAdapter extends RecyclerView.Adapter<TeamMem
|
|||
super(itemView);
|
||||
avatar = itemView.findViewById(R.id.avatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,13 +49,70 @@ public class TeamRepositoriesAdapter extends RecyclerView.Adapter<TeamRepositori
|
|||
reposArr = new ArrayList<>();
|
||||
}
|
||||
|
||||
class TeamReposViewHolder extends RecyclerView.ViewHolder {
|
||||
@NonNull
|
||||
@Override
|
||||
public TeamRepositoriesAdapter.TeamReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_collaborators_search, parent, false);
|
||||
return new TeamRepositoriesAdapter.TeamReposViewHolder(v);
|
||||
}
|
||||
|
||||
private Repository repoInfo;
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final TeamRepositoriesAdapter.TeamReposViewHolder holder, int position) {
|
||||
|
||||
Repository currentItem = reposList.get(position);
|
||||
holder.repoInfo = currentItem;
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
holder.name.setText(currentItem.getName());
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig()
|
||||
.buildRoundRect(String.valueOf(currentItem.getFullName().charAt(0)), ColorGenerator.Companion.getMATERIAL().getColor(currentItem.getName()), 14);
|
||||
|
||||
if(currentItem.getAvatarUrl() != null && !currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.repoAvatar);
|
||||
}
|
||||
else {
|
||||
holder.repoAvatar.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return reposList.size();
|
||||
}
|
||||
|
||||
private void getTeamRepos() {
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
Call<List<Repository>> call = RetrofitClient.getApiInterface(context).orgListTeamRepos((long) teamId, 1, 50);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
for(int i = 0; i < Objects.requireNonNull(response.body()).size(); i++) {
|
||||
reposArr.addAll(response.body());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class TeamReposViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView repoAvatar;
|
||||
private final TextView name;
|
||||
private final ImageView addRepoButtonAdd;
|
||||
private Repository repoInfo;
|
||||
|
||||
private TeamReposViewHolder(View itemView) {
|
||||
|
||||
|
@ -89,69 +146,9 @@ public class TeamRepositoriesAdapter extends RecyclerView.Adapter<TeamRepositori
|
|||
|
||||
addRepoButtonAdd.setOnClickListener(v -> AlertDialogs.addRepoDialog(context, orgName, repoInfo.getName(), Integer.parseInt(String.valueOf(teamId)), teamName));
|
||||
|
||||
addRepoButtonRemove.setOnClickListener(v ->
|
||||
AlertDialogs.removeRepoDialog(context, orgName, repoInfo.getName(), Integer.parseInt(String.valueOf(teamId)), teamName));
|
||||
addRepoButtonRemove.setOnClickListener(v -> AlertDialogs.removeRepoDialog(context, orgName, repoInfo.getName(), Integer.parseInt(String.valueOf(teamId)), teamName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public TeamRepositoriesAdapter.TeamReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_collaborators_search, parent, false);
|
||||
return new TeamRepositoriesAdapter.TeamReposViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final TeamRepositoriesAdapter.TeamReposViewHolder holder, int position) {
|
||||
|
||||
Repository currentItem = reposList.get(position);
|
||||
holder.repoInfo = currentItem;
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
|
||||
|
||||
holder.name.setText(currentItem.getName());
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28)
|
||||
.endConfig().buildRoundRect(String.valueOf(currentItem.getFullName().charAt(0)), ColorGenerator.Companion.getMATERIAL().getColor(currentItem.getName()), 14);
|
||||
|
||||
if(currentItem.getAvatarUrl() != null && !currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.repoAvatar);
|
||||
}
|
||||
else {
|
||||
holder.repoAvatar.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return reposList.size();
|
||||
}
|
||||
|
||||
private void getTeamRepos() {
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
Call<List<Repository>> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.orgListTeamRepos((long) teamId, 1, 50);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
for(int i = 0; i < Objects.requireNonNull(response.body()).size(); i++) {
|
||||
reposArr.addAll(response.body());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Repository>> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,46 +36,38 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
|||
private final List<Team> teamListFull;
|
||||
private final OrganizationPermissions permissions;
|
||||
private final String orgName;
|
||||
private final Filter orgTeamsFilter = new Filter() {
|
||||
|
||||
static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<Team> filteredList = new ArrayList<>();
|
||||
|
||||
private Team team;
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(teamListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
private OrganizationPermissions permissions;
|
||||
private final TextView teamTitle;
|
||||
private final TextView teamDescription;
|
||||
private final LinearLayout membersPreviewFrame;
|
||||
|
||||
private final List<User> userInfos;
|
||||
private final TeamMembersByOrgPreviewAdapter adapter;
|
||||
private String orgName;
|
||||
|
||||
private OrgTeamsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
teamTitle = itemView.findViewById(R.id.teamTitle);
|
||||
teamDescription = itemView.findViewById(R.id.teamDescription);
|
||||
membersPreviewFrame = itemView.findViewById(R.id.membersPreviewFrame);
|
||||
|
||||
RecyclerView membersPreview = itemView.findViewById(R.id.membersPreview);
|
||||
|
||||
userInfos = new ArrayList<>();
|
||||
adapter = new TeamMembersByOrgPreviewAdapter(itemView.getContext(), userInfos);
|
||||
|
||||
membersPreview.setLayoutManager(new LinearLayoutManager(itemView.getContext(), RecyclerView.HORIZONTAL, false));
|
||||
membersPreview.setAdapter(adapter);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
|
||||
Intent intent = new Intent(context, OrganizationTeamInfoActivity.class);
|
||||
intent.putExtra("team", team);
|
||||
intent.putExtra("permissions", permissions);
|
||||
intent.putExtra("orgName", orgName);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
for(Team item : teamListFull) {
|
||||
if(item.getName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
teamList.clear();
|
||||
teamList.addAll((List<Team>) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public TeamsByOrgAdapter(Context ctx, List<Team> teamListMain, OrganizationPermissions permissions, String orgName) {
|
||||
this.context = ctx;
|
||||
|
@ -106,31 +98,29 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
|||
holder.userInfos.clear();
|
||||
holder.adapter.notifyDataSetChanged();
|
||||
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.orgListTeamMembers(currentItem.getId(), null, null)
|
||||
.enqueue(new Callback<List<User>>() {
|
||||
RetrofitClient.getApiInterface(context).orgListTeamMembers(currentItem.getId(), null, null).enqueue(new Callback<List<User>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<User>> call, @NonNull Response<List<User>> response) {
|
||||
if(response.isSuccessful() &&
|
||||
response.body() != null &&
|
||||
response.body().size() > 0) {
|
||||
if(response.isSuccessful() && response.body() != null && response.body().size() > 0) {
|
||||
|
||||
holder.membersPreviewFrame.setVisibility(View.VISIBLE);
|
||||
holder.userInfos.addAll(response.body().stream()
|
||||
.limit(Math.min(response.body().size(), 6))
|
||||
.collect(Collectors.toList()));
|
||||
holder.userInfos.addAll(response.body().stream().limit(Math.min(response.body().size(), 6)).collect(Collectors.toList()));
|
||||
|
||||
holder.adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
|
||||
if (currentItem.getDescription() != null && !currentItem.getDescription().isEmpty()) {
|
||||
if(currentItem.getDescription() != null && !currentItem.getDescription().isEmpty()) {
|
||||
holder.teamDescription.setVisibility(View.VISIBLE);
|
||||
holder.teamDescription.setText(currentItem.getDescription());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
holder.teamDescription.setVisibility(View.GONE);
|
||||
holder.teamDescription.setText("");
|
||||
}
|
||||
|
@ -146,35 +136,43 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
|||
return orgTeamsFilter;
|
||||
}
|
||||
|
||||
private final Filter orgTeamsFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<Team> filteredList = new ArrayList<>();
|
||||
static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(teamListFull);
|
||||
} else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
private final TextView teamTitle;
|
||||
private final TextView teamDescription;
|
||||
private final LinearLayout membersPreviewFrame;
|
||||
private final List<User> userInfos;
|
||||
private final TeamMembersByOrgPreviewAdapter adapter;
|
||||
private Team team;
|
||||
private OrganizationPermissions permissions;
|
||||
private String orgName;
|
||||
|
||||
for (Team item : teamListFull) {
|
||||
if (item.getName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
private OrgTeamsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
teamTitle = itemView.findViewById(R.id.teamTitle);
|
||||
teamDescription = itemView.findViewById(R.id.teamDescription);
|
||||
membersPreviewFrame = itemView.findViewById(R.id.membersPreviewFrame);
|
||||
|
||||
RecyclerView membersPreview = itemView.findViewById(R.id.membersPreview);
|
||||
|
||||
userInfos = new ArrayList<>();
|
||||
adapter = new TeamMembersByOrgPreviewAdapter(itemView.getContext(), userInfos);
|
||||
|
||||
membersPreview.setLayoutManager(new LinearLayoutManager(itemView.getContext(), RecyclerView.HORIZONTAL, false));
|
||||
membersPreview.setAdapter(adapter);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
|
||||
Intent intent = new Intent(context, OrganizationTeamInfoActivity.class);
|
||||
intent.putExtra("team", team);
|
||||
intent.putExtra("permissions", permissions);
|
||||
intent.putExtra("orgName", orgName);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
teamList.clear();
|
||||
teamList.addAll((List<Team>) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -42,98 +42,6 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
private final Context context;
|
||||
private final Dialog dialog;
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private int accountId;
|
||||
private String accountName;
|
||||
|
||||
private final TextView accountUrl;
|
||||
private final TextView userId;
|
||||
private final ImageView activeAccount;
|
||||
private final ImageView deleteAccount;
|
||||
private final ImageView repoAvatar;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
accountUrl = itemView.findViewById(R.id.accountUrl);
|
||||
userId = itemView.findViewById(R.id.userId);
|
||||
activeAccount = itemView.findViewById(R.id.activeAccount);
|
||||
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
||||
repoAvatar = itemView.findViewById(R.id.repoAvatar);
|
||||
|
||||
deleteAccount.setOnClickListener(itemDelete -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context)
|
||||
.setTitle(context.getResources().getString(R.string.removeAccountPopupTitle))
|
||||
.setMessage(context.getResources().getString(R.string.removeAccountPopupMessage))
|
||||
.setNeutralButton(context.getResources().getString(R.string.cancelButton), null)
|
||||
.setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||
|
||||
updateLayoutByPosition(getBindingAdapterPosition());
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(switchAccount -> {
|
||||
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
UserAccount userAccount = userAccountsApi.getAccountByName(accountName);
|
||||
|
||||
if(!userAccount.isLoggedIn()) {
|
||||
UrlBuilder url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
||||
.withPath("/");
|
||||
|
||||
String host;
|
||||
if(url.scheme.equals("http")) {
|
||||
if(url.port == 80 || url.port == 0) {
|
||||
host = url.hostName;
|
||||
} else {
|
||||
host = url.hostName + ":" + url.port;
|
||||
}
|
||||
} else {
|
||||
if(url.port == 443 || url.port == 0) {
|
||||
host = url.hostName;
|
||||
} else {
|
||||
host = url.hostName + ":" + url.port;
|
||||
}
|
||||
}
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.logInAgain));
|
||||
dialog.dismiss();
|
||||
|
||||
Intent i = new Intent(context, AddNewAccountActivity.class);
|
||||
i.putExtra("instanceUrl", host);
|
||||
i.putExtra("scheme", url.scheme);
|
||||
i.putExtra("token", userAccount.getToken());
|
||||
context.startActivity(i);
|
||||
return;
|
||||
}
|
||||
|
||||
if(AppUtil.switchToAccount(context, userAccount)) {
|
||||
|
||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
|
||||
Toasty.success(context, context.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
||||
getNotificationsCount();
|
||||
((Activity) context).recreate();
|
||||
dialog.dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public UserAccountsAdapter(Context ctx, Dialog dialog) {
|
||||
this.dialog = dialog;
|
||||
this.context = ctx;
|
||||
|
@ -190,9 +98,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
UserAccount currentItem = userAccountsList.get(position);
|
||||
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
holder.accountId = currentItem.getAccountId();
|
||||
holder.accountName = currentItem.getAccountName();
|
||||
|
@ -200,18 +106,14 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
holder.userId.setText(currentItem.getUserName());
|
||||
if(currentItem.isLoggedIn()) {
|
||||
holder.accountUrl.setText(url);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
holder.accountUrl.setText(context.getString(R.string.notLoggedIn, url));
|
||||
}
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(url + "assets/img/favicon.png")
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(120, 120)
|
||||
.centerCrop()
|
||||
PicassoService.getInstance(context).get().load(url + "assets/img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.repoAvatar);
|
||||
|
||||
if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) {
|
||||
|
@ -227,4 +129,93 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
return userAccountsList.size();
|
||||
}
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView accountUrl;
|
||||
private final TextView userId;
|
||||
private final ImageView activeAccount;
|
||||
private final ImageView deleteAccount;
|
||||
private final ImageView repoAvatar;
|
||||
private int accountId;
|
||||
private String accountName;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
accountUrl = itemView.findViewById(R.id.accountUrl);
|
||||
userId = itemView.findViewById(R.id.userId);
|
||||
activeAccount = itemView.findViewById(R.id.activeAccount);
|
||||
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
||||
repoAvatar = itemView.findViewById(R.id.repoAvatar);
|
||||
|
||||
deleteAccount.setOnClickListener(itemDelete -> {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context).setTitle(context.getResources().getString(R.string.removeAccountPopupTitle))
|
||||
.setMessage(context.getResources().getString(R.string.removeAccountPopupMessage)).setNeutralButton(context.getResources().getString(R.string.cancelButton), null)
|
||||
.setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||
|
||||
updateLayoutByPosition(getBindingAdapterPosition());
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(switchAccount -> {
|
||||
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||
assert userAccountsApi != null;
|
||||
UserAccount userAccount = userAccountsApi.getAccountByName(accountName);
|
||||
|
||||
if(!userAccount.isLoggedIn()) {
|
||||
UrlBuilder url = UrlBuilder.fromString(userAccount.getInstanceUrl()).withPath("/");
|
||||
|
||||
String host;
|
||||
if(url.scheme.equals("http")) {
|
||||
if(url.port == 80 || url.port == 0) {
|
||||
host = url.hostName;
|
||||
}
|
||||
else {
|
||||
host = url.hostName + ":" + url.port;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(url.port == 443 || url.port == 0) {
|
||||
host = url.hostName;
|
||||
}
|
||||
else {
|
||||
host = url.hostName + ":" + url.port;
|
||||
}
|
||||
}
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.logInAgain));
|
||||
dialog.dismiss();
|
||||
|
||||
Intent i = new Intent(context, AddNewAccountActivity.class);
|
||||
i.putExtra("instanceUrl", host);
|
||||
i.putExtra("scheme", url.scheme);
|
||||
i.putExtra("token", userAccount.getToken());
|
||||
context.startActivity(i);
|
||||
return;
|
||||
}
|
||||
|
||||
if(AppUtil.switchToAccount(context, userAccount)) {
|
||||
|
||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
Toasty.success(context, context.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
||||
getNotificationsCount();
|
||||
((Activity) context).recreate();
|
||||
dialog.dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,23 +41,6 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||
this.drawer = drawerLayout;
|
||||
}
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView userAccountAvatar;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
userAccountAvatar = itemView.findViewById(R.id.userAccountAvatar);
|
||||
|
||||
itemView.setOnClickListener(item -> {
|
||||
customDialogUserAccountsList();
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public UserAccountsNavAdapter.UserAccountsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -72,18 +55,11 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||
|
||||
UserAccount currentItem = userAccountsList.get(position);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
int imageSize = AppUtil.getPixelsFromDensity(context, 35);
|
||||
|
||||
PicassoService.getInstance(context).get()
|
||||
.load(url + "assets/img/favicon.png")
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0))
|
||||
.resize(imageSize, imageSize)
|
||||
.centerCrop()
|
||||
PicassoService.getInstance(context).get().load(url + "assets/img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(imageSize, imageSize).centerCrop()
|
||||
.into(holder.userAccountAvatar);
|
||||
}
|
||||
|
||||
|
@ -101,7 +77,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||
RecyclerView listView = dialog.findViewById(R.id.accountsList);
|
||||
Button newAccount = dialog.findViewById(R.id.newAccount);
|
||||
|
||||
if (dialog.getWindow() != null) {
|
||||
if(dialog.getWindow() != null) {
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
|
@ -117,4 +93,22 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||
dialog.show();
|
||||
}
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView userAccountAvatar;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
userAccountAvatar = itemView.findViewById(R.id.userAccountAvatar);
|
||||
|
||||
itemView.setOnClickListener(item -> {
|
||||
customDialogUserAccountsList();
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,11 +7,7 @@ import android.text.Html;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.*;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
|
@ -30,31 +26,40 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
|||
private final List<User> membersList;
|
||||
private final Context context;
|
||||
private final List<User> membersListFull;
|
||||
private final Filter membersFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
private class ViewHolder {
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
|
||||
private String userLoginId;
|
||||
filteredList.addAll(membersListFull);
|
||||
}
|
||||
else {
|
||||
|
||||
private final ImageView memberAvatar;
|
||||
private final TextView memberName;
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
ViewHolder(View v) {
|
||||
|
||||
memberAvatar = v.findViewById(R.id.userAvatarImageView);
|
||||
memberName = v.findViewById(R.id.userNameTv);
|
||||
|
||||
v.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
v.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
for(User item : membersListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
membersList.clear();
|
||||
membersList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public UserGridAdapter(Context ctx, List<User> membersListMain) {
|
||||
|
||||
|
@ -84,7 +89,7 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
|||
|
||||
UserGridAdapter.ViewHolder viewHolder;
|
||||
|
||||
if (finalView == null) {
|
||||
if(finalView == null) {
|
||||
|
||||
finalView = LayoutInflater.from(context).inflate(R.layout.list_users_grid, null);
|
||||
viewHolder = new ViewHolder(finalView);
|
||||
|
@ -104,7 +109,8 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
|||
User currentItem = membersList.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 0);
|
||||
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(viewHolder.memberAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(viewHolder.memberAvatar);
|
||||
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
|
||||
|
@ -123,39 +129,29 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
|||
return membersFilter;
|
||||
}
|
||||
|
||||
private final Filter membersFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
private class ViewHolder {
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
private final ImageView memberAvatar;
|
||||
private final TextView memberName;
|
||||
private String userLoginId;
|
||||
|
||||
filteredList.addAll(membersListFull);
|
||||
}
|
||||
else {
|
||||
ViewHolder(View v) {
|
||||
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
memberAvatar = v.findViewById(R.id.userAvatarImageView);
|
||||
memberName = v.findViewById(R.id.userNameTv);
|
||||
|
||||
for (User item : membersListFull) {
|
||||
if (item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
v.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
v.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
membersList.clear();
|
||||
membersList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue