Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
f448e3dcad | |||
d448a06d95 | |||
b6950e5238 | |||
17a4958a65 |
@ -24,7 +24,6 @@ Option 1 - Download the source code, open it in Android Studio and build it ther
|
||||
Option 2 - Open terminal(Linux) and cd to the project dir. Run `./gradlew build`.
|
||||
|
||||
## Features
|
||||
- Multiple accounts support
|
||||
- Repositories / issues/ org list
|
||||
- File and directory browser
|
||||
- File viewer
|
||||
@ -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)
|
||||
|
@ -6,8 +6,8 @@ android {
|
||||
applicationId "org.mian.gitnex"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 311
|
||||
versionName "3.1.1"
|
||||
versionCode 301
|
||||
versionName "3.0.1"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildFeatures {
|
||||
@ -28,9 +28,6 @@ android {
|
||||
targetCompatibility = "8"
|
||||
sourceCompatibility = "8"
|
||||
}
|
||||
defaultConfig{
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@ -39,14 +36,14 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def lifecycle_version = "2.3.0-alpha06"
|
||||
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-alpha01"
|
||||
implementation "com.google.android.material:material:1.3.0-alpha02"
|
||||
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"
|
||||
@ -84,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,8 +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" />
|
||||
|
||||
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
|
||||
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
|
||||
|
@ -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));
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,269 +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}
|
||||
|
||||
@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<AddNewAccountActivity.Protocol> adapterProtocols = new ArrayAdapter<>(AddNewAccountActivity.this, R.layout.spinner_item, AddNewAccountActivity.Protocol.values());
|
||||
adapterProtocols.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
||||
|
||||
viewBinding.protocolSpinner.setAdapter(adapterProtocols);
|
||||
|
||||
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 = viewBinding.instanceUrl.getText().toString();
|
||||
String loginToken = viewBinding.loginToken.getText().toString();
|
||||
Protocol protocol = (Protocol) viewBinding.protocolSpinner.getSelectedItem();
|
||||
|
||||
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 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();
|
||||
|
||||
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(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();
|
||||
Version giteaVersion;
|
||||
|
||||
assert version != null;
|
||||
|
||||
tinyDB.putString("giteaVersion", version.getVersion());
|
||||
|
||||
try {
|
||||
giteaVersion = new Version(version.getVersion());
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
//enableProcessButton();
|
||||
});
|
||||
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
|
@ -51,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;
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
@ -303,83 +248,12 @@ public class CreateFileActivity extends BaseActivity {
|
||||
else {
|
||||
|
||||
if(response.code() == 404) {
|
||||
enableProcessButton();
|
||||
Toasty.warning(ctx, getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
enableProcessButton();
|
||||
Toasty.error(ctx, getString(R.string.orgCreatedError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
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));
|
||||
Toasty.info(ctx, getString(R.string.orgCreatedError));
|
||||
}
|
||||
|
||||
}
|
||||
@ -388,79 +262,6 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
@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();
|
||||
}
|
||||
@ -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;
|
||||
@ -125,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);
|
||||
@ -135,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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -167,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;
|
||||
|
||||
}*/
|
||||
@ -291,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();
|
||||
|
||||
@ -309,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()));
|
||||
|
||||
@ -327,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) {
|
||||
@ -529,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) {
|
||||
@ -537,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) {
|
||||
@ -569,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,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,7 +98,9 @@ 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);
|
||||
|
||||
@ -108,44 +111,44 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
else {
|
||||
pBuilder.setCancelable(false);
|
||||
}
|
||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
|
||||
permissionSelectedChoice = i;
|
||||
teamPermission.setText(permissionList[i]);
|
||||
|
||||
switch(permissionList[i]) {
|
||||
case "Read":
|
||||
|
||||
if(permissionList[i].equals("Read")) {
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionRead);
|
||||
break;
|
||||
case "Write":
|
||||
|
||||
}
|
||||
else if(permissionList[i].equals("Write")) {
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionWrite);
|
||||
break;
|
||||
case "Admin":
|
||||
|
||||
}
|
||||
else if(permissionList[i].equals("Admin")) {
|
||||
teamPermissionDetail.setVisibility(View.VISIBLE);
|
||||
teamPermissionDetail.setText(R.string.newTeamPermissionAdmin);
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
else {
|
||||
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("");
|
||||
@ -153,12 +156,20 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
AlertDialog.Builder aDialogBuilder = new AlertDialog.Builder(ctx);
|
||||
|
||||
aDialogBuilder.setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, (dialog, which, isChecked) -> {
|
||||
aDialogBuilder.setMultiChoiceItems(accessControlsList, selectedAccessControlsTrueFalse, new DialogInterface.OnMultiChoiceClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
.setCancelable(false)
|
||||
.setTitle(R.string.newTeamAccessControls)
|
||||
.setPositiveButton(R.string.okButton, (dialog, which) -> {
|
||||
.setPositiveButton(R.string.okButton, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
int selectedVal = 0;
|
||||
while(selectedVal < selectedAccessControlsTrueFalse.length)
|
||||
@ -207,10 +218,14 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
//Log.i("orgName", String.valueOf(teamAccessControlsArray.getText()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
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() {
|
||||
|
||||
@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,6 +340,8 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
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) {
|
||||
|
||||
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,7 +96,7 @@ 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;
|
||||
@ -398,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));
|
||||
}
|
||||
});
|
||||
|
||||
@ -180,7 +184,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
if(instanceUrlET.getText().toString().equals("")) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.emptyFieldURL));
|
||||
SnackBar.warning(ctx, layoutView, getResources().getString(R.string.emptyFieldURL));
|
||||
enableProcessButton();
|
||||
return;
|
||||
|
||||
@ -190,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;
|
||||
|
||||
@ -205,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;
|
||||
|
||||
@ -213,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;
|
||||
|
||||
@ -229,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;
|
||||
|
||||
@ -243,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();
|
||||
|
||||
}
|
||||
@ -280,14 +292,12 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
assert version != null;
|
||||
|
||||
tinyDB.putString("giteaVersion", version.getVersion());
|
||||
|
||||
try {
|
||||
gitea_version = new Version(version.getVersion());
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.versionUnknown));
|
||||
SnackBar.error(ctx, layoutView, getResources().getString(R.string.versionUnknown));
|
||||
enableProcessButton();
|
||||
return;
|
||||
}
|
||||
@ -319,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);
|
||||
|
||||
}
|
||||
@ -348,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();
|
||||
}
|
||||
});
|
||||
@ -378,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();
|
||||
@ -398,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();
|
||||
|
||||
}
|
||||
@ -414,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();
|
||||
|
||||
}
|
||||
@ -474,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();
|
||||
|
||||
}
|
||||
@ -484,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();
|
||||
|
||||
}
|
||||
@ -497,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();
|
||||
|
||||
}
|
||||
@ -507,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();
|
||||
|
||||
}
|
||||
@ -568,18 +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.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());
|
||||
userAccountsApi
|
||||
.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), newToken.getSha1(), "");
|
||||
}
|
||||
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
@ -587,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();
|
||||
|
||||
}
|
||||
@ -603,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();
|
||||
|
||||
}
|
||||
@ -612,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();
|
||||
|
||||
}
|
||||
@ -661,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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,16 +18,13 @@ 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;
|
||||
@ -56,8 +53,6 @@ import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.GiteaVersion;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import eightbitlab.com.blurview.BlurView;
|
||||
import eightbitlab.com.blurview.RenderScriptBlur;
|
||||
@ -128,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);
|
||||
@ -204,13 +198,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
@Override
|
||||
public void onDrawerOpened(@NonNull View drawerView) {
|
||||
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -225,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);
|
||||
}
|
||||
@ -298,12 +272,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
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) {}
|
||||
|
||||
@ -312,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);
|
||||
|
||||
@ -338,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:
|
||||
@ -384,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();
|
||||
@ -402,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);
|
||||
@ -454,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();
|
||||
|
||||
})
|
||||
.setNeutralButton(R.string.cancelButton, null).show();
|
||||
}).setNegativeButton(R.string.cancelButton, (dialog, which) -> dialog.dismiss()).show();
|
||||
|
||||
}
|
||||
else {
|
||||
@ -481,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() {
|
||||
|
||||
@ -690,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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
@ -44,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;
|
||||
@ -84,7 +81,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
private String repositoryOwner;
|
||||
private String repositoryName;
|
||||
|
||||
public static ViewPager mViewPager;
|
||||
private int tabsCount;
|
||||
|
||||
@Override
|
||||
@ -176,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));
|
||||
@ -349,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;
|
||||
@ -444,7 +432,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
pBuilder.setNeutralButton(R.string.cancelButton, null);
|
||||
|
||||
pBuilder.create().show();
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -143,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();
|
||||
@ -157,7 +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)
|
||||
|
@ -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());
|
||||
@ -292,7 +264,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
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());
|
||||
|
@ -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,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());
|
||||
@ -297,7 +268,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
||||
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());
|
||||
|
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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());
|
||||
@ -298,7 +269,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
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());
|
||||
|
@ -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());
|
||||
@ -298,7 +269,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
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());
|
||||
|
@ -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());
|
||||
@ -301,7 +272,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
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());
|
||||
|
@ -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,72 +0,0 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.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 List<UserAccount> userAccountsList;
|
||||
|
||||
public UserAccountsListDialogAdapter(@NonNull Context mCtx, int resource, @NonNull List<UserAccount> objects) {
|
||||
|
||||
super(mCtx, resource, objects);
|
||||
userAccountsList = objects;
|
||||
this.mCtx = mCtx;
|
||||
}
|
||||
|
||||
@SuppressLint("ViewHolder")
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) mCtx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
assert inflater != null;
|
||||
View rowView = inflater.inflate(R.layout.custom_user_accounts_list, parent, false);
|
||||
|
||||
TinyDB tinyDB = new TinyDB(mCtx);
|
||||
|
||||
ImageView profileImage = rowView.findViewById(R.id.profileImage);
|
||||
TextView userName = rowView.findViewById(R.id.userName);
|
||||
TextView accountUrl = rowView.findViewById(R.id.accountUrl);
|
||||
ImageView activeAccount = rowView.findViewById(R.id.activeAccount);
|
||||
|
||||
UserAccount currentItem = userAccountsList.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);
|
||||
}
|
||||
|
||||
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 rowView;
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreditsActivity;
|
||||
import org.mian.gitnex.activities.SponsorsActivity;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import java.util.Objects;
|
||||
@ -31,62 +33,83 @@ public class AboutFragment extends Fragment {
|
||||
final TextView donationLink;
|
||||
final TextView donationLinkPatreon;
|
||||
final TextView translateLink;
|
||||
final TextView creditsButton;
|
||||
final TextView sponsorsButton;
|
||||
final TextView appWebsite;
|
||||
final TextView appRepo;
|
||||
|
||||
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);
|
||||
|
||||
appVerBuild.setText(getString(R.string.appVerBuild, AppUtil.getAppVersion(Objects.requireNonNull(getContext())), AppUtil.getAppBuildNo(getContext())));
|
||||
|
||||
donationLink.setOnClickListener(v1 -> {
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
donationLinkPatreon.setOnClickListener(v12 -> {
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
translateLink.setOnClickListener(v13 -> {
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
appWebsite.setOnClickListener(v14 -> {
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
appRepo.setOnClickListener(v15 -> {
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
creditsButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getContext(), CreditsActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
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");
|
||||
|
@ -26,10 +26,12 @@ public class BottomSheetAdminUsersFragment extends BottomSheetDialogFragment {
|
||||
|
||||
TextView createNewUser = v.findViewById(R.id.createNewUser);
|
||||
|
||||
createNewUser.setOnClickListener(v1 -> {
|
||||
|
||||
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,25 +26,13 @@ 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 -> {
|
||||
|
||||
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 -> {
|
||||
|
||||
addNewEmailAddress.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getContext(), ProfileEmailActivity.class));
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return v;
|
||||
|
@ -40,7 +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);
|
||||
|
||||
createLabel.setOnClickListener(v112 -> {
|
||||
|
||||
@ -94,12 +93,6 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
copyRepoUrl.setOnClickListener(copyUrl -> {
|
||||
|
||||
bmListener.onButtonClicked("copyRepoUrl");
|
||||
dismiss();
|
||||
});
|
||||
|
||||
newFile.setOnClickListener(v17 -> {
|
||||
|
||||
bmListener.onButtonClicked("newFile");
|
||||
@ -169,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() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(ctx, MergePullRequestActivity.class));
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
openFilesDiff.setOnClickListener(v14 -> {
|
||||
openFilesDiff.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(ctx, FileDiffActivity.class));
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
editIssue.setOnClickListener(v15 -> {
|
||||
editIssue.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(ctx, EditIssueActivity.class));
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
editLabels.setOnClickListener(v16 -> {
|
||||
editLabels.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(ctx, AddRemoveLabelsActivity.class));
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
addRemoveAssignees.setOnClickListener(v17 -> {
|
||||
addRemoveAssignees.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(ctx, AddRemoveAssigneesActivity.class));
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
shareIssue.setOnClickListener(v1 -> {
|
||||
|
||||
try {
|
||||
|
||||
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, tinyDB.getString("singleIssueHtmlUrl"));
|
||||
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 -> {
|
||||
|
||||
try {
|
||||
|
||||
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();
|
||||
|
||||
// copy to clipboard
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("issueUrl", tinyDB.getString("singleIssueHtmlUrl"));
|
||||
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();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -29,8 +30,9 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Template Author Author M M Arif
|
||||
* Author 6543
|
||||
* + * Template Author M M Arif
|
||||
* + * Author 6543
|
||||
* +
|
||||
*/
|
||||
|
||||
public class ExploreRepositoriesFragment extends Fragment {
|
||||
@ -90,7 +92,10 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
searchKeyword.setOnEditorActionListener((v1, actionId, event) -> {
|
||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
|
||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(!searchKeyword.getText().toString().equals("")) {
|
||||
@ -100,9 +105,10 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
int limitDefault = 25;
|
||||
int limitDefault = 10;
|
||||
loadDefaultList(instanceUrl, instanceToken, loginUid, repoTypeInclude, sort, order, getContext(), limitDefault);
|
||||
|
||||
return v;
|
||||
|
@ -55,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
|
||||
@ -84,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);
|
||||
|
||||
@ -228,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);
|
||||
|
||||
@ -239,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;
|
||||
@ -250,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);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -219,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);
|
||||
|
||||
@ -249,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,11 +105,16 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
createNewRepo = v.findViewById(R.id.addNewRepo);
|
||||
createNewRepo.setOnClickListener(view -> {
|
||||
createNewRepo.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@ -130,11 +135,18 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
||||
|
||||
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));
|
||||
}
|
||||
}, 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,9 +29,9 @@ 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;
|
||||
@ -51,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;
|
||||
@ -86,6 +88,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||
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);
|
||||
@ -147,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);
|
||||
|
||||
});
|
||||
@ -155,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());
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -67,7 +67,7 @@ public class ProfileFragment extends Fragment {
|
||||
if(userLanguageCodes.length >= 2) {
|
||||
|
||||
Locale locale = new Locale(userLanguageCodes[0], userLanguageCodes[1]);
|
||||
userLanguage.setText(locale.getDisplayLanguage());
|
||||
userLanguage.setText(locale.getDisplayCountry());
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -55,7 +55,6 @@ public class PullRequestsFragment extends Fragment {
|
||||
private int pageSize = StaticGlobalVariables.prPageInit;
|
||||
private TextView noData;
|
||||
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||
private ProgressBar progressLoadMore;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@ -84,7 +83,6 @@ public class PullRequestsFragment extends Fragment {
|
||||
recyclerView = v.findViewById(R.id.recyclerView);
|
||||
prList = new ArrayList<>();
|
||||
|
||||
progressLoadMore = v.findViewById(R.id.progressLoadMore);
|
||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||
noData = v.findViewById(R.id.noData);
|
||||
|
||||
@ -235,7 +233,9 @@ public class PullRequestsFragment extends Fragment {
|
||||
|
||||
private void loadMore(String token, String repoOwner, String repoName, int page, String prState, int resultLimit) {
|
||||
|
||||
progressLoadMore.setVisibility(View.VISIBLE);
|
||||
//add loading progress view
|
||||
prList.add(new PullRequests("load"));
|
||||
adapter.notifyItemInserted((prList.size() - 1));
|
||||
|
||||
Call<List<PullRequests>> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState, resultLimit);
|
||||
|
||||
@ -266,7 +266,6 @@ public class PullRequestsFragment extends Fragment {
|
||||
}
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
progressLoadMore.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@ -20,10 +19,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.mian.gitnex.R;
|
||||
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.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
@ -148,9 +143,6 @@ public class RepoInfoFragment extends Fragment {
|
||||
repoFilenameExpandCollapse = v.findViewById(R.id.repoFilenameExpandCollapse);
|
||||
fileContentsFrameHeader = v.findViewById(R.id.fileContentsFrameHeader);
|
||||
fileContentsFrame = v.findViewById(R.id.fileContentsFrame);
|
||||
LinearLayout repoMetaStarsFrame = v.findViewById(R.id.repoMetaStarsFrame);
|
||||
LinearLayout repoMetaForksFrame = v.findViewById(R.id.repoMetaForksFrame);
|
||||
LinearLayout repoMetaWatchersFrame = v.findViewById(R.id.repoMetaWatchersFrame);
|
||||
|
||||
repoMetaFrame.setVisibility(View.GONE);
|
||||
|
||||
@ -177,29 +169,6 @@ public class RepoInfoFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
repoMetaStarsFrame.setOnClickListener(metaStars -> {
|
||||
|
||||
Intent intent = new Intent(ctx, RepoStargazersActivity.class);
|
||||
intent.putExtra("repoFullNameForStars", repoOwner + "/" + repoName);
|
||||
ctx.startActivity(intent);
|
||||
});
|
||||
|
||||
repoMetaForksFrame.setOnClickListener(metaForks -> {
|
||||
|
||||
Intent intent = new Intent(ctx, RepoForksActivity.class);
|
||||
intent.putExtra("repoFullNameForForks", repoOwner + "/" + repoName);
|
||||
ctx.startActivity(intent);
|
||||
});
|
||||
|
||||
repoMetaWatchersFrame.setOnClickListener(metaWatchers -> {
|
||||
|
||||
Intent intent = new Intent(ctx, RepoWatchersActivity.class);
|
||||
intent.putExtra("repoFullNameForWatchers", repoOwner + "/" + repoName);
|
||||
ctx.startActivity(intent);
|
||||
});
|
||||
|
||||
repoMetaPullRequestsFrame.setOnClickListener(metaPR -> RepoDetailActivity.mViewPager.setCurrentItem(3));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@ -358,7 +327,7 @@ public class RepoInfoFragment extends Fragment {
|
||||
|
||||
alertDialog.setTitle(getResources().getString(R.string.infoMoreInformation));
|
||||
alertDialog.setView(view);
|
||||
alertDialog.setNeutralButton(getResources().getString(R.string.close), null);
|
||||
alertDialog.setPositiveButton(getResources().getString(R.string.close), (dialog, which) -> dialog.dismiss());
|
||||
alertDialog.create().show();
|
||||
|
||||
});
|
||||
@ -487,7 +456,7 @@ public class RepoInfoFragment extends Fragment {
|
||||
|
||||
} 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) {
|
||||
|
||||
@ -496,7 +465,7 @@ public class RepoInfoFragment extends Fragment {
|
||||
|
||||
} else {
|
||||
|
||||
Toasty.error(getContext(), getString(R.string.genericError));
|
||||
Toasty.info(getContext(), getString(R.string.genericError));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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.CreateRepoActivity;
|
||||
import org.mian.gitnex.adapters.ReposListAdapter;
|
||||
@ -42,7 +42,7 @@ public class RepositoriesFragment extends Fragment {
|
||||
private ProgressBar mProgressBar;
|
||||
private RecyclerView mRecyclerView;
|
||||
private ReposListAdapter adapter;
|
||||
private ExtendedFloatingActionButton createNewRepo;
|
||||
private ImageView createNewRepo;
|
||||
private TextView noDataRepo;
|
||||
private int pageSize = 1;
|
||||
private int resultLimit = 50;
|
||||
@ -75,10 +75,14 @@ public class RepositoriesFragment extends Fragment {
|
||||
|
||||
createNewRepo = v.findViewById(R.id.addNewRepo);
|
||||
|
||||
createNewRepo.setOnClickListener(view -> {
|
||||
createNewRepo.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@ -98,11 +102,18 @@ public class RepositoriesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
||||
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit);
|
||||
}, 50));
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), pageSize, resultLimit);
|
||||
|
||||
|
@ -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.StarredReposListAdapter;
|
||||
@ -45,7 +45,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
private ProgressBar mProgressBar;
|
||||
private RecyclerView mRecyclerView;
|
||||
private StarredReposListAdapter adapter;
|
||||
private ExtendedFloatingActionButton createNewRepo;
|
||||
private ImageView createNewRepo;
|
||||
private TextView noData;
|
||||
private int pageSize = 1;
|
||||
private int resultLimit = 50;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
@ -12,9 +11,7 @@ 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.AddNewAccountActivity;
|
||||
import org.mian.gitnex.adapters.UserAccountsAdapter;
|
||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
@ -32,7 +29,6 @@ public class UserAccountsFragment extends Fragment {
|
||||
private RecyclerView mRecyclerView;
|
||||
private UserAccountsApi userAccountsApi;
|
||||
private List<UserAccount> userAccountsList;
|
||||
private ExtendedFloatingActionButton addNewAccount;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
@ -65,13 +61,6 @@ public class UserAccountsFragment extends Fragment {
|
||||
|
||||
}, 250));
|
||||
|
||||
addNewAccount = v.findViewById(R.id.addNewAccount);
|
||||
addNewAccount.setOnClickListener(view -> {
|
||||
|
||||
Intent intent = new Intent(view.getContext(), AddNewAccountActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
fetchDataAsync();
|
||||
|
||||
return v;
|
||||
|
@ -22,7 +22,7 @@ public class AlertDialogs {
|
||||
.setMessage(message)
|
||||
.setCancelable(true)
|
||||
.setIcon(R.drawable.ic_warning)
|
||||
.setNeutralButton(copyNegativeButton, (dialog, which) -> dialog.dismiss())
|
||||
.setNegativeButton(copyNegativeButton, (dialog, which) -> dialog.dismiss())
|
||||
.setPositiveButton(copyPositiveButton, (dialog, which) -> {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
@ -76,7 +76,7 @@ public class AlertDialogs {
|
||||
context.startActivity(intent);
|
||||
|
||||
})
|
||||
.setNeutralButton(negativeButton, null).show();
|
||||
.setNegativeButton(negativeButton, null).show();
|
||||
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class AlertDialogs {
|
||||
.setTitle(title + userNameMain)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(positiveButton, (dialog, whichButton) -> CollaboratorActions.deleteCollaborator(context, searchKeyword, userNameMain))
|
||||
.setNeutralButton(negativeButton, null).show();
|
||||
.setNegativeButton(negativeButton, null).show();
|
||||
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public class AlertDialogs {
|
||||
.setTitle(title + userNameMain)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(positiveButton, (dialog, whichButton) -> TeamActions.addTeamMember(context, userNameMain, teamId))
|
||||
.setNeutralButton(negativeButton, null).show();
|
||||
.setNegativeButton(negativeButton, null).show();
|
||||
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ public class AlertDialogs {
|
||||
.setTitle(title + userNameMain)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(positiveButton, (dialog, whichButton) -> TeamActions.removeTeamMember(context, userNameMain, teamId))
|
||||
.setNeutralButton(negativeButton, null).show();
|
||||
.setNegativeButton(negativeButton, null).show();
|
||||
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class ChangeLog {
|
||||
androidx.appcompat.app.AlertDialog.Builder builder = new AlertDialog.Builder(changelogActivity);
|
||||
builder.setTitle(R.string.changelogTitle);
|
||||
builder.setMessage(Html.fromHtml("<small>" + changelogMessage + "</small>"));
|
||||
builder.setNeutralButton(R.string.close, null);
|
||||
builder.setNegativeButton(R.string.close, (dialog, which) -> dialog.cancel());
|
||||
builder.setCancelable(false);
|
||||
builder.create();
|
||||
builder.show();
|
||||
|
@ -27,7 +27,7 @@ public class ClickListener implements View.OnClickListener {
|
||||
{
|
||||
|
||||
LayoutInflater inflater1 = LayoutInflater.from(mCtx);
|
||||
View layout = inflater1.inflate(R.layout.custom_toast_success,
|
||||
View layout = inflater1.inflate(R.layout.custom_toast,
|
||||
(ViewGroup) v.findViewById(R.id.custom_toast_container));
|
||||
|
||||
TextView text = layout.findViewById(R.id.toastText);
|
||||
|
63
app/src/main/java/org/mian/gitnex/helpers/SnackBar.java
Normal file
63
app/src/main/java/org/mian/gitnex/helpers/SnackBar.java
Normal file
@ -0,0 +1,63 @@
|
||||
package org.mian.gitnex.helpers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import org.mian.gitnex.R;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class SnackBar {
|
||||
|
||||
public static void info(Context context, View createRepository, String message) {
|
||||
|
||||
Snackbar snackBar = Snackbar.make(createRepository, message, Snackbar.LENGTH_LONG);
|
||||
|
||||
View sbView = snackBar.getView();
|
||||
TextView textView = sbView.findViewById(R.id.snackbar_text);
|
||||
textView.setTextColor(context.getResources().getColor(R.color.lightBlue));
|
||||
|
||||
snackBar.show();
|
||||
|
||||
}
|
||||
|
||||
public static void success(Context context, View createRepository, String message) {
|
||||
|
||||
Snackbar snackBar = Snackbar.make(createRepository, message, Snackbar.LENGTH_LONG);
|
||||
|
||||
View sbView = snackBar.getView();
|
||||
TextView textView = sbView.findViewById(R.id.snackbar_text);
|
||||
textView.setTextColor(context.getResources().getColor(R.color.white));
|
||||
|
||||
snackBar.show();
|
||||
|
||||
}
|
||||
|
||||
public static void warning(Context context, View createRepository, String message) {
|
||||
|
||||
Snackbar snackBar = Snackbar.make(createRepository, message, Snackbar.LENGTH_LONG);
|
||||
|
||||
View sbView = snackBar.getView();
|
||||
TextView textView = sbView.findViewById(R.id.snackbar_text);
|
||||
textView.setTextColor(context.getResources().getColor(R.color.lightYellow));
|
||||
|
||||
snackBar.show();
|
||||
|
||||
}
|
||||
|
||||
public static void error(Context context, View createRepository, String message) {
|
||||
|
||||
Snackbar snackBar = Snackbar.make(createRepository, message, Snackbar.LENGTH_LONG);
|
||||
|
||||
View sbView = snackBar.getView();
|
||||
TextView textView = sbView.findViewById(R.id.snackbar_text);
|
||||
textView.setTextColor(context.getResources().getColor(R.color.darkRed));
|
||||
|
||||
snackBar.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -16,7 +16,7 @@ public class Toasty {
|
||||
public static void info(Context context, String message) {
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View view = inflater.inflate(context.getResources().getLayout(R.layout.custom_toast_info), null);
|
||||
View view = inflater.inflate(context.getResources().getLayout(R.layout.custom_toast), null);
|
||||
|
||||
TextView text = view.findViewById(R.id.toastText);
|
||||
text.setText(message);
|
||||
@ -43,34 +43,4 @@ public class Toasty {
|
||||
|
||||
}
|
||||
|
||||
public static void warning(Context context, String message) {
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View view = inflater.inflate(context.getResources().getLayout(R.layout.custom_toast_warning), null);
|
||||
|
||||
TextView text = view.findViewById(R.id.toastText);
|
||||
text.setText(message);
|
||||
|
||||
Toast toast = new Toast(context);
|
||||
toast.setDuration(Toast.LENGTH_LONG);
|
||||
toast.setView(view);
|
||||
toast.show();
|
||||
|
||||
}
|
||||
|
||||
public static void success(Context context, String message) {
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View view = inflater.inflate(context.getResources().getLayout(R.layout.custom_toast_success), null);
|
||||
|
||||
TextView text = view.findViewById(R.id.toastText);
|
||||
text.setText(message);
|
||||
|
||||
Toast toast = new Toast(context);
|
||||
toast.setDuration(Toast.LENGTH_LONG);
|
||||
toast.setView(view);
|
||||
toast.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ import org.mian.gitnex.models.Collaborators;
|
||||
import org.mian.gitnex.models.Commits;
|
||||
import org.mian.gitnex.models.CreateIssue;
|
||||
import org.mian.gitnex.models.CreateLabel;
|
||||
import org.mian.gitnex.models.DeleteFile;
|
||||
import org.mian.gitnex.models.EditFile;
|
||||
import org.mian.gitnex.models.Emails;
|
||||
import org.mian.gitnex.models.ExploreRepositories;
|
||||
import org.mian.gitnex.models.Files;
|
||||
@ -41,7 +39,6 @@ import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.DELETE;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.HTTP;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.PATCH;
|
||||
import retrofit2.http.POST;
|
||||
@ -268,12 +265,6 @@ public interface ApiInterface {
|
||||
@GET("repos/{owner}/{repo}/contents/{fileDir}") // get all the sub files and dirs of a repository
|
||||
Call<List<Files>> getDirFiles(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("fileDir") String fileDir, @Query("ref") String ref);
|
||||
|
||||
@HTTP(method = "DELETE", path = "repos/{owner}/{repo}/contents/{filepath}", hasBody = true) // delete a file
|
||||
Call<JsonElement> deleteFile(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("filepath") String filepath, @Body DeleteFile jsonStr);
|
||||
|
||||
@PUT("repos/{owner}/{repo}/contents/{filepath}") // edit/update a file
|
||||
Call<JsonElement> editFile(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("filepath") String filepath, @Body EditFile jsonStr);
|
||||
|
||||
@GET("user/starred/{owner}/{repo}") // check star status of a repository
|
||||
Call<JsonElement> checkRepoStarStatus(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
|
||||
|
||||
@ -330,7 +321,4 @@ public interface ApiInterface {
|
||||
|
||||
@DELETE("repos/{owner}/{repo}/branches/{branch}") // delete branch
|
||||
Call<JsonElement> deleteBranch(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("branch") String branchName);
|
||||
|
||||
@GET("repos/{owner}/{repo}/forks") // get all repo forks
|
||||
Call<List<UserRepositories>> getRepositoryForks(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Query("page") int page, @Query("limit") int limit);
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
package org.mian.gitnex.models;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class DeleteFile {
|
||||
|
||||
private String branch;
|
||||
private String message;
|
||||
private String new_branch;
|
||||
private String sha;
|
||||
|
||||
public String getBranch() {
|
||||
|
||||
return branch;
|
||||
}
|
||||
|
||||
public void setBranch(String branch) {
|
||||
|
||||
this.branch = branch;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getNew_branch() {
|
||||
|
||||
return new_branch;
|
||||
}
|
||||
|
||||
public void setNew_branch(String new_branch) {
|
||||
|
||||
this.new_branch = new_branch;
|
||||
}
|
||||
|
||||
public String getSha() {
|
||||
|
||||
return sha;
|
||||
}
|
||||
|
||||
public void setSha(String sha) {
|
||||
|
||||
this.sha = sha;
|
||||
}
|
||||
|
||||
public DeleteFile(String branch, String message, String new_branch, String sha) {
|
||||
this.branch = branch;
|
||||
this.message = message;
|
||||
this.new_branch = new_branch;
|
||||
this.sha = sha;
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package org.mian.gitnex.models;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class EditFile {
|
||||
|
||||
private String branch;
|
||||
private String message;
|
||||
private String new_branch;
|
||||
private String sha;
|
||||
private String content;
|
||||
|
||||
public String getBranch() {
|
||||
|
||||
return branch;
|
||||
}
|
||||
|
||||
public void setBranch(String branch) {
|
||||
|
||||
this.branch = branch;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getNew_branch() {
|
||||
|
||||
return new_branch;
|
||||
}
|
||||
|
||||
public void setNew_branch(String new_branch) {
|
||||
|
||||
this.new_branch = new_branch;
|
||||
}
|
||||
|
||||
public String getSha() {
|
||||
|
||||
return sha;
|
||||
}
|
||||
|
||||
public void setSha(String sha) {
|
||||
|
||||
this.sha = sha;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public EditFile(String branch, String message, String new_branch, String sha, String content) {
|
||||
this.branch = branch;
|
||||
this.message = message;
|
||||
this.new_branch = new_branch;
|
||||
this.sha = sha;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
@ -11,7 +11,6 @@ public class Issues {
|
||||
|
||||
private int id;
|
||||
private String url;
|
||||
private String html_url;
|
||||
private int number;
|
||||
private String title;
|
||||
private String body;
|
||||
@ -32,7 +31,7 @@ public class Issues {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public static class userObject {
|
||||
public class userObject {
|
||||
|
||||
private int id;
|
||||
private String login;
|
||||
@ -72,7 +71,7 @@ public class Issues {
|
||||
|
||||
}
|
||||
|
||||
public static class labelsObject {
|
||||
public class labelsObject {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
@ -96,7 +95,7 @@ public class Issues {
|
||||
}
|
||||
}
|
||||
|
||||
public static class pullRequestObject {
|
||||
public class pullRequestObject {
|
||||
|
||||
private boolean merged;
|
||||
private String merged_at;
|
||||
@ -110,7 +109,7 @@ public class Issues {
|
||||
}
|
||||
}
|
||||
|
||||
public static class milestoneObject {
|
||||
public class milestoneObject {
|
||||
|
||||
private int id;
|
||||
private String title;
|
||||
@ -154,7 +153,7 @@ public class Issues {
|
||||
}
|
||||
}
|
||||
|
||||
public static class assigneesObject {
|
||||
public class assigneesObject {
|
||||
|
||||
private int id;
|
||||
private String login;
|
||||
@ -257,14 +256,4 @@ public class Issues {
|
||||
return assignees;
|
||||
}
|
||||
|
||||
public String getHtml_url() {
|
||||
|
||||
return html_url;
|
||||
}
|
||||
|
||||
public void setHtml_url(String html_url) {
|
||||
|
||||
this.html_url = html_url;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class NewFile {
|
||||
this.new_branch = new_branch;
|
||||
}
|
||||
|
||||
public static class authorObject {
|
||||
public class authorObject {
|
||||
|
||||
private String email;
|
||||
private String name;
|
||||
@ -68,7 +68,7 @@ public class NewFile {
|
||||
}
|
||||
}
|
||||
|
||||
public static class committerObject {
|
||||
public class committerObject {
|
||||
|
||||
private String email;
|
||||
private String name;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user