Compare commits
4 Commits
3.2.0
...
release-3.
Author | SHA1 | Date | |
---|---|---|---|
f448e3dcad | |||
d448a06d95 | |||
b6950e5238 | |||
17a4958a65 |
@ -66,7 +66,7 @@ steps:
|
||||
- name: build
|
||||
image: nextcloudci/android:android-49
|
||||
commands:
|
||||
- ./gradlew assembleFreeRelease
|
||||
- ./gradlew build
|
||||
|
||||
- name: sign
|
||||
image: nextcloudci/android:android-49
|
||||
@ -78,7 +78,7 @@ steps:
|
||||
KEY_PASS:
|
||||
from_secret: KEY_PASS
|
||||
OUTPUT: signed.apk
|
||||
INSTANCE: https://codeberg.org
|
||||
GITEA: https://gitea.com
|
||||
KS_FILE: ci_keystore.jks
|
||||
KS_REPO:
|
||||
from_secret: KS_REPO
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,9 +11,6 @@
|
||||
# Release dir
|
||||
app/release/*
|
||||
|
||||
# Pro dir
|
||||
app/pro/*
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
|
@ -7,9 +7,6 @@ stages:
|
||||
test:
|
||||
image: nextcloudci/android:android-49
|
||||
stage: test
|
||||
only:
|
||||
- master
|
||||
- tags
|
||||
script:
|
||||
- ./gradlew test
|
||||
|
||||
@ -18,9 +15,8 @@ build:
|
||||
stage: build
|
||||
only:
|
||||
- master
|
||||
- tags
|
||||
script:
|
||||
- ./gradlew assembleFreeRelease
|
||||
- ./gradlew build
|
||||
artifacts:
|
||||
paths:
|
||||
- app/build/outputs/
|
||||
@ -31,10 +27,9 @@ sign:
|
||||
stage: sign
|
||||
only:
|
||||
- master
|
||||
- tags
|
||||
variables:
|
||||
OUTPUT: "signed.apk"
|
||||
INSTANCE: "https://codeberg.org"
|
||||
GITEA: "https://gitea.com"
|
||||
KS_FILE: "ci_keystore.jks"
|
||||
script:
|
||||
- ./scripts/sign-build.sh
|
||||
@ -48,7 +43,6 @@ latest:
|
||||
stage: publish
|
||||
only:
|
||||
- master
|
||||
- tags
|
||||
variables:
|
||||
WEBDAV_USERNAME: "GitNexBot"
|
||||
PLUGIN_FILE: "signed.apk"
|
||||
|
20
.idea/codeStyles/Project.xml
generated
20
.idea/codeStyles/Project.xml
generated
@ -16,24 +16,6 @@
|
||||
</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>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="RIGHT_MARGIN" value="220" />
|
||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||
@ -180,4 +162,4 @@
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
</component>
|
19
README.md
19
README.md
@ -1,16 +1,16 @@
|
||||
[](https://www.gnu.org/licenses/gpl-3.0)  [](https://codeberg.org/gitnex/GitNex/releases) [](https://crowdin.com/project/gitnex) [](https://discord.gg/FbSS4rf)
|
||||
[](https://www.gnu.org/licenses/gpl-3.0) [](https://codeberg.org/gitnex/GitNex/releases) [](https://crowdin.com/project/gitnex) [](https://discord.gg/FbSS4rf)
|
||||
|
||||
[<img alt="Become a Patroen" src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" height="40"/>](https://www.patreon.com/mmarif) [<img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg" height="40"/>](https://liberapay.com/mmarif/donate)
|
||||
|
||||
# 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, 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.
|
||||
|
||||
## Downloads
|
||||
[<img alt='Get it on F-droid' src='https://gitlab.com/fdroid/artwork/raw/master/badge/get-it-on.png' height="80"/>](https://f-droid.org/en/packages/org.mian.gitnex/)
|
||||
[<img alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' height="80"/>](https://play.google.com/store/apps/details?id=org.mian.gitnex.pro)
|
||||
[<img alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' height="80"/>](https://play.google.com/store/apps/details?id=org.mian.gitnex)
|
||||
[<img alt='Download builds and releases' src='assets/apk-badge.png' height="82"/>](https://cloud.swatian.com/s/DN7E5xxtaw4fRbE)
|
||||
|
||||
## Note about Gitea version
|
||||
@ -21,10 +21,10 @@ Check the versions [compatibility page](https://codeberg.org/gitnex/GitNex/wiki/
|
||||
## 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`.
|
||||
Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew build`.
|
||||
|
||||
## Features
|
||||
- Multiple accounts support
|
||||
- Repositories / issues/ org list
|
||||
- File and directory browser
|
||||
- File viewer
|
||||
- Create files
|
||||
@ -33,7 +33,6 @@ Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew assemb
|
||||
- Files diff for PRs
|
||||
- Notifications
|
||||
- Drafts
|
||||
- Repositories / issues / org list
|
||||
- [MANY MORE](https://codeberg.org/gitnex/GitNex/wiki/Features)
|
||||
|
||||
## Contributing
|
||||
@ -87,9 +86,9 @@ Thanks to all the open source libraries, contributors and donators.
|
||||
- Apache/commons-io
|
||||
- Caverock/androidsvg
|
||||
- Droidsonroids.gif/android-gif-drawable
|
||||
- Barteksc/androidPdfViewer
|
||||
- Ge0rg/memorizingTrustManager
|
||||
- Dimezis/blurView
|
||||
- Mikaelhg/urlbuilder
|
||||
- Barteksc/AndroidPdfViewer
|
||||
- Ge0rg/MemorizingTrustManager
|
||||
- Dimezis/BlurView
|
||||
- mikaelhg/urlbuilder
|
||||
|
||||
[Follow me on Fediverse - mastodon.social/@mmarif](https://mastodon.social/@mmarif)
|
||||
|
@ -1,28 +1,15 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 29
|
||||
defaultConfig {
|
||||
applicationId "org.mian.gitnex"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 320
|
||||
versionName "3.2.0"
|
||||
multiDexEnabled true
|
||||
targetSdkVersion 29
|
||||
versionCode 301
|
||||
versionName "3.0.1"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
dexOptions {
|
||||
javaMaxHeapSize "4g"
|
||||
}
|
||||
flavorDimensions "default"
|
||||
productFlavors {
|
||||
free {
|
||||
applicationId "org.mian.gitnex"
|
||||
}
|
||||
pro {
|
||||
applicationId "org.mian.gitnex.pro"
|
||||
}
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
}
|
||||
@ -41,9 +28,6 @@ android {
|
||||
targetCompatibility = "8"
|
||||
sourceCompatibility = "8"
|
||||
}
|
||||
defaultConfig{
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@ -52,29 +36,29 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def lifecycle_version = '2.3.0-alpha07'
|
||||
def markwon_version = '4.6.0'
|
||||
def lifecycle_version = "2.3.0-alpha05"
|
||||
def markwon_version = "4.4.0"
|
||||
def work_version = "2.4.0"
|
||||
def acra = "5.5.0"
|
||||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
|
||||
implementation "com.google.android.material:material:1.3.0-alpha02"
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||
implementation "androidx.appcompat:appcompat:1.3.0-alpha01"
|
||||
implementation "com.google.android.material:material:1.3.0-alpha01"
|
||||
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
|
||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||
testImplementation "junit:junit:4.13"
|
||||
androidTestImplementation 'androidx.test:runner:1.3.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
androidTestImplementation "androidx.test:runner:1.2.0"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
|
||||
implementation "com.github.vihtarb:tooltip:0.2.0"
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.8.0'
|
||||
implementation "com.google.code.gson:gson:2.8.6"
|
||||
implementation "com.squareup.picasso:picasso:2.71828"
|
||||
implementation "com.amulyakhare:com.amulyakhare.textdrawable:1.0.1"
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.8.0'
|
||||
implementation 'org.ocpsoft.prettytime:prettytime:4.0.5.Final'
|
||||
implementation "com.vdurmont:emoji-java:5.1.1"
|
||||
implementation "com.pes.materialcolorpicker:library:1.2.5"
|
||||
@ -97,7 +81,7 @@ dependencies {
|
||||
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
||||
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
||||
implementation "commons-io:commons-io:20030203.000550"
|
||||
implementation 'org.apache.commons:commons-lang3:3.11'
|
||||
implementation "org.apache.commons:commons-lang3:3.10"
|
||||
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
||||
implementation "com.github.barteksc:android-pdf-viewer:3.2.0-beta.1"
|
||||
implementation "ch.acra:acra-mail:$acra"
|
||||
|
@ -48,6 +48,8 @@
|
||||
android:name=".activities.OrganizationDetailActivity"
|
||||
android:label="@string/title_activity_org_detail"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity android:name=".activities.SponsorsActivity" />
|
||||
<activity android:name=".activities.CreditsActivity" />
|
||||
<activity android:name=".activities.CreateLabelActivity" />
|
||||
<activity android:name=".activities.CreateIssueActivity" />
|
||||
<activity android:name=".activities.CreateMilestoneActivity" />
|
||||
@ -82,10 +84,6 @@
|
||||
<activity android:name=".activities.SettingsReportsActivity" />
|
||||
<activity android:name=".activities.AddNewTeamMemberActivity" />
|
||||
<activity android:name=".activities.SettingsDraftsActivity" />
|
||||
<activity android:name=".activities.RepoForksActivity" />
|
||||
<activity android:name=".activities.AddNewAccountActivity" />
|
||||
<activity android:name=".activities.RepositorySettingsActivity" />
|
||||
<activity android:name=".activities.CreatePullRequestActivity" />
|
||||
|
||||
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
|
||||
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
BIN
app/src/main/app_logo-web.png
Normal file
BIN
app/src/main/app_logo-web.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
@ -47,7 +47,7 @@ public class CollaboratorActions {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
Toasty.success(context, context.getString(R.string.removeCollaboratorToastText));
|
||||
Toasty.info(context, context.getString(R.string.removeCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||
//Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
|
||||
//tinyDb.putBoolean("updateDataSet", true);
|
||||
@ -66,17 +66,17 @@ public class CollaboratorActions {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.info(context, context.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
Toasty.info(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ public class CollaboratorActions {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
||||
Toasty.info(context, context.getString(R.string.addCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
||||
//usersSearchData.loadUserSearchList(instanceUrl, instanceToken, searchKeyword, context);
|
||||
@ -134,17 +134,17 @@ public class CollaboratorActions {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.info(context, context.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
Toasty.info(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.ReplyToIssueActivity;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
@ -23,7 +22,7 @@ import retrofit2.Callback;
|
||||
|
||||
public class IssueActions {
|
||||
|
||||
public static void editIssueComment(final Context ctx, final int commentId, final String commentBody, long draftIdOnCreate) {
|
||||
public static void editIssueComment(final Context ctx, final int commentId, final String commentBody) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(ctx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
@ -49,10 +48,6 @@ public class IssueActions {
|
||||
|
||||
tinyDb.putBoolean("commentEdited", true);
|
||||
Toasty.info(ctx, ctx.getString(R.string.editCommentUpdatedText));
|
||||
|
||||
DraftsApi draftsApi = new DraftsApi(ctx);
|
||||
draftsApi.deleteSingleDraft((int) draftIdOnCreate);
|
||||
|
||||
((ReplyToIssueActivity) ctx).finish();
|
||||
|
||||
}
|
||||
@ -64,17 +59,17 @@ public class IssueActions {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -118,13 +113,13 @@ public class IssueActions {
|
||||
|
||||
if(issueState.equals("closed")) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.issueStateClosed));
|
||||
Toasty.info(ctx, ctx.getString(R.string.issueStateClosed));
|
||||
tinyDb.putString("issueState", "closed");
|
||||
|
||||
}
|
||||
else if(issueState.equals("open")) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.issueStateReopened));
|
||||
Toasty.info(ctx, ctx.getString(R.string.issueStateReopened));
|
||||
tinyDb.putString("issueState", "open");
|
||||
|
||||
}
|
||||
@ -138,17 +133,17 @@ public class IssueActions {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -189,14 +184,14 @@ public class IssueActions {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.subscribedSuccessfully));
|
||||
Toasty.info(ctx, ctx.getString(R.string.subscribedSuccessfully));
|
||||
tinyDB.putBoolean("issueSubscribed", true);
|
||||
|
||||
}
|
||||
else if(response.code() == 200) {
|
||||
|
||||
tinyDB.putBoolean("issueSubscribed", true);
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadySubscribed));
|
||||
Toasty.info(ctx, ctx.getString(R.string.alreadySubscribed));
|
||||
|
||||
}
|
||||
|
||||
@ -208,7 +203,7 @@ public class IssueActions {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.subscriptionError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.subscriptionError));
|
||||
|
||||
}
|
||||
|
||||
@ -217,7 +212,7 @@ public class IssueActions {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
||||
Toasty.info(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
||||
}
|
||||
});
|
||||
|
||||
@ -249,14 +244,14 @@ public class IssueActions {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
||||
Toasty.info(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
||||
tinyDB.putBoolean("issueSubscribed", false);
|
||||
|
||||
}
|
||||
else if(response.code() == 200) {
|
||||
|
||||
tinyDB.putBoolean("issueSubscribed", false);
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadyUnsubscribed));
|
||||
Toasty.info(ctx, ctx.getString(R.string.alreadyUnsubscribed));
|
||||
|
||||
}
|
||||
|
||||
@ -268,7 +263,7 @@ public class IssueActions {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.unsubscriptionError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.unsubscriptionError));
|
||||
|
||||
}
|
||||
|
||||
@ -277,7 +272,7 @@ public class IssueActions {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.unsubscriptionError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.unsubscriptionError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class MilestoneActions {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||
Toasty.info(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -61,7 +61,7 @@ public class MilestoneActions {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ public class MilestoneActions {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||
Toasty.info(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -119,7 +119,7 @@ public class MilestoneActions {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class RepositoryActions {
|
||||
if(response.code() == 204) {
|
||||
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
Toasty.success(context, context.getString(R.string.starRepositorySuccess));
|
||||
Toasty.info(context, context.getString(R.string.starRepositorySuccess));
|
||||
|
||||
}
|
||||
}
|
||||
@ -60,17 +60,17 @@ public class RepositoryActions {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.info(context, context.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
Toasty.info(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public class RepositoryActions {
|
||||
if(response.code() == 204) {
|
||||
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
Toasty.success(context, context.getString(R.string.unStarRepositorySuccess));
|
||||
Toasty.info(context, context.getString(R.string.unStarRepositorySuccess));
|
||||
|
||||
}
|
||||
}
|
||||
@ -125,17 +125,17 @@ public class RepositoryActions {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.info(context, context.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
Toasty.info(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ public class RepositoryActions {
|
||||
if(response.code() == 200) {
|
||||
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
Toasty.success(context, context.getString(R.string.watchRepositorySuccess));
|
||||
Toasty.info(context, context.getString(R.string.watchRepositorySuccess));
|
||||
|
||||
}
|
||||
}
|
||||
@ -190,17 +190,17 @@ public class RepositoryActions {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.info(context, context.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
Toasty.info(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ public class RepositoryActions {
|
||||
if(response.code() == 204) {
|
||||
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
Toasty.success(context, context.getString(R.string.unWatchRepositorySuccess));
|
||||
Toasty.info(context, context.getString(R.string.unWatchRepositorySuccess));
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -253,17 +253,17 @@ public class RepositoryActions {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.info(context, context.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
Toasty.info(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class TeamActions {
|
||||
if(response.code() == 204) {
|
||||
|
||||
tinyDb.putBoolean("teamActionFlag", true);
|
||||
Toasty.success(context, context.getString(R.string.memberRemovedMessage));
|
||||
Toasty.info(context, context.getString(R.string.memberRemovedMessage));
|
||||
((AddNewTeamMemberActivity)context).finish();
|
||||
|
||||
}
|
||||
@ -59,17 +59,17 @@ public class TeamActions {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.info(context, context.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
Toasty.info(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public class TeamActions {
|
||||
if(response.code() == 204) {
|
||||
|
||||
tinyDb.putBoolean("teamActionFlag", true);
|
||||
Toasty.success(context, context.getString(R.string.memberAddedMessage));
|
||||
Toasty.info(context, context.getString(R.string.memberAddedMessage));
|
||||
((AddNewTeamMemberActivity)context).finish();
|
||||
|
||||
}
|
||||
@ -125,17 +125,17 @@ public class TeamActions {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.info(context, context.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
Toasty.info(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
Toasty.info(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
|
@ -144,4 +144,5 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,268 +0,0 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.GiteaVersion;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import java.net.URI;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class AddNewAccountActivity extends BaseActivity {
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private ActivityAddNewAccountBinding viewBinding;
|
||||
|
||||
private enum Protocol {HTTPS, HTTP}
|
||||
private String spinnerSelectedValue;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
|
||||
return R.layout.activity_add_new_account;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDB = new TinyDB(appCtx);
|
||||
|
||||
viewBinding = ActivityAddNewAccountBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
getWindow().getDecorView().setBackground(new ColorDrawable(Color.TRANSPARENT));
|
||||
|
||||
initCloseListener();
|
||||
viewBinding.close.setOnClickListener(onClickListener);
|
||||
|
||||
ArrayAdapter<Protocol> adapterProtocols = new ArrayAdapter<>(ctx, R.layout.list_spinner_items, Protocol.values());
|
||||
viewBinding.protocolSpinner.setAdapter(adapterProtocols);
|
||||
|
||||
viewBinding.protocolSpinner.setOnItemClickListener((parent, view1, position, id) -> spinnerSelectedValue = String.valueOf(parent.getItemAtPosition(position)));
|
||||
|
||||
viewBinding.addNewAccount.setOnClickListener(login -> {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
processLogin();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void processLogin() {
|
||||
|
||||
try {
|
||||
|
||||
String instanceUrlET = String.valueOf(viewBinding.instanceUrl.getText());
|
||||
String loginToken = String.valueOf(viewBinding.loginToken.getText());
|
||||
String protocol = spinnerSelectedValue;
|
||||
|
||||
if(protocol == null) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.protocolEmptyError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(instanceUrlET.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldURL));
|
||||
return;
|
||||
}
|
||||
|
||||
if(loginToken.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.loginTokenError));
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
versionCheck(instanceUrl.toString(), loginToken);
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
Log.e("onFailure-login", e.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.malformedUrl));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void versionCheck(final String instanceUrl, final String loginToken) {
|
||||
|
||||
Call<GiteaVersion> callVersion;
|
||||
|
||||
callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken("token " + loginToken);
|
||||
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull final Call<GiteaVersion> callVersion, @NonNull retrofit2.Response<GiteaVersion> responseVersion) {
|
||||
|
||||
if(responseVersion.code() == 200) {
|
||||
|
||||
GiteaVersion version = responseVersion.body();
|
||||
|
||||
assert version != null;
|
||||
if(!Version.valid(version.getVersion())) {
|
||||
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
|
||||
return;
|
||||
}
|
||||
|
||||
tinyDB.putString("giteaVersion", version.getVersion());
|
||||
Version giteaVersion = new Version(version.getVersion());
|
||||
|
||||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setIcon(R.drawable.ic_warning)
|
||||
.setCancelable(true);
|
||||
|
||||
alertDialogBuilder.setNegativeButton(getString(R.string.cancelButton), (dialog, which) -> {
|
||||
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
alertDialogBuilder.setPositiveButton(getString(R.string.textContinue), (dialog, which) -> {
|
||||
|
||||
dialog.dismiss();
|
||||
login(instanceUrl, loginToken);
|
||||
});
|
||||
|
||||
alertDialogBuilder.create().show();
|
||||
|
||||
}
|
||||
else if(giteaVersion.lessOrEqual(getString(R.string.versionHigh))) {
|
||||
|
||||
login(instanceUrl, loginToken);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.warning(ctx, getResources().getString(R.string.versionUnsupportedNew));
|
||||
login(instanceUrl, loginToken);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if(responseVersion.code() == 403) {
|
||||
|
||||
login(instanceUrl, loginToken);
|
||||
}
|
||||
}
|
||||
|
||||
private void login(String instanceUrl, String loginToken) {
|
||||
|
||||
setupNewAccountWithToken(instanceUrl, loginToken);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-versionCheck", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.errorOnLogin));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupNewAccountWithToken(String instanceUrl, final String loginToken) {
|
||||
|
||||
Call<UserInfo> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserInfo("token " + loginToken);
|
||||
|
||||
call.enqueue(new Callback<UserInfo>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserInfo> call, @NonNull retrofit2.Response<UserInfo> response) {
|
||||
|
||||
UserInfo userDetails = response.body();
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
case 200:
|
||||
|
||||
assert userDetails != null;
|
||||
// insert new account to db if does not exist
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||
int checkAccount = userAccountsApi.getCount(accountName);
|
||||
|
||||
if(checkAccount == 0) {
|
||||
|
||||
userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
||||
Toasty.success(ctx, getResources().getString(R.string.accountAddedMessage));
|
||||
finish();
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.warning(ctx, getResources().getString(R.string.accountAlreadyExistsError));
|
||||
}
|
||||
break;
|
||||
|
||||
case 401:
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
@ -28,10 +28,6 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
@ -68,7 +64,7 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
addNewTeamMember = findViewById(R.id.addNewTeamMember);
|
||||
addNewTeamMember = findViewById(R.id.addNewTeamMeber);
|
||||
mRecyclerView = findViewById(R.id.recyclerViewUserSearch);
|
||||
mProgressBar = findViewById(R.id.progress_bar);
|
||||
noData = findViewById(R.id.noData);
|
||||
@ -125,8 +121,6 @@ public class AddNewTeamMemberActivity extends BaseActivity {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getUserBySearch(Authorization.returnAuthentication(ctx, loginUid, token), searchKeyword, 10);
|
||||
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
call.enqueue(new Callback<UserSearch>() {
|
||||
|
||||
@Override
|
||||
|
@ -207,17 +207,17 @@ public class AddRemoveAssigneesActivity extends BaseActivity {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
|
||||
}
|
||||
}
|
||||
@ -254,7 +254,7 @@ public class AddRemoveAssigneesActivity extends BaseActivity {
|
||||
|
||||
if(response2.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.assigneesUpdated));
|
||||
Toasty.info(ctx, ctx.getString(R.string.assigneesUpdated));
|
||||
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
@ -267,17 +267,17 @@ public class AddRemoveAssigneesActivity extends BaseActivity {
|
||||
}
|
||||
else if(response2.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response2.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
|
@ -224,17 +224,17 @@ public class AddRemoveLabelsActivity extends BaseActivity {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
|
||||
}
|
||||
}
|
||||
@ -265,7 +265,7 @@ public class AddRemoveLabelsActivity extends BaseActivity {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.labelsUpdated));
|
||||
Toasty.info(ctx, ctx.getString(R.string.labelsUpdated));
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -278,17 +278,17 @@ public class AddRemoveLabelsActivity extends BaseActivity {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import org.acra.ACRA;
|
||||
import org.acra.BuildConfig;
|
||||
import org.acra.annotation.AcraCore;
|
||||
import org.acra.annotation.AcraNotification;
|
||||
import org.acra.config.CoreConfigurationBuilder;
|
||||
import org.acra.config.LimiterConfigurationBuilder;
|
||||
@ -17,7 +16,6 @@ import org.mian.gitnex.helpers.FontsOverride;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.notifications.NotificationsMaster;
|
||||
import static org.acra.ReportField.*;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -27,7 +25,6 @@ import static org.acra.ReportField.*;
|
||||
resTitle = R.string.crashTitle,
|
||||
resChannelName = R.string.setCrashReports,
|
||||
resText = R.string.crashMessage)
|
||||
@AcraCore(reportContent = { ANDROID_VERSION, PHONE_MODEL, STACK_TRACE })
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
@ -54,19 +51,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
setTheme(R.style.AppThemeRetro);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
else {
|
||||
setTheme(R.style.AppThemeRetro);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
setTheme(R.style.AppTheme);
|
||||
break;
|
||||
@ -136,6 +120,11 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
tinyDb.putString("draftsCommentsDeletionEnabledInit", "yes");
|
||||
}
|
||||
|
||||
if(!tinyDb.getString("instanceUrlWithProtocol").endsWith("/")) {
|
||||
|
||||
tinyDb.putString("instanceUrlWithProtocol", tinyDb.getString("instanceUrlWithProtocol") + "/");
|
||||
}
|
||||
|
||||
if (tinyDb.getBoolean("crashReportingEnabled")) {
|
||||
|
||||
CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
|
||||
|
@ -52,7 +52,6 @@ public class CommitsActivity extends BaseActivity {
|
||||
private List<Commits> commitsList;
|
||||
private CommitsAdapter adapter;
|
||||
private ApiInterface api;
|
||||
private ProgressBar progressLoadMore;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
@ -85,7 +84,6 @@ public class CommitsActivity extends BaseActivity {
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
noData = findViewById(R.id.noDataCommits);
|
||||
progressLoadMore = findViewById(R.id.progressLoadMore);
|
||||
progressBar = findViewById(R.id.progress_bar);
|
||||
SwipeRefreshLayout swipeRefresh = findViewById(R.id.pullToRefresh);
|
||||
|
||||
@ -178,7 +176,9 @@ public class CommitsActivity extends BaseActivity {
|
||||
|
||||
private void loadMore(String token, String repoOwner, String repoName, final int page, String branchName, int resultLimit) {
|
||||
|
||||
progressLoadMore.setVisibility(View.VISIBLE);
|
||||
//add loading progress view
|
||||
commitsList.add(new Commits("load"));
|
||||
adapter.notifyItemInserted((commitsList.size() - 1));
|
||||
|
||||
Call<List<Commits>> call = api.getRepositoryCommits(token, repoOwner, repoName, page, branchName, resultLimit);
|
||||
|
||||
@ -189,6 +189,9 @@ public class CommitsActivity extends BaseActivity {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
//remove loading view
|
||||
commitsList.remove(commitsList.size() - 1);
|
||||
|
||||
List<Commits> result = response.body();
|
||||
|
||||
assert result != null;
|
||||
@ -205,7 +208,6 @@ public class CommitsActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
progressLoadMore.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -22,8 +24,6 @@ import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.DeleteFile;
|
||||
import org.mian.gitnex.models.EditFile;
|
||||
import org.mian.gitnex.models.NewFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -45,12 +45,8 @@ public class CreateFileActivity extends BaseActivity {
|
||||
private EditText newFileBranchName;
|
||||
private EditText newFileCommitMessage;
|
||||
private Spinner newFileBranchesSpinner;
|
||||
private String filePath;
|
||||
private String fileSha;
|
||||
private int fileAction = 0; // 0 = create, 1 = delete, 2 = edit
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
List<Branches> branchesList = new ArrayList<>();
|
||||
|
||||
@ -64,12 +60,12 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
@ -85,8 +81,6 @@ public class CreateFileActivity extends BaseActivity {
|
||||
newFileCommitMessage = findViewById(R.id.newFileCommitMessage);
|
||||
TextView branchNameId = findViewById(R.id.branchNameId);
|
||||
TextView branchNameHintText = findViewById(R.id.branchNameHintText);
|
||||
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
|
||||
TextView fileNameHint = findViewById(R.id.fileNameHint);
|
||||
|
||||
newFileName.requestFocus();
|
||||
assert imm != null;
|
||||
@ -97,50 +91,11 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
newFileCreate = findViewById(R.id.newFileCreate);
|
||||
|
||||
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", 1) == 1) {
|
||||
|
||||
fileNameHint.setVisibility(View.GONE);
|
||||
fileAction = getIntent().getIntExtra("fileAction", 1);
|
||||
|
||||
filePath = getIntent().getStringExtra("filePath");
|
||||
String fileContents = getIntent().getStringExtra("fileContents");
|
||||
fileSha = getIntent().getStringExtra("fileSha");
|
||||
|
||||
toolbarTitle.setText(getString(R.string.deleteFileText, filePath));
|
||||
|
||||
newFileCreate.setText(R.string.deleteFile);
|
||||
newFileName.setText(filePath);
|
||||
newFileName.setEnabled(false);
|
||||
newFileName.setFocusable(false);
|
||||
|
||||
newFileContent.setText(fileContents);
|
||||
newFileContent.setEnabled(false);
|
||||
newFileContent.setFocusable(false);
|
||||
}
|
||||
|
||||
if(getIntent().getStringExtra("filePath") != null && getIntent().getIntExtra("fileAction", 2) == 2) {
|
||||
|
||||
fileNameHint.setVisibility(View.GONE);
|
||||
fileAction = getIntent().getIntExtra("fileAction", 2);
|
||||
|
||||
filePath = getIntent().getStringExtra("filePath");
|
||||
String fileContents = getIntent().getStringExtra("fileContents");
|
||||
fileSha = getIntent().getStringExtra("fileSha");
|
||||
|
||||
toolbarTitle.setText(getString(R.string.editFileText, filePath));
|
||||
|
||||
newFileCreate.setText(R.string.editFile);
|
||||
newFileName.setText(filePath);
|
||||
newFileName.setEnabled(false);
|
||||
newFileName.setFocusable(false);
|
||||
|
||||
newFileContent.setText(fileContents);
|
||||
}
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
newFileBranchesSpinner = findViewById(R.id.newFileBranchesSpinner);
|
||||
newFileBranchesSpinner.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
|
||||
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
||||
|
||||
newFileBranchesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
||||
@ -174,10 +129,15 @@ public class CreateFileActivity extends BaseActivity {
|
||||
if(!connToInternet) {
|
||||
|
||||
newFileCreate.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
newFileCreate.setBackground(shape);
|
||||
|
||||
} else {
|
||||
|
||||
newFileCreate.setOnClickListener(createFileListener);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -206,14 +166,14 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(newFileName_.equals("") || newFileContent_.equals("") || newFileCommitMessage_.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.newFileRequiredFields));
|
||||
Toasty.info(ctx, getString(R.string.newFileRequiredFields));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -221,13 +181,13 @@ public class CreateFileActivity extends BaseActivity {
|
||||
if(currentBranch.toString().equals("No branch")) {
|
||||
|
||||
if(newFileBranchName_.equals("")) {
|
||||
Toasty.error(ctx, getString(R.string.newFileRequiredFieldNewBranchName));
|
||||
Toasty.info(ctx, getString(R.string.newFileRequiredFieldNewBranchName));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if(!appUtil.checkStringsWithDash(newFileBranchName_)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.newFileInvalidBranchName));
|
||||
Toasty.info(ctx, getString(R.string.newFileInvalidBranchName));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -237,28 +197,13 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
if(appUtil.charactersLength(newFileCommitMessage_) > 255) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.newFileCommitMessageError));
|
||||
Toasty.info(ctx, getString(R.string.newFileCommitMessageError));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
if(fileAction == 1) {
|
||||
|
||||
deleteFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, filePath,
|
||||
newFileBranchName_, newFileCommitMessage_, currentBranch.toString(), fileSha);
|
||||
}
|
||||
else if(fileAction == 2) {
|
||||
|
||||
editFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, filePath,
|
||||
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, currentBranch.toString(), fileSha);
|
||||
}
|
||||
else {
|
||||
|
||||
createNewFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newFileName_,
|
||||
appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, currentBranch.toString());
|
||||
}
|
||||
createNewFile(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, newFileName_, appUtil.encodeBase64(newFileContent_), newFileBranchName_, newFileCommitMessage_, currentBranch.toString());
|
||||
|
||||
}
|
||||
|
||||
@ -287,7 +232,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
if(response.code() == 201) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.success(ctx, getString(R.string.newFileSuccessMessage));
|
||||
Toasty.info(ctx, getString(R.string.newFileSuccessMessage));
|
||||
finish();
|
||||
|
||||
}
|
||||
@ -304,11 +249,11 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
if(response.code() == 404) {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.orgCreatedError));
|
||||
Toasty.info(ctx, getString(R.string.orgCreatedError));
|
||||
}
|
||||
|
||||
}
|
||||
@ -317,7 +262,6 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
@ -325,149 +269,6 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void deleteFile(final String instanceUrl, final String token, String repoOwner, String repoName, String fileName, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
||||
|
||||
String branchName;
|
||||
DeleteFile deleteFileJsonStr;
|
||||
if(currentBranch.equals("No branch")) {
|
||||
|
||||
branchName = fileBranchName;
|
||||
deleteFileJsonStr = new DeleteFile("", fileCommitMessage, fileBranchName, fileSha);
|
||||
}
|
||||
else {
|
||||
|
||||
branchName = currentBranch;
|
||||
deleteFileJsonStr = new DeleteFile(currentBranch, fileCommitMessage, "", fileSha);
|
||||
}
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.deleteFile(token, repoOwner, repoName, fileName, deleteFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.deleteFileMessage, branchName));
|
||||
getIntent().removeExtra("filePath");
|
||||
getIntent().removeExtra("fileSha");
|
||||
getIntent().removeExtra("fileContents");
|
||||
finish();
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if(response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void editFile(final String instanceUrl, final String token, String repoOwner, String repoName, String fileName, String fileContent, String fileBranchName, String fileCommitMessage, String currentBranch, String fileSha) {
|
||||
|
||||
String branchName;
|
||||
EditFile editFileJsonStr;
|
||||
if(currentBranch.equals("No branch")) {
|
||||
|
||||
branchName = fileBranchName;
|
||||
editFileJsonStr = new EditFile("", fileCommitMessage, fileBranchName, fileSha, fileContent);
|
||||
}
|
||||
else {
|
||||
|
||||
branchName = currentBranch;
|
||||
editFileJsonStr = new EditFile(currentBranch, fileCommitMessage, "", fileSha, fileContent);
|
||||
}
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.editFile(token, repoOwner, repoName, fileName, editFileJsonStr);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.editFileMessage, branchName));
|
||||
getIntent().removeExtra("filePath");
|
||||
getIntent().removeExtra("fileSha");
|
||||
getIntent().removeExtra("fileContents");
|
||||
tinyDb.putBoolean("fileModified", true);
|
||||
finish();
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
enableProcessButton();
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if(response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void getBranches(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
@ -525,11 +326,21 @@ public class CreateFileActivity extends BaseActivity {
|
||||
private void disableProcessButton() {
|
||||
|
||||
newFileCreate.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
newFileCreate.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
newFileCreate.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
newFileCreate.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -94,9 +96,8 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
final String repoName = parts[1];
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
// require gitea 1.12 or higher
|
||||
// if gitea is 1.12 or higher use the new limit
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
|
||||
@ -126,6 +127,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
newIssueDueDate.setOnClickListener(this);
|
||||
|
||||
newIssueMilestoneSpinner = findViewById(R.id.newIssueMilestoneSpinner);
|
||||
newIssueMilestoneSpinner.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
|
||||
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
|
||||
|
||||
getLabels(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
||||
@ -136,10 +138,15 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
if(!connToInternet) {
|
||||
|
||||
createNewIssueButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createNewIssueButton.setBackground(shape);
|
||||
|
||||
} else {
|
||||
|
||||
createNewIssueButton.setOnClickListener(this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -168,21 +175,21 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (newIssueTitleForm.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
||||
Toasty.info(ctx, getString(R.string.issueTitleEmpty));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/*if (newIssueDescriptionForm.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.issueDescriptionEmpty));
|
||||
Toasty.info(ctx, getString(R.string.issueDescriptionEmpty));
|
||||
return;
|
||||
|
||||
}*/
|
||||
@ -200,9 +207,9 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
}
|
||||
|
||||
int[] integers;
|
||||
if (!newIssueLabelsIdHolderForm.equals("") && !newIssueLabelsIdHolderForm.equals("[]")) {
|
||||
if (!newIssueLabelsIdHolderForm.equals("")) {
|
||||
|
||||
String[] items = newIssueLabelsIdHolderForm.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\\s", "").split(",");
|
||||
String[] items = newIssueLabelsIdHolderForm.replaceAll("\\[", "").replaceAll("\\]", "").replaceAll("\\s", "").split(",");
|
||||
integers = new int[items.length];
|
||||
for (int i = 0; i < integers.length; i++) {
|
||||
integers[i] = Integer.parseInt(items[i]);
|
||||
@ -292,7 +299,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
|
||||
Toasty.success(ctx, getString(R.string.issueCreated));
|
||||
Toasty.info(ctx, getString(R.string.issueCreated));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
|
||||
@ -310,7 +317,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.issueCreatedError));
|
||||
Toasty.info(ctx, getString(R.string.issueCreatedError));
|
||||
enableProcessButton();
|
||||
//Log.i("isSuccessful2", String.valueOf(response2.body()));
|
||||
|
||||
@ -328,8 +335,12 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void getMilestones(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid, int resultLimit) {
|
||||
@ -530,7 +541,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
multiSelectDialog.show(getSupportFragmentManager(), "multiSelectDialog");
|
||||
}
|
||||
else {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.noAssigneesFound));
|
||||
Toasty.info(ctx, getResources().getString(R.string.noAssigneesFound));
|
||||
}
|
||||
}
|
||||
else if (v == newIssueLabels) {
|
||||
@ -538,7 +549,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
multiSelectDialogLabels.show(getSupportFragmentManager(), "multiSelectDialogLabels");
|
||||
}
|
||||
else {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.noLabelsFound));
|
||||
Toasty.info(ctx, getResources().getString(R.string.noLabelsFound));
|
||||
}
|
||||
}
|
||||
else if (v == newIssueDueDate) {
|
||||
@ -570,10 +581,20 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
private void disableProcessButton() {
|
||||
|
||||
createNewIssueButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createNewIssueButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
createNewIssueButton.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
createNewIssueButton.setBackground(shape);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -117,23 +118,38 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
createLabelButton.setText(getResources().getString(R.string.newUpdateButtonCopy));
|
||||
|
||||
createLabelButton.setOnClickListener(updateLabelListener);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
createLabelButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createLabelButton.setBackground(shape);
|
||||
|
||||
} else {
|
||||
|
||||
createLabelButton.setOnClickListener(createLabelListener);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private View.OnClickListener createLabelListener = v -> processCreateLabel();
|
||||
private View.OnClickListener createLabelListener = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
processCreateLabel();
|
||||
}
|
||||
};
|
||||
|
||||
private View.OnClickListener updateLabelListener = v -> processUpdateLabel();
|
||||
private View.OnClickListener updateLabelListener = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
processUpdateLabel();
|
||||
}
|
||||
};
|
||||
|
||||
private void processUpdateLabel() {
|
||||
|
||||
@ -160,28 +176,27 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(updateLabelName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
||||
Toasty.info(ctx, getString(R.string.labelEmptyError));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(!appUtil.checkStrings(updateLabelName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
||||
Toasty.info(ctx, getString(R.string.labelNameError));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
disableProcessButton();
|
||||
patchLabel(instanceUrl, instanceToken, repoOwner, repoName, updateLabelName, updateLabelColor, Integer.parseInt(
|
||||
Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
||||
patchLabel(instanceUrl, instanceToken, repoOwner, repoName, updateLabelName, updateLabelColor, Integer.valueOf(getIntent().getStringExtra("labelId")), loginUid);
|
||||
|
||||
}
|
||||
|
||||
@ -209,21 +224,21 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(newLabelName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelEmptyError));
|
||||
Toasty.info(ctx, getString(R.string.labelEmptyError));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(!appUtil.checkStrings(newLabelName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelNameError));
|
||||
Toasty.info(ctx, getString(R.string.labelNameError));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -252,7 +267,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelCreated));
|
||||
Toasty.info(ctx, getString(R.string.labelCreated));
|
||||
tinyDb.putString("labelColor", "");
|
||||
tinyDb.putBoolean("labelsRefresh", true);
|
||||
finish();
|
||||
@ -271,7 +286,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
enableProcessButton();
|
||||
tinyDb.putString("labelColor", "");
|
||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||
Toasty.info(ctx, getString(R.string.labelGeneralError));
|
||||
|
||||
}
|
||||
|
||||
@ -279,7 +294,6 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDb.putString("labelColor", "");
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
@ -308,7 +322,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelUpdated));
|
||||
Toasty.info(ctx, getString(R.string.labelUpdated));
|
||||
tinyDb.putString("labelColor", "");
|
||||
tinyDb.putBoolean("labelsRefresh", true);
|
||||
tinyDb.putString("labelColorDefault", "");
|
||||
@ -334,7 +348,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
enableProcessButton();
|
||||
tinyDb.putString("labelColor", "");
|
||||
tinyDb.putString("labelColorDefault", "");
|
||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||
Toasty.info(ctx, getString(R.string.labelGeneralError));
|
||||
|
||||
}
|
||||
|
||||
@ -342,7 +356,6 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<CreateLabel> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDb.putString("labelColor", "");
|
||||
tinyDb.putString("labelColorDefault", "");
|
||||
Log.e("onFailure", t.toString());
|
||||
@ -382,7 +395,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.labelDeleteText));
|
||||
Toasty.info(ctx, getString(R.string.labelDeleteText));
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName, ctx);
|
||||
getIntent().removeExtra("labelAction");
|
||||
getIntent().removeExtra("labelId");
|
||||
@ -399,7 +412,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelDeleteErrorText));
|
||||
Toasty.info(ctx, getString(R.string.labelDeleteErrorText));
|
||||
|
||||
}
|
||||
|
||||
@ -416,11 +429,21 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
private void disableProcessButton() {
|
||||
|
||||
createLabelButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createLabelButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
createLabelButton.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
createLabelButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -70,15 +71,24 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
if(!connToInternet) {
|
||||
|
||||
createNewMilestoneButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createNewMilestoneButton.setBackground(shape);
|
||||
|
||||
} else {
|
||||
|
||||
createNewMilestoneButton.setOnClickListener(createMilestoneListener);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private View.OnClickListener createMilestoneListener = v -> processNewMilestone();
|
||||
private View.OnClickListener createMilestoneListener = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
processNewMilestone();
|
||||
}
|
||||
};
|
||||
|
||||
private void processNewMilestone() {
|
||||
|
||||
@ -100,14 +110,14 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(newMilestoneTitle.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.milestoneNameErrorEmpty));
|
||||
Toasty.info(ctx, getString(R.string.milestoneNameErrorEmpty));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -115,7 +125,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
if(!newMilestoneDescription.equals("")) {
|
||||
if (appUtil.charactersLength(newMilestoneDescription) > 255) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.milestoneDescError));
|
||||
Toasty.info(ctx, getString(R.string.milestoneDescError));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -123,13 +133,10 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
String finalMilestoneDueDate = null;
|
||||
if(!newMilestoneDueDate.isEmpty()) {
|
||||
|
||||
finalMilestoneDueDate = (AppUtil.customDateCombine(AppUtil.customDateFormat(newMilestoneDueDate)));
|
||||
}
|
||||
else if (new Version(tinyDb.getString("giteaVersion")).less("1.10.0")) {
|
||||
|
||||
} else if (new Version(tinyDb.getString("giteaVersion")).less("1.10.0")) {
|
||||
// if Gitea version is less than 1.10.0 DueDate is required
|
||||
Toasty.warning(ctx, getString(R.string.milestoneDateEmpty));
|
||||
Toasty.info(ctx, getString(R.string.milestoneDateEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -159,7 +166,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
tinyDb.putBoolean("milestoneCreated", true);
|
||||
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
||||
Toasty.info(ctx, getString(R.string.milestoneCreated));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
|
||||
@ -177,7 +184,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.milestoneCreatedError));
|
||||
Toasty.info(ctx, getString(R.string.milestoneCreatedError));
|
||||
|
||||
}
|
||||
|
||||
@ -219,18 +226,32 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
||||
createNewMilestoneButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createNewMilestoneButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
createNewMilestoneButton.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
createNewMilestoneButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
@ -68,10 +69,11 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
if(!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
createUserButton.setOnClickListener(createNewUserListener);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -92,35 +94,35 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(newFullName.equals("") || newUserName.equals("") | newUserEmail.equals("") || newUserPassword.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.emptyFields));
|
||||
Toasty.info(ctx, getString(R.string.emptyFields));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(!appUtil.checkStrings(newFullName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.userInvalidFullName));
|
||||
Toasty.info(ctx, getString(R.string.userInvalidFullName));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(!appUtil.checkStringsWithAlphaNumeric(newUserName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.userInvalidUserName));
|
||||
Toasty.info(ctx, getString(R.string.userInvalidUserName));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.userInvalidEmail));
|
||||
Toasty.info(ctx, getString(R.string.userInvalidEmail));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -148,7 +150,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.userCreatedText));
|
||||
Toasty.info(ctx, getString(R.string.userCreatedText));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
|
||||
@ -165,25 +167,25 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
else if(response.code() == 403) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else if(response.code() == 422) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.userExistsError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.userExistsError));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -191,7 +193,6 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
@ -199,21 +200,39 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private View.OnClickListener createNewUserListener = v -> processCreateNewUser();
|
||||
private View.OnClickListener createNewUserListener = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
processCreateNewUser();
|
||||
}
|
||||
};
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
||||
createUserButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createUserButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
createUserButton.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
createUserButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -66,10 +67,15 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
if(!connToInternet) {
|
||||
|
||||
createOrganizationButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createOrganizationButton.setBackground(shape);
|
||||
|
||||
} else {
|
||||
|
||||
createOrganizationButton.setOnClickListener(createOrgListener);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -103,7 +109,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -111,7 +117,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
if(!newOrgDesc.equals("")) {
|
||||
if (appUtil.charactersLength(newOrgDesc) > 255) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.orgDescError));
|
||||
Toasty.info(ctx, getString(R.string.orgDescError));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -119,12 +125,12 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
|
||||
if(newOrgName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.orgNameErrorEmpty));
|
||||
Toasty.info(ctx, getString(R.string.orgNameErrorEmpty));
|
||||
|
||||
}
|
||||
else if(!appUtil.checkStrings(newOrgName)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.orgNameErrorInvalid));
|
||||
Toasty.info(ctx, getString(R.string.orgNameErrorInvalid));
|
||||
|
||||
}
|
||||
else {
|
||||
@ -155,7 +161,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
tinyDb.putBoolean("orgCreated", true);
|
||||
enableProcessButton();
|
||||
Toasty.success(ctx, getString(R.string.orgCreated));
|
||||
Toasty.info(ctx, getString(R.string.orgCreated));
|
||||
finish();
|
||||
|
||||
}
|
||||
@ -171,24 +177,24 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
else if(response.code() == 409) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
||||
Toasty.info(ctx, getString(R.string.orgExistsError));
|
||||
|
||||
}
|
||||
else if(response.code() == 422) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.orgExistsError));
|
||||
Toasty.info(ctx, getString(R.string.orgExistsError));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if(response.code() == 404) {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.orgCreatedError));
|
||||
Toasty.info(ctx, getString(R.string.orgCreatedError));
|
||||
}
|
||||
|
||||
}
|
||||
@ -207,11 +213,21 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
private void disableProcessButton() {
|
||||
|
||||
createOrganizationButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createOrganizationButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
createOrganizationButton.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
createOrganizationButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,431 +0,0 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.LabelsListAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreatePrBinding;
|
||||
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.CreatePullRequest;
|
||||
import org.mian.gitnex.models.Labels;
|
||||
import org.mian.gitnex.models.Milestones;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
private ActivityCreatePrBinding viewBinding;
|
||||
private CustomLabelsSelectionDialogBinding labelsBinding;
|
||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||
private Dialog dialogLabels;
|
||||
private String labelsSetter;
|
||||
private ArrayList<Integer> labelsIds = new ArrayList<>();
|
||||
private ArrayList<String> assignees = new ArrayList<>();
|
||||
private int milestoneId;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
|
||||
List<Milestones> milestonesList = new ArrayList<>();
|
||||
List<Branches> branchesList = new ArrayList<>();
|
||||
List<Labels> labelsList = new ArrayList<>();
|
||||
|
||||
public CreatePullRequestActivity() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_create_pr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
viewBinding = ActivityCreatePrBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repoOwner = parts[0];
|
||||
repoName = parts[1];
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
// require gitea 1.12 or higher
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
|
||||
labelsAdapter = new LabelsListAdapter(labelsList, CreatePullRequestActivity.this);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
viewBinding.prDueDate.setOnClickListener(dueDate ->
|
||||
setDueDate()
|
||||
);
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
getMilestones(instanceUrl, instanceToken, repoOwner, repoName, loginUid, resultLimit);
|
||||
getBranches(instanceUrl, instanceToken, repoOwner, repoName, loginUid);
|
||||
|
||||
viewBinding.prLabels.setOnClickListener(prLabels ->
|
||||
showLabels()
|
||||
);
|
||||
|
||||
viewBinding.createPr.setOnClickListener(createPr ->
|
||||
processPullRequest()
|
||||
);
|
||||
}
|
||||
|
||||
private void processPullRequest() {
|
||||
|
||||
String prTitle = String.valueOf(viewBinding.prTitle.getText());
|
||||
String prDescription = String.valueOf(viewBinding.prBody.getText());
|
||||
String mergeInto = viewBinding.mergeIntoBranchSpinner.getText().toString();
|
||||
String pullFrom = viewBinding.pullFromBranchSpinner.getText().toString();
|
||||
String dueDate = String.valueOf(viewBinding.prDueDate.getText());
|
||||
|
||||
assignees.add("");
|
||||
|
||||
if (labelsIds.size() == 0) {
|
||||
labelsIds.add(0);
|
||||
}
|
||||
|
||||
if (dueDate.matches("")) {
|
||||
dueDate = null;
|
||||
}
|
||||
else {
|
||||
dueDate = AppUtil.customDateCombine(AppUtil.customDateFormat(dueDate));
|
||||
}
|
||||
|
||||
if(prTitle.matches("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.titleError));
|
||||
}
|
||||
else if(mergeInto.matches("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.mergeIntoError));
|
||||
}
|
||||
else if(pullFrom.matches("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.pullFromError));
|
||||
}
|
||||
else if(pullFrom.equals(mergeInto)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.sameBranchesError));
|
||||
}
|
||||
else {
|
||||
createPullRequest(prTitle, prDescription, mergeInto, pullFrom, milestoneId, dueDate, assignees);
|
||||
}
|
||||
//Log.e("processPullRequest", String.valueOf(milestoneId));
|
||||
}
|
||||
|
||||
private void createPullRequest(String prTitle, String prDescription, String mergeInto, String pullFrom, int milestoneId, String dueDate, ArrayList<String> assignees) {
|
||||
|
||||
CreatePullRequest createPullRequest = new CreatePullRequest(prTitle, prDescription, loginUid, mergeInto, pullFrom, milestoneId, dueDate, assignees, labelsIds);
|
||||
|
||||
Call<ResponseBody> transferCall = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.createPullRequest(instanceToken, repoOwner, repoName, createPullRequest);
|
||||
|
||||
transferCall.enqueue(new Callback<ResponseBody>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull retrofit2.Response<ResponseBody> response) {
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
if (response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.prCreateSuccess));
|
||||
finish();
|
||||
}
|
||||
else if (response.code() == 409 && response.message().equals("Conflict")) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.prAlreadyExists));
|
||||
}
|
||||
else if (response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void labelsStringData(ArrayList<String> data) {
|
||||
|
||||
labelsSetter = String.valueOf(data);
|
||||
viewBinding.prLabels.setText(labelsSetter.replace("]", "").replace("[", ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void labelsIdsData(ArrayList<Integer> data) {
|
||||
|
||||
labelsIds = data;
|
||||
}
|
||||
|
||||
private void showLabels() {
|
||||
|
||||
dialogLabels = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||
|
||||
if (dialogLabels.getWindow() != null) {
|
||||
dialogLabels.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
labelsBinding = CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
|
||||
View view = labelsBinding.getRoot();
|
||||
dialogLabels.setContentView(view);
|
||||
|
||||
labelsBinding.cancel.setOnClickListener(editProperties ->
|
||||
dialogLabels.dismiss()
|
||||
);
|
||||
|
||||
Call<List<Labels>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getlabels(instanceToken, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Labels>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> response) {
|
||||
|
||||
labelsList.clear();
|
||||
List<Labels> labelsList_ = response.body();
|
||||
|
||||
labelsBinding.progressBar.setVisibility(View.GONE);
|
||||
labelsBinding.dialogFrame.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 200) {
|
||||
|
||||
assert labelsList_ != null;
|
||||
if(labelsList_.size() > 0) {
|
||||
for (int i = 0; i < labelsList_.size(); i++) {
|
||||
|
||||
labelsList.add(new Labels(labelsList_.get(i).getId(), labelsList_.get(i).getName()));
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
dialogLabels.dismiss();
|
||||
Toasty.warning(ctx, getString(R.string.noLabelsFound));
|
||||
}
|
||||
|
||||
labelsBinding.labelsRecyclerView.setAdapter(labelsAdapter);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
dialogLabels.show();
|
||||
|
||||
}
|
||||
|
||||
private void getBranches(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getBranches(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull retrofit2.Response<List<Branches>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
List<Branches> branchesList_ = response.body();
|
||||
|
||||
assert branchesList_ != null;
|
||||
if(branchesList_.size() > 0) {
|
||||
for (int i = 0; i < branchesList_.size(); i++) {
|
||||
|
||||
Branches data = new Branches(
|
||||
branchesList_.get(i).getName()
|
||||
);
|
||||
branchesList.add(data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<Branches> adapter = new ArrayAdapter<>(CreatePullRequestActivity.this,
|
||||
R.layout.list_spinner_items, branchesList);
|
||||
|
||||
viewBinding.mergeIntoBranchSpinner.setAdapter(adapter);
|
||||
viewBinding.pullFromBranchSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void getMilestones(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid, int resultLimit) {
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getMilestones(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, 1, resultLimit, msState);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull retrofit2.Response<List<Milestones>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
List<Milestones> milestonesList_ = response.body();
|
||||
|
||||
milestonesList.add(new Milestones(0,getString(R.string.issueCreatedNoMilestone)));
|
||||
assert milestonesList_ != null;
|
||||
if(milestonesList_.size() > 0) {
|
||||
for (int i = 0; i < milestonesList_.size(); i++) {
|
||||
|
||||
//Don't translate "open" is a enum
|
||||
if(milestonesList_.get(i).getState().equals("open")) {
|
||||
Milestones data = new Milestones(
|
||||
milestonesList_.get(i).getId(),
|
||||
milestonesList_.get(i).getTitle()
|
||||
);
|
||||
milestonesList.add(data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<Milestones> adapter = new ArrayAdapter<>(CreatePullRequestActivity.this,
|
||||
R.layout.list_spinner_items, milestonesList);
|
||||
|
||||
viewBinding.milestonesSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
|
||||
viewBinding.milestonesSpinner.setOnItemClickListener ((parent, view, position, id) ->
|
||||
|
||||
milestoneId = milestonesList.get(position).getId()
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setDueDate() {
|
||||
|
||||
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) -> viewBinding.prDueDate.setText(getString(R.string.setDueDate, year, (monthOfYear + 1), dayOfMonth)), mYear, mMonth, mDay);
|
||||
datePickerDialog.show();
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
||||
viewBinding.createPr.setEnabled(false);
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
viewBinding.createPr.setEnabled(true);
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -86,6 +88,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
releaseBranch = findViewById(R.id.releaseBranch);
|
||||
releaseBranch.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
|
||||
getBranches(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName);
|
||||
releaseBranch.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
@ -105,15 +108,20 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
if(!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
createNewRelease.setOnClickListener(createReleaseListener);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private View.OnClickListener createReleaseListener = v -> processNewRelease();
|
||||
private View.OnClickListener createReleaseListener = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
processNewRelease();
|
||||
}
|
||||
};
|
||||
|
||||
private void processNewRelease() {
|
||||
|
||||
@ -137,21 +145,21 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(newReleaseTagName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.tagNameErrorEmpty));
|
||||
Toasty.info(ctx, getString(R.string.tagNameErrorEmpty));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(newReleaseTitle.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.titleErrorEmpty));
|
||||
Toasty.info(ctx, getString(R.string.titleErrorEmpty));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -181,7 +189,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
tinyDb.putBoolean("updateReleases", true);
|
||||
Toasty.success(ctx, getString(R.string.releaseCreatedText));
|
||||
Toasty.info(ctx, getString(R.string.releaseCreatedText));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
|
||||
@ -198,19 +206,19 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
else if(response.code() == 403) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -294,11 +302,21 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
private void disableProcessButton() {
|
||||
|
||||
createNewRelease.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createNewRelease.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
createNewRelease.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
createNewRelease.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -85,8 +87,8 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
spinner = findViewById(R.id.ownerSpinner);
|
||||
spinner.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
|
||||
getOrganizations(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), userLogin);
|
||||
|
||||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
@ -105,10 +107,12 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
if(!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
createRepo.setOnClickListener(createRepoListener);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,38 +138,45 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(!newRepoDesc.equals("")) {
|
||||
if (appUtil.charactersLength(newRepoDesc) > 255) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoDescError));
|
||||
Toasty.info(ctx, getString(R.string.repoDescError));
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(newRepoName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.repoNameErrorEmpty));
|
||||
Toasty.info(ctx, getString(R.string.repoNameErrorEmpty));
|
||||
|
||||
}
|
||||
else if(!appUtil.checkStrings(newRepoName)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoNameErrorInvalid));
|
||||
Toasty.info(ctx, getString(R.string.repoNameErrorInvalid));
|
||||
|
||||
}
|
||||
else if (reservedRepoNames.contains(newRepoName)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoNameErrorReservedName));
|
||||
Toasty.info(ctx, getString(R.string.repoNameErrorReservedName));
|
||||
|
||||
}
|
||||
else if (reservedRepoPatterns.matcher(newRepoName).find()) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.repoNameErrorReservedPatterns));
|
||||
Toasty.info(ctx, getString(R.string.repoNameErrorReservedPatterns));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
createNewRepository(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), loginUid, newRepoName, newRepoDesc, repoOwner, newRepoAccess);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,6 +191,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.createNewUserRepository(token, createRepository);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
@ -187,6 +199,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.createNewUserOrgRepository(token, repoOwner, createRepository);
|
||||
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<OrganizationRepository>() {
|
||||
@ -198,7 +211,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
tinyDb.putBoolean("repoCreated", true);
|
||||
Toasty.success(ctx, getString(R.string.repoCreated));
|
||||
Toasty.info(ctx, getString(R.string.repoCreated));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
}
|
||||
@ -209,23 +222,25 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
|
||||
}
|
||||
else if(response.code() == 409) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.repoExistsError));
|
||||
Toasty.info(ctx, getString(R.string.repoExistsError));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.repoCreatedError));
|
||||
Toasty.info(ctx, getString(R.string.repoCreatedError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<OrganizationRepository> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
@ -256,16 +271,13 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
organizationsList.add(new OrgOwner(userLogin));
|
||||
assert organizationsList_ != null;
|
||||
if(organizationsList_.size() > 0) {
|
||||
|
||||
for (int i = 0; i < organizationsList_.size(); i++) {
|
||||
|
||||
if(!tinyDb.getString("organizationId").isEmpty()) {
|
||||
|
||||
if (Integer.parseInt(tinyDb.getString("organizationId")) == organizationsList_.get(i).getId()) {
|
||||
organizationId = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
OrgOwner data = new OrgOwner(
|
||||
organizationsList_.get(i).getUsername()
|
||||
);
|
||||
@ -281,7 +293,6 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
spinner.setAdapter(adapter);
|
||||
|
||||
if (tinyDb.getBoolean("organizationAction") & organizationId != 0) {
|
||||
|
||||
spinner.setSelection(organizationId);
|
||||
tinyDb.putBoolean("organizationAction", false);
|
||||
}
|
||||
@ -297,13 +308,13 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<OrgOwner>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
@ -311,18 +322,32 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
||||
createRepo.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
createRepo.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
createRepo.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
createRepo.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@ -97,120 +98,134 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
teamPermission.setOnClickListener(view -> {
|
||||
teamPermission.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
AlertDialog.Builder pBuilder = new AlertDialog.Builder(ctx);
|
||||
AlertDialog.Builder pBuilder = new AlertDialog.Builder(ctx);
|
||||
|
||||
pBuilder.setTitle(R.string.newTeamPermission);
|
||||
if(permissionSelectedChoice != -1) {
|
||||
pBuilder.setCancelable(true);
|
||||
}
|
||||
else {
|
||||
pBuilder.setCancelable(false);
|
||||
}
|
||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
|
||||
permissionSelectedChoice = i;
|
||||
teamPermission.setText(permissionList[i]);
|
||||
|
||||
if(permissionList[i].equals("Read")) {
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionRead);
|
||||
}
|
||||
else if(permissionList[i].equals("Write")) {
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionWrite);
|
||||
}
|
||||
else if(permissionList[i].equals("Admin")) {
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionAdmin);
|
||||
}
|
||||
else {
|
||||
teamPermissionDetail.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
dialogInterface.dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog pDialog = pBuilder.create();
|
||||
pDialog.show();
|
||||
|
||||
pBuilder.setTitle(R.string.newTeamPermission);
|
||||
if(permissionSelectedChoice != -1) {
|
||||
pBuilder.setCancelable(true);
|
||||
}
|
||||
else {
|
||||
pBuilder.setCancelable(false);
|
||||
}
|
||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
||||
|
||||
permissionSelectedChoice = i;
|
||||
teamPermission.setText(permissionList[i]);
|
||||
|
||||
switch(permissionList[i]) {
|
||||
case "Read":
|
||||
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionRead);
|
||||
break;
|
||||
case "Write":
|
||||
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionWrite);
|
||||
break;
|
||||
case "Admin":
|
||||
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionAdmin);
|
||||
break;
|
||||
default:
|
||||
|
||||
teamPermissionDetail.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
|
||||
dialogInterface.dismiss();
|
||||
|
||||
});
|
||||
|
||||
AlertDialog pDialog = pBuilder.create();
|
||||
pDialog.show();
|
||||
|
||||
});
|
||||
|
||||
|
||||
teamAccessControls.setOnClickListener(v -> {
|
||||
teamAccessControls.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
teamAccessControls.setText("");
|
||||
teamAccessControlsArray.setText("");
|
||||
pushAccessList = Arrays.asList(accessControlsList);
|
||||
teamAccessControls.setText("");
|
||||
teamAccessControlsArray.setText("");
|
||||
pushAccessList = Arrays.asList(accessControlsList);
|
||||
|
||||
AlertDialog.Builder aDialogBuilder = new AlertDialog.Builder(ctx);
|
||||
AlertDialog.Builder aDialogBuilder = new AlertDialog.Builder(ctx);
|
||||
|
||||
aDialogBuilder.setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, (dialog, which, isChecked) -> {
|
||||
aDialogBuilder.setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, new DialogInterface.OnMultiChoiceClickListener() {
|
||||
|
||||
})
|
||||
.setCancelable(false)
|
||||
.setTitle(R.string.newTeamAccessControls)
|
||||
.setPositiveButton(R.string.okButton, (dialog, which) -> {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||
|
||||
int selectedVal = 0;
|
||||
while(selectedVal < selectedAccessControlsTrueFalse.length)
|
||||
{
|
||||
boolean value = selectedAccessControlsTrueFalse[selectedVal];
|
||||
|
||||
String repoCode = "";
|
||||
if(selectedVal == 0) {
|
||||
repoCode = "repo.code";
|
||||
}
|
||||
if(selectedVal == 1) {
|
||||
repoCode = "repo.issues";
|
||||
}
|
||||
if(selectedVal == 2) {
|
||||
repoCode = "repo.pulls";
|
||||
}
|
||||
if(selectedVal == 3) {
|
||||
repoCode = "repo.releases";
|
||||
}
|
||||
if(selectedVal == 4) {
|
||||
repoCode = "repo.wiki";
|
||||
}
|
||||
if(selectedVal == 5) {
|
||||
repoCode = "repo.ext_wiki";
|
||||
}
|
||||
if(selectedVal == 6) {
|
||||
repoCode = "repo.ext_issues";
|
||||
}
|
||||
|
||||
if(value){
|
||||
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
||||
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
||||
})
|
||||
.setCancelable(false)
|
||||
.setTitle(R.string.newTeamAccessControls)
|
||||
.setPositiveButton(R.string.okButton, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
int selectedVal = 0;
|
||||
while(selectedVal < selectedAccessControlsTrueFalse.length)
|
||||
{
|
||||
boolean value = selectedAccessControlsTrueFalse[selectedVal];
|
||||
|
||||
String repoCode = "";
|
||||
if(selectedVal == 0) {
|
||||
repoCode = "repo.code";
|
||||
}
|
||||
if(selectedVal == 1) {
|
||||
repoCode = "repo.issues";
|
||||
}
|
||||
if(selectedVal == 2) {
|
||||
repoCode = "repo.pulls";
|
||||
}
|
||||
if(selectedVal == 3) {
|
||||
repoCode = "repo.releases";
|
||||
}
|
||||
if(selectedVal == 4) {
|
||||
repoCode = "repo.wiki";
|
||||
}
|
||||
if(selectedVal == 5) {
|
||||
repoCode = "repo.ext_wiki";
|
||||
}
|
||||
if(selectedVal == 6) {
|
||||
repoCode = "repo.ext_issues";
|
||||
}
|
||||
|
||||
if(value){
|
||||
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
||||
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
||||
}
|
||||
|
||||
selectedVal++;
|
||||
}
|
||||
|
||||
String data = String.valueOf(teamAccessControls.getText());
|
||||
if(!data.equals("")) {
|
||||
teamAccessControls.setText(data.substring(0, data.length() - 2));
|
||||
}
|
||||
|
||||
String dataArray = String.valueOf(teamAccessControlsArray.getText());
|
||||
if(!dataArray.equals("")) {
|
||||
teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
|
||||
}
|
||||
//Log.i("orgName", String.valueOf(teamAccessControlsArray.getText()));
|
||||
|
||||
}
|
||||
|
||||
selectedVal++;
|
||||
}
|
||||
|
||||
String data = String.valueOf(teamAccessControls.getText());
|
||||
if(!data.equals("")) {
|
||||
teamAccessControls.setText(data.substring(0, data.length() - 2));
|
||||
}
|
||||
});
|
||||
|
||||
String dataArray = String.valueOf(teamAccessControlsArray.getText());
|
||||
if(!dataArray.equals("")) {
|
||||
teamAccessControlsArray.setText(dataArray.substring(0, dataArray.length() - 2));
|
||||
}
|
||||
//Log.i("orgName", String.valueOf(teamAccessControlsArray.getText()));
|
||||
|
||||
});
|
||||
|
||||
AlertDialog aDialog = aDialogBuilder.create();
|
||||
aDialog.show();
|
||||
AlertDialog aDialog = aDialogBuilder.create();
|
||||
aDialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
createTeamButton.setEnabled(false);
|
||||
@ -249,21 +264,21 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (newTeamName.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.teamNameEmpty));
|
||||
Toasty.info(ctx, getString(R.string.teamNameEmpty));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(!appUtil.checkStringsWithAlphaNumericDashDotUnderscore(newTeamName)) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.teamNameError));
|
||||
Toasty.info(ctx, getString(R.string.teamNameError));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -271,12 +286,12 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
if(!newTeamDesc.equals("")) {
|
||||
|
||||
if(!appUtil.checkStrings(newTeamDesc)) {
|
||||
Toasty.warning(ctx, getString(R.string.teamDescError));
|
||||
Toasty.info(ctx, getString(R.string.teamDescError));
|
||||
return;
|
||||
}
|
||||
|
||||
if(newTeamDesc.length() > 100) {
|
||||
Toasty.warning(ctx, getString(R.string.teamDescLimit));
|
||||
Toasty.info(ctx, getString(R.string.teamDescLimit));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -284,7 +299,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
if (newTeamPermission.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.teamPermissionEmpty));
|
||||
Toasty.info(ctx, getString(R.string.teamPermissionEmpty));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -321,14 +336,16 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
tinyDb.putBoolean("resumeTeams", true);
|
||||
|
||||
Toasty.success(ctx, getString(R.string.teamCreated));
|
||||
Toasty.info(ctx, getString(R.string.teamCreated));
|
||||
finish();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if(response2.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
|
||||
@ -336,10 +353,12 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.teamCreatedError));
|
||||
Toasty.info(ctx, getString(R.string.teamCreatedError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -354,15 +373,19 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if(v == createTeamButton) {
|
||||
processCreateTeam();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.CreditsAdapter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class CreditsActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
final Context ctx = this;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_credits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
Resources res = getResources();
|
||||
CharSequence[] creditsInfo = res.getTextArray(R.array.creditsInfo);
|
||||
|
||||
List<CharSequence> creditsList = new ArrayList<>(Arrays.asList(creditsInfo));
|
||||
|
||||
RecyclerView mRecyclerView = findViewById(R.id.recyclerView);
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
CreditsAdapter adapter = new CreditsAdapter(creditsList);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ package org.mian.gitnex.activities;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -107,6 +109,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
loadCollaboratorsList();
|
||||
|
||||
editIssueMilestoneSpinner = findViewById(R.id.editIssueMilestoneSpinner);
|
||||
editIssueMilestoneSpinner.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
editIssueDescription.setMentionAdapter(defaultMentionAdapter);
|
||||
|
||||
@ -214,14 +217,14 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (editIssueTitleForm.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.issueTitleEmpty));
|
||||
Toasty.info(ctx, getString(R.string.issueTitleEmpty));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -264,10 +267,10 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
if(response.code() == 201) {
|
||||
|
||||
if(tinyDb.getString("issueType").equalsIgnoreCase("Pull")) {
|
||||
Toasty.success(ctx, getString(R.string.editPrSuccessMessage));
|
||||
Toasty.info(ctx, getString(R.string.editPrSuccessMessage));
|
||||
}
|
||||
else {
|
||||
Toasty.success(ctx, getString(R.string.editIssueSuccessMessage));
|
||||
Toasty.info(ctx, getString(R.string.editIssueSuccessMessage));
|
||||
}
|
||||
|
||||
tinyDb.putBoolean("issueEdited", true);
|
||||
@ -287,7 +290,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -424,6 +427,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
@SuppressLint("SimpleDateFormat") DateFormat formatter = new SimpleDateFormat("yyyy-M-dd");
|
||||
String dueDate = formatter.format(response.body().getDue_date());
|
||||
editIssueDueDate.setText(dueDate);
|
||||
|
||||
}
|
||||
//enableProcessButton();
|
||||
|
||||
@ -434,10 +438,12 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
||||
getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -453,11 +459,21 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
private void disableProcessButton() {
|
||||
|
||||
editIssueButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
editIssueButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
editIssueButton.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
editIssueButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,9 +82,8 @@ public class FileDiffActivity extends BaseActivity {
|
||||
|
||||
// fallback for old gitea instances
|
||||
if(new Version(tinyDb.getString("giteaVersion")).less("1.13.0")) {
|
||||
|
||||
apiCall = false;
|
||||
instanceUrl = instanceUrl.substring(0, instanceUrl.lastIndexOf("api/v1/"));
|
||||
instanceUrl = tinyDb.getString("instanceUrlWithProtocol");
|
||||
}
|
||||
|
||||
getPullDiffContent(instanceUrl, repoOwner, repoName, pullIndex, instanceToken, apiCall);
|
||||
@ -140,17 +139,17 @@ public class FileDiffActivity extends BaseActivity {
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||
Toasty.info(ctx, getString(R.string.labelGeneralError));
|
||||
|
||||
}
|
||||
|
||||
@ -167,10 +166,14 @@ public class FileDiffActivity extends BaseActivity {
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> {
|
||||
onClickListener = new View.OnClickListener() {
|
||||
|
||||
getIntent().removeExtra("singleFileName");
|
||||
finish();
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
getIntent().removeExtra("singleFileName");
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
@ -43,24 +42,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.core.CorePlugin;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.ext.tables.TablePlugin;
|
||||
import io.noties.markwon.ext.tasklist.TaskListPlugin;
|
||||
import io.noties.markwon.html.HtmlPlugin;
|
||||
import io.noties.markwon.image.DefaultMediaDecoder;
|
||||
import io.noties.markwon.image.ImageItem;
|
||||
import io.noties.markwon.image.ImagesPlugin;
|
||||
import io.noties.markwon.image.SchemeHandler;
|
||||
import io.noties.markwon.image.gif.GifMediaDecoder;
|
||||
import io.noties.markwon.image.svg.SvgMediaDecoder;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -83,10 +65,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
private LinearLayout pdfViewFrame;
|
||||
private byte[] decodedPdf;
|
||||
private Boolean pdfNightMode;
|
||||
private String singleFileName;
|
||||
private String fileSha;
|
||||
private AppUtil appUtil;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
@ -99,12 +77,11 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
appUtil = new AppUtil();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoBranch = tinyDb.getString("repoBranch");
|
||||
String[] parts = repoFullName.split("/");
|
||||
@ -114,8 +91,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
tinyDb.putBoolean("enableMarkdownInFileView", false);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
singleFileContents = findViewById(R.id.singleFileContents);
|
||||
singleCodeContents = findViewById(R.id.singleCodeContents);
|
||||
@ -125,7 +100,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
pdfViewFrame = findViewById(R.id.pdfViewFrame);
|
||||
singleFileContentsFrame = findViewById(R.id.singleFileContentsFrame);
|
||||
|
||||
singleFileName = getIntent().getStringExtra("singleFileName");
|
||||
String singleFileName = getIntent().getStringExtra("singleFileName");
|
||||
|
||||
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
||||
toolbar_title.setMovementMethod(new ScrollingMovementMethod());
|
||||
@ -144,6 +119,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
}
|
||||
catch(UnsupportedEncodingException e) {
|
||||
|
||||
assert singleFileName != null;
|
||||
Log.i("singleFileName", singleFileName);
|
||||
|
||||
}
|
||||
@ -154,29 +130,10 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoBranch = tinyDb.getString("repoBranch");
|
||||
String[] parts = repoFullName.split("/");
|
||||
String repoOwner = parts[0];
|
||||
String repoName = parts[1];
|
||||
String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
String loginUid = tinyDb.getString("loginUid");
|
||||
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("fileModified")) {
|
||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||
tinyDb.putBoolean("fileModified", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename, String ref) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
Call<Files> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getSingleFileContents(token, owner, repo, filename, ref);
|
||||
|
||||
call.enqueue(new Callback<Files>() {
|
||||
@ -186,6 +143,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
AppUtil appUtil = new AppUtil();
|
||||
assert response.body() != null;
|
||||
|
||||
if(!response.body().getContent().equals("")) {
|
||||
@ -193,8 +151,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
String fileExtension = FileUtils.getExtension(filename);
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
|
||||
fileSha = response.body().getSha();
|
||||
|
||||
// download file meta
|
||||
tinyDb.putString("downloadFileName", filename);
|
||||
tinyDb.putString("downloadFileContents", response.body().getContent());
|
||||
@ -291,17 +247,17 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||
Toasty.info(ctx, getString(R.string.labelGeneralError));
|
||||
|
||||
}
|
||||
|
||||
@ -321,13 +277,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
inflater.inflate(R.menu.files_view_menu, menu);
|
||||
|
||||
String fileExtension = FileUtils.getExtension(singleFileName);
|
||||
if(!fileExtension.equalsIgnoreCase("md")) {
|
||||
menu.getItem(0).setVisible(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -338,82 +287,11 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
switch(id) {
|
||||
case android.R.id.home:
|
||||
|
||||
finish();
|
||||
return true;
|
||||
case R.id.genericMenu:
|
||||
|
||||
BottomSheetFileViewerFragment bottomSheet = new BottomSheetFileViewerFragment();
|
||||
bottomSheet.show(getSupportFragmentManager(), "fileViewerBottomSheet");
|
||||
return true;
|
||||
case R.id.markdown:
|
||||
|
||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create())
|
||||
.usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
|
||||
|
||||
final int resourceId = ctx.getResources().getIdentifier(
|
||||
raw.substring("drawable://".length()),
|
||||
"drawable",
|
||||
ctx.getPackageName());
|
||||
|
||||
final Drawable drawable = ctx.getDrawable(resourceId);
|
||||
|
||||
assert drawable != null;
|
||||
return ImageItem.withResult(drawable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> supportedSchemes() {
|
||||
|
||||
return Collections.singleton("drawable");
|
||||
}
|
||||
});
|
||||
plugin.placeholderProvider(drawable -> null);
|
||||
plugin.addMediaDecoder(GifMediaDecoder.create(false));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create(ctx.getResources()));
|
||||
plugin.addMediaDecoder(SvgMediaDecoder.create());
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(ctx.getResources()));
|
||||
plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
|
||||
}))
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@Override
|
||||
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||
|
||||
builder.codeTextColor(tinyDb.getInt("codeBlockColor")).codeBackgroundColor(tinyDb.getInt("codeBlockBackground"))
|
||||
.linkColor(getResources().getColor(R.color.lightBlue));
|
||||
}
|
||||
})
|
||||
.usePlugin(TablePlugin.create(ctx))
|
||||
.usePlugin(TaskListPlugin.create(ctx))
|
||||
.usePlugin(HtmlPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(LinkifyPlugin.create())
|
||||
.build();
|
||||
|
||||
if(!tinyDb.getBoolean("enableMarkdownInFileView")) {
|
||||
|
||||
singleCodeContents.setVisibility(View.GONE);
|
||||
singleFileContentsFrame.setVisibility(View.VISIBLE);
|
||||
singleFileContents.setVisibility(View.VISIBLE);
|
||||
Spanned bodyWithMD = markwon.toMarkdown(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
|
||||
markwon.setParsedMarkdown(singleFileContents, bodyWithMD);
|
||||
tinyDb.putBoolean("enableMarkdownInFileView", true);
|
||||
}
|
||||
else {
|
||||
|
||||
singleCodeContents.setVisibility(View.VISIBLE);
|
||||
singleFileContentsFrame.setVisibility(View.GONE);
|
||||
singleFileContents.setVisibility(View.GONE);
|
||||
singleCodeContents.setSource(appUtil.decodeBase64(tinyDb.getString("downloadFileContents")));
|
||||
tinyDb.putBoolean("enableMarkdownInFileView", false);
|
||||
}
|
||||
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
@ -427,48 +305,15 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
if("downloadFile".equals(text)) {
|
||||
|
||||
requestFileDownload();
|
||||
}
|
||||
|
||||
if("deleteFile".equals(text)) {
|
||||
|
||||
String fileExtension = FileUtils.getExtension(singleFileName);
|
||||
String data = appUtil.decodeBase64(tinyDb.getString("downloadFileContents"));
|
||||
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
||||
intent.putExtra("fileAction", 1);
|
||||
intent.putExtra("filePath", singleFileName);
|
||||
intent.putExtra("fileSha", fileSha);
|
||||
if(!appUtil.imageExtension(fileExtension)) {
|
||||
intent.putExtra("fileContents", data);
|
||||
}
|
||||
else {
|
||||
intent.putExtra("fileContents", "");
|
||||
}
|
||||
|
||||
ctx.startActivity(intent);
|
||||
}
|
||||
|
||||
if("editFile".equals(text)) {
|
||||
|
||||
String fileExtension = FileUtils.getExtension(singleFileName);
|
||||
String data = appUtil.decodeBase64(tinyDb.getString("downloadFileContents"));
|
||||
Intent intent = new Intent(ctx, CreateFileActivity.class);
|
||||
intent.putExtra("fileAction", 2);
|
||||
intent.putExtra("filePath", singleFileName);
|
||||
intent.putExtra("fileSha", fileSha);
|
||||
if(!appUtil.imageExtension(fileExtension)) {
|
||||
intent.putExtra("fileContents", data);
|
||||
}
|
||||
else {
|
||||
intent.putExtra("fileContents", "");
|
||||
}
|
||||
|
||||
ctx.startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void requestFileDownload() {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
if(!tinyDb.getString("downloadFileContents").isEmpty()) {
|
||||
|
||||
int CREATE_REQUEST_CODE = 40;
|
||||
@ -485,8 +330,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.waitLoadingDownloadFile));
|
||||
Toasty.error(ctx, getString(R.string.waitLoadingDownloadFile));
|
||||
}
|
||||
|
||||
}
|
||||
@ -496,7 +340,9 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if(requestCode == 40 && resultCode == RESULT_OK) {
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
if (requestCode == 40 && resultCode == RESULT_OK) {
|
||||
|
||||
try {
|
||||
|
||||
@ -512,11 +358,10 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
outputStream.write(dataAsBytes);
|
||||
outputStream.close();
|
||||
|
||||
Toasty.success(ctx, getString(R.string.downloadFileSaved));
|
||||
Toasty.info(ctx, getString(R.string.downloadFileSaved));
|
||||
|
||||
}
|
||||
catch(IOException e) {
|
||||
|
||||
catch (IOException e) {
|
||||
Log.e("errorFileDownloading", Objects.requireNonNull(e.getMessage()));
|
||||
}
|
||||
|
||||
@ -530,6 +375,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
getIntent().removeExtra("singleFileName");
|
||||
finish();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.IssueCommentsAdapter;
|
||||
@ -97,14 +96,13 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
private HorizontalScrollView assigneesScrollView;
|
||||
private ScrollView scrollViewComments;
|
||||
private TextView issueModified;
|
||||
private ExtendedFloatingActionButton createNewComment;
|
||||
private ImageView createNewComment;
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private LinearLayout labelsLayout;
|
||||
private LinearLayout assigneesLayout;
|
||||
private View divider;
|
||||
private ProgressBar progressBar;
|
||||
private ImageView issuePrState;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
@ -146,7 +144,6 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
assigneesLayout = findViewById(R.id.frameAssignees);
|
||||
divider = findViewById(R.id.divider);
|
||||
progressBar = findViewById(R.id.progressBar);
|
||||
issuePrState = findViewById(R.id.issuePrState);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
@ -353,27 +350,6 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
Issues singleIssue = response.body();
|
||||
assert singleIssue != null;
|
||||
|
||||
issuePrState.setVisibility(View.VISIBLE);
|
||||
if(singleIssue.getPull_request() != null) {
|
||||
|
||||
if(singleIssue.getPull_request().isMerged()) { // merged
|
||||
|
||||
issuePrState.setImageResource(R.drawable.ic_pull_request_merged);
|
||||
}
|
||||
else if(!singleIssue.getPull_request().isMerged() && singleIssue.getState().equals("closed")) { // closed
|
||||
|
||||
issuePrState.setImageResource(R.drawable.ic_pull_request_closed);
|
||||
}
|
||||
else { // open
|
||||
|
||||
issuePrState.setImageResource(R.drawable.ic_pull_request);
|
||||
}
|
||||
}
|
||||
else if(singleIssue.getState().equals("closed")) { // issue closed
|
||||
|
||||
issuePrState.setImageResource(R.drawable.ic_issue_closed_red);
|
||||
}
|
||||
|
||||
final Markwon markwon = Markwon.builder(Objects.requireNonNull(ctx)).usePlugin(CorePlugin.create())
|
||||
.usePlugin(ImagesPlugin.create(plugin -> {
|
||||
plugin.addSchemeHandler(new SchemeHandler() {
|
||||
@ -421,7 +397,6 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
tinyDb.putString("issueState", singleIssue.getState());
|
||||
tinyDb.putString("issueTitle", singleIssue.getTitle());
|
||||
tinyDb.putString("singleIssueHtmlUrl", singleIssue.getHtml_url());
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(singleIssue.getUser().getAvatar_url()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(assigneeAvatar);
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
@ -12,6 +13,7 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
@ -20,12 +22,11 @@ import com.tooltip.Tooltip;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.NetworkObserver;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.UrlHelper;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.GiteaVersion;
|
||||
@ -60,6 +61,7 @@ public class LoginActivity extends BaseActivity {
|
||||
private TextView otpInfo;
|
||||
private RadioGroup loginMethod;
|
||||
private String device_id = "token";
|
||||
private ScrollView layoutView;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
@ -86,6 +88,7 @@ public class LoginActivity extends BaseActivity {
|
||||
protocolSpinner = findViewById(R.id.httpsSpinner);
|
||||
loginMethod = findViewById(R.id.loginMethod);
|
||||
loginTokenCode = findViewById(R.id.loginTokenCode);
|
||||
layoutView = findViewById(R.id.loginForm);
|
||||
|
||||
((TextView) findViewById(R.id.appVersion)).setText(AppUtil.getAppVersion(appCtx));
|
||||
|
||||
@ -98,7 +101,7 @@ public class LoginActivity extends BaseActivity {
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
|
||||
if(protocolSpinner.getSelectedItem() == Protocol.HTTP) {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.protocolError));
|
||||
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.protocolError));
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +112,7 @@ public class LoginActivity extends BaseActivity {
|
||||
});
|
||||
|
||||
info_button.setOnClickListener(
|
||||
view -> new Tooltip.Builder(view).setText(R.string.urlInfoTooltip).setTextColor(getResources().getColor(R.color.colorWhite))
|
||||
view -> new Tooltip.Builder(view).setText(R.string.urlInfoTooltip).setTextColor(getResources().getColor(R.color.white))
|
||||
.setBackgroundColor(getResources().getColor(R.color.tooltipBackground)).setCancelable(true).setDismissOnClick(true).setPadding(30)
|
||||
.setCornerRadius(R.dimen.tooltipCornor).setGravity(Gravity.BOTTOM).show());
|
||||
|
||||
@ -134,12 +137,13 @@ public class LoginActivity extends BaseActivity {
|
||||
if(isAvailable) {
|
||||
|
||||
enableProcessButton();
|
||||
SnackBar.success(ctx, layoutView, getResources().getString(R.string.netConnectionIsBack));
|
||||
}
|
||||
else {
|
||||
|
||||
disableProcessButton();
|
||||
loginButton.setText(getResources().getString(R.string.btnLogin));
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.checkNetConnection));
|
||||
}
|
||||
});
|
||||
|
||||
@ -167,16 +171,20 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET.getText().toString(), "http")).toUri();
|
||||
|
||||
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(protocol.name().toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/"))
|
||||
URI instanceUrlWithProtocol = UrlBuilder.fromUri(rawInstanceUrl).withPath(PathsHelper.join(rawInstanceUrl.getPath()))
|
||||
.withScheme(protocol.name().toLowerCase()).toUri();
|
||||
|
||||
URI instanceUrl = UrlBuilder.fromUri(instanceUrlWithProtocol).withPath(PathsHelper.join(instanceUrlWithProtocol.getPath(), "/api/v1/"))
|
||||
.toUri();
|
||||
|
||||
tinyDB.putString("loginType", loginType.name().toLowerCase());
|
||||
tinyDB.putString("instanceUrlRaw", instanceUrlET.getText().toString());
|
||||
tinyDB.putString("instanceUrl", instanceUrl.toString());
|
||||
tinyDB.putString("instanceUrlWithProtocol", instanceUrlWithProtocol.toString());
|
||||
|
||||
if(instanceUrlET.getText().toString().equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldURL));
|
||||
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.emptyFieldURL));
|
||||
enableProcessButton();
|
||||
return;
|
||||
|
||||
@ -186,7 +194,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(otpCode.length() != 0 && otpCode.length() != 6) {
|
||||
|
||||
Toasty.warning(ctx, getResources().getString(R.string.loginOTPTypeError));
|
||||
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.loginOTPTypeError));
|
||||
enableProcessButton();
|
||||
return;
|
||||
|
||||
@ -201,7 +209,15 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(loginUid.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldUsername));
|
||||
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.emptyFieldUsername));
|
||||
enableProcessButton();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(loginUid.contains("@")) {
|
||||
|
||||
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.userInvalidUserName));
|
||||
enableProcessButton();
|
||||
return;
|
||||
|
||||
@ -209,7 +225,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(loginPass.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldPassword));
|
||||
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.emptyFieldPassword));
|
||||
enableProcessButton();
|
||||
return;
|
||||
|
||||
@ -225,7 +241,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(loginToken.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.loginTokenError));
|
||||
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.loginTokenError));
|
||||
enableProcessButton();
|
||||
return;
|
||||
|
||||
@ -239,7 +255,7 @@ public class LoginActivity extends BaseActivity {
|
||||
catch(Exception e) {
|
||||
|
||||
Log.e("onFailure-login", e.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.malformedUrl));
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.malformedUrl));
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@ -252,7 +268,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(!loginToken.equals("")) {
|
||||
|
||||
callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken("token " + loginToken);
|
||||
callVersion = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getGiteaVersionWithToken(loginToken);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -272,17 +288,20 @@ public class LoginActivity extends BaseActivity {
|
||||
if(responseVersion.code() == 200) {
|
||||
|
||||
GiteaVersion version = responseVersion.body();
|
||||
Version gitea_version;
|
||||
|
||||
assert version != null;
|
||||
if(!Version.valid(version.getVersion())) {
|
||||
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
|
||||
|
||||
try {
|
||||
gitea_version = new Version(version.getVersion());
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.versionUnknown));
|
||||
enableProcessButton();
|
||||
return;
|
||||
}
|
||||
|
||||
tinyDB.putString("giteaVersion", version.getVersion());
|
||||
Version gitea_version = new Version(version.getVersion());
|
||||
|
||||
if(gitea_version.less(getString(R.string.versionLow))) {
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
@ -310,7 +329,7 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.warning(ctx, getResources().getString(R.string.versionUnsupportedNew));
|
||||
SnackBar.info(ctx, layoutView, getResources().getString(R.string.versionUnsupportedNew));
|
||||
login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken);
|
||||
|
||||
}
|
||||
@ -339,7 +358,7 @@ public class LoginActivity extends BaseActivity {
|
||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-versionCheck", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.errorOnLogin));
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.errorOnLogin));
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
@ -369,18 +388,9 @@ public class LoginActivity extends BaseActivity {
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||
int checkAccount = userAccountsApi.getCount(accountName);
|
||||
long accountId;
|
||||
|
||||
if(checkAccount == 0) {
|
||||
|
||||
accountId = userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||
}
|
||||
else {
|
||||
|
||||
userAccountsApi.updateTokenByAccountName(accountName, loginToken);
|
||||
UserAccount data = userAccountsApi.getAccountData(accountName);
|
||||
tinyDB.putInt("currentActiveAccountId", data.getAccountId());
|
||||
userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
||||
}
|
||||
|
||||
enableProcessButton();
|
||||
@ -389,12 +399,12 @@ public class LoginActivity extends BaseActivity {
|
||||
break;
|
||||
|
||||
case 401:
|
||||
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.unauthorizedApiError));
|
||||
enableProcessButton();
|
||||
break;
|
||||
|
||||
default:
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@ -405,7 +415,7 @@ public class LoginActivity extends BaseActivity {
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericError));
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@ -465,7 +475,7 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@ -475,7 +485,7 @@ public class LoginActivity extends BaseActivity {
|
||||
public void onFailure(@NonNull Call<Void> delcall, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-login", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.malformedJson));
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@ -488,7 +498,7 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@ -498,7 +508,7 @@ public class LoginActivity extends BaseActivity {
|
||||
public void onFailure(@NonNull Call<List<UserTokens>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-login", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.malformedJson));
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.malformedJson));
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@ -559,19 +569,10 @@ public class LoginActivity extends BaseActivity {
|
||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
||||
int checkAccount = userAccountsApi.getCount(accountName);
|
||||
long accountId;
|
||||
|
||||
if(checkAccount == 0) {
|
||||
|
||||
accountId = userAccountsApi
|
||||
userAccountsApi
|
||||
.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), newToken.getSha1(), "");
|
||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||
}
|
||||
else {
|
||||
|
||||
userAccountsApi.updateTokenByAccountName(accountName, newToken.getSha1());
|
||||
UserAccount data = userAccountsApi.getAccountData(accountName);
|
||||
tinyDB.putInt("currentActiveAccountId", data.getAccountId());
|
||||
}
|
||||
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
@ -579,12 +580,12 @@ public class LoginActivity extends BaseActivity {
|
||||
break;
|
||||
|
||||
case 401:
|
||||
Toasty.error(ctx, getResources().getString(R.string.unauthorizedApiError));
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.unauthorizedApiError));
|
||||
enableProcessButton();
|
||||
break;
|
||||
|
||||
default:
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericApiStatusError) + response.code());
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@ -595,7 +596,7 @@ public class LoginActivity extends BaseActivity {
|
||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericError));
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@ -604,7 +605,7 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
else if(responseCreate.code() == 500) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericApiStatusError) + responseCreate.code());
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.genericApiStatusError) + responseCreate.code());
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@ -653,14 +654,26 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius(8);
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
|
||||
loginButton.setText(R.string.processingText);
|
||||
loginButton.setBackground(shape);
|
||||
loginButton.setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius(8);
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
|
||||
loginButton.setText(R.string.btnLogin);
|
||||
loginButton.setBackground(shape);
|
||||
loginButton.setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -17,24 +18,22 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserAccountsNavAdapter;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.fragments.AboutFragment;
|
||||
import org.mian.gitnex.fragments.AdministrationFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetDraftsFragment;
|
||||
import org.mian.gitnex.fragments.DraftsFragment;
|
||||
import org.mian.gitnex.fragments.ExploreFragment;
|
||||
import org.mian.gitnex.fragments.ExploreRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.MyRepositoriesFragment;
|
||||
import org.mian.gitnex.fragments.NotificationsFragment;
|
||||
import org.mian.gitnex.fragments.OrganizationsFragment;
|
||||
@ -53,10 +52,7 @@ import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.GiteaVersion;
|
||||
import org.mian.gitnex.models.NotificationCount;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import eightbitlab.com.blurview.BlurView;
|
||||
import eightbitlab.com.blurview.RenderScriptBlur;
|
||||
@ -81,14 +77,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
private Context appCtx;
|
||||
private Typeface myTypeface;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
|
||||
private View hView;
|
||||
private MenuItem navNotifications;
|
||||
private TextView notificationCounter;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
|
||||
@ -107,9 +95,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
Intent mainIntent = getIntent();
|
||||
String launchFragment = mainIntent.getStringExtra("launchFragment");
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getString("dateFormat").isEmpty()) {
|
||||
tinyDb.putString("dateFormat", "pretty");
|
||||
@ -135,9 +123,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
return;
|
||||
}
|
||||
|
||||
if(tinyDb.getInt("currentActiveAccountId") <= 0) {
|
||||
AlertDialogs.forceLogoutDialog(ctx, getResources().getString(R.string.forceLogoutDialogHeader), getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
}
|
||||
String accountName = loginUid + "@" + instanceUrl;
|
||||
getAccountData(accountName);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
@ -176,7 +163,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
else if(fragmentById instanceof OrganizationsFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
||||
}
|
||||
else if(fragmentById instanceof ExploreFragment) {
|
||||
else if(fragmentById instanceof ExploreRepositoriesFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
||||
}
|
||||
else if(fragmentById instanceof NotificationsFragment) {
|
||||
@ -185,6 +172,9 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
else if(fragmentById instanceof ProfileFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||
}
|
||||
else if(fragmentById instanceof AboutFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAbout));
|
||||
}
|
||||
else if(fragmentById instanceof DraftsFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
}
|
||||
@ -195,15 +185,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
||||
}
|
||||
|
||||
getNotificationsCount(instanceUrl, instanceToken);
|
||||
|
||||
drawer = findViewById(R.id.drawer_layout);
|
||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
hView = navigationView.getHeaderView(0);
|
||||
|
||||
Menu menu = navigationView.getMenu();
|
||||
navNotifications = menu.findItem(R.id.nav_notifications);
|
||||
final View hView = navigationView.getHeaderView(0);
|
||||
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
|
||||
@ -213,14 +198,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
@Override
|
||||
public void onDrawerOpened(@NonNull View drawerView) {
|
||||
|
||||
getNotificationsCount(instanceUrl, instanceToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
||||
|
||||
if(tinyDb.getBoolean("noConnection")) {
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
tinyDb.putBoolean("noConnection", false);
|
||||
}
|
||||
|
||||
@ -235,29 +214,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
userAvatarBackground = hView.findViewById(R.id.userAvatarBackground);
|
||||
navHeaderFrame = hView.findViewById(R.id.navHeaderFrame);
|
||||
|
||||
List<UserAccount> userAccountsList;
|
||||
userAccountsList = new ArrayList<>();
|
||||
UserAccountsApi userAccountsApi;
|
||||
userAccountsApi = new UserAccountsApi(ctx);
|
||||
|
||||
RecyclerView navRecyclerViewUserAccounts = hView.findViewById(R.id.navRecyclerViewUserAccounts);
|
||||
UserAccountsNavAdapter adapterUserAccounts;
|
||||
|
||||
adapterUserAccounts = new UserAccountsNavAdapter(ctx, userAccountsList, drawer, toolbarTitle);
|
||||
|
||||
userAccountsApi.getAllAccounts().observe((AppCompatActivity) ctx, userAccounts -> {
|
||||
|
||||
if(userAccounts.size() > 0) {
|
||||
|
||||
userAccountsList.addAll(userAccounts);
|
||||
navRecyclerViewUserAccounts.setAdapter(adapterUserAccounts);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
userEmail.setTypeface(myTypeface);
|
||||
userFullName.setTypeface(myTypeface);
|
||||
|
||||
String currentVersion = tinyDb.getString("giteaVersion");
|
||||
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(tinyDb.getBoolean("userIsAdmin"));
|
||||
navigationView.getMenu().findItem(R.id.nav_notifications).setVisible(new Version(currentVersion).higherOrEqual("1.12.3"));
|
||||
|
||||
if(!userEmailNav.equals("")) {
|
||||
userEmail.setText(userEmailNav);
|
||||
}
|
||||
@ -305,16 +269,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ProfileFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_profile);
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
|
||||
String currentVersion = tinyDb.getString("giteaVersion");
|
||||
|
||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(tinyDb.getBoolean("userIsAdmin"));
|
||||
navigationView.getMenu().findItem(R.id.nav_notifications).setVisible(new Version(currentVersion).higherOrEqual("1.12.3"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed(@NonNull View drawerView) {}
|
||||
|
||||
@ -323,6 +285,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
});
|
||||
|
||||
ImageView userAccounts = hView.findViewById(R.id.userAccounts);
|
||||
userAccounts.setOnClickListener(v -> {
|
||||
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new UserAccountsFragment()).commit();
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
|
||||
toggle.syncState();
|
||||
toolbar.setNavigationIcon(R.drawable.ic_menu);
|
||||
|
||||
@ -349,14 +319,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
if(savedInstanceState == null) {
|
||||
|
||||
if(!new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||
|
||||
if(tinyDb.getInt("homeScreenId") == 7) {
|
||||
|
||||
tinyDb.putInt("homeScreenId", 0);
|
||||
}
|
||||
}
|
||||
|
||||
switch(tinyDb.getInt("homeScreenId")) {
|
||||
|
||||
case 1:
|
||||
@ -385,7 +347,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
case 5:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreRepositoriesFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_explore);
|
||||
break;
|
||||
|
||||
@ -395,12 +357,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
||||
navigationView.setCheckedItem(R.id.nav_notifications);
|
||||
break;
|
||||
|
||||
default:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyRepositoriesFragment()).commit();
|
||||
@ -413,7 +369,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
if(!connToInternet) {
|
||||
|
||||
if(!tinyDb.getBoolean("noConnection")) {
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
}
|
||||
|
||||
tinyDb.putBoolean("noConnection", true);
|
||||
@ -450,11 +406,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
}
|
||||
|
||||
public void setActionBarTitle(String title) {
|
||||
|
||||
toolbarTitle.setText(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
@ -470,18 +421,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
if(frag != null) {
|
||||
|
||||
new AlertDialog.Builder(ctx)
|
||||
.setTitle(R.string.deleteAllDrafts)
|
||||
.setIcon(R.drawable.ic_delete)
|
||||
.setCancelable(false)
|
||||
.setMessage(R.string.deleteAllDraftsDialogMessage)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
new AlertDialog.Builder(ctx).setTitle(R.string.deleteAllDrafts).setIcon(R.drawable.ic_delete).setCancelable(false).setMessage(R.string.deleteAllDraftsDialogMessage).setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
frag.deleteAllDrafts(currentActiveAccountId);
|
||||
dialog.dismiss();
|
||||
frag.deleteAllDrafts(currentActiveAccountId);
|
||||
dialog.dismiss();
|
||||
|
||||
})
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
}).setNegativeButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).show();
|
||||
|
||||
}
|
||||
else {
|
||||
@ -497,6 +442,20 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
}
|
||||
|
||||
public void getAccountData(String accountName) {
|
||||
|
||||
UserAccountsApi accountData = new UserAccountsApi(ctx);
|
||||
UserAccount data = accountData.getAccountData(accountName);
|
||||
|
||||
if(data != null) {
|
||||
TinyDB tinyDb = new TinyDB(ctx.getApplicationContext());
|
||||
tinyDb.putInt("currentActiveAccountId", data.getAccountId());
|
||||
}
|
||||
else {
|
||||
AlertDialogs.forceLogoutDialog(ctx, getResources().getString(R.string.forceLogoutDialogHeader), getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
||||
@ -544,6 +503,15 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
break;
|
||||
|
||||
case R.id.nav_about:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAbout));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AboutFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_rate_app:
|
||||
rateThisApp();
|
||||
break;
|
||||
|
||||
case R.id.nav_starred_repos:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StarredRepositoriesFragment()).commit();
|
||||
@ -551,7 +519,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
case R.id.nav_explore:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreFragment()).commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreRepositoriesFragment()).commit();
|
||||
break;
|
||||
|
||||
case R.id.nav_notifications:
|
||||
@ -575,6 +543,16 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
return true;
|
||||
}
|
||||
|
||||
public void rateThisApp() {
|
||||
|
||||
try {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())));
|
||||
}
|
||||
catch(ActivityNotFoundException e) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName())));
|
||||
}
|
||||
}
|
||||
|
||||
public static void logout(Activity activity, Context ctx) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx.getApplicationContext());
|
||||
@ -687,7 +665,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
else {
|
||||
|
||||
String toastError = getResources().getString(R.string.genericApiStatusError) + response.code();
|
||||
Toasty.error(ctx, toastError);
|
||||
Toasty.info(ctx, toastError);
|
||||
|
||||
}
|
||||
|
||||
@ -702,31 +680,4 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
}
|
||||
|
||||
private void getNotificationsCount(String instanceUrl, String token) {
|
||||
|
||||
Call<NotificationCount> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkUnreadNotifications(token);
|
||||
|
||||
call.enqueue(new Callback<NotificationCount>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<NotificationCount> call, @NonNull retrofit2.Response<NotificationCount> response) {
|
||||
|
||||
NotificationCount notificationCount = response.body();
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
assert notificationCount != null;
|
||||
notificationCounter = navNotifications.getActionView().findViewById(R.id.counterBadgeNotification);
|
||||
notificationCounter.setText(String.valueOf(notificationCount.getCounter()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<NotificationCount> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-notification", t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -126,10 +126,12 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
if(!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.mergeButton.setOnClickListener(mergePullRequest);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -219,7 +221,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -264,7 +266,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
deleteBranchFunction(repoOwner, repoName);
|
||||
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
Toasty.info(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
tinyDb.putBoolean("prMerged", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
@ -279,7 +281,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
|
||||
deleteBranchFunction(repoOwner, repoName);
|
||||
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
Toasty.info(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
tinyDb.putBoolean("prMerged", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
@ -289,7 +291,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
Toasty.info(ctx, getString(R.string.mergePRSuccessMsg));
|
||||
tinyDb.putBoolean("prMerged", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
finish();
|
||||
@ -306,13 +308,13 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
else if(response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.mergePR404ErrorMsg));
|
||||
Toasty.info(ctx, getString(R.string.mergePR404ErrorMsg));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
Toasty.info(ctx, getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
@ -371,11 +373,15 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
private void disableProcessButton() {
|
||||
|
||||
viewBinding.mergeButton.setEnabled(false);
|
||||
viewBinding.mergeButton.setBackground(getResources().getDrawable(R.drawable.shape_buttons_disabled));
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
viewBinding.mergeButton.setEnabled(true);
|
||||
viewBinding.mergeButton.setBackground(getResources().getDrawable(R.drawable.shape_buttons));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,9 +30,7 @@ public class OpenRepoInBrowserActivity extends AppCompatActivity {
|
||||
|
||||
try {
|
||||
|
||||
URI instanceUrl = new URI(UrlBuilder.fromString(tinyDb.getString("instanceUrl"))
|
||||
.withPath("/")
|
||||
.toString());
|
||||
URI instanceUrl = new URI(tinyDb.getString("instanceUrlWithProtocol"));
|
||||
|
||||
String browserPath = PathsHelper.join(instanceUrl.getPath(), getIntent().getStringExtra("repoFullNameBrowser"));
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -26,9 +24,7 @@ import org.mian.gitnex.fragments.OrganizationInfoFragment;
|
||||
import org.mian.gitnex.fragments.RepositoriesByOrgFragment;
|
||||
import org.mian.gitnex.fragments.TeamsByOrgFragment;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.Objects;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -38,7 +34,6 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@ -50,7 +45,6 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String orgName = tinyDb.getString("orgName");
|
||||
@ -111,7 +105,6 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.repo_dotted_menu, menu);
|
||||
return true;
|
||||
@ -139,28 +132,19 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
switch (text) {
|
||||
case "repository":
|
||||
|
||||
tinyDb.putBoolean("organizationAction", true);
|
||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
||||
break;
|
||||
case "team":
|
||||
|
||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class));
|
||||
break;
|
||||
case "copyOrgUrl":
|
||||
|
||||
String url = UrlBuilder.fromString(tinyDb.getString("instanceUrl"))
|
||||
.withPath("/")
|
||||
.toString();
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("orgUrl", url + tinyDb.getString("orgName"));
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
break;
|
||||
}
|
||||
//Log.i("clicked", text);
|
||||
|
||||
}
|
||||
|
||||
public class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||
@ -173,6 +157,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String orgName;
|
||||
if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) {
|
||||
orgName = getIntent().getStringExtra("orgName");
|
||||
|
@ -9,7 +9,6 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
@ -31,7 +30,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
||||
private View.OnClickListener onClickListener;
|
||||
private TeamMembersByOrgAdapter adapter;
|
||||
private GridView mGridView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
@ -60,7 +58,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||
noDataMembers = findViewById(R.id.noDataMembers);
|
||||
mGridView = findViewById(R.id.gridView);
|
||||
progressBar = findViewById(R.id.progressBar);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
@ -117,7 +114,6 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
|
||||
noDataMembers.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
@ -66,9 +67,11 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
if(!connToInternet) {
|
||||
|
||||
disableProcessButton();
|
||||
|
||||
} else {
|
||||
|
||||
addEmailButton.setOnClickListener(addEmailListener);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -91,20 +94,20 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(newUserEmail.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.emailErrorEmpty));
|
||||
Toasty.info(ctx, getString(R.string.emailErrorEmpty));
|
||||
return;
|
||||
|
||||
}
|
||||
else if(!Patterns.EMAIL_ADDRESS.matcher(newUserEmail).matches()) {
|
||||
|
||||
Toasty.warning(ctx, getString(R.string.emailErrorInvalid));
|
||||
Toasty.info(ctx, getString(R.string.emailErrorInvalid));
|
||||
return;
|
||||
|
||||
}
|
||||
@ -135,7 +138,7 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.emailAddedText));
|
||||
Toasty.info(ctx, getString(R.string.emailAddedText));
|
||||
tinyDb.putBoolean("emailsRefresh", true);
|
||||
enableProcessButton();
|
||||
finish();
|
||||
@ -153,25 +156,25 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
else if(response.code() == 403) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else if(response.code() == 422) {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, ctx.getString(R.string.emailErrorInUse));
|
||||
Toasty.info(ctx, ctx.getString(R.string.emailErrorInUse));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.labelGeneralError));
|
||||
Toasty.info(ctx, getString(R.string.labelGeneralError));
|
||||
|
||||
}
|
||||
|
||||
@ -187,18 +190,32 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void disableProcessButton() {
|
||||
|
||||
addEmailButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
addEmailButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
addEmailButton.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius( 8 );
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
addEmailButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
@ -33,7 +34,6 @@ import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -55,7 +55,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
private ArrayAdapter<Mention> defaultMentionAdapter;
|
||||
private Button replyButton;
|
||||
private String TAG = StaticGlobalVariables.replyToIssueActivity;
|
||||
private long draftIdOnCreate;
|
||||
private long draftId;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@ -98,20 +98,6 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
if(getIntent().getStringExtra("draftId") != null) {
|
||||
|
||||
draftIdOnCreate = Long.parseLong(Objects.requireNonNull(getIntent().getStringExtra("draftId")));
|
||||
}
|
||||
else {
|
||||
|
||||
if(getIntent().getStringExtra("commentBody") != null) {
|
||||
draftIdOnCreate = returnDraftId(getIntent().getStringExtra("commentBody"));
|
||||
}
|
||||
else {
|
||||
draftIdOnCreate = returnDraftId("");
|
||||
}
|
||||
}
|
||||
|
||||
replyButton = findViewById(R.id.replyButton);
|
||||
|
||||
if(getIntent().getStringExtra("commentBody") != null) {
|
||||
@ -130,7 +116,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
if(getIntent().getStringExtra("commentAction") != null && Objects.equals(getIntent().getStringExtra("commentAction"), "edit") && !Objects.equals(getIntent().getStringExtra("commentId"), "new")) {
|
||||
if(getIntent().getStringExtra("commentAction") != null && getIntent().getStringExtra("commentAction").equals("edit")) {
|
||||
|
||||
final String commentId = getIntent().getStringExtra("commentId");
|
||||
|
||||
@ -149,7 +135,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
saveDraft(addComment.getText().toString(), commentId, draftIdOnCreate);
|
||||
saveDraft(addComment.getText().toString());
|
||||
draftSaved.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
@ -160,7 +146,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
disableProcessButton();
|
||||
assert commentId != null;
|
||||
IssueActions.editIssueComment(ctx, Integer.parseInt(commentId), addComment.getText().toString(), draftIdOnCreate);
|
||||
IssueActions.editIssueComment(ctx, Integer.parseInt(commentId), addComment.getText().toString());
|
||||
|
||||
});
|
||||
|
||||
@ -180,7 +166,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
saveDraft(addComment.getText().toString(), "new", draftIdOnCreate);
|
||||
saveDraft(addComment.getText().toString());
|
||||
draftSaved.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
@ -200,7 +186,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void saveDraft(String draftText, String commentId, long draftIdOnCreate) {
|
||||
private void saveDraft(String draftText) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
@ -210,31 +196,17 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
||||
|
||||
if(draftIdOnCreate == 0) {
|
||||
int countDraft = draftsApi.checkDraft(issueNumber, repositoryId);
|
||||
|
||||
draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, draftText, StaticGlobalVariables.draftTypeComment, commentId);
|
||||
if(countDraft == 0) {
|
||||
draftId = draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, draftText, StaticGlobalVariables.draftTypeComment);
|
||||
}
|
||||
else {
|
||||
|
||||
DraftsApi.updateDraft(draftText, (int) draftIdOnCreate, commentId); //updateDraftByIssueIdAsyncTask(draftText, issueNumber, repositoryId, commentId);
|
||||
DraftsApi.updateDraftByIssueIdAsyncTask(draftText, issueNumber, repositoryId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private long returnDraftId(String draftText) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
int repositoryId = (int) tinyDb.getLong("repositoryId", 0);
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
int issueNumber = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
|
||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
||||
|
||||
return draftsApi.insertDraft(repositoryId, currentActiveAccountId, issueNumber, draftText, StaticGlobalVariables.draftTypeComment, "");
|
||||
|
||||
}
|
||||
|
||||
public void loadCollaboratorsList() {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
@ -300,14 +272,14 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
Toasty.info(ctx, getResources().getString(R.string.checkNetConnection));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(newReplyDT.equals("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.commentEmptyError));
|
||||
Toasty.info(ctx, getString(R.string.commentEmptyError));
|
||||
|
||||
}
|
||||
else {
|
||||
@ -346,7 +318,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, getString(R.string.commentSuccess));
|
||||
Toasty.info(ctx, getString(R.string.commentSuccess));
|
||||
tinyDb.putBoolean("commentPosted", true);
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("resumePullRequests", true);
|
||||
@ -354,8 +326,12 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
// delete draft comment
|
||||
if(tinyDb.getBoolean("draftsCommentsDeletionEnabled")) {
|
||||
|
||||
int repositoryId = (int) tinyDb.getLong("repositoryId", 0);
|
||||
int issueNumber = Integer.parseInt(tinyDb.getString("issueNumber"));
|
||||
|
||||
DraftsApi draftsApi = new DraftsApi(appCtx);
|
||||
draftsApi.deleteSingleDraft((int) draftIdOnCreate);
|
||||
draftId = draftsApi.getDraftIdAsync(issueNumber, repositoryId);
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
}
|
||||
|
||||
finish();
|
||||
@ -373,7 +349,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.commentError));
|
||||
Toasty.info(ctx, getString(R.string.commentError));
|
||||
|
||||
}
|
||||
|
||||
@ -421,11 +397,21 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
private void disableProcessButton() {
|
||||
|
||||
replyButton.setEnabled(false);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius(8);
|
||||
shape.setColor(getResources().getColor(R.color.hintColor));
|
||||
replyButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
private void enableProcessButton() {
|
||||
|
||||
replyButton.setEnabled(true);
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius(8);
|
||||
shape.setColor(getResources().getColor(R.color.btnBackground));
|
||||
replyButton.setBackground(shape);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@ -33,6 +31,7 @@ import org.mian.gitnex.fragments.BottomSheetIssuesFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetMilestonesFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetPullRequestFilterFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetRepoFragment;
|
||||
import org.mian.gitnex.fragments.BranchesFragment;
|
||||
import org.mian.gitnex.fragments.CollaboratorsFragment;
|
||||
import org.mian.gitnex.fragments.FilesFragment;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
@ -43,7 +42,6 @@ import org.mian.gitnex.fragments.ReleasesFragment;
|
||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -83,7 +81,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
|
||||
public static ViewPager mViewPager;
|
||||
private int tabsCount;
|
||||
|
||||
@Override
|
||||
@ -162,7 +159,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
}
|
||||
|
||||
// Only show collaborators tab, if you have permission to
|
||||
View collaboratorTab = viewGroup.getChildAt(7);
|
||||
View collaboratorTab = viewGroup.getChildAt(8);
|
||||
|
||||
if(tinyDB.getBoolean("isRepoAdmin") || new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
@ -175,7 +172,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
}
|
||||
|
||||
mViewPager = findViewById(R.id.container);
|
||||
ViewPager mViewPager = findViewById(R.id.container);
|
||||
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
@ -228,8 +225,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
if(textViewBadgeRelease.getText() != "") { // only show if API returned a number
|
||||
|
||||
Objects.requireNonNull(tabLayout.getTabAt(4)).setCustomView(tabHeader6);
|
||||
TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(4);
|
||||
Objects.requireNonNull(tabLayout.getTabAt(5)).setCustomView(tabHeader6);
|
||||
TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(5);
|
||||
assert tabOpenRelease != null; // FIXME This should be cleaned up
|
||||
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
|
||||
openReleaseTabView.setTextColor(textColor);
|
||||
@ -299,12 +296,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
chooseBranch();
|
||||
return true;
|
||||
|
||||
case R.id.branchCommits:
|
||||
Intent intent = new Intent(ctx, CommitsActivity.class);
|
||||
intent.putExtra("branchName", tinyDB.getString("repoBranch"));
|
||||
ctx.startActivity(intent);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
@ -354,14 +345,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
startActivity(Intent.createChooser(sharingIntent, tinyDB.getString("repoHtmlUrl")));
|
||||
break;
|
||||
|
||||
case "copyRepoUrl":
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", tinyDB.getString("repoHtmlUrl"));
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
break;
|
||||
|
||||
case "newFile":
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
|
||||
break;
|
||||
@ -402,14 +385,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
}
|
||||
break;
|
||||
|
||||
case "repoSettings":
|
||||
startActivity(new Intent(RepoDetailActivity.this, RepositorySettingsActivity.class));
|
||||
break;
|
||||
|
||||
case "newPullRequest":
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreatePullRequestActivity.class));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -457,7 +432,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
pBuilder.setNeutralButton(R.string.cancelButton, null);
|
||||
|
||||
pBuilder.create().show();
|
||||
|
||||
@ -503,17 +477,20 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
fragment = new PullRequestsFragment();
|
||||
break;
|
||||
|
||||
case 4: // Releases
|
||||
case 4: // Branches
|
||||
return BranchesFragment.newInstance(repositoryOwner, repositoryName);
|
||||
|
||||
case 5: // Releases
|
||||
return ReleasesFragment.newInstance(repositoryOwner, repositoryName);
|
||||
|
||||
case 5: // Milestones
|
||||
case 6: // Milestones
|
||||
fragment = new MilestonesFragment();
|
||||
break;
|
||||
|
||||
case 6: // Labels
|
||||
case 7: // Labels
|
||||
return LabelsFragment.newInstance(repositoryOwner, repositoryName);
|
||||
|
||||
case 7: // Collaborators
|
||||
case 8: // Collaborators
|
||||
return CollaboratorsFragment.newInstance(repositoryOwner, repositoryName);
|
||||
|
||||
}
|
||||
|
@ -1,296 +0,0 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.RepoForksAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class RepoForksActivity extends BaseActivity {
|
||||
|
||||
final Context ctx = this;
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView noData;
|
||||
private ProgressBar progressBar;
|
||||
private String TAG = "RepositoryForks";
|
||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||
private int pageSize = 1;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private List<UserRepositories> forksList;
|
||||
private RepoForksAdapter adapter;
|
||||
private ProgressBar progressLoadMore;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId() {
|
||||
|
||||
return R.layout.activity_forks;
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
String repoFullNameForForks = getIntent().getStringExtra("repoFullNameForForks");
|
||||
assert repoFullNameForForks != null;
|
||||
String[] parts = repoFullNameForForks.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
||||
toolbar_title.setMovementMethod(new ScrollingMovementMethod());
|
||||
toolbar_title.setText(String.format("%s : %s", ctx.getResources().getString(R.string.infoTabRepoForksCount), repoName));
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
noData = findViewById(R.id.noData);
|
||||
progressLoadMore = findViewById(R.id.progressLoadMore);
|
||||
progressBar = findViewById(R.id.progress_bar);
|
||||
SwipeRefreshLayout swipeRefresh = findViewById(R.id.pullToRefresh);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12")) {
|
||||
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
forksList = new ArrayList<>();
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
|
||||
adapter.notifyDataChanged();
|
||||
|
||||
}, 200));
|
||||
|
||||
adapter = new RepoForksAdapter(ctx, forksList);
|
||||
adapter.setLoadMoreListener(() -> recyclerView.post(() -> {
|
||||
|
||||
if(forksList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (forksList.size() + resultLimit) / resultLimit;
|
||||
loadMore(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, resultLimit);
|
||||
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
|
||||
|
||||
}
|
||||
|
||||
private void loadInitial(String instanceUrl, String instanceToken, String repoOwner, String repoName, int pageSize, int resultLimit) {
|
||||
|
||||
Call<List<UserRepositories>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getRepositoryForks(instanceToken, repoOwner, repoName, pageSize, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserRepositories>> call, @NonNull Response<List<UserRepositories>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
if(response.body().size() > 0) {
|
||||
|
||||
forksList.clear();
|
||||
forksList.addAll(response.body());
|
||||
adapter.notifyDataChanged();
|
||||
noData.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
forksList.clear();
|
||||
adapter.notifyDataChanged();
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void loadMore(String instanceUrl, String instanceToken, String repoOwner, String repoName, int page, int resultLimit) {
|
||||
|
||||
progressLoadMore.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<UserRepositories>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getRepositoryForks(instanceToken, repoOwner, repoName, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserRepositories>> call, @NonNull Response<List<UserRepositories>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
//remove loading view
|
||||
forksList.remove(forksList.size() - 1);
|
||||
|
||||
List<UserRepositories> result = response.body();
|
||||
|
||||
assert result != null;
|
||||
if(result.size() > 0) {
|
||||
|
||||
pageSize = result.size();
|
||||
forksList.addAll(result);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
adapter.setMoreDataAvailable(false);
|
||||
|
||||
}
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
progressLoadMore.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
filter(newText);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
|
||||
}
|
||||
|
||||
private void filter(String text) {
|
||||
|
||||
List<UserRepositories> arr = new ArrayList<>();
|
||||
|
||||
for(UserRepositories d : forksList) {
|
||||
if(d.getName().toLowerCase().contains(text) || d.getDescription().toLowerCase().contains(text)) {
|
||||
arr.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
adapter.updateList(arr);
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> {
|
||||
getIntent().removeExtra("repoFullNameForForks");
|
||||
finish();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -93,8 +93,12 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -93,8 +93,12 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,435 +0,0 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.databinding.ActivityRepositorySettingsBinding;
|
||||
import org.mian.gitnex.databinding.CustomRepositoryDeleteDialogBinding;
|
||||
import org.mian.gitnex.databinding.CustomRepositoryEditPropertiesDialogBinding;
|
||||
import org.mian.gitnex.databinding.CustomRepositoryTransferDialogBinding;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.RepositoryTransfer;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class RepositorySettingsActivity extends BaseActivity {
|
||||
|
||||
private ActivityRepositorySettingsBinding viewBinding;
|
||||
private CustomRepositoryEditPropertiesDialogBinding propBinding;
|
||||
private CustomRepositoryDeleteDialogBinding deleteRepoBinding;
|
||||
private CustomRepositoryTransferDialogBinding transferRepoBinding;
|
||||
private Dialog dialogProp;
|
||||
private Dialog dialogDeleteRepository;
|
||||
private Dialog dialogTransferRepository;
|
||||
private View.OnClickListener onClickListener;
|
||||
private Context ctx = this;
|
||||
private Context appCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_repository_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
tinyDb = new TinyDB(appCtx);
|
||||
|
||||
viewBinding = ActivityRepositorySettingsBinding.inflate(getLayoutInflater());
|
||||
View view = viewBinding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
repositoryOwner = parts[0];
|
||||
repositoryName = parts[1];
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
// require gitea 1.12 or higher
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
|
||||
viewBinding.transferOwnerFrame.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
viewBinding.editProperties.setOnClickListener(editProperties -> {
|
||||
showRepositoryProperties();
|
||||
});
|
||||
|
||||
viewBinding.deleteRepository.setOnClickListener(deleteRepository -> {
|
||||
showDeleteRepository();
|
||||
});
|
||||
|
||||
viewBinding.transferOwnerFrame.setOnClickListener(transferRepositoryOwnership -> {
|
||||
showTransferRepository();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void showTransferRepository() {
|
||||
|
||||
dialogTransferRepository = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||
|
||||
if (dialogTransferRepository.getWindow() != null) {
|
||||
|
||||
dialogTransferRepository.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
transferRepoBinding = CustomRepositoryTransferDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
|
||||
View view = transferRepoBinding.getRoot();
|
||||
dialogTransferRepository.setContentView(view);
|
||||
|
||||
transferRepoBinding.cancel.setOnClickListener(editProperties -> {
|
||||
dialogTransferRepository.dismiss();
|
||||
});
|
||||
|
||||
transferRepoBinding.transfer.setOnClickListener(deleteRepo -> {
|
||||
|
||||
String newOwner = String.valueOf(transferRepoBinding.ownerNameForTransfer.getText());
|
||||
String repoName = String.valueOf(transferRepoBinding.repoNameForTransfer.getText());
|
||||
|
||||
if(!repositoryName.equals(repoName)) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.repoSettingsDeleteError));
|
||||
}
|
||||
else if(newOwner.matches("")) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.repoTransferOwnerError));
|
||||
}
|
||||
else {
|
||||
|
||||
transferRepository(newOwner);
|
||||
}
|
||||
});
|
||||
|
||||
dialogTransferRepository.show();
|
||||
}
|
||||
|
||||
private void transferRepository(String newOwner) {
|
||||
|
||||
RepositoryTransfer repositoryTransfer = new RepositoryTransfer(newOwner);
|
||||
|
||||
Call<JsonElement> transferCall = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.transferRepository(instanceToken, repositoryOwner, repositoryName, repositoryTransfer);
|
||||
|
||||
transferCall.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
transferRepoBinding.transfer.setVisibility(View.GONE);
|
||||
transferRepoBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 202) {
|
||||
|
||||
dialogTransferRepository.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
||||
|
||||
finish();
|
||||
RepositoriesApi.deleteRepository((int) tinyDb.getLong("repositoryId", 0));
|
||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
}
|
||||
else if (response.code() == 404) {
|
||||
|
||||
transferRepoBinding.transfer.setVisibility(View.VISIBLE);
|
||||
transferRepoBinding.processingRequest.setVisibility(View.GONE);
|
||||
Toasty.error(ctx, getString(R.string.repoTransferError));
|
||||
}
|
||||
else {
|
||||
|
||||
transferRepoBinding.transfer.setVisibility(View.VISIBLE);
|
||||
transferRepoBinding.processingRequest.setVisibility(View.GONE);
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
transferRepoBinding.transfer.setVisibility(View.VISIBLE);
|
||||
transferRepoBinding.processingRequest.setVisibility(View.GONE);
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showDeleteRepository() {
|
||||
|
||||
dialogDeleteRepository = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||
|
||||
if (dialogDeleteRepository.getWindow() != null) {
|
||||
dialogDeleteRepository.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
deleteRepoBinding = CustomRepositoryDeleteDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
|
||||
View view = deleteRepoBinding.getRoot();
|
||||
dialogDeleteRepository.setContentView(view);
|
||||
|
||||
deleteRepoBinding.cancel.setOnClickListener(editProperties -> {
|
||||
dialogDeleteRepository.dismiss();
|
||||
});
|
||||
|
||||
deleteRepoBinding.delete.setOnClickListener(deleteRepo -> {
|
||||
|
||||
if(!repositoryName.equals(String.valueOf(deleteRepoBinding.repoNameForDeletion.getText()))) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.repoSettingsDeleteError));
|
||||
}
|
||||
else {
|
||||
|
||||
deleteRepository();
|
||||
}
|
||||
});
|
||||
|
||||
dialogDeleteRepository.show();
|
||||
}
|
||||
|
||||
private void deleteRepository() {
|
||||
|
||||
Call<JsonElement> deleteCall = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.deleteRepository(instanceToken, repositoryOwner, repositoryName);
|
||||
|
||||
deleteCall.enqueue(new Callback<JsonElement>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
deleteRepoBinding.delete.setVisibility(View.GONE);
|
||||
deleteRepoBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 204) {
|
||||
|
||||
dialogDeleteRepository.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
||||
|
||||
finish();
|
||||
RepositoriesApi.deleteRepository((int) tinyDb.getLong("repositoryId", 0));
|
||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
}
|
||||
else {
|
||||
|
||||
deleteRepoBinding.delete.setVisibility(View.VISIBLE);
|
||||
deleteRepoBinding.processingRequest.setVisibility(View.GONE);
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
deleteRepoBinding.delete.setVisibility(View.VISIBLE);
|
||||
deleteRepoBinding.processingRequest.setVisibility(View.GONE);
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showRepositoryProperties() {
|
||||
|
||||
dialogProp = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||
|
||||
if (dialogProp.getWindow() != null) {
|
||||
dialogProp.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
propBinding = CustomRepositoryEditPropertiesDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
|
||||
View view = propBinding.getRoot();
|
||||
dialogProp.setContentView(view);
|
||||
|
||||
propBinding.cancel.setOnClickListener(editProperties -> {
|
||||
dialogProp.dismiss();
|
||||
});
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getUserRepository(instanceToken, repositoryOwner, repositoryName);
|
||||
|
||||
call.enqueue(new Callback<UserRepositories>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
|
||||
UserRepositories repoInfo = response.body();
|
||||
|
||||
propBinding.progressBar.setVisibility(View.GONE);
|
||||
propBinding.mainView.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 200) {
|
||||
|
||||
assert repoInfo != null;
|
||||
propBinding.repoName.setText(repoInfo.getName());
|
||||
propBinding.repoWebsite.setText(repoInfo.getWebsite());
|
||||
propBinding.repoDescription.setText(repoInfo.getDescription());
|
||||
propBinding.repoPrivate.setChecked(repoInfo.getPrivateFlag());
|
||||
propBinding.repoAsTemplate.setChecked(repoInfo.isTemplate());
|
||||
|
||||
propBinding.repoEnableIssues.setChecked(repoInfo.getHas_issues());
|
||||
|
||||
propBinding.repoEnableIssues.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
if (isChecked) {
|
||||
propBinding.repoEnableTimer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
if(repoInfo.getInternal_tracker() != null) {
|
||||
propBinding.repoEnableTimer.setChecked(repoInfo.getInternal_tracker().isEnable_time_tracker());
|
||||
}
|
||||
else {
|
||||
propBinding.repoEnableTimer.setVisibility(View.GONE);
|
||||
}
|
||||
propBinding.repoEnableWiki.setChecked(repoInfo.isHas_wiki());
|
||||
propBinding.repoEnablePr.setChecked(repoInfo.isHas_pull_requests());
|
||||
propBinding.repoEnableMerge.setChecked(repoInfo.isAllow_merge_commits());
|
||||
propBinding.repoEnableRebase.setChecked(repoInfo.isAllow_rebase());
|
||||
propBinding.repoEnableSquash.setChecked(repoInfo.isAllow_squash_merge());
|
||||
propBinding.repoEnableForceMerge.setChecked(repoInfo.isAllow_rebase_explicit());
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
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()));
|
||||
|
||||
dialogProp.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) {
|
||||
|
||||
UserRepositories.internalTimeTrackerObject repoPropsTimeTracker = new UserRepositories.internalTimeTrackerObject(repoEnableTimer);
|
||||
|
||||
UserRepositories repoProps;
|
||||
if(!repoEnableIssues) {
|
||||
repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoEnableMerge,
|
||||
repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
|
||||
}
|
||||
else {
|
||||
repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoPropsTimeTracker, repoEnableMerge,
|
||||
repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
|
||||
}
|
||||
|
||||
Call<UserRepositories> propsCall = RetrofitClient
|
||||
.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.updateRepositoryProperties(instanceToken, repositoryOwner, repositoryName, repoProps);
|
||||
|
||||
propsCall.enqueue(new Callback<UserRepositories>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserRepositories> call, @NonNull retrofit2.Response<UserRepositories> response) {
|
||||
|
||||
propBinding.save.setVisibility(View.GONE);
|
||||
propBinding.processingRequest.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 200) {
|
||||
|
||||
tinyDb.putBoolean("hasIssues", repoEnableIssues);
|
||||
tinyDb.putBoolean("hasPullRequests", repoEnablePr);
|
||||
|
||||
dialogProp.dismiss();
|
||||
Toasty.success(ctx, getString(R.string.repoPropertiesSaveSuccess));
|
||||
|
||||
if(!repositoryName.equals(repoName)) {
|
||||
|
||||
finish();
|
||||
RepositoriesApi.updateRepositoryOwnerAndName(repositoryOwner, repoName, (int) tinyDb.getLong("repositoryId", 0));
|
||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||
RepositorySettingsActivity.this.startActivity(intent);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
propBinding.save.setVisibility(View.VISIBLE);
|
||||
propBinding.processingRequest.setVisibility(View.GONE);
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserRepositories> call, @NonNull Throwable t) {
|
||||
|
||||
propBinding.save.setVisibility(View.VISIBLE);
|
||||
propBinding.processingRequest.setVisibility(View.GONE);
|
||||
Toasty.error(ctx, getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
}
|
@ -11,7 +11,6 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -29,13 +28,12 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
private static int codeBlockSelectedChoice = 0;
|
||||
|
||||
private static String[] homeScreenList = {"My Repositories", "Starred Repositories", "Organizations", "Repositories", "Profile", "Explore", "Drafts"};
|
||||
private static String[] homeScreenListNew = {"My Repositories", "Starred Repositories", "Organizations", "Repositories", "Profile", "Explore", "Drafts", "Notifications"};
|
||||
private static int homeScreenSelectedChoice = 0;
|
||||
|
||||
private static String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
|
||||
private static int customFontSelectedChoice = 0;
|
||||
|
||||
private static String[] themeList = {"Dark", "Light", "Auto (Light / Dark)", "Retro", "Auto (Retro / Dark)"};
|
||||
private static String[] themeList = {"Dark", "Light", "Auto (Day/Night)"};
|
||||
private static int themeSelectedChoice = 0;
|
||||
|
||||
@Override
|
||||
@ -71,11 +69,6 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||
|
||||
homeScreenList = homeScreenListNew;
|
||||
}
|
||||
|
||||
if(!tinyDb.getString("timeStr").isEmpty()) {
|
||||
tvDateTimeSelected.setText(tinyDb.getString("timeStr"));
|
||||
}
|
||||
@ -128,11 +121,11 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
|
||||
if (isChecked) {
|
||||
tinyDb.putBoolean("enableCounterBadges", true);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
}
|
||||
else {
|
||||
tinyDb.putBoolean("enableCounterBadges", false);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
}
|
||||
|
||||
});
|
||||
@ -161,7 +154,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceTheme.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
@ -194,7 +187,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceCustomFont.dismiss();
|
||||
Toasty.success(appCtx, appCtx.getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, appCtx.getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
@ -224,7 +217,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
tinyDb.putInt("homeScreenId", i);
|
||||
|
||||
dialogInterfaceHomeScreen.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
@ -255,7 +248,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
|
||||
switch(codeBlockList[i]) {
|
||||
case "White - Black":
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorWhite));
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.white));
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
||||
break;
|
||||
case "Grey - Black":
|
||||
@ -263,12 +256,12 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.black));
|
||||
break;
|
||||
case "White - Grey":
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorWhite));
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.white));
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorAccent));
|
||||
break;
|
||||
case "Dark - White":
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorPrimary));
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.colorWhite));
|
||||
tinyDb.putInt("codeBlockBackground", getResources().getColor(R.color.white));
|
||||
break;
|
||||
default:
|
||||
tinyDb.putInt("codeBlockColor", getResources().getColor(R.color.colorLightGreen));
|
||||
@ -277,7 +270,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
dialogInterfaceCodeBlock.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
@ -314,7 +307,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
dialogInterfaceTime.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
@ -327,7 +320,9 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = view -> {
|
||||
finish();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ public class SettingsDraftsActivity extends BaseActivity {
|
||||
|
||||
if(isChecked) {
|
||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", true);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
}
|
||||
else {
|
||||
tinyDb.putBoolean("draftsCommentsDeletionEnabled", false);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -85,7 +85,7 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
||||
tinyDb.putInt("fileviewerSourceCodeThemeId", i);
|
||||
|
||||
dialogInterfaceTheme.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
@ -100,12 +100,12 @@ public class SettingsFileViewerActivity extends BaseActivity {
|
||||
if(isChecked) {
|
||||
tinyDb.putBoolean("enablePdfMode", true);
|
||||
tinyDb.putString("enablePdfModeInit", "yes");
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
}
|
||||
else {
|
||||
tinyDb.putBoolean("enablePdfMode", false);
|
||||
tinyDb.putString("enablePdfModeInit", "yes");
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -51,11 +51,11 @@ public class SettingsReportsActivity extends BaseActivity {
|
||||
|
||||
if(isChecked) {
|
||||
tinyDb.putBoolean("crashReportingEnabled", true);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
}
|
||||
else {
|
||||
tinyDb.putBoolean("crashReportingEnabled", false);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
}
|
||||
|
||||
});
|
||||
@ -63,7 +63,9 @@ public class SettingsReportsActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = view -> {
|
||||
finish();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
tinyDb.putInt("cacheSizeImagesId", i);
|
||||
|
||||
dialogInterfaceTheme.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
@ -185,7 +185,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
tinyDb.putInt("cacheSizeId", i);
|
||||
|
||||
dialogInterfaceTheme.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
@ -242,11 +242,11 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||
NotificationsMaster.hireWorker(ctx);
|
||||
|
||||
pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), numberPicker.getValue()));
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
builder.setNeutralButton(R.string.cancelButton, null);
|
||||
builder.setNegativeButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss());
|
||||
builder.setView(numberPicker);
|
||||
builder.create().show();
|
||||
|
||||
|
@ -22,8 +22,8 @@ public class SettingsTranslationActivity extends BaseActivity {
|
||||
private Context appCtx;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static String[] langList = {"English", "Arabic", "Chinese", "Czech", "Finnish", "French", "German", "Italian", "Latvian", "Persian",
|
||||
"Polish", "Portuguese/Brazilian", "Russian", "Serbian", "Spanish", "Turkish", "Ukrainian"};
|
||||
private static String[] langList = {"English", "Arabic", "Chinese", "Finnish", "French", "German", "Italian", "Latvian", "Persian", "Polish", "Portuguese/Brazilian", "Russian", "Serbian", "Spanish", "Turkish",
|
||||
"Ukrainian"};
|
||||
private static int langSelectedChoice = 0;
|
||||
|
||||
@Override
|
||||
@ -95,9 +95,6 @@ public class SettingsTranslationActivity extends BaseActivity {
|
||||
case "Chinese":
|
||||
tinyDb.putString("locale", "zh");
|
||||
break;
|
||||
case "Czech":
|
||||
tinyDb.putString("locale", "cs");
|
||||
break;
|
||||
case "Finnish":
|
||||
tinyDb.putString("locale", "fi");
|
||||
break;
|
||||
@ -146,11 +143,11 @@ public class SettingsTranslationActivity extends BaseActivity {
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterface.dismiss();
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
|
||||
lBuilder.setNeutralButton(getString(R.string.cancelButton), null);
|
||||
lBuilder.setNegativeButton(getString(R.string.cancelButton), (dialog, which) -> dialog.dismiss());
|
||||
|
||||
AlertDialog lDialog = lBuilder.create();
|
||||
lDialog.show();
|
||||
@ -160,8 +157,9 @@ public class SettingsTranslationActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
onClickListener = view -> {
|
||||
finish();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.SponsorsAdapter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class SponsorsActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
private Context appCtx;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
return R.layout.activity_sponsors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
Resources res = getResources();
|
||||
CharSequence[] sponsorsInfo = res.getTextArray(R.array.sponsorsInfo);
|
||||
|
||||
List<CharSequence> sponsorsList = new ArrayList<>(Arrays.asList(sponsorsInfo));
|
||||
|
||||
RecyclerView mRecyclerView = findViewById(R.id.recyclerView);
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(appCtx));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
SponsorsAdapter adapter = new SponsorsAdapter(sponsorsList);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -86,7 +86,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdap
|
||||
holder.userRole.setVisibility(View.VISIBLE);
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.textColor(mCtx.getResources().getColor(R.color.colorWhite))
|
||||
.textColor(mCtx.getResources().getColor(R.color.white))
|
||||
.fontSize(44)
|
||||
.width(180)
|
||||
.height(60)
|
||||
|
@ -0,0 +1,90 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CommitsActivity;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class BranchesAdapter extends RecyclerView.Adapter<BranchesAdapter.BranchesViewHolder> {
|
||||
|
||||
private List<Branches> branchesList;
|
||||
private Context mCtx;
|
||||
|
||||
static class BranchesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView branchNameTv;
|
||||
private TextView branchCommitAuthor;
|
||||
|
||||
private BranchesViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
branchNameTv = itemView.findViewById(R.id.branchName);
|
||||
branchCommitAuthor = itemView.findViewById(R.id.branchCommitAuthor);
|
||||
Button branchCommitHash = itemView.findViewById(R.id.branchCommitHash);
|
||||
|
||||
branchCommitHash.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
|
||||
Intent intent = new Intent(v.getContext(), CommitsActivity.class);
|
||||
intent.putExtra("branchName", String.valueOf(branchNameTv.getText()));
|
||||
Objects.requireNonNull(v.getContext()).startActivity(intent);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public BranchesAdapter(Context mCtx, List<Branches> branchesMain) {
|
||||
this.mCtx = mCtx;
|
||||
this.branchesList = branchesMain;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BranchesAdapter.BranchesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_branches, parent, false);
|
||||
return new BranchesAdapter.BranchesViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull BranchesAdapter.BranchesViewHolder holder, int position) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
||||
Branches currentItem = branchesList.get(position);
|
||||
holder.branchNameTv.setText(currentItem.getName());
|
||||
|
||||
if(currentItem.getCommit().getAuthor().getName() != null || !currentItem.getCommit().getAuthor().getName().equals("")) {
|
||||
holder.branchCommitAuthor.setText(mCtx.getResources().getString(R.string.commitAuthor, currentItem.getCommit().getAuthor().getName()));
|
||||
}
|
||||
else {
|
||||
holder.branchCommitAuthor.setText(mCtx.getResources().getString(R.string.commitAuthor, currentItem.getCommit().getAuthor().getUsername()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return branchesList.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -39,8 +38,6 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
private TextView issueType;
|
||||
private TextView repoOwner;
|
||||
private TextView repoName;
|
||||
private TextView commentId;
|
||||
private ImageView editCommentStatus;
|
||||
|
||||
private DraftsViewHolder(View itemView) {
|
||||
|
||||
@ -54,9 +51,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
issueType = itemView.findViewById(R.id.issueType);
|
||||
repoOwner = itemView.findViewById(R.id.repoOwner);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
commentId = itemView.findViewById(R.id.commentId);
|
||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
||||
|
||||
deleteDraft.setOnClickListener(itemDelete -> {
|
||||
|
||||
@ -74,12 +69,6 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
intent.putExtra("issueNumber", issueNumber.getText().toString());
|
||||
intent.putExtra("repositoryId", repoId.getText().toString());
|
||||
intent.putExtra("draftTitle", repoInfo.getText().toString());
|
||||
intent.putExtra("commentId", commentId.getText().toString());
|
||||
intent.putExtra("draftId", draftId.getText().toString());
|
||||
|
||||
if(!commentId.getText().toString().equalsIgnoreCase("")) {
|
||||
intent.putExtra("commentAction", "edit");
|
||||
}
|
||||
|
||||
TinyDB tinyDb = new TinyDB(mCtx);
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
@ -104,7 +93,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
draftsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, draftsList.size());
|
||||
Toasty.success(mCtx, mCtx.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
||||
Toasty.info(mCtx, mCtx.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
||||
|
||||
}
|
||||
|
||||
@ -128,18 +117,9 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
holder.repoOwner.setText(currentItem.getRepositoryOwner());
|
||||
holder.repoName.setText(currentItem.getRepositoryName());
|
||||
holder.draftText.setText(currentItem.getDraftText());
|
||||
holder.commentId.setText(currentItem.getCommentId());
|
||||
|
||||
String issueNumber = "<font color='" + mCtx.getResources().getColor(R.color.lightGray) + "'>" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||
Spanned headTitle = Html.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName());
|
||||
holder.repoInfo.setText(headTitle);
|
||||
|
||||
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
||||
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.editCommentStatus.setVisibility(View.GONE);
|
||||
}
|
||||
holder.repoInfo.setText(Html.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName()));
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -21,7 +19,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -34,7 +31,6 @@ import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -44,6 +40,7 @@ import retrofit2.Callback;
|
||||
|
||||
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> {
|
||||
|
||||
|
||||
private List<UserRepositories> searchedReposList;
|
||||
private Context mCtx;
|
||||
|
||||
@ -67,7 +64,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private TextView htmlUrl;
|
||||
|
||||
private ReposSearchViewHolder(View itemView) {
|
||||
|
||||
@ -86,7 +82,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -153,7 +148,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
|
||||
if(response.code() != 404) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
|
||||
@ -165,7 +160,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
});
|
||||
@ -185,8 +180,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||
@ -194,17 +187,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
repoCopyUrl.setOnClickListener(openInBrowser -> {
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
@ -232,15 +214,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
|
||||
});
|
||||
|
||||
repoForksList.setOnClickListener(forks -> {
|
||||
|
||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
||||
context.startActivity(intentW);
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@ -261,7 +234,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
UserRepositories currentItem = searchedReposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -286,13 +258,13 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullName());
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
@ -318,9 +290,4 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
return searchedReposList.size();
|
||||
}
|
||||
|
||||
public void notifyDataChanged() {
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,8 +37,6 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
class FilesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView fileTypeImage;
|
||||
private ImageView dirTypeImage;
|
||||
private ImageView unknownTypeImage;
|
||||
private TextView fileName;
|
||||
private TextView fileType;
|
||||
private TextView fileInfo;
|
||||
@ -48,8 +46,6 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
super(itemView);
|
||||
fileName = itemView.findViewById(R.id.fileName);
|
||||
fileTypeImage = itemView.findViewById(R.id.fileImage);
|
||||
dirTypeImage = itemView.findViewById(R.id.dirImage);
|
||||
unknownTypeImage = itemView.findViewById(R.id.unknownImage);
|
||||
fileType = itemView.findViewById(R.id.fileType);
|
||||
fileInfo = itemView.findViewById(R.id.fileInfo);
|
||||
|
||||
@ -66,7 +62,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
filesListener.onClickDir(fileName.getText().toString());
|
||||
}
|
||||
else {
|
||||
Toasty.warning(context, context.getString(R.string.filesGenericError));
|
||||
Toasty.info(context, context.getString(R.string.filesGenericError));
|
||||
}
|
||||
|
||||
});
|
||||
@ -161,22 +157,16 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
||||
holder.fileName.setText(currentItem.getName());
|
||||
|
||||
if(currentItem.getType().equals("file")) {
|
||||
holder.fileTypeImage.setVisibility(View.VISIBLE);
|
||||
holder.dirTypeImage.setVisibility(View.GONE);
|
||||
holder.unknownTypeImage.setVisibility(View.GONE);
|
||||
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_file));
|
||||
holder.fileInfo.setVisibility(View.VISIBLE);
|
||||
holder.fileInfo.setText(AppUtil.formatFileSizeInDetail(currentItem.getSize()));
|
||||
}
|
||||
else if(currentItem.getType().equals("dir")) {
|
||||
holder.dirTypeImage.setVisibility(View.VISIBLE);
|
||||
holder.unknownTypeImage.setVisibility(View.GONE);
|
||||
holder.fileTypeImage.setVisibility(View.GONE);
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_directory));
|
||||
}
|
||||
else {
|
||||
holder.unknownTypeImage.setVisibility(View.VISIBLE);
|
||||
holder.dirTypeImage.setVisibility(View.GONE);
|
||||
holder.fileTypeImage.setVisibility(View.GONE);
|
||||
holder.fileTypeImage.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_question));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -109,7 +109,6 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
TextView commentMenuQuote = view.findViewById(R.id.commentMenuQuote);
|
||||
TextView commentMenuCopy = view.findViewById(R.id.commentMenuCopy);
|
||||
TextView commentMenuDelete = view.findViewById(R.id.commentMenuDelete);
|
||||
TextView issueCommentCopyUrl = view.findViewById(R.id.issueCommentCopyUrl);
|
||||
|
||||
if(!loginUid.contentEquals(commenterUsername.getText())) {
|
||||
commentMenuEdit.setVisibility(View.GONE);
|
||||
@ -152,22 +151,6 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
|
||||
});
|
||||
|
||||
issueCommentCopyUrl.setOnClickListener(ediComment -> {
|
||||
|
||||
// comment Url
|
||||
CharSequence commentUrl = htmlUrl.getText();
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
assert clipboard != null;
|
||||
|
||||
ClipData clip = ClipData.newPlainText(commentUrl, commentUrl);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
dialog.dismiss();
|
||||
Toasty.success(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
|
||||
});
|
||||
|
||||
commentMenuQuote.setOnClickListener(v1 -> {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
@ -206,7 +189,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
dialog.dismiss();
|
||||
Toasty.success(ctx, ctx.getString(R.string.copyIssueCommentToastMsg));
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueCommentToastMsg));
|
||||
|
||||
});
|
||||
|
||||
@ -259,7 +242,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
if(response.code() == 204) {
|
||||
|
||||
updateAdapter(position);
|
||||
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
||||
Toasty.info(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
@ -272,17 +255,17 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
Toasty.info(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
Toasty.info(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,95 +0,0 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.models.Labels;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.LabelsViewHolder> {
|
||||
|
||||
private List<Labels> labels;
|
||||
private ArrayList<String> labelsStrings = new ArrayList<>();
|
||||
private ArrayList<Integer> labelsIds = new ArrayList<>();
|
||||
|
||||
private LabelsListAdapterListener labelsListener;
|
||||
|
||||
public interface LabelsListAdapterListener {
|
||||
|
||||
void labelsStringData(ArrayList<String> data);
|
||||
void labelsIdsData(ArrayList<Integer> data);
|
||||
}
|
||||
|
||||
public LabelsListAdapter(List<Labels> labelsMain, LabelsListAdapterListener labelsListener) {
|
||||
|
||||
this.labels = labelsMain;
|
||||
this.labelsListener = labelsListener;
|
||||
}
|
||||
|
||||
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private CheckBox labelSelection;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
labelSelection = itemView.findViewById(R.id.labelSelection);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LabelsListAdapter.LabelsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_labels_list, parent, false);
|
||||
return new LabelsListAdapter.LabelsViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LabelsListAdapter.LabelsViewHolder holder, int position) {
|
||||
|
||||
Labels currentItem = labels.get(position);
|
||||
|
||||
holder.labelSelection.setText(currentItem.getName());
|
||||
|
||||
for(int i = 0; i < labelsIds.size(); i++) {
|
||||
|
||||
if(labelsStrings.contains(currentItem.getName())) {
|
||||
|
||||
holder.labelSelection.setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
holder.labelSelection.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
|
||||
if(isChecked) {
|
||||
|
||||
labelsStrings.add(currentItem.getName());
|
||||
labelsIds.add(currentItem.getId());
|
||||
}
|
||||
else {
|
||||
|
||||
labelsStrings.remove(currentItem.getName());
|
||||
labelsIds.remove(Integer.valueOf(currentItem.getId()));
|
||||
}
|
||||
|
||||
labelsListener.labelsStringData(labelsStrings);
|
||||
labelsListener.labelsIdsData(labelsIds);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return labels.size();
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -23,7 +21,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
@ -37,7 +34,6 @@ import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -65,7 +61,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
private CheckBox isRepoAdmin;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private TextView htmlUrl;
|
||||
|
||||
private MyReposViewHolder(View itemView) {
|
||||
|
||||
@ -83,7 +78,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -151,7 +145,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
|
||||
if(response.code() != 404) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
|
||||
@ -163,7 +157,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
});
|
||||
@ -183,8 +177,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(String.format("%s / %s", repoFullName.getText().toString().split("/")[0], repoFullName.getText().toString().split("/")[1]));
|
||||
@ -192,17 +184,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
repoCopyUrl.setOnClickListener(openInBrowser -> {
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
@ -230,15 +211,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
|
||||
});
|
||||
|
||||
repoForksList.setOnClickListener(forks -> {
|
||||
|
||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||
intentW.putExtra("repoFullNameForForks", repoFullName.getText());
|
||||
context.startActivity(intentW);
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@ -266,7 +238,6 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -291,13 +262,13 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.repoFullName.setText(currentItem.getFullName());
|
||||
holder.repoFullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
@ -344,7 +315,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(UserRepositories item : reposListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
if(item.getFullname().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -44,9 +44,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
||||
private LinearLayout frame;
|
||||
private TextView subject;
|
||||
private TextView repository;
|
||||
private ImageView typePr;
|
||||
private ImageView typeIssue;
|
||||
private ImageView typeUnknown;
|
||||
private ImageView type;
|
||||
private ImageView pinned;
|
||||
private ImageView more;
|
||||
|
||||
@ -57,9 +55,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
||||
frame = itemView.findViewById(R.id.frame);
|
||||
subject = itemView.findViewById(R.id.subject);
|
||||
repository = itemView.findViewById(R.id.repository);
|
||||
typePr = itemView.findViewById(R.id.typePr);
|
||||
typeIssue = itemView.findViewById(R.id.typeIssue);
|
||||
typeUnknown = itemView.findViewById(R.id.typeUnknown);
|
||||
type = itemView.findViewById(R.id.type);
|
||||
pinned = itemView.findViewById(R.id.pinned);
|
||||
more = itemView.findViewById(R.id.more);
|
||||
|
||||
@ -85,7 +81,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
||||
.getString(R.string.hash) + url.substring(url.lastIndexOf("/") + 1) + "</font>";
|
||||
|
||||
holder.subject.setText(Html.fromHtml(subjectId + " " + notificationThread.getSubject().getTitle()));
|
||||
holder.repository.setText(notificationThread.getRepository().getFullName());
|
||||
holder.repository.setText(notificationThread.getRepository().getFullname());
|
||||
|
||||
if(notificationThread.isPinned()) {
|
||||
holder.pinned.setVisibility(View.VISIBLE);
|
||||
@ -97,21 +93,15 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
||||
switch(notificationThread.getSubject().getType()) {
|
||||
|
||||
case "Pull":
|
||||
holder.typePr.setVisibility(View.VISIBLE);
|
||||
holder.typeIssue.setVisibility(View.GONE);
|
||||
holder.typeUnknown.setVisibility(View.GONE);
|
||||
holder.type.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_pull_request, null));
|
||||
break;
|
||||
|
||||
case "Issue":
|
||||
holder.typePr.setVisibility(View.GONE);
|
||||
holder.typeIssue.setVisibility(View.VISIBLE);
|
||||
holder.typeUnknown.setVisibility(View.GONE);
|
||||
holder.type.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_issue, null));
|
||||
break;
|
||||
|
||||
default:
|
||||
holder.typePr.setVisibility(View.GONE);
|
||||
holder.typeIssue.setVisibility(View.GONE);
|
||||
holder.typeUnknown.setVisibility(View.VISIBLE);
|
||||
holder.type.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_question, null));
|
||||
break;
|
||||
|
||||
}
|
||||
@ -120,7 +110,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
||||
|
||||
onNotificationClickedListener.onNotificationClicked(notificationThread);
|
||||
|
||||
String[] parts = notificationThread.getRepository().getFullName().split("/");
|
||||
String[] parts = notificationThread.getRepository().getFullname().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class ProfileEmailsAdapter extends RecyclerView.Adapter<ProfileEmailsAdap
|
||||
if(currentItem.getPrimary()) {
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.textColor(mCtx.getResources().getColor(R.color.colorWhite))
|
||||
.textColor(mCtx.getResources().getColor(R.color.white))
|
||||
.fontSize(36)
|
||||
.width(220)
|
||||
.height(60)
|
||||
|
@ -1,396 +0,0 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private Context ctx;
|
||||
private final int TYPE_LOAD = 0;
|
||||
private List<UserRepositories> forksList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false;
|
||||
private boolean isMoreDataAvailable = true;
|
||||
|
||||
public RepoForksAdapter(Context ctx, List<UserRepositories> forksListMain) {
|
||||
|
||||
this.ctx = ctx;
|
||||
this.forksList = forksListMain;
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(ctx);
|
||||
|
||||
if(viewType == TYPE_LOAD) {
|
||||
return new RepoForksAdapter.ForksHolder(inflater.inflate(R.layout.list_repositories, parent, false));
|
||||
}
|
||||
else {
|
||||
return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
|
||||
}
|
||||
|
||||
if(getItemViewType(position) == TYPE_LOAD) {
|
||||
|
||||
((RepoForksAdapter.ForksHolder) holder).bindData(forksList.get(position));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
|
||||
if(forksList.get(position).getName() != null) {
|
||||
return TYPE_LOAD;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return forksList.size();
|
||||
|
||||
}
|
||||
|
||||
class ForksHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView image;
|
||||
private TextView repoName;
|
||||
private TextView repoDescription;
|
||||
private TextView fullName;
|
||||
private CheckBox isRepoAdmin;
|
||||
private ImageView repoPrivatePublic;
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private ImageView reposDropdownMenu;
|
||||
|
||||
ForksHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
fullName = itemView.findViewById(R.id.repoFullName);
|
||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
||||
repoStars = itemView.findViewById(R.id.repoStars);
|
||||
repoForks = itemView.findViewById(R.id.repoForks);
|
||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||
reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(UserRepositories forksModel) {
|
||||
|
||||
repoDescription.setVisibility(View.GONE);
|
||||
repoBranch.setText(forksModel.getDefault_branch());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(forksModel.getName());
|
||||
String firstCharacter = String.valueOf(forksModel.getName().charAt(0));
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28)
|
||||
.endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(forksModel.getAvatar_url() != null) {
|
||||
if(!forksModel.getAvatar_url().equals("")) {
|
||||
PicassoService.getInstance(ctx).get().load(forksModel.getAvatar_url()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(image);
|
||||
}
|
||||
else {
|
||||
image.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
image.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
repoName.setText(forksModel.getName());
|
||||
|
||||
if(!forksModel.getDescription().equals("")) {
|
||||
repoDescription.setVisibility(View.VISIBLE);
|
||||
repoDescription.setText(forksModel.getDescription());
|
||||
}
|
||||
fullName.setText(forksModel.getFullName());
|
||||
|
||||
if(forksModel.getPrivateFlag()) {
|
||||
repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
repoPrivatePublic.setVisibility(View.GONE);
|
||||
repoType.setText(R.string.strPublic);
|
||||
}
|
||||
|
||||
repoStars.setText(forksModel.getStars_count());
|
||||
repoForks.setText(forksModel.getForks_count());
|
||||
repoOpenIssuesCount.setText(forksModel.getOpen_issues_count());
|
||||
|
||||
if(isRepoAdmin == null) {
|
||||
isRepoAdmin = new CheckBox(ctx);
|
||||
}
|
||||
isRepoAdmin.setChecked(forksModel.getPermissions().isAdmin());
|
||||
|
||||
if(forksModel.isArchived()) {
|
||||
archiveRepo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
archiveRepo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
Context context = v.getContext();
|
||||
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
||||
TextView repoType_ = v.findViewById(R.id.repoType);
|
||||
|
||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||
//tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
||||
|
||||
String[] parts = repoFullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||
|
||||
WatchInfo watch = new WatchInfo();
|
||||
|
||||
Call<WatchInfo> call;
|
||||
|
||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<WatchInfo>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
|
||||
if(response.code() != 404) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
|
||||
});
|
||||
|
||||
reposDropdownMenu.setOnClickListener(v -> {
|
||||
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader
|
||||
.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
||||
context.startActivity(intentOpenInBrowser);
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
repoStargazers.setOnClickListener(stargazers -> {
|
||||
|
||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
||||
intent.putExtra("repoFullNameForStars", fullName.getText());
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
repoWatchers.setOnClickListener(watchers -> {
|
||||
|
||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
||||
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
||||
context.startActivity(intentW);
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
repoForksList.setOnClickListener(watchers -> {
|
||||
|
||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
||||
context.startActivity(intentW);
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class LoadHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
LoadHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
|
||||
}
|
||||
|
||||
public void notifyDataChanged() {
|
||||
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(RepoForksAdapter.OnLoadMoreListener loadMoreListener) {
|
||||
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
|
||||
}
|
||||
|
||||
public void updateList(List<UserRepositories> list) {
|
||||
|
||||
forksList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -25,7 +23,6 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
@ -37,7 +34,6 @@ import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -65,7 +61,6 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private TextView htmlUrl;
|
||||
|
||||
private ReposViewHolder(View itemView) {
|
||||
|
||||
@ -83,7 +78,6 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -152,7 +146,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
|
||||
if(response.code() != 404) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
|
||||
@ -164,7 +158,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
});
|
||||
@ -184,8 +178,6 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||
@ -193,17 +185,6 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
repoCopyUrl.setOnClickListener(openInBrowser -> {
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
@ -231,15 +212,6 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
|
||||
});
|
||||
|
||||
repoForksList.setOnClickListener(forks -> {
|
||||
|
||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
||||
context.startActivity(intentW);
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@ -267,7 +239,6 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -292,13 +263,13 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullName());
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
@ -344,7 +315,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(UserRepositories item : reposListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
if(item.getFullname().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -25,7 +23,6 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
@ -37,7 +34,6 @@ import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -65,7 +61,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private TextView htmlUrl;
|
||||
|
||||
private OrgReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -82,7 +77,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -147,7 +141,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
|
||||
if(response.code() != 404) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
|
||||
@ -159,7 +153,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||
|
||||
tinyDb.putBoolean("repoWatch", false);
|
||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||
|
||||
}
|
||||
});
|
||||
@ -179,8 +173,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||
@ -188,17 +180,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
repoCopyUrl.setOnClickListener(openInBrowser -> {
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
@ -208,7 +189,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
|
||||
});
|
||||
|
||||
repoStargazers.setOnClickListener(stargazers -> {
|
||||
repoStargazers.setOnClickListener(openInBrowser -> {
|
||||
|
||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
||||
intent.putExtra("repoFullNameForStars", fullName.getText());
|
||||
@ -217,7 +198,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
|
||||
});
|
||||
|
||||
repoWatchers.setOnClickListener(watchers -> {
|
||||
repoWatchers.setOnClickListener(openInBrowser -> {
|
||||
|
||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
||||
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
||||
@ -226,15 +207,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
|
||||
});
|
||||
|
||||
repoForksList.setOnClickListener(forks -> {
|
||||
|
||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
||||
context.startActivity(intentW);
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@ -260,7 +232,6 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -292,13 +263,13 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullName());
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
@ -340,7 +311,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (UserRepositories item : reposListFull) {
|
||||
if (item.getFullName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
if (item.getFullname().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -1,172 +0,0 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.helpers.ClickListener;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TimeHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapter.SearchViewHolder> {
|
||||
|
||||
private List<Issues> searchedList;
|
||||
private Context mCtx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
public SearchIssuesAdapter(List<Issues> dataList, Context mCtx) {
|
||||
|
||||
this.mCtx = mCtx;
|
||||
this.searchedList = dataList;
|
||||
this.tinyDb = new TinyDB(mCtx);
|
||||
}
|
||||
|
||||
class SearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView issueNumber;
|
||||
private ImageView issueAssigneeAvatar;
|
||||
private TextView issueTitle;
|
||||
private TextView issueCreatedTime;
|
||||
private TextView issueCommentsCount;
|
||||
private TextView repoFullName;
|
||||
|
||||
private SearchViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
issueNumber = itemView.findViewById(R.id.issueNumber);
|
||||
issueAssigneeAvatar = itemView.findViewById(R.id.assigneeAvatar);
|
||||
issueTitle = itemView.findViewById(R.id.issueTitle);
|
||||
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
||||
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
||||
repoFullName = itemView.findViewById(R.id.repoFullName);
|
||||
|
||||
issueTitle.setOnClickListener(v -> {
|
||||
|
||||
Context context = v.getContext();
|
||||
|
||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||
intent.putExtra("issueNumber", issueNumber.getText());
|
||||
|
||||
tinyDb.putString("issueNumber", issueNumber.getText().toString());
|
||||
tinyDb.putString("issueType", "Issue");
|
||||
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
|
||||
String[] parts = repoFullName.getText().toString().split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
|
||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||
|
||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
|
||||
if(count == 0) {
|
||||
|
||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", id);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||
|
||||
}
|
||||
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public SearchIssuesAdapter.SearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_issues, parent, false);
|
||||
return new SearchIssuesAdapter.SearchViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final SearchIssuesAdapter.SearchViewHolder holder, int position) {
|
||||
|
||||
Issues currentItem = searchedList.get(position);
|
||||
|
||||
String locale = tinyDb.getString("locale");
|
||||
String timeFormat = tinyDb.getString("dateFormat");
|
||||
|
||||
if(!currentItem.getUser().getFull_name().equals("")) {
|
||||
holder.issueAssigneeAvatar.setOnClickListener(new ClickListener(mCtx.getResources().getString(R.string.issueCreator) + currentItem.getUser().getFull_name(), mCtx));
|
||||
}
|
||||
else {
|
||||
holder.issueAssigneeAvatar.setOnClickListener(new ClickListener(mCtx.getResources().getString(R.string.issueCreator) + currentItem.getUser().getLogin(), mCtx));
|
||||
}
|
||||
|
||||
PicassoService
|
||||
.getInstance(mCtx).get().load(currentItem.getUser().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.issueAssigneeAvatar);
|
||||
|
||||
String issueNumber_ = "<font color='" + mCtx.getResources().getColor(R.color.lightGray) + "'>" + currentItem.getRepository().getFull_name() + mCtx.getResources().getString(R.string.hash) + currentItem.getNumber() + "</font>";
|
||||
holder.issueTitle.setText(Html.fromHtml(issueNumber_ + " " + currentItem.getTitle()));
|
||||
|
||||
holder.issueNumber.setText(String.valueOf(currentItem.getNumber()));
|
||||
holder.issueCommentsCount.setText(String.valueOf(currentItem.getComments()));
|
||||
holder.repoFullName.setText(currentItem.getRepository().getFull_name());
|
||||
|
||||
switch(timeFormat) {
|
||||
case "pretty": {
|
||||
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
||||
String createdTime = prettyTime.format(currentItem.getCreated_at());
|
||||
holder.issueCreatedTime.setText(createdTime);
|
||||
holder.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), mCtx));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + mCtx.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||
String createdTime = formatter.format(currentItem.getCreated_at());
|
||||
holder.issueCreatedTime.setText(createdTime);
|
||||
break;
|
||||
}
|
||||
case "normal1": {
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + mCtx.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||
String createdTime = formatter.format(currentItem.getCreated_at());
|
||||
holder.issueCreatedTime.setText(createdTime);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return searchedList.size();
|
||||
}
|
||||
|
||||
public void notifyDataChanged() {
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -25,7 +23,6 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.activities.RepoForksActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
@ -37,7 +34,6 @@ import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -65,7 +61,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
private TextView repoType;
|
||||
private LinearLayout archiveRepo;
|
||||
private TextView repoBranch;
|
||||
private TextView htmlUrl;
|
||||
|
||||
private StarredReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -82,7 +77,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
repoType = itemView.findViewById(R.id.repoType);
|
||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
|
||||
@ -182,8 +176,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||
|
||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||
@ -191,17 +183,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
repoCopyUrl.setOnClickListener(openInBrowser -> {
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||
|
||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||
@ -229,15 +210,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
|
||||
});
|
||||
|
||||
repoForksList.setOnClickListener(forks -> {
|
||||
|
||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
||||
context.startActivity(intentW);
|
||||
dialog.dismiss();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@ -263,7 +235,6 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -295,13 +266,13 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullName());
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||
holder.repoType.setText(R.string.strPrivate);
|
||||
}
|
||||
else {
|
||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_unlock);
|
||||
holder.repoType.setText(R.string.strPublic);
|
||||
}
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
@ -342,7 +313,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (UserRepositories item : reposListFull) {
|
||||
if (item.getFullName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
if (item.getFullname().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -9,11 +8,9 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
@ -31,15 +28,13 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
private Context mCtx;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
static class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView accountUrl;
|
||||
private TextView userId;
|
||||
private ImageView activeAccount;
|
||||
private ImageView deleteAccount;
|
||||
private ImageView repoAvatar;
|
||||
private TextView accountId;
|
||||
private TextView accountName;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
@ -50,46 +45,14 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
activeAccount = itemView.findViewById(R.id.activeAccount);
|
||||
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
||||
repoAvatar = itemView.findViewById(R.id.repoAvatar);
|
||||
accountId = itemView.findViewById(R.id.accountId);
|
||||
accountName = itemView.findViewById(R.id.accountName);
|
||||
|
||||
deleteAccount.setOnClickListener(itemDelete -> {
|
||||
|
||||
new AlertDialog.Builder(mCtx)
|
||||
.setIcon(mCtx.getDrawable(R.drawable.ic_delete))
|
||||
.setTitle(mCtx.getResources().getString(R.string.removeAccountPopupTitle))
|
||||
.setMessage(mCtx.getResources().getString(R.string.removeAccountPopupMessage))
|
||||
.setPositiveButton(mCtx.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||
|
||||
updateLayoutByPosition(getAdapterPosition());
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx);
|
||||
userAccountsApi.deleteAccount(Integer.parseInt(accountId.getText().toString()));
|
||||
}).setNeutralButton(mCtx.getResources().getString(R.string.cancelButton), null)
|
||||
.show();
|
||||
// use later to delete an account
|
||||
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(itemEdit -> {
|
||||
|
||||
String accountNameSwitch = accountName.getText().toString();
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx);
|
||||
UserAccount userAccount = userAccountsApi.getAccountData(accountNameSwitch);
|
||||
|
||||
if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) {
|
||||
|
||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
|
||||
tinyDB.putString("loginUid", userAccount.getUserName());
|
||||
tinyDB.putString("userLogin", userAccount.getUserName());
|
||||
tinyDB.putString(userAccount.getUserName() + "-token", userAccount.getToken());
|
||||
tinyDB.putString("instanceUrl", userAccount.getInstanceUrl());
|
||||
tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId());
|
||||
|
||||
Toasty.success(mCtx, mCtx.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
||||
((Activity) mCtx).recreate();
|
||||
}
|
||||
// use later to switch account
|
||||
|
||||
});
|
||||
|
||||
@ -103,12 +66,12 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
this.userAccountsList = userAccountsListMain;
|
||||
}
|
||||
|
||||
private void updateLayoutByPosition(int position) {
|
||||
private void deleteAccount(int position) {
|
||||
|
||||
userAccountsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, userAccountsList.size());
|
||||
Toasty.success(mCtx, mCtx.getResources().getString(R.string.accountDeletedMessage));
|
||||
Toasty.info(mCtx, mCtx.getResources().getString(R.string.accountDeletedMessage));
|
||||
|
||||
}
|
||||
|
||||
@ -131,8 +94,6 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
.withPath("/")
|
||||
.toString();
|
||||
|
||||
holder.accountId.setText(String.valueOf(currentItem.getAccountId()));
|
||||
holder.accountName.setText(currentItem.getAccountName());
|
||||
holder.userId.setText(String.format("@%s", currentItem.getUserName()));
|
||||
holder.accountUrl.setText(url);
|
||||
|
||||
@ -142,7 +103,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||
holder.activeAccount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.deleteAccount.setVisibility(View.VISIBLE);
|
||||
holder.deleteAccount.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,76 +0,0 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.List;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
|
||||
|
||||
private final Context mCtx;
|
||||
private final TinyDB tinyDB;
|
||||
private final List<UserAccount> userAccounts;
|
||||
|
||||
public UserAccountsListDialogAdapter(@NonNull Context mCtx, int resource, @NonNull List<UserAccount> userAccounts) {
|
||||
|
||||
super(mCtx, resource, userAccounts);
|
||||
|
||||
tinyDB = new TinyDB(mCtx);
|
||||
this.userAccounts = userAccounts;
|
||||
this.mCtx = mCtx;
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
|
||||
if(convertView == null) {
|
||||
convertView = LayoutInflater.from(mCtx).inflate(R.layout.custom_user_accounts_list, parent, false);
|
||||
}
|
||||
|
||||
ImageView profileImage = convertView.findViewById(R.id.profileImage);
|
||||
TextView userName = convertView.findViewById(R.id.userName);
|
||||
TextView accountUrl = convertView.findViewById(R.id.accountUrl);
|
||||
ImageView activeAccount = convertView.findViewById(R.id.activeAccount);
|
||||
|
||||
UserAccount currentItem = userAccounts.get(position);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
|
||||
userName.setText(currentItem.getUserName());
|
||||
accountUrl.setText(url);
|
||||
|
||||
if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) {
|
||||
activeAccount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
activeAccount.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
PicassoService
|
||||
.getInstance(mCtx).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(profileImage);
|
||||
|
||||
return convertView;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.fragments.UserAccountsFragment;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNavAdapter.UserAccountsViewHolder> {
|
||||
|
||||
private static DrawerLayout drawer;
|
||||
private List<UserAccount> userAccountsList;
|
||||
private Context mCtx;
|
||||
private TextView toolbarTitle;
|
||||
|
||||
public UserAccountsNavAdapter(Context mCtx, List<UserAccount> userAccountsListMain, DrawerLayout drawerLayout, TextView toolbarTitle) {
|
||||
|
||||
this.mCtx = mCtx;
|
||||
this.userAccountsList = userAccountsListMain;
|
||||
drawer = drawerLayout;
|
||||
this.toolbarTitle = toolbarTitle;
|
||||
}
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView userAccountAvatar;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
userAccountAvatar = itemView.findViewById(R.id.userAccountAvatar);
|
||||
|
||||
itemView.setOnClickListener(item -> {
|
||||
|
||||
customDialogUserAccountsList(userAccountsList);
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public UserAccountsNavAdapter.UserAccountsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.nav_user_accounts, parent, false);
|
||||
return new UserAccountsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull UserAccountsNavAdapter.UserAccountsViewHolder holder, int position) {
|
||||
|
||||
UserAccount currentItem = userAccountsList.get(position);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
|
||||
PicassoService
|
||||
.getInstance(mCtx).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAccountAvatar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return userAccountsList.size();
|
||||
}
|
||||
|
||||
private void customDialogUserAccountsList(List<UserAccount> allAccountsList) {
|
||||
|
||||
TinyDB tinyDB = new TinyDB(mCtx);
|
||||
Dialog dialog = new Dialog(mCtx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||
dialog.setContentView(R.layout.custom_user_accounts_dialog);
|
||||
|
||||
ListView listView = dialog.findViewById(R.id.accountsList);
|
||||
TextView manageAccounts = dialog.findViewById(R.id.manageAccounts);
|
||||
|
||||
if (dialog.getWindow() != null) {
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
manageAccounts.setOnClickListener(item -> {
|
||||
|
||||
toolbarTitle.setText(mCtx.getResources().getString(R.string.pageTitleUserAccounts));
|
||||
AppCompatActivity activity = (AppCompatActivity) mCtx;
|
||||
activity.getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new UserAccountsFragment()).commit();
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
UserAccountsListDialogAdapter arrayAdapter = new UserAccountsListDialogAdapter(mCtx, R.layout.custom_user_accounts_list, allAccountsList);
|
||||
listView.setAdapter(arrayAdapter);
|
||||
|
||||
listView.setOnItemClickListener((adapterView, view, which, l) -> {
|
||||
|
||||
String accountNameSwitch = allAccountsList.get(which).getAccountName();
|
||||
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx);
|
||||
UserAccount userAccount = userAccountsApi.getAccountData(accountNameSwitch);
|
||||
|
||||
if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) {
|
||||
|
||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
||||
.withPath("/")
|
||||
.toString();
|
||||
|
||||
tinyDB.putString("loginUid", userAccount.getUserName());
|
||||
tinyDB.putString("userLogin", userAccount.getUserName());
|
||||
tinyDB.putString(userAccount.getUserName() + "-token", userAccount.getToken());
|
||||
tinyDB.putString("instanceUrl", userAccount.getInstanceUrl());
|
||||
tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId());
|
||||
|
||||
Toasty.success(mCtx, mCtx.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
||||
((Activity) mCtx).recreate();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,7 @@ public class DraftsApi {
|
||||
draftsDao = db.draftsDao();
|
||||
}
|
||||
|
||||
public long insertDraft(int repositoryId, int draftAccountId, int issueId, String draftText, String draftType, String commentId) {
|
||||
public long insertDraft(int repositoryId, int draftAccountId, int issueId, String draftText, String draftType) {
|
||||
|
||||
Draft draft = new Draft();
|
||||
draft.setDraftRepositoryId(repositoryId);
|
||||
@ -35,7 +35,6 @@ public class DraftsApi {
|
||||
draft.setIssueId(issueId);
|
||||
draft.setDraftText(draftText);
|
||||
draft.setDraftType(draftType);
|
||||
draft.setCommentId(draftType);
|
||||
|
||||
return insertDraftAsyncTask(draft);
|
||||
}
|
||||
@ -72,11 +71,11 @@ public class DraftsApi {
|
||||
return draftId;
|
||||
}
|
||||
|
||||
public Integer checkDraft(int issueId, int draftRepositoryId, String commentId) {
|
||||
public Integer checkDraft(int issueId, int draftRepositoryId) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> checkDraftFlag = draftsDao.checkDraftDao(issueId, draftRepositoryId, commentId));
|
||||
Thread thread = new Thread(() -> checkDraftFlag = draftsDao.checkDraftDao(issueId, draftRepositoryId));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
@ -113,14 +112,14 @@ public class DraftsApi {
|
||||
new Thread(() -> draftsDao.deleteAllDrafts(accountId)).start();
|
||||
}
|
||||
|
||||
public static void updateDraft(final String draftText, final int draftId, final String commentId) {
|
||||
public static void updateDraft(final String draftText, final int draftId) {
|
||||
|
||||
new Thread(() -> draftsDao.updateDraft(draftText, draftId, commentId)).start();
|
||||
new Thread(() -> draftsDao.updateDraft(draftText, draftId)).start();
|
||||
}
|
||||
|
||||
public static void updateDraftByIssueIdAsyncTask(final String draftText, final int issueId, final int draftRepositoryId, final String commentId) {
|
||||
public static void updateDraftByIssueIdAsyncTask(final String draftText, final int issueId, final int draftRepositoryId) {
|
||||
|
||||
new Thread(() -> draftsDao.updateDraftByIssueId(draftText, issueId, draftRepositoryId, commentId)).start();
|
||||
new Thread(() -> draftsDao.updateDraftByIssueId(draftText, issueId, draftRepositoryId)).start();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -127,11 +127,6 @@ public class RepositoriesApi {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public static void updateRepositoryOwnerAndName(String repositoryOwner, String repositoryName, int repositoryId) {
|
||||
|
||||
new Thread(() -> repositoriesDao.updateRepositoryOwnerAndName(repositoryOwner, repositoryName, repositoryId)).start();
|
||||
}
|
||||
|
||||
public static void deleteRepositoriesByAccount(final int repoAccountId) {
|
||||
|
||||
new Thread(() -> repositoriesDao.deleteRepositoriesByAccount(repoAccountId)).start();
|
||||
|
@ -18,7 +18,6 @@ public class UserAccountsApi {
|
||||
private static UserAccountsDao userAccountsDao;
|
||||
private static UserAccount userAccount;
|
||||
private static Integer checkAccount;
|
||||
private static long accountId;
|
||||
|
||||
public UserAccountsApi(Context context) {
|
||||
|
||||
@ -27,7 +26,7 @@ public class UserAccountsApi {
|
||||
userAccountsDao = db.userAccountsDao();
|
||||
}
|
||||
|
||||
public long insertNewAccount(String accountName, String instanceUrl, String userName, String token, String serverVersion) {
|
||||
public void insertNewAccount(String accountName, String instanceUrl, String userName, String token, String serverVersion) {
|
||||
|
||||
UserAccount userAccount = new UserAccount();
|
||||
userAccount.setAccountName(accountName);
|
||||
@ -36,23 +35,12 @@ public class UserAccountsApi {
|
||||
userAccount.setToken(token);
|
||||
userAccount.setServerVersion(serverVersion);
|
||||
|
||||
return insertNewAccountAsync(userAccount);
|
||||
insertNewAccountAsync(userAccount);
|
||||
}
|
||||
|
||||
private static long insertNewAccountAsync(final UserAccount userAccount) {
|
||||
private static void insertNewAccountAsync(final UserAccount userAccount) {
|
||||
|
||||
try {
|
||||
|
||||
Thread thread = new Thread(() -> accountId = userAccountsDao.newAccount(userAccount));
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
|
||||
Log.e(StaticGlobalVariables.userAccountsRepository, e.toString());
|
||||
}
|
||||
|
||||
return accountId;
|
||||
new Thread(() -> userAccountsDao.newAccount(userAccount)).start();
|
||||
}
|
||||
|
||||
public static void updateServerVersion(final String serverVersion, final int accountId) {
|
||||
@ -60,16 +48,11 @@ public class UserAccountsApi {
|
||||
new Thread(() -> userAccountsDao.updateServerVersion(serverVersion, accountId)).start();
|
||||
}
|
||||
|
||||
public void updateToken(final int accountId, final String token) {
|
||||
public static void updateToken(final int accountId, final String token) {
|
||||
|
||||
new Thread(() -> userAccountsDao.updateAccountToken(accountId, token)).start();
|
||||
}
|
||||
|
||||
public void updateTokenByAccountName(final String accountName, final String token) {
|
||||
|
||||
new Thread(() -> userAccountsDao.updateAccountTokenByAccountName(accountName, token)).start();
|
||||
}
|
||||
|
||||
public UserAccount getAccountData(String accountName) {
|
||||
|
||||
try {
|
||||
@ -107,7 +90,7 @@ public class UserAccountsApi {
|
||||
return userAccountsDao.fetchAllAccounts();
|
||||
}
|
||||
|
||||
public void deleteAccount(final int accountId) {
|
||||
public static void deleteAccount(final int accountId) {
|
||||
|
||||
new Thread(() -> userAccountsDao.deleteAccount(accountId)).start();
|
||||
}
|
||||
|
@ -35,14 +35,14 @@ public interface DraftsDao {
|
||||
@Query("SELECT * FROM Drafts WHERE issueId = :issueId")
|
||||
LiveData<Draft> fetchDraftByIssueId(int issueId);
|
||||
|
||||
@Query("SELECT count(draftId) FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId AND commentId = :commentId")
|
||||
Integer checkDraftDao(int issueId, int draftRepositoryId, String commentId);
|
||||
@Query("SELECT count(draftId) FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||
Integer checkDraftDao(int issueId, int draftRepositoryId);
|
||||
|
||||
@Query("UPDATE Drafts SET draftText = :draftText, commentId = :commentId WHERE draftId = :draftId")
|
||||
void updateDraft(String draftText, int draftId, String commentId);
|
||||
@Query("UPDATE Drafts SET draftText= :draftText WHERE draftId = :draftId")
|
||||
void updateDraft(String draftText, int draftId);
|
||||
|
||||
@Query("UPDATE Drafts SET draftText = :draftText WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId AND commentId = :commentId")
|
||||
void updateDraftByIssueId(String draftText, int issueId, int draftRepositoryId, String commentId);
|
||||
@Query("UPDATE Drafts SET draftText= :draftText WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||
void updateDraftByIssueId(String draftText, int issueId, int draftRepositoryId);
|
||||
|
||||
@Query("SELECT draftId FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||
Integer getDraftId(int issueId, int draftRepositoryId);
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||
public interface UserAccountsDao {
|
||||
|
||||
@Insert
|
||||
long newAccount(UserAccount userAccounts);
|
||||
void newAccount(UserAccount userAccounts);
|
||||
|
||||
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
||||
LiveData<List<UserAccount>> fetchAllAccounts();
|
||||
@ -38,9 +38,6 @@ public interface UserAccountsDao {
|
||||
@Query("UPDATE UserAccounts SET token = :token WHERE accountId = :accountId")
|
||||
void updateAccountToken(int accountId, String token);
|
||||
|
||||
@Query("UPDATE UserAccounts SET token = :token WHERE accountName = :accountName")
|
||||
void updateAccountTokenByAccountName(String accountName, String token);
|
||||
|
||||
@Query("UPDATE UserAccounts SET instanceUrl = :instanceUrl, token = :token WHERE accountId = :accountId")
|
||||
void updateHostInfo(String instanceUrl, String token, int accountId);
|
||||
|
||||
|
@ -19,7 +19,7 @@ import org.mian.gitnex.database.models.UserAccount;
|
||||
*/
|
||||
|
||||
@Database(entities = {Draft.class, Repository.class, UserAccount.class},
|
||||
version = 2, exportSchema = false)
|
||||
version = 1, exportSchema = false)
|
||||
public abstract class GitnexDatabase extends RoomDatabase {
|
||||
|
||||
private static GitnexDatabase gitnexDatabase;
|
||||
@ -30,7 +30,7 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
||||
String DB_NAME = "gitnex";
|
||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||
//.fallbackToDestructiveMigration()
|
||||
.addMigrations(MIGRATION_1_2)
|
||||
//.addMigrations(MIGRATION_1_2)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
|
||||
//database.execSQL("DROP TABLE Drafts");
|
||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
||||
//database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'draftType' TEXT");
|
||||
|
||||
}
|
||||
};
|
||||
|
@ -24,8 +24,6 @@ public class Draft implements Serializable {
|
||||
private String draftText;
|
||||
@Nullable
|
||||
private String draftType;
|
||||
@Nullable
|
||||
private String commentId;
|
||||
|
||||
public int getDraftId() {
|
||||
|
||||
@ -88,15 +86,4 @@ public class Draft implements Serializable {
|
||||
this.draftType = draftType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCommentId() {
|
||||
|
||||
return commentId;
|
||||
}
|
||||
|
||||
public void setCommentId(@Nullable String commentId) {
|
||||
|
||||
this.commentId = commentId;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ public class DraftWithRepository {
|
||||
private int issueId;
|
||||
private String draftText;
|
||||
private String draftType;
|
||||
private String commentId;
|
||||
|
||||
public int getRepositoryId() {
|
||||
|
||||
@ -120,14 +119,4 @@ public class DraftWithRepository {
|
||||
this.draftType = draftType;
|
||||
}
|
||||
|
||||
public String getCommentId() {
|
||||
|
||||
return commentId;
|
||||
}
|
||||
|
||||
public void setCommentId(String commentId) {
|
||||
|
||||
this.commentId = commentId;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,13 +6,16 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.databinding.FragmentAboutBinding;
|
||||
import org.mian.gitnex.activities.CreditsActivity;
|
||||
import org.mian.gitnex.activities.SponsorsActivity;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -20,63 +23,99 @@ import org.mian.gitnex.helpers.TinyDB;
|
||||
|
||||
public class AboutFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_about, container, false);
|
||||
|
||||
FragmentAboutBinding viewBinding = FragmentAboutBinding.inflate(inflater, container, false);
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
|
||||
viewBinding.appVersion.setText(AppUtil.getAppVersion(requireContext()));
|
||||
viewBinding.userServerVersion.setText(tinyDb.getString("giteaVersion"));
|
||||
viewBinding.appBuild.setText(String.valueOf(AppUtil.getAppBuildNo(requireContext())));
|
||||
final TextView appVerBuild;
|
||||
final TextView donationLink;
|
||||
final TextView donationLinkPatreon;
|
||||
final TextView translateLink;
|
||||
final TextView creditsButton;
|
||||
final TextView sponsorsButton;
|
||||
final TextView appWebsite;
|
||||
final TextView appRepo;
|
||||
|
||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.pageTitleAbout));
|
||||
appVerBuild = v.findViewById(R.id.appVerBuild);
|
||||
TextView viewTextGiteaVersion = v.findViewById(R.id.giteaVersion);
|
||||
creditsButton = v.findViewById(R.id.creditsButton);
|
||||
donationLink = v.findViewById(R.id.donationLink);
|
||||
donationLinkPatreon = v.findViewById(R.id.donationLinkPatreon);
|
||||
translateLink = v.findViewById(R.id.translateLink);
|
||||
sponsorsButton = v.findViewById(R.id.sponsorsButton);
|
||||
appWebsite = v.findViewById(R.id.appWebsite);
|
||||
appRepo = v.findViewById(R.id.appRepo);
|
||||
|
||||
viewBinding.donationLinkLiberapay.setOnClickListener(v1 -> {
|
||||
appVerBuild.setText(getString(R.string.appVerBuild, AppUtil.getAppVersion(Objects.requireNonNull(getContext())), AppUtil.getAppBuildNo(getContext())));
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setData(Uri.parse(getResources().getString(R.string.supportLink)));
|
||||
startActivity(intent);
|
||||
donationLink.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setData(Uri.parse(getResources().getString(R.string.supportLink)));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
viewBinding.donationLinkPatreon.setOnClickListener(v12 -> {
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setData(Uri.parse(getResources().getString(R.string.supportLinkPatreon)));
|
||||
startActivity(intent);
|
||||
donationLinkPatreon.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setData(Uri.parse(getResources().getString(R.string.supportLinkPatreon)));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
viewBinding.translateLink.setOnClickListener(v13 -> {
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setData(Uri.parse(getResources().getString(R.string.crowdInLink)));
|
||||
startActivity(intent);
|
||||
translateLink.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setData(Uri.parse(getResources().getString(R.string.crowdInLink)));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
viewBinding.appWebsite.setOnClickListener(v14 -> {
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setData(Uri.parse(getResources().getString(R.string.appWebsiteLink)));
|
||||
startActivity(intent);
|
||||
appWebsite.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setData(Uri.parse(getResources().getString(R.string.appWebsiteLink)));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
if(AppUtil.isPro(requireContext())) {
|
||||
appRepo.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
intent.setData(Uri.parse(getResources().getString(R.string.appRepoLink)));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
viewBinding.supportHeader.setVisibility(View.GONE);
|
||||
viewBinding.dividerSupport.setVisibility(View.GONE);
|
||||
viewBinding.donationLinkLiberapay.setVisibility(View.GONE);
|
||||
viewBinding.donationLinkPatreon.setVisibility(View.GONE);
|
||||
}
|
||||
creditsButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getContext(), CreditsActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
return viewBinding.getRoot();
|
||||
sponsorsButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getContext(), SponsorsActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
String commit = getResources().getString(R.string.commitPage) + tinyDb.getString("giteaVersion");
|
||||
viewTextGiteaVersion.setText(commit);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,10 +26,12 @@ public class BottomSheetAdminUsersFragment extends BottomSheetDialogFragment {
|
||||
|
||||
TextView createNewUser = v.findViewById(R.id.createNewUser);
|
||||
|
||||
createNewUser.setOnClickListener(v1 -> {
|
||||
|
||||
bmListener.onButtonClicked("newUser");
|
||||
dismiss();
|
||||
createNewUser.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bmListener.onButtonClicked("newUser");
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return v;
|
||||
@ -45,9 +47,9 @@ public class BottomSheetAdminUsersFragment extends BottomSheetDialogFragment {
|
||||
|
||||
try {
|
||||
bmListener = (BottomSheetAdminUsersFragment.BottomSheetListener) context;
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(context.toString()
|
||||
+ " must implement BottomSheetListener");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,27 +26,15 @@ public class BottomSheetFileViewerFragment extends BottomSheetDialogFragment {
|
||||
View v = inflater.inflate(R.layout.bottom_sheet_file_viewer, container, false);
|
||||
|
||||
TextView downloadFile = v.findViewById(R.id.downloadFile);
|
||||
TextView deleteFile = v.findViewById(R.id.deleteFile);
|
||||
TextView editFile = v.findViewById(R.id.editFile);
|
||||
|
||||
downloadFile.setOnClickListener(v1 -> {
|
||||
|
||||
bmListener.onButtonClicked("downloadFile");
|
||||
dismiss();
|
||||
downloadFile.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bmListener.onButtonClicked("downloadFile");
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
deleteFile.setOnClickListener(v1 -> {
|
||||
|
||||
bmListener.onButtonClicked("deleteFile");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
editFile.setOnClickListener(v1 -> {
|
||||
|
||||
bmListener.onButtonClicked("editFile");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@ -59,12 +47,10 @@ public class BottomSheetFileViewerFragment extends BottomSheetDialogFragment {
|
||||
super.onAttach(context);
|
||||
|
||||
try {
|
||||
|
||||
bmListener = (BottomSheetFileViewerFragment.BottomSheetListener) context;
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
|
||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(context.toString()
|
||||
+ " must implement BottomSheetListener");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
|
||||
TextView createTeam = v.findViewById(R.id.createTeam);
|
||||
TextView createRepository = v.findViewById(R.id.createRepository);
|
||||
TextView copyOrgUrl = v.findViewById(R.id.copyOrgUrl);
|
||||
|
||||
createTeam.setOnClickListener(v1 -> {
|
||||
|
||||
@ -41,12 +40,6 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
copyOrgUrl.setOnClickListener(v1 -> {
|
||||
|
||||
bmListener.onButtonClicked("copyOrgUrl");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,12 @@ public class BottomSheetProfileFragment extends BottomSheetDialogFragment {
|
||||
|
||||
TextView addNewEmailAddress = v.findViewById(R.id.addNewEmailAddress);
|
||||
|
||||
addNewEmailAddress.setOnClickListener(v1 -> {
|
||||
|
||||
startActivity(new Intent(getContext(), ProfileEmailActivity.class));
|
||||
dismiss();
|
||||
addNewEmailAddress.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getContext(), ProfileEmailActivity.class));
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return v;
|
||||
|
@ -40,10 +40,6 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
TextView watchRepository = v.findViewById(R.id.watchRepository);
|
||||
TextView unWatchRepository = v.findViewById(R.id.unWatchRepository);
|
||||
TextView shareRepository = v.findViewById(R.id.shareRepository);
|
||||
TextView copyRepoUrl = v.findViewById(R.id.copyRepoUrl);
|
||||
View repoSettingsDivider = v.findViewById(R.id.repoSettingsDivider);
|
||||
TextView repoSettings = v.findViewById(R.id.repoSettings);
|
||||
TextView createPullRequest = v.findViewById(R.id.createPullRequest);
|
||||
|
||||
createLabel.setOnClickListener(v112 -> {
|
||||
|
||||
@ -52,7 +48,6 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
});
|
||||
|
||||
if(tinyDb.getBoolean("hasIssues")) {
|
||||
|
||||
createIssue.setVisibility(View.VISIBLE);
|
||||
createIssue.setOnClickListener(v12 -> {
|
||||
|
||||
@ -61,24 +56,9 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
createIssue.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(tinyDb.getBoolean("hasPullRequests")) {
|
||||
|
||||
createPullRequest.setVisibility(View.VISIBLE);
|
||||
createPullRequest.setOnClickListener(vPr -> {
|
||||
|
||||
bmListener.onButtonClicked("newPullRequest");
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
createPullRequest.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
createMilestone.setOnClickListener(v13 -> {
|
||||
|
||||
bmListener.onButtonClicked("newMilestone");
|
||||
@ -86,24 +66,13 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
});
|
||||
|
||||
if (tinyDb.getBoolean("isRepoAdmin")) {
|
||||
|
||||
repoSettings.setOnClickListener(repoSettingsView -> {
|
||||
|
||||
bmListener.onButtonClicked("repoSettings");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
addCollaborator.setOnClickListener(v1 -> {
|
||||
|
||||
bmListener.onButtonClicked("addCollaborator");
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
addCollaborator.setVisibility(View.GONE);
|
||||
repoSettingsDivider.setVisibility(View.GONE);
|
||||
repoSettings.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
createRelease.setOnClickListener(v14 -> {
|
||||
@ -124,12 +93,6 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
copyRepoUrl.setOnClickListener(copyUrl -> {
|
||||
|
||||
bmListener.onButtonClicked("copyRepoUrl");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
newFile.setOnClickListener(v17 -> {
|
||||
|
||||
bmListener.onButtonClicked("newFile");
|
||||
@ -199,9 +162,9 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
|
||||
try {
|
||||
bmListener = (BottomSheetListener) context;
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(context.toString()
|
||||
+ " must implement BottomSheetListener");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,14 @@ import org.mian.gitnex.activities.AddRemoveLabelsActivity;
|
||||
import org.mian.gitnex.activities.EditIssueActivity;
|
||||
import org.mian.gitnex.activities.FileDiffActivity;
|
||||
import org.mian.gitnex.activities.MergePullRequestActivity;
|
||||
import org.mian.gitnex.helpers.PathsHelper;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Objects;
|
||||
import io.mikael.urlbuilder.UrlBuilder;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -81,64 +85,117 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
||||
|
||||
}
|
||||
|
||||
mergePullRequest.setOnClickListener(v13 -> {
|
||||
mergePullRequest.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
startActivity(new Intent(ctx, MergePullRequestActivity.class));
|
||||
dismiss();
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(ctx, MergePullRequestActivity.class));
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
openFilesDiff.setOnClickListener(v14 -> {
|
||||
openFilesDiff.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
startActivity(new Intent(ctx, FileDiffActivity.class));
|
||||
dismiss();
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(ctx, FileDiffActivity.class));
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
editIssue.setOnClickListener(v15 -> {
|
||||
editIssue.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
startActivity(new Intent(ctx, EditIssueActivity.class));
|
||||
dismiss();
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(ctx, EditIssueActivity.class));
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
editLabels.setOnClickListener(v16 -> {
|
||||
editLabels.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
startActivity(new Intent(ctx, AddRemoveLabelsActivity.class));
|
||||
dismiss();
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(ctx, AddRemoveLabelsActivity.class));
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
addRemoveAssignees.setOnClickListener(v17 -> {
|
||||
addRemoveAssignees.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
startActivity(new Intent(ctx, AddRemoveAssigneesActivity.class));
|
||||
dismiss();
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(ctx, AddRemoveAssigneesActivity.class));
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
shareIssue.setOnClickListener(v1 -> {
|
||||
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle"));
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, tinyDB.getString("singleIssueHtmlUrl"));
|
||||
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle")));
|
||||
try {
|
||||
|
||||
dismiss();
|
||||
URI instanceUrl = new URI(tinyDB.getString("instanceUrlWithProtocol"));
|
||||
|
||||
String issuePath = PathsHelper.join(instanceUrl.getPath(), tinyDB.getString("repoFullName"), "/issues/", tinyDB.getString("issueNumber"));
|
||||
|
||||
String issueUrl = UrlBuilder.fromUri(instanceUrl)
|
||||
.withPath(issuePath)
|
||||
.toString();
|
||||
|
||||
// share issue
|
||||
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
sharingIntent.setType("text/plain");
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle"));
|
||||
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, issueUrl);
|
||||
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle")));
|
||||
|
||||
}
|
||||
catch(URISyntaxException e) {
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
finally {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
copyIssueUrl.setOnClickListener(v12 -> {
|
||||
|
||||
// copy to clipboard
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("issueUrl", tinyDB.getString("singleIssueHtmlUrl"));
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
try {
|
||||
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
URI instanceUrl = new URI(tinyDB.getString("instanceUrlWithProtocol"));
|
||||
|
||||
dismiss();
|
||||
String issuePath = PathsHelper.join(instanceUrl.getPath(), tinyDB.getString("repoFullName"), "/issues/", tinyDB.getString("issueNumber"));
|
||||
|
||||
String issueUrl = UrlBuilder.fromUri(instanceUrl)
|
||||
.withPath(issuePath)
|
||||
.toString();
|
||||
|
||||
// copy to clipboard
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("issueUrl", issueUrl);
|
||||
assert clipboard != null;
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Toasty.info(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
|
||||
|
||||
}
|
||||
catch(URISyntaxException e) {
|
||||
Toasty.error(ctx, getString(R.string.genericError));
|
||||
}
|
||||
finally {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@ -0,0 +1,149 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.BranchesAdapter;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.viewmodels.BranchesViewModel;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class BranchesFragment extends Fragment {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private BranchesAdapter adapter;
|
||||
private RecyclerView mRecyclerView;
|
||||
private TextView noDataBranches;
|
||||
private static String repoNameF = "param2";
|
||||
private static String repoOwnerF = "param1";
|
||||
|
||||
private String repoName;
|
||||
private String repoOwner;
|
||||
|
||||
private OnFragmentInteractionListener mListener;
|
||||
|
||||
public BranchesFragment() {
|
||||
}
|
||||
|
||||
public static BranchesFragment newInstance(String param1, String param2) {
|
||||
BranchesFragment fragment = new BranchesFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(repoOwnerF, param1);
|
||||
args.putString(repoNameF, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
repoName = getArguments().getString(repoNameF);
|
||||
repoOwner = getArguments().getString(repoOwnerF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_branches, container, false);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final String locale = tinyDb.getString("locale");
|
||||
final String timeFormat = tinyDb.getString("dateFormat");
|
||||
noDataBranches = v.findViewById(R.id.noDataBranches);
|
||||
|
||||
final SwipeRefreshLayout swipeRefresh = v.findViewById(R.id.pullToRefresh);
|
||||
|
||||
mRecyclerView = v.findViewById(R.id.recyclerView);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
BranchesViewModel.loadBranchesList(instanceUrl, instanceToken, repoOwner, repoName, getContext());
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public void onButtonPressed(Uri uri) {
|
||||
if (mListener != null) {
|
||||
mListener.onFragmentInteraction(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
public interface OnFragmentInteractionListener {
|
||||
void onFragmentInteraction(Uri uri);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String owner, String repo) {
|
||||
|
||||
BranchesViewModel branchesModel = new ViewModelProvider(this).get(BranchesViewModel.class);
|
||||
|
||||
branchesModel.getBranchesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Branches>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Branches> branchesListMain) {
|
||||
adapter = new BranchesAdapter(getContext(), branchesListMain);
|
||||
if(adapter.getItemCount() > 0) {
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noDataBranches.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
adapter.notifyDataSetChanged();
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noDataBranches.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -122,11 +122,11 @@ public class DraftsFragment extends Fragment {
|
||||
DraftsApi.deleteAllDrafts(accountId);
|
||||
draftsList_.clear();
|
||||
adapter.notifyDataSetChanged();
|
||||
Toasty.success(ctx, getResources().getString(R.string.draftsDeleteSuccess));
|
||||
Toasty.info(ctx, getResources().getString(R.string.draftsDeleteSuccess));
|
||||
|
||||
}
|
||||
else {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.draftsListEmpty));
|
||||
Toasty.error(ctx, getResources().getString(R.string.draftsListEmpty));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,129 +0,0 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class ExploreFragment extends Fragment {
|
||||
|
||||
private Context ctx;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
private int tabsCount;
|
||||
public ViewPager mViewPager;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_explore, container,false);
|
||||
ctx = getContext();
|
||||
tinyDB = new TinyDB(ctx);
|
||||
|
||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navExplore));
|
||||
|
||||
TabLayout tabLayout = v.findViewById(R.id.tabsExplore);
|
||||
|
||||
ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);
|
||||
tabsCount = viewGroup.getChildCount();
|
||||
|
||||
Typeface myTypeface;
|
||||
|
||||
switch(tinyDB.getInt("customFontId", -1)) {
|
||||
|
||||
case 0:
|
||||
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/roboto.ttf");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
|
||||
default:
|
||||
myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/manroperegular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
for(int j = 0; j < tabsCount; j++) {
|
||||
|
||||
ViewGroup vgTab = (ViewGroup) viewGroup.getChildAt(j);
|
||||
int tabChildCount = vgTab.getChildCount();
|
||||
|
||||
for(int i = 0; i < tabChildCount; i++) {
|
||||
|
||||
View tabViewChild = vgTab.getChildAt(i);
|
||||
|
||||
if(tabViewChild instanceof TextView) {
|
||||
((TextView) tabViewChild).setTypeface(myTypeface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mViewPager = v.findViewById(R.id.containerExplore);
|
||||
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
|
||||
SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
SectionsPagerAdapter(FragmentManager fm) {
|
||||
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
|
||||
Fragment fragment = null;
|
||||
|
||||
switch(position) {
|
||||
|
||||
case 0: // Repositories
|
||||
fragment = new ExploreRepositoriesFragment();
|
||||
break;
|
||||
|
||||
case 1: // Issues
|
||||
fragment = new SearchIssuesFragment();
|
||||
break;
|
||||
}
|
||||
|
||||
assert fragment != null;
|
||||
return fragment;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
|
||||
return tabsCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +1,28 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
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.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.ExploreRepositoriesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomExploreRepositoriesDialogBinding;
|
||||
import org.mian.gitnex.databinding.FragmentExploreRepoBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.InfiniteScrollListener;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.ExploreRepositories;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
@ -39,300 +30,194 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Template Author M M Arif
|
||||
* Author 6543
|
||||
* + * Template Author M M Arif
|
||||
* + * Author 6543
|
||||
* +
|
||||
*/
|
||||
|
||||
public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
private FragmentExploreRepoBinding viewBinding;
|
||||
private Context ctx;
|
||||
private TinyDB tinyDb;
|
||||
|
||||
private int pageCurrentIndex = 1;
|
||||
private boolean repoTypeInclude = true;
|
||||
private static String repoNameF = "param2";
|
||||
private static String repoOwnerF = "param1";
|
||||
private ProgressBar mProgressBar;
|
||||
private RecyclerView mRecyclerView;
|
||||
private TextView noData;
|
||||
private TextView searchKeyword;
|
||||
private Boolean repoTypeInclude = true;
|
||||
private String sort = "updated";
|
||||
private String order = "desc";
|
||||
private int limit = 10;
|
||||
private List<UserRepositories> dataList;
|
||||
private ExploreRepositoriesAdapter adapter;
|
||||
private int limit = 50;
|
||||
|
||||
private String instanceUrl;
|
||||
private String loginUid;
|
||||
private String instanceToken;
|
||||
private OnFragmentInteractionListener mListener;
|
||||
|
||||
private Dialog dialogFilterOptions;
|
||||
private CustomExploreRepositoriesDialogBinding filterBinding;
|
||||
public ExploreRepositoriesFragment() {
|
||||
|
||||
}
|
||||
|
||||
public static ExploreRepositoriesFragment newInstance(String param1, String param2) {
|
||||
|
||||
ExploreRepositoriesFragment fragment = new ExploreRepositoriesFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(repoOwnerF, param1);
|
||||
args.putString(repoNameF, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
if(getArguments() != null) {
|
||||
String repoName = getArguments().getString(repoNameF);
|
||||
String repoOwner = getArguments().getString(repoOwnerF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
viewBinding = FragmentExploreRepoBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
final View v = inflater.inflate(R.layout.fragment_explore_repo, container, false);
|
||||
//setHasOptionsMenu(true);
|
||||
|
||||
ctx = getContext();
|
||||
tinyDb = new TinyDB(getContext());
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
instanceUrl = tinyDb.getString("instanceUrl");
|
||||
loginUid = tinyDb.getString("loginUid");
|
||||
instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
searchKeyword = v.findViewById(R.id.searchKeyword);
|
||||
noData = v.findViewById(R.id.noData);
|
||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||
mRecyclerView = v.findViewById(R.id.recyclerViewReposSearch);
|
||||
|
||||
dataList = new ArrayList<>();
|
||||
adapter = new ExploreRepositoriesAdapter(dataList, ctx);
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
tinyDb.putBoolean("exploreRepoIncludeTopic", false);
|
||||
tinyDb.putBoolean("exploreRepoIncludeDescription", false);
|
||||
tinyDb.putBoolean("exploreRepoIncludeTemplate", false);
|
||||
tinyDb.putBoolean("exploreRepoOnlyArchived", false);
|
||||
|
||||
// if gitea is 1.12 or higher use the new limit
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
limit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(ctx);
|
||||
|
||||
viewBinding.recyclerViewReposSearch.setHasFixedSize(true);
|
||||
viewBinding.recyclerViewReposSearch.setLayoutManager(linearLayoutManager);
|
||||
viewBinding.recyclerViewReposSearch.setAdapter(adapter);
|
||||
|
||||
viewBinding.searchKeyword.setOnEditorActionListener((v1, actionId, event) -> {
|
||||
|
||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
|
||||
if(!Objects.requireNonNull(viewBinding.searchKeyword.getText()).toString().equals("")) {
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(viewBinding.searchKeyword.getWindowToken(), 0);
|
||||
|
||||
// if gitea is 1.12 or higher use the new limit
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
limit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
else {
|
||||
limit = 10;
|
||||
}
|
||||
|
||||
pageCurrentIndex = 1;
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadData(false, viewBinding.searchKeyword.getText().toString(), tinyDb.getBoolean("exploreRepoIncludeTopic"), tinyDb.getBoolean("exploreRepoIncludeDescription"), tinyDb.getBoolean("exploreRepoIncludeTemplate"), tinyDb.getBoolean("exploreRepoOnlyArchived"));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
viewBinding.recyclerViewReposSearch.addOnScrollListener(new InfiniteScrollListener(pageCurrentIndex, linearLayoutManager) {
|
||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
|
||||
@Override
|
||||
public void onScrolledToEnd(int firstVisibleItemPosition) {
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
|
||||
pageCurrentIndex++;
|
||||
loadData(true, Objects.requireNonNull(viewBinding.searchKeyword.getText()).toString(), tinyDb.getBoolean("exploreRepoIncludeTopic"), tinyDb.getBoolean("exploreRepoIncludeDescription"), tinyDb.getBoolean("exploreRepoIncludeTemplate"), tinyDb.getBoolean("exploreRepoOnlyArchived"));
|
||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(!searchKeyword.getText().toString().equals("")) {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
loadSearchReposList(instanceUrl, instanceToken, loginUid, searchKeyword.getText().toString(), repoTypeInclude, sort, order, getContext(), limit);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> {
|
||||
int limitDefault = 10;
|
||||
loadDefaultList(instanceUrl, instanceToken, loginUid, repoTypeInclude, sort, order, getContext(), limitDefault);
|
||||
|
||||
pageCurrentIndex = 1;
|
||||
|
||||
// if gitea is 1.12 or higher use the new limit
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
limit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
else {
|
||||
limit = 10;
|
||||
}
|
||||
|
||||
loadData(false, Objects.requireNonNull(viewBinding.searchKeyword.getText()).toString(), tinyDb.getBoolean("exploreRepoIncludeTopic"), tinyDb.getBoolean("exploreRepoIncludeDescription"), tinyDb.getBoolean("exploreRepoIncludeTemplate"), tinyDb.getBoolean("exploreRepoOnlyArchived"));
|
||||
});
|
||||
|
||||
loadData(false, "", tinyDb.getBoolean("exploreRepoIncludeTopic"), tinyDb.getBoolean("exploreRepoIncludeDescription"), tinyDb.getBoolean("exploreRepoIncludeTemplate"), tinyDb.getBoolean("exploreRepoOnlyArchived"));
|
||||
|
||||
return viewBinding.getRoot();
|
||||
return v;
|
||||
|
||||
}
|
||||
|
||||
private void loadData(boolean append, String searchKeyword, boolean exploreRepoIncludeTopic, boolean exploreRepoIncludeDescription, boolean exploreRepoIncludeTemplate, boolean exploreRepoOnlyArchived) {
|
||||
private void loadDefaultList(String instanceUrl, String instanceToken, String loginUid, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
||||
|
||||
viewBinding.noData.setVisibility(View.GONE);
|
||||
|
||||
int apiCallDefaultLimit = 10;
|
||||
// if gitea is 1.12 or higher use the new limit
|
||||
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
|
||||
apiCallDefaultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||
}
|
||||
|
||||
if(apiCallDefaultLimit > limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(pageCurrentIndex == 1 || !append) {
|
||||
|
||||
dataList.clear();
|
||||
adapter.notifyDataSetChanged();
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
|
||||
viewBinding.loadingMoreView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
Call<ExploreRepositories> call = RetrofitClient.getInstance(instanceUrl, getContext()).getApiInterface().queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order, exploreRepoIncludeTopic, exploreRepoIncludeDescription, exploreRepoIncludeTemplate, exploreRepoOnlyArchived, limit, pageCurrentIndex);
|
||||
Call<ExploreRepositories> call = RetrofitClient.getInstance(instanceUrl, getContext()).getApiInterface().queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), null, repoTypeInclude, sort, order, limit);
|
||||
|
||||
call.enqueue(new Callback<ExploreRepositories>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
|
||||
limit = response.body().getSearchedData().size();
|
||||
|
||||
if(!append) {
|
||||
|
||||
dataList.clear();
|
||||
}
|
||||
|
||||
dataList.addAll(response.body().getSearchedData());
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
getReposList(response.body().getSearchedData(), context);
|
||||
}
|
||||
else {
|
||||
|
||||
dataList.clear();
|
||||
adapter.notifyDataChanged();
|
||||
viewBinding.noData.setVisibility(View.VISIBLE);
|
||||
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
onCleanup();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", Objects.requireNonNull(t.getMessage()));
|
||||
onCleanup();
|
||||
|
||||
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
||||
}
|
||||
|
||||
private void onCleanup() {
|
||||
});
|
||||
|
||||
AppUtil.setMultiVisibility(View.GONE, viewBinding.loadingMoreView, viewBinding.progressBar);
|
||||
}
|
||||
|
||||
if(dataList.isEmpty()) {
|
||||
private void loadSearchReposList(String instanceUrl, String instanceToken, String loginUid, String searchKeyword, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
||||
|
||||
viewBinding.noData.setVisibility(View.VISIBLE);
|
||||
Call<ExploreRepositories> call = RetrofitClient.getInstance(instanceUrl, getContext()).getApiInterface().queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order, limit);
|
||||
|
||||
call.enqueue(new Callback<ExploreRepositories>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
getReposList(response.body().getSearchedData(), context);
|
||||
}
|
||||
else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||
|
||||
menu.clear();
|
||||
inflater.inflate(R.menu.filter_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
||||
}
|
||||
|
||||
MenuItem filter = menu.findItem(R.id.filter);
|
||||
|
||||
filter.setOnMenuItemClickListener(filter_ -> {
|
||||
|
||||
showFilterOptions();
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void showFilterOptions() {
|
||||
private void getReposList(List<UserRepositories> dataList, Context context) {
|
||||
|
||||
dialogFilterOptions = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||
ExploreRepositoriesAdapter adapter = new ExploreRepositoriesAdapter(dataList, context);
|
||||
|
||||
if (dialogFilterOptions.getWindow() != null) {
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
if(adapter.getItemCount() > 0) {
|
||||
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.GONE);
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
|
||||
dialogFilterOptions.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
filterBinding = CustomExploreRepositoriesDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
}
|
||||
|
||||
View view = filterBinding.getRoot();
|
||||
dialogFilterOptions.setContentView(view);
|
||||
public void onButtonPressed(Uri uri) {
|
||||
|
||||
filterBinding.includeTopic.setOnClickListener(includeTopic -> {
|
||||
|
||||
if(filterBinding.includeTopic.isChecked()) {
|
||||
|
||||
tinyDb.putBoolean("exploreRepoIncludeTopic", true);
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putBoolean("exploreRepoIncludeTopic", false);
|
||||
}
|
||||
});
|
||||
|
||||
filterBinding.includeDesc.setOnClickListener(includeDesc -> {
|
||||
|
||||
if(filterBinding.includeDesc.isChecked()) {
|
||||
|
||||
tinyDb.putBoolean("exploreRepoIncludeDescription", true);
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putBoolean("exploreRepoIncludeDescription", false);
|
||||
}
|
||||
});
|
||||
|
||||
filterBinding.includeTemplate.setOnClickListener(includeTemplate -> {
|
||||
|
||||
if(filterBinding.includeTemplate.isChecked()) {
|
||||
|
||||
tinyDb.putBoolean("exploreRepoIncludeTemplate", true);
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putBoolean("exploreRepoIncludeTemplate", false);
|
||||
}
|
||||
});
|
||||
|
||||
filterBinding.onlyArchived.setOnClickListener(onlyArchived -> {
|
||||
|
||||
if(filterBinding.onlyArchived.isChecked()) {
|
||||
|
||||
tinyDb.putBoolean("exploreRepoOnlyArchived", true);
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDb.putBoolean("exploreRepoOnlyArchived", false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
filterBinding.includeTopic.setChecked(tinyDb.getBoolean("exploreRepoIncludeTopic"));
|
||||
filterBinding.includeDesc.setChecked(tinyDb.getBoolean("exploreRepoIncludeDescription"));
|
||||
filterBinding.includeTemplate.setChecked(tinyDb.getBoolean("exploreRepoIncludeTemplate"));
|
||||
filterBinding.onlyArchived.setChecked(tinyDb.getBoolean("exploreRepoOnlyArchived"));
|
||||
|
||||
filterBinding.cancel.setOnClickListener(editProperties -> {
|
||||
dialogFilterOptions.dismiss();
|
||||
});
|
||||
|
||||
dialogFilterOptions.show();
|
||||
if(mListener != null) {
|
||||
mListener.onFragmentInteraction(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
public interface OnFragmentInteractionListener {
|
||||
|
||||
void onFragmentInteraction(Uri uri);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.FilesViewModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import moe.feng.common.view.breadcrumbs.BreadcrumbsView;
|
||||
import moe.feng.common.view.breadcrumbs.DefaultBreadcrumbsCallback;
|
||||
import moe.feng.common.view.breadcrumbs.model.BreadcrumbItem;
|
||||
@ -110,7 +111,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
mBreadcrumbsView = v.findViewById(R.id.breadcrumbs_view);
|
||||
mBreadcrumbsView.setItems(new ArrayList<>(Collections.singletonList(BreadcrumbItem.createSimpleItem(getResources().getString(R.string.filesBreadcrumbRoot) + getResources().getString(R.string.colonDivider) + ref))));
|
||||
|
||||
((RepoDetailActivity) requireActivity()).setFragmentRefreshListenerFiles(repoBranch -> {
|
||||
((RepoDetailActivity) Objects.requireNonNull(getActivity())).setFragmentRefreshListenerFiles(repoBranch -> {
|
||||
|
||||
fileStructure.setText("");
|
||||
ref = repoBranch;
|
||||
@ -197,7 +198,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
intent.putExtra("singleFileName", fileName);
|
||||
}
|
||||
|
||||
requireContext().startActivity(intent);
|
||||
Objects.requireNonNull(getContext()).startActivity(intent);
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String instanceUrl, String instanceToken, String owner, String repo, String ref) {
|
||||
@ -262,7 +263,6 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
menu.clear();
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
inflater.inflate(R.menu.files_switch_branches_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
@ -32,6 +32,7 @@ import org.mian.gitnex.interfaces.ApiInterface;
|
||||
import org.mian.gitnex.models.Issues;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -54,7 +55,6 @@ public class IssuesFragment extends Fragment {
|
||||
private TextView noDataIssues;
|
||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||
private String requestType = StaticGlobalVariables.issuesRequestType;
|
||||
private ProgressBar progressLoadMore;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@ -83,7 +83,6 @@ public class IssuesFragment extends Fragment {
|
||||
recyclerView = v.findViewById(R.id.recyclerView);
|
||||
issuesList = new ArrayList<>();
|
||||
|
||||
progressLoadMore = v.findViewById(R.id.progressLoadMore);
|
||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||
noDataIssues = v.findViewById(R.id.noDataIssues);
|
||||
|
||||
@ -111,7 +110,7 @@ public class IssuesFragment extends Fragment {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
((RepoDetailActivity) requireActivity()).setFragmentRefreshListener(issueState -> {
|
||||
((RepoDetailActivity) Objects.requireNonNull(getActivity())).setFragmentRefreshListener(issueState -> {
|
||||
|
||||
if(issueState.equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
@ -227,7 +226,9 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
private void loadMore(String token, String repoOwner, String repoName, int page, int resultLimit, String requestType, String issueState) {
|
||||
|
||||
progressLoadMore.setVisibility(View.VISIBLE);
|
||||
//add loading progress view
|
||||
issuesList.add(new Issues("load"));
|
||||
adapter.notifyItemInserted((issuesList.size() - 1));
|
||||
|
||||
Call<List<Issues>> call = api.getIssues(token, repoOwner, repoName, page, resultLimit, requestType, issueState);
|
||||
|
||||
@ -238,6 +239,9 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
//remove loading view
|
||||
issuesList.remove(issuesList.size() - 1);
|
||||
|
||||
List<Issues> result = response.body();
|
||||
|
||||
assert result != null;
|
||||
@ -249,13 +253,12 @@ public class IssuesFragment extends Fragment {
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.warning(context, getString(R.string.noMoreData));
|
||||
Toasty.info(context, getString(R.string.noMoreData));
|
||||
adapter.setMoreDataAvailable(false);
|
||||
|
||||
}
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
progressLoadMore.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -10,7 +10,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -40,7 +39,6 @@ public class MembersByOrgFragment extends Fragment {
|
||||
private String orgName;
|
||||
private MembersByOrgAdapter adapter;
|
||||
private GridView mGridView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
public MembersByOrgFragment() {
|
||||
}
|
||||
@ -74,7 +72,6 @@ public class MembersByOrgFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
noDataMembers = v.findViewById(R.id.noDataMembers);
|
||||
|
||||
progressBar = v.findViewById(R.id.progressBar);
|
||||
mGridView = v.findViewById(R.id.gridView);
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||
@ -99,8 +96,6 @@ public class MembersByOrgFragment extends Fragment {
|
||||
mGridView.setAdapter(adapter);
|
||||
noDataMembers.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -27,6 +27,7 @@ import org.mian.gitnex.interfaces.ApiInterface;
|
||||
import org.mian.gitnex.models.Milestones;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -103,7 +104,7 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
}, 50));
|
||||
|
||||
((RepoDetailActivity) requireActivity()).setFragmentRefreshListenerMilestone(milestoneState -> {
|
||||
((RepoDetailActivity) Objects.requireNonNull(getActivity())).setFragmentRefreshListenerMilestone(milestoneState -> {
|
||||
|
||||
if(milestoneState.equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
@ -218,7 +219,9 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
private void loadMore(String token, String repoOwner, String repoName, int page, int resultLimit, String milestoneState) {
|
||||
|
||||
viewBinding.progressLoadMore.setVisibility(View.VISIBLE);
|
||||
//add loading progress view
|
||||
dataList.add(new Milestones("load"));
|
||||
adapter.notifyItemInserted((dataList.size() - 1));
|
||||
|
||||
Call<List<Milestones>> call = api.getMilestones(token, repoOwner, repoName, page, resultLimit, milestoneState);
|
||||
|
||||
@ -248,7 +251,6 @@ public class MilestonesFragment extends Fragment {
|
||||
}
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
viewBinding.progressLoadMore.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -11,6 +11,7 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
@ -22,7 +23,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateRepoActivity;
|
||||
import org.mian.gitnex.adapters.MyReposListAdapter;
|
||||
@ -45,7 +45,7 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
private ProgressBar mProgressBar;
|
||||
private RecyclerView mRecyclerView;
|
||||
private MyReposListAdapter adapter;
|
||||
private ExtendedFloatingActionButton createNewRepo;
|
||||
private ImageView createNewRepo;
|
||||
private TextView noDataMyRepo;
|
||||
|
||||
private int pageSize = 1;
|
||||
@ -105,10 +105,15 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
createNewRepo = v.findViewById(R.id.addNewRepo);
|
||||
createNewRepo.setOnClickListener(view -> {
|
||||
createNewRepo.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
||||
startActivity(intent);
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@ -130,11 +135,18 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setRefreshing(false);
|
||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext(), pageSize, resultLimit);
|
||||
}, 50));
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext(), pageSize, resultLimit);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, pageSize, resultLimit);
|
||||
|
||||
|
@ -11,7 +11,9 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -19,7 +21,6 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.NotificationsActions;
|
||||
@ -28,14 +29,15 @@ import org.mian.gitnex.adapters.NotificationsAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.InfiniteScrollListener;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.NotificationThread;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -50,8 +52,9 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||
private NotificationsAdapter notificationsAdapter;
|
||||
private NotificationsActions notificationsActions;
|
||||
|
||||
private ExtendedFloatingActionButton markAllAsRead;
|
||||
private ImageView markAllAsRead;
|
||||
private ProgressBar progressBar;
|
||||
private RelativeLayout mainLayout;
|
||||
private ProgressBar loadingMoreView;
|
||||
private TextView noDataNotifications;
|
||||
private SwipeRefreshLayout pullToRefresh;
|
||||
@ -78,13 +81,14 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||
View v = inflater.inflate(R.layout.fragment_notifications, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
activity = requireActivity();
|
||||
activity = Objects.requireNonNull(getActivity());
|
||||
context = getContext();
|
||||
tinyDB = new TinyDB(context);
|
||||
|
||||
pageResultLimit = StaticGlobalVariables.getCurrentResultLimit(context);
|
||||
tinyDB.putString("notificationsFilterState", currentFilterMode);
|
||||
|
||||
mainLayout = v.findViewById(R.id.mainLayout);
|
||||
markAllAsRead = v.findViewById(R.id.markAllAsRead);
|
||||
noDataNotifications = v.findViewById(R.id.noDataNotifications);
|
||||
loadingMoreView = v.findViewById(R.id.loadingMoreView);
|
||||
@ -146,7 +150,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||
|
||||
activity.runOnUiThread(() -> {
|
||||
|
||||
Toasty.success(context, getString(R.string.markedNotificationsAsRead));
|
||||
SnackBar.info(context, mainLayout, getString(R.string.markedNotificationsAsRead));
|
||||
loadNotifications(true);
|
||||
|
||||
});
|
||||
@ -154,7 +158,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||
}
|
||||
catch(IOException e) {
|
||||
|
||||
activity.runOnUiThread(() -> Toasty.error(context, getString(R.string.genericError)));
|
||||
activity.runOnUiThread(() -> SnackBar.error(context, mainLayout, getString(R.string.genericError)));
|
||||
Log.e("onError", e.toString());
|
||||
|
||||
}
|
||||
@ -336,7 +340,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||
|
||||
tinyDB.putString("issueNumber", issueUrl.substring(issueUrl.lastIndexOf("/") + 1));
|
||||
tinyDB.putString("issueType", notificationThread.getSubject().getType());
|
||||
tinyDB.putString("repoFullName", notificationThread.getRepository().getFullName());
|
||||
tinyDB.putString("repoFullName", notificationThread.getRepository().getFullname());
|
||||
|
||||
startActivity(intent);
|
||||
|
||||
|
@ -10,6 +10,7 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
@ -21,7 +22,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateOrganizationActivity;
|
||||
import org.mian.gitnex.adapters.OrganizationsListAdapter;
|
||||
@ -42,7 +42,7 @@ public class OrganizationsFragment extends Fragment {
|
||||
private ProgressBar mProgressBar;
|
||||
private OrganizationsListAdapter adapter;
|
||||
private RecyclerView mRecyclerView;
|
||||
private ExtendedFloatingActionButton createNewOrganization;
|
||||
private ImageView createNewOrganization;
|
||||
private TextView noDataOrg;
|
||||
|
||||
@Nullable
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user